forked from LunarVim/Neovim-from-scratch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbind.lua
48 lines (45 loc) · 1 KB
/
bind.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
42
43
44
45
46
47
48
--
-- Bind utility
--
local api = vim.api
local stdext = require('user.lib.stdext')
local map = function()
local base = {
silent = true
}
local partial = function(prefix)
return function(lhs, rhs, opt)
local rhs = rhs or ""
local opt = opt or {}
local options = stdext.merge {base, opt}
if options.buffer then
local buf = options.buffer
options.buffer = nil
for _, mode in ipairs(prefix) do
api.nvim_buf_set_keymap(buf, mode, lhs, rhs, options)
end
else
for _, mode in ipairs(prefix) do
api.nvim_set_keymap(mode, lhs, rhs, options)
end
end
end
end
return {
n = partial {"n"},
x = partial {"x"},
c = partial {"c"},
v = partial {"v"},
i = partial {"i"},
r = partial {"r"},
op = partial {"o"},
t = partial {"t"},
no = partial {"n", "o"},
nv = partial {"n", "v"},
ni = partial {"n", "i"},
nov = partial {"n", "o", "v"}
}
end
return {
map = map()
}