Compare commits

...

3 Commits

Author SHA1 Message Date
dundargoc cd5ee58014
Merge a57dcc666a into c18d7941ef 2024-05-09 18:57:59 +02:00
dundargoc a57dcc666a feat: allow gx to function for markdown links
In other words, `gx` works regardless of where it was used in
`[...](https://...)`.

Co-authored-by: ribru17 <ribru17@gmail.com>
2024-05-09 18:57:52 +02:00
dundargoc c18d7941ef build: allow sccache as compiler cache
Also enable caching for dependencies.

Closes https://github.com/neovim/neovim/issues/28670
2024-05-09 16:39:45 +02:00
3 changed files with 29 additions and 10 deletions

View File

@ -50,11 +50,6 @@ file(GLOB DOCFILES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt)
set_directory_properties(PROPERTIES
EP_PREFIX "${DEPS_BUILD_DIR}")
find_program(CCACHE_PRG ccache)
if(CCACHE_PRG)
set(CMAKE_C_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E env CCACHE_SLOPPINESS=pch_defines,time_macros ${CCACHE_PRG})
endif()
if(NOT CI_BUILD)
set(CMAKE_INSTALL_MESSAGE NEVER)
endif()

View File

@ -23,6 +23,12 @@ if(POLICY CMP0092)
list(APPEND DEPS_CMAKE_ARGS -D CMAKE_POLICY_DEFAULT_CMP0092=NEW)
endif()
find_program(CACHE_PRG NAMES ccache sccache)
if(CACHE_PRG)
set(CMAKE_C_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E env CCACHE_SLOPPINESS=pch_defines,time_macros ${CACHE_PRG})
list(APPEND DEPS_CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER_LAUNCHER:STRING=${CMAKE_C_COMPILER_LAUNCHER})
endif()
# MAKE_PRG
if(UNIX)
find_program(MAKE_PRG NAMES gmake make)
@ -58,7 +64,8 @@ function(get_externalproject_options name DEPS_IGNORE_SHA)
set(EXTERNALPROJECT_OPTIONS
DOWNLOAD_NO_PROGRESS TRUE
EXTERNALPROJECT_OPTIONS URL ${${name_allcaps}_URL})
EXTERNALPROJECT_OPTIONS URL ${${name_allcaps}_URL}
CMAKE_CACHE_ARGS ${DEPS_CMAKE_CACHE_ARGS})
if(NOT ${DEPS_IGNORE_SHA})
list(APPEND EXTERNALPROJECT_OPTIONS URL_HASH SHA256=${${name_allcaps}_SHA256})

View File

@ -107,22 +107,39 @@ do
vim.inspect(cmd.cmd)
)
end
return err
end
if err then
vim.notify(err, vim.log.levels.ERROR)
--- Gets the URL at cursor, if any.
local function get_url()
local current_node = vim.treesitter.get_node { lang = 'markdown_inline' }
while current_node do
local type = current_node:type()
if type == 'inline_link' or type == 'image' then
local child = assert(current_node:named_child(1))
return vim.treesitter.get_node_text(child, 0)
end
current_node = current_node:parent()
end
return vim.fn.expand('<cfile>')
end
local gx_desc =
'Opens filepath or URI under cursor with the system handler (file explorer, web browser, …)'
vim.keymap.set({ 'n' }, 'gx', function()
do_open(vim.fn.expand('<cfile>'))
local err = do_open(get_url())
if err then
vim.notify(err, vim.log.levels.ERROR)
end
end, { desc = gx_desc })
vim.keymap.set({ 'x' }, 'gx', function()
local lines =
vim.fn.getregion(vim.fn.getpos('.'), vim.fn.getpos('v'), { type = vim.fn.mode() })
-- Trim whitespace on each line and concatenate.
do_open(table.concat(vim.iter(lines):map(vim.trim):totable()))
local err = do_open(table.concat(vim.iter(lines):map(vim.trim):totable()))
if err then
vim.notify(err, vim.log.levels.ERROR)
end
end, { desc = gx_desc })
end