forked from miltonllera/neovim-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.lua
41 lines (26 loc) · 1.19 KB
/
utils.lua
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
38
39
40
41
-- Keymap functions
local M = {}
function M.map(mode, lhs, rhs)
vim.api.nvim_set_keymap(mode, lhs, rhs, {silent = true})
end
function M.noremap(mode, lhs, rhs)
vim.api.nvim_set_keymap(mode, lhs, rhs, {noremap = true, silent = true})
end
function M.exprnoremap(mode, lhs, rhs)
vim.api.nvim_set_keymap(mode, lhs, rhs, {noremap = true, silent = true, expr = true})
end
-- Useful mode-specific shortcuts
-- nomenclature: "<expr?><mode><nore?>map(lhs, rhs)" where:
-- "expr?" optional expr option
-- "nore?" optional no-remap option
-- modes -> 'n' = NORMAL, 'i' = INSERT, 'x' = 'VISUAL', 'v' = VISUAL + SELECT, 't' = TERMINAL
function M.nmap(lhs, rhs) M.map('n', lhs, rhs) end
function M.xmap(lhs, rhs) M.map('x', lhs, rhs) end
function M.nnoremap(lhs, rhs) M.noremap('n', lhs, rhs) end
function M.vnoremap(lhs, rhs) M.noremap('v', lhs, rhs) end
function M.xnoremap(lhs, rhs) M.noremap('x', lhs, rhs) end
function M.inoremap(lhs, rhs) M.noremap('i', lhs, rhs) end
function M.tnoremap(lhs, rhs) M.noremap('t', lhs, rhs) end
function M.exprnnoremap(lhs, rhs) M.exprnoremap('n', lhs, rhs) end
function M.exprinoremap(lhs, rhs) M.exprnoremap('i', lhs, rhs) end
return M