neovim: Add focus moving bindings for term and normal

This commit is contained in:
Peter Cai 2022-08-07 17:49:06 -04:00
parent cefce76d7a
commit ebcba42537
1 changed files with 26 additions and 1 deletions

View File

@ -42,7 +42,32 @@ fun! ShowNumberIfNecessary()
setlocal nu
endfun
autocmd BufEnter * call ShowNumberIfNecessary()
autocmd TermOpen term://* setlocal nonumber
autocmd TermOpen,TermEnter term://* setlocal nonumber
" Terminal remapping
lua << EOF
function _G.set_terminal_keymaps()
local opts = {buffer = 0}
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
vim.keymap.set('t', 'jk', [[<C-\><C-n>]], opts)
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
end
EOF
autocmd TermOpen term://* lua set_terminal_keymaps()
" Focus moving remaps
lua << EOF
function _G.set_focus_keymaps()
vim.keymap.set('n', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
vim.keymap.set('n', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
vim.keymap.set('n', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
vim.keymap.set('n', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
end
EOF
autocmd BufEnter * lua set_focus_keymaps()
" Startup commands
autocmd UIEnter * Neotree