summaryrefslogtreecommitdiff
path: root/.config/nvim/after/ftplugin/c.lua
blob: c65969c892f633462a8e92d9b06044004da708c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
vim.bo.commentstring = '// %s'

vim.keymap.set('x', '<LocalLeader>=', ":'<'>!clang-format -style=file<CR>", {
	desc = 'Format the current selection with Clang Format',
})

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 - &"
	]]
end, {
	buffer = 0,
	desc = 'View the manual page for the word under the cursor',
})