diff --git a/init.lua b/init.lua index 38994fb..acce7d4 100644 --- a/init.lua +++ b/init.lua @@ -93,6 +93,10 @@ require('config.treesitter') require('config.lspconfig') +-- Custom + +Custom = require('config.custom') + -- Keybinds let(nil, 'mapleader', ',') @@ -164,3 +168,6 @@ vnoremap :m '<-2gv=gv -- Clean highlight map('n', '', 'nohlscall clearmatches()', opts, "CleanHighlights", "clear_all", "Clear all highlights and matches") + +-- Open links with reader +map('n', 'gx', 'lua Custom.open_with_reader()', {}, "OpenWithReader", "open_with_reader", "Open the link under the cursor with `reader` in a floating tab") diff --git a/lua/config/custom.lua b/lua/config/custom.lua new file mode 100644 index 0000000..65451b7 --- /dev/null +++ b/lua/config/custom.lua @@ -0,0 +1,11 @@ +local win = require("plenary.window.float") + +local function open_with_reader() + vim.cmd [[ + normal! "uyiW + ]] + win.centered({ winblend = 0 }) + vim.fn.termopen('reader ' .. vim.fn.getreg('u')) +end + +return {open_with_reader = open_with_reader, win = win}