aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/home/.config/nvim/lua/mapper.lua
blob: c31aecaa453f9238d9a6022cc08a9ee07a949d51 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
local M = {}

M.map = function(mode, keys, action, opts, bufnr)
  opts = vim.tbl_extend("force", { silent = true, buffer = bufnr }, opts or {})
  vim.keymap.set(mode, keys, action, opts)
end

M.cmdi = function(mode, keys, action, opts, bufnr)
  opts = vim.tbl_extend("force", { silent = false }, opts or {})
  M.map(mode, keys, ":" .. action, opts, bufnr)
end

M.cmd = function(mode, keys, action, opts, bufnr)
  M.map(mode, keys, "<cmd>" .. action .. "<cr>", opts, bufnr)
end

M.plug = function(mode, keys, action, opts, bufnr)
  M.map(mode, keys, "<Plug>" .. action, opts, bufnr)
end

M.n = function(keys, action, opts, bufnr)
  M.map("n", keys, action, opts, bufnr)
end
M.ncmdi = function(keys, action, opts, bufnr)
  M.cmdi("n", keys, action, opts, bufnr)
end
M.ncmd = function(keys, action, opts, bufnr)
  M.cmd("n", keys, action, opts, bufnr)
end
M.nplug = function(keys, action, opts, bufnr)
  M.plug("n", keys, "(" .. action .. ")", opts, bufnr)
end

M.v = function(keys, action, opts, bufnr)
  M.map("v", keys, action, opts, bufnr)
end
M.vcmdi = function(keys, action, opts, bufnr)
  opts = vim.tbl_extend("force", { silent = false }, opts or {})
  M.v(keys, ":" .. action, opts, bufnr)
end
M.vcmd = function(keys, action, opts, bufnr)
  M.vcmdi(keys, action .. "<cr>", opts, bufnr)
end
M.vplug = function(keys, action, opts, bufnr)
  M.plug("v", keys, "(" .. action .. ")", opts, bufnr)
end

M.nv = function(keys, action, opts, bufnr)
  M.map({ "n", "v" }, keys, action, opts, bufnr)
end
M.nvcmdi = function(keys, action, opts, bufnr)
  M.ncmdi(keys, action, opts, bufnr)
  M.vcmdi(keys, action, opts, bufnr)
end
M.nvcmd = function(keys, action, opts, bufnr)
  M.ncmd(keys, action, opts, bufnr)
  M.vcmd(keys, action, opts, bufnr)
end
M.nvplug = function(keys, action, opts, bufnr)
  M.plug({ "n", "v" }, keys, "(" .. action .. ")", opts, bufnr)
end

M.i = function(keys, action, opts, bufnr)
  M.map("i", keys, action, opts, bufnr)
end
M.iplug = function(keys, action, opts, bufnr)
  opts = vim.tbl_extend("force", { silent = false }, opts or {})
  M.plug("i", keys, action, opts, bufnr)
end

M.t = function(keys, action, opts, bufnr)
  M.map("t", keys, action, opts, bufnr)
end
M.tcmdi = function(keys, action, opts, bufnr)
  M.cmdi("t", keys, action, opts, bufnr)
end
M.tcmd = function(keys, action, opts, bufnr)
  M.cmd("t", keys, action, opts, bufnr)
end
M.tplug = function(keys, action, opts, bufnr)
  M.plug("t", keys, action, opts, bufnr)
end

return M