dotfiles/lua/keymaps.lua

45 lines
1.3 KiB
Lua

-- source file everytime it changes
vim.cmd([[
augroup user_keymaps
autocmd!
autocmd BufWritePost keymaps.lua source <afile>
augroup end
]])
local function nnoremap(key, command)
vim.api.nvim_set_keymap("n",key,command, { noremap = true, silent = true })
end
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- Move around windows
nnoremap("<C-h>", "<C-w>h")
nnoremap("<C-j>", "<C-w>j")
nnoremap("<C-k>", "<C-w>k")
nnoremap("<C-l>", "<C-w>l")
-- Switch buffers
nnoremap("<TAB>", ":TablineBufferNext<CR>")
nnoremap("<S-TAB>", ":TablineBufferPrevious<CR>")
-- fugitive
nnoremap("<leader>G", ":tab G<CR>")
-- telescope
nnoremap("<leader>ff", "<Cmd>Telescope find_files theme=dropdown<CR>")
nnoremap("<leader>fb", "<Cmd>Telescope buffers theme=dropdown<CR>")
nnoremap("<leader>fg", "<Cmd>Telescope git_files theme=dropdown<CR>")
-- terminal
function _G.set_terminal_keymaps()
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()')