mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 16:53:00 +00:00
nvim: ft keymaps via ftplugin/
This commit is contained in:
parent
51e6343b9e
commit
32429308f3
22 changed files with 112 additions and 213 deletions
|
|
@ -21,13 +21,28 @@ M.set_lang_keymaps = function(maps)
|
|||
})
|
||||
end
|
||||
|
||||
-- This fuction is used in ftplugin/*.lua
|
||||
M.set_buf_keymaps = function(maps)
|
||||
vim.api.create_autocmd("BufEnter", {
|
||||
pattern = maps.filetype,
|
||||
callback = function()
|
||||
M.set_keymaps(maps.keymaps)
|
||||
end,
|
||||
})
|
||||
if not maps then
|
||||
return
|
||||
end
|
||||
for _, map in ipairs(maps) do
|
||||
local opts = vim.tbl_extend("force", map.opt or {}, { buffer = true })
|
||||
vim.keymap.set(map.mode, map.keys, map.cmd, opts)
|
||||
end
|
||||
end
|
||||
|
||||
M.set_buf_keymaps_prefix = function(maps)
|
||||
local n_prefix = "<leader>m"
|
||||
local i_prefix = "<C-m>"
|
||||
if not maps then
|
||||
return
|
||||
end
|
||||
for _, map in ipairs(maps) do
|
||||
local opts = vim.tbl_extend("force", map.opt or {}, { buffer = true })
|
||||
vim.keymap.set("n", n_prefix .. map.keys, map.cmd, opts)
|
||||
vim.keymap.set("i", i_prefix .. map.keys, map.cmd, opts)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue