summaryrefslogtreecommitdiff
path: root/.config/nvim
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-06-11 00:10:45 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-06-11 00:10:45 +0200
commitbd337833342ca7ac4a35a416806bcd34d82ed045 (patch)
tree46078c5202a1a5fd232720182cd5de371d4f885a /.config/nvim
parent511efe89ed084bc922ae142d32e08427859198f4 (diff)
nvim: Check to see if a manual actually exists
Diffstat (limited to '.config/nvim')
-rw-r--r--.config/nvim/after/ftplugin/c.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/.config/nvim/after/ftplugin/c.lua b/.config/nvim/after/ftplugin/c.lua
index 6058e31..2c378f4 100644
--- a/.config/nvim/after/ftplugin/c.lua
+++ b/.config/nvim/after/ftplugin/c.lua
@@ -5,6 +5,15 @@ vim.keymap.set('v', '<localleader>=', ":'<'>!clang-format -style=file -<CR>", {
})
vim.keymap.set('n', 'K', function()
+ local w = vim.fn.expand('<cword>')
+ local proc = vim.system({'man', w}):wait()
+ if proc.code == 16 then
+ print('No manual for ‘' .. w .. '’ found')
+ return
+ elseif proc.code ~= 0 then
+ print('An error occured')
+ return
+ end
vim.cmd [[
execute "silent !man -Tpdf '" . expand('<cword>') . "' | zathura - &"
]]