summaryrefslogtreecommitdiff
path: root/dot_config/nvim/lua/bindings.lua
blob: 42c5896f295e85bb9669bb5fffe9b7eaeed4adb2 (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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---@diagnostic disable:undefined-global

local util = require 'util'

local env = vim.env

-- TODO: write a wrapper for both
if not util.hp 'which-key.nvim' then
	-- minimal bindings for a no-plugin environment
	local km = vim.keymap.set
	km('n', '<leader>sv', function() dofile(env.MYVIMRC) end, { desc = 'source vimrc'})
	km('n', '<leader>s%', '<cmd>source %<cr>', { desc = 'source current file'})
else
	-- general bindings that aren't specific to a plugin
	require 'which-key'.register {
		-- diagnostics
		['<leader>'] = {
			e = { vim.diagnostic.open_float, 'diag float' },
			q = { vim.diagnostic.setloclist, 'diag locations' },
		},
		['[d'] = { vim.diagnostic.goto_prev, 'prev diag' },
		[']d'] = { vim.diagnostic.goto_next, 'next diag' },

		-- source
		['<leader>s'] = {
			name = '+source',
			v = { function() dofile(env.MYVIMRC) end, 'Vimrc' },
			['%'] = { '<cmd>source %<cr>', 'Current File' },
		},

		-- document missing builtins
		['g'] = {
			t = 'Next tab',
			T = 'Previous tab',
		},
	}
end