diff options
Diffstat (limited to '.config/nvim/lua/helpers/keys.lua')
-rw-r--r-- | .config/nvim/lua/helpers/keys.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/.config/nvim/lua/helpers/keys.lua b/.config/nvim/lua/helpers/keys.lua new file mode 100644 index 0000000..ebbcf6e --- /dev/null +++ b/.config/nvim/lua/helpers/keys.lua | |||
@@ -0,0 +1,21 @@ | |||
1 | local M = {} | ||
2 | |||
3 | M.map = function(mode, lhs, rhs, desc, opts) | ||
4 | local options = { noremap = true, silent = true, desc = desc } | ||
5 | if opts then | ||
6 | options = vim.tbl_extend("force", options, opts) | ||
7 | end | ||
8 | vim.keymap.set(mode, lhs, rhs, options) | ||
9 | end | ||
10 | |||
11 | M.lsp_map = function(lhs, rhs, bufnr, desc) | ||
12 | vim.keymap.set("n", lhs, rhs, { silent = true, buffer = bufnr, desc = desc }) | ||
13 | end | ||
14 | |||
15 | M.set_leader = function(key) | ||
16 | vim.g.mapleader = key | ||
17 | vim.g.maplocalleader = key | ||
18 | M.map({ "n", "v" }, key, "<nop>") | ||
19 | end | ||
20 | |||
21 | return M | ||