dotfiles/nvim/lua/keymaps.lua

50 lines
1.5 KiB
Lua
Raw Normal View History

2022-02-21 14:15:15 +00:00
-- source file everytime it changes
vim.cmd([[
augroup user_keymaps
autocmd!
autocmd BufWritePost keymaps.lua source <afile>
augroup end
]])
local function nnoremap(key, command)
2022-02-22 19:01:23 +00:00
vim.api.nvim_set_keymap("n", key, command, {noremap = true})
2022-02-21 14:15:15 +00:00
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
2022-03-12 09:41:18 +00:00
nnoremap("<leader>g", ":0Git<CR>")
2022-02-21 14:15:15 +00:00
-- 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>")
2022-02-23 20:11:30 +00:00
nnoremap("<C-f>", "<Cmd>Telescope grep_string<CR>")
nnoremap("<C-g>", "<Cmd>Telescope live_grep<CR>")
2022-02-21 15:46:37 +00:00
-- terminal
function _G.set_terminal_keymaps()
2022-02-22 19:01:23 +00:00
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)
2022-02-21 15:46:37 +00:00
end
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
2022-02-21 18:54:49 +00:00
-- buffer closing
nnoremap("<leader>q", ":Bdelete<CR>")