summaryrefslogtreecommitdiffstats
path: root/.config/nvim/lua/helpers/keys.lua
blob: ebbcf6e4f9eee508270c72994fcee70bb8cef43e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
local M = {}

M.map = function(mode, lhs, rhs, desc, opts)
    local options = { noremap = true, silent = true, desc = desc }
    if opts then
        options = vim.tbl_extend("force", options, opts)
    end
    vim.keymap.set(mode, lhs, rhs, options)
end

M.lsp_map = function(lhs, rhs, bufnr, desc)
    vim.keymap.set("n", lhs, rhs, { silent = true, buffer = bufnr, desc = desc })
end

M.set_leader = function(key)
    vim.g.mapleader = key
    vim.g.maplocalleader = key
    M.map({ "n", "v" }, key, "<nop>")
end

return M