dotfiles/.config/nvim/lua/core/keymaps.lua

23 lines
1,003 B
Lua

-- Convenience function. description parameter is used by `whichkey`
local function map(mode, keybind, command, description)
vim.api.nvim_set_keymap(mode, keybind, command, { desc = description, silent = true, noremap = true })
end
-- Switch to <space> as global mapleader
vim.g.mapleader = " "
-- Don't place single deleted characters in a buffer
map("n", "x", '"_x')
-- Increment and decrement numbers
map("n", "<leader>+", "<C-a>", "Increment number under cursor")
map("n", "<leader>-", "<C-x>", "Decrement number under cursor")
-- File explorer
map("n", "<leader>e", ":NvimTreeToggle<CR>", "Toggle file explorer")
-- telescope
map("n", "<leader>ff", "<cmd>Telescope find_files<cr>", "Find files within cwd") -- respects .gitignore
map("n", "<leader>fs", "<cmd>Telescope live_grep<cr>", "Find string in cwd")
map("n", "<leader>fb", "<cmd>Telescope buffers<cr>", "List open buffers in current neovim instance")
map("n", "<leader>fh", "<cmd>Telescope help_tags<cr>", "List available help tags")