nixos/lua/keymaps.lua

55 lines
1.9 KiB
Lua

local function map(mode, shortcut, command)
vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true })
end
local function nmap(shortcut, command)
map('n', shortcut, command)
end
local function imap(shortcut, command)
map('i', shortcut, command)
end
vim.g.mapleader = ' '
-- Misc
imap('jk', '<Esc>')
nmap('<leader>gf', '<cmd>Git fetch<cr>')
nmap('<leader>gp', '<cmd>Git pull<cr>')
nmap('<leader>gP', '<cmd>Git push<cr>')
-- Telescope
nmap('<leader>;', '<cmd>Telescope builtin<cr>')
nmap('<leader>ff', '<cmd>Telescope find_files<cr>')
nmap('<leader>fr', '<cmd>Telescope resume<cr>')
nmap('<leader>fb', '<cmd>Telescope buffers<cr>')
nmap('<leader>fh', '<cmd>Telescope help_tags<cr>')
nmap('<leader>fk', '<cmd>Telescope aerial<cr>')
nmap('<leader>fd', '<cmd>Telescope lsp_document_symbols<cr>')
nmap('<leader>fe', '<cmd>Telescope diagnostics<cr>')
nmap('<leader>fn', '<cmd>Telescope notify<cr>')
nmap('<leader>ft', '<cmd>Telescope treesitter<cr>')
nmap('<leader>fz', '<cmd>Telescope current_buffer_fuzzy_find<cr>')
nmap('<leader>fg', '<cmd>Telescope live_grep<cr>')
-- Hop
nmap('<leader>hl', '<cmd>HopLine<cr>')
nmap('<leader>hw', '<cmd>HopWord<cr>')
-- Nvim-tree
nmap('<leader>nt', '<cmd>NvimTreeToggle<cr>')
nmap('<leader>nf', '<cmd>NvimTreeFindFile<cr>')
-- Trouble
nmap('<leader>tq', '<cmd>TroubleToggle quickfix<cr>')
nmap('<leader>tl', '<cmd>TroubleToggle loclist<cr>')
nmap('<leader>tr', '<cmd>TroubleToggle lsp_references<cr>')
nmap('<leader>td', '<cmd>TroubleToggle lsp_definitions<cr>')
nmap('<leader>tt', '<cmd>TroubleToggle lsp_type_definitions<cr>')
nmap('<leader>ti', '<cmd>TroubleToggle lsp_implementations<cr>')
nmap('<leader>tdd', '<cmd>TroubleToggle document_diagnostics<cr>')
nmap('<leader>twd', '<cmd>TroubleToggle workspace_diagnostics<cr>')
-- SnipRun
nmap('<leader>srs', '<cmd>SnipRun<cr>')
nmap('<leader>srr', '<cmd>%SnipRun<cr>')