feat: use lua autocmd to set term keymaps
This commit is contained in:
parent
95e22170e0
commit
c97822479f
@ -35,16 +35,18 @@ nnoremap("<C-f>", "<Cmd>Telescope grep_string<CR>")
|
||||
nnoremap("<C-g>", "<Cmd>Telescope live_grep<CR>")
|
||||
|
||||
-- terminal
|
||||
function _G.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', '<esc>', [[<C-\><C-n>]], opts)
|
||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
|
||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
|
||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
|
||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
|
||||
end
|
||||
|
||||
vim.cmd('autocmd TermOpen term://* lua set_terminal_keymaps()')
|
||||
end,
|
||||
desc = "Map terminal esc and window switch keys",
|
||||
})
|
||||
|
||||
-- buffer closing
|
||||
nnoremap("<leader>q", ":Bdelete<CR>")
|
||||
|
Reference in New Issue
Block a user