aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/home/.config/nvim/lua/mapper.lua
diff options
context:
space:
mode:
authorLibravatar Arnold Sommerfeld <sommerfeld@strisemarx.com>2023-05-17 18:44:48 +0100
committerLibravatar Arnold Sommerfeld <sommerfeld@strisemarx.com>2023-10-18 11:16:43 +0100
commitb487984ecc61c6229cf92550030745c192fd3d0b (patch)
tree937e598c941fc1172467aeeed8ef51cbfceaca62 /home/.config/nvim/lua/mapper.lua
downloaddotfiles-b487984ecc61c6229cf92550030745c192fd3d0b.tar.gz
dotfiles-b487984ecc61c6229cf92550030745c192fd3d0b.tar.bz2
dotfiles-b487984ecc61c6229cf92550030745c192fd3d0b.zip
first commit
Diffstat (limited to 'home/.config/nvim/lua/mapper.lua')
-rw-r--r--home/.config/nvim/lua/mapper.lua84
1 files changed, 84 insertions, 0 deletions
diff --git a/home/.config/nvim/lua/mapper.lua b/home/.config/nvim/lua/mapper.lua
new file mode 100644
index 0000000..c31aeca
--- /dev/null
+++ b/home/.config/nvim/lua/mapper.lua
@@ -0,0 +1,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