nix-configs/old-conf/hm-modules/nvim/config/lua/utils.lua
Lucy Hochkamp 83de52d5db Add 'old-conf/' from commit '62a64a79a8'
git-subtree-dir: old-conf
git-subtree-mainline: 4667974392
git-subtree-split: 62a64a79a8
2025-11-21 13:33:06 +01:00

21 lines
541 B
Lua

-- cool map funciton from https://vonheikemen.github.io/devlog/tools/configuring-neovim-using-lua/
utils = {}
utils.map = function(key)
-- get the extra options
local opts = {noremap = false}
for i, v in pairs(key) do
if (i) == 'string' then opts[i] = v end
end
-- basic support for buffer-scoped keybindings
local buffer = opts.buffer
opts.buffer = nil
if buffer then
vim.api.nvim_buf_set_keymap(0, key[1], key[2], key[3], opts)
else
vim.api.nvim_set_keymap(key[1], key[2], key[3], opts)
end
end
return utils