Add open_with_reader

This commit is contained in:
sfigato 2022-02-22 00:03:07 +01:00
parent abac026ed6
commit 703de6f1fe
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
2 changed files with 18 additions and 0 deletions

View File

@ -93,6 +93,10 @@ require('config.treesitter')
require('config.lspconfig')
-- Custom
Custom = require('config.custom')
-- Keybinds
let(nil, 'mapleader', ',')
@ -164,3 +168,6 @@ vnoremap <silent> <C-Up> :m '<-2<CR>gv=gv
-- Clean highlight
map('n', '<leader><esc>', '<cmd>nohls<CR><cmd>call clearmatches()<cr>', opts, "CleanHighlights", "clear_all", "Clear all highlights and matches")
-- Open links with reader
map('n', 'gx', '<cmd>lua Custom.open_with_reader()<cr>', {}, "OpenWithReader", "open_with_reader", "Open the link under the cursor with `reader` in a floating tab")

11
lua/config/custom.lua Normal file
View File

@ -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}