From 703de6f1feb37d094cda6efa8ef25bad19b88af8 Mon Sep 17 00:00:00 2001 From: Blallo Date: Tue, 22 Feb 2022 00:03:07 +0100 Subject: [PATCH] Add open_with_reader --- init.lua | 7 +++++++ lua/config/custom.lua | 11 +++++++++++ 2 files changed, 18 insertions(+) create mode 100644 lua/config/custom.lua 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}