feat: use lua autocmd to set term keymaps
This commit is contained in:
parent
95e22170e0
commit
c97822479f
1 changed files with 13 additions and 11 deletions
|
@ -7,7 +7,7 @@ vim.cmd([[
|
||||||
]])
|
]])
|
||||||
|
|
||||||
local function nnoremap(key, command)
|
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
|
end
|
||||||
|
|
||||||
vim.g.mapleader = " "
|
vim.g.mapleader = " "
|
||||||
|
@ -35,16 +35,18 @@ nnoremap("<C-f>", "<Cmd>Telescope grep_string<CR>")
|
||||||
nnoremap("<C-g>", "<Cmd>Telescope live_grep<CR>")
|
nnoremap("<C-g>", "<Cmd>Telescope live_grep<CR>")
|
||||||
|
|
||||||
-- terminal
|
-- terminal
|
||||||
function _G.set_terminal_keymaps()
|
vim.api.nvim_create_autocmd("TermOpen", {
|
||||||
local opts = {noremap = true}
|
pattern = "term://*",
|
||||||
vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts)
|
callback = function()
|
||||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
|
local opts = { noremap = true }
|
||||||
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', '<esc>', [[<C-\><C-n>]], 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-h>', [[<C-\><C-n><C-W>h]], opts)
|
||||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
|
vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
|
||||||
end
|
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)
|
||||||
vim.cmd('autocmd TermOpen term://* lua set_terminal_keymaps()')
|
end,
|
||||||
|
desc = "Map terminal esc and window switch keys",
|
||||||
|
})
|
||||||
|
|
||||||
-- buffer closing
|
-- buffer closing
|
||||||
nnoremap("<leader>q", ":Bdelete<CR>")
|
nnoremap("<leader>q", ":Bdelete<CR>")
|
||||||
|
|
Loading…
Reference in a new issue