diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua index e212784..3b40c13 100644 --- a/nvim/lua/keymaps.lua +++ b/nvim/lua/keymaps.lua @@ -7,7 +7,7 @@ vim.cmd([[ ]]) local function nnoremap(key, command) - vim.api.nvim_set_keymap("n", key, command, {noremap = true}) + vim.api.nvim_set_keymap("n", key, command, { noremap = true }) end vim.g.mapleader = " " @@ -35,16 +35,18 @@ nnoremap("", "Telescope grep_string") nnoremap("", "Telescope live_grep") -- terminal -function _G.set_terminal_keymaps() - local opts = {noremap = true} - vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) - vim.api.nvim_buf_set_keymap(0, 't', '', [[h]], opts) - vim.api.nvim_buf_set_keymap(0, 't', '', [[j]], opts) - vim.api.nvim_buf_set_keymap(0, 't', '', [[k]], opts) - vim.api.nvim_buf_set_keymap(0, 't', '', [[l]], opts) -end - -vim.cmd('autocmd TermOpen term://* lua set_terminal_keymaps()') +vim.api.nvim_create_autocmd("TermOpen", { + pattern = "term://*", + callback = function() + local opts = { noremap = true } + vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[h]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[j]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[k]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[l]], opts) + end, + desc = "Map terminal esc and window switch keys", +}) -- buffer closing nnoremap("q", ":Bdelete")