From bd337833342ca7ac4a35a416806bcd34d82ed045 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 11 Jun 2024 00:10:45 +0200 Subject: nvim: Check to see if a manual actually exists --- .config/nvim/after/ftplugin/c.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to '.config/nvim/after/ftplugin') 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', '=', ":'<'>!clang-format -style=file -", { }) vim.keymap.set('n', 'K', function() + local w = vim.fn.expand('') + 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('') . "' | zathura - &" ]] -- cgit v1.2.3