diff options
author | dundargoc <gocdundar@gmail.com> | 2024-05-03 20:32:06 +0200 |
---|---|---|
committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2024-05-24 11:07:43 +0200 |
commit | f864b68c5b0fe1482249167712cd16ff2b50ec45 (patch) | |
tree | e8361e05037eceaeba92c021a19451704e3ba6df /runtime/lua/vim/_defaults.lua | |
parent | 6dc62c2e2b413a9bbaf0746660c5638936303249 (diff) | |
download | rneovim-f864b68c5b0fe1482249167712cd16ff2b50ec45.tar.gz rneovim-f864b68c5b0fe1482249167712cd16ff2b50ec45.tar.bz2 rneovim-f864b68c5b0fe1482249167712cd16ff2b50ec45.zip |
feat: allow gx to function for markdown links
In other words, `gx` works regardless of where it was used in
`[...](https://...)`. This only works on markdown buffers.
Co-authored-by: ribru17 <ribru17@gmail.com>
Diffstat (limited to 'runtime/lua/vim/_defaults.lua')
-rw-r--r-- | runtime/lua/vim/_defaults.lua | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua index 4684902410..ede634636e 100644 --- a/runtime/lua/vim/_defaults.lua +++ b/runtime/lua/vim/_defaults.lua @@ -107,22 +107,25 @@ do vim.inspect(cmd.cmd) ) end - - if err then - vim.notify(err, vim.log.levels.ERROR) - end + return err 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(require('vim.ui')._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 |