{ ... }: { programs.nixvim = { keymaps = [ # ----------------------------------------------------- # nvim-tree # ----------------------------------------------------- ## Go to current buffer's file in nvim-tree { mode = [ "n" ]; key = ",n"; action = ":NvimTreeFindFile<CR>"; } ## Toggle nvim-tree visibility { mode = [ "n" ]; key = ",m"; action = ":NvimTreeToggle<CR>"; } # ----------------------------------------------------- # buffer manipulation # ----------------------------------------------------- ## Next Buffer { key = "<Tab>"; action = ":bn<CR>"; options = { noremap = true; }; } ## Previous Buffer { key = "<S-Tab>"; action = ":bp<CR>"; options = { noremap = true; }; } ## Close Buffer { key = "<leader><Tab>"; action = ":bd<CR>"; options = { noremap = true; }; } ## Force Close Buffer { key = "<leader><S-Tab>"; action = ":bd!<CR>"; options = { noremap = true; }; } ## New Tab { key = "<leader>t"; action = ":tabnew split<CR>"; options = { noremap = true; }; } # ----------------------------------------------------- # Telescope # ----------------------------------------------------- ## Lists files in your current working directory, respects .gitignore { mode = [ "n" ]; key = "<leader>ff"; action = "<cmd>Telescope find_files<cr>"; options = { noremap = true; }; } ## Finds files by filename { mode = [ "n" ]; key = "<c-p>"; action = "<cmd>Telescope find_files<cr>"; # action = "<cmd>FzfLua files<cr>"; options = { noremap = true; }; } # Search for a string in your current working directory and get results live as you type, respects .gitignore. (Requires ripgrep) { mode = [ "n" ]; key = "<leader>fg"; action = "<cmd>Telescope live_grep<cr>"; # action = "<cmd>FzfLua live_grep<cr>"; options = { noremap = true; }; } # Search file contents { mode = [ "n" ]; key = "<c-s>"; action = "<cmd>Telescope live_grep<cr>"; # action = "<cmd>FzfLua live_grep<cr>"; options = { noremap = true; }; } # Lists open buffers in current neovim instance { mode = [ "n" ]; key = "<leader>db"; action = "<cmd>Telescope buffers<cr>"; # action = "<cmd>FzfLua buffers<cr>"; options = { noremap = true; }; } # Lists available help tags and opens a new window with the relevant help info on <cr> { mode = [ "n" ]; key = "<leader>fh"; action = "<cmd>Telescope help_tags<cr>"; # action = "<cmd>FzfLua helptags<cr>"; options = { noremap = true; }; } # Lists manpage entries, opens them in a help window on <cr> { mode = [ "n" ]; key = "<leader>fm"; action = "<cmd>Telescope man_pages<cr>"; # action = "<cmd>FzfLua manpages<cr>"; options = { noremap = true; }; } # Lists previously open files { mode = [ "n" ]; key = "<leader>fp"; action = "<cmd>Telescope oldfiles<cr>"; # action = "<cmd>FzfLua oldfiles<cr>"; options = { noremap = true; }; } # Lists previously open files, Maps to ctrl-/ { mode = [ "n" ]; key = "<c-_>"; action = "<cmd>Telescope oldfiles<cr>"; # action = "<cmd>FzfLua oldfiles<cr>"; options = { noremap = true; }; } # Lists spelling suggestions for the current word under the cursor, replaces word with selected suggestion on <cr> { mode = [ "n" ]; key = "<leader>fs"; action = "<cmd>Telescope spell_suggest<cr>"; # action = "<cmd>FzfLua spell_suggest<cr>"; options = { noremap = true; }; } # Lists LSP references for iword under the cursor { mode = [ "n" ]; key = "<leader>fr"; action = "<cmd>Telescope lsp_references<cr>"; # action = "<cmd>FzfLua lsp_references<cr>"; options = { noremap = true; }; } # Lists LSP incoming calls for word under the cursor { mode = [ "n" ]; key = "<leader>fi"; action = "<cmd>Telescope lsp_incoming_calls<cr>"; # action = "<cmd>FzfLua lsp_incoming_calls<cr>"; options = { noremap = true; }; } # Lists LSP outgoing calls for word under the cursor { mode = [ "n" ]; key = "<leader>fo"; action = "<cmd>Telescope lsp_outgoing_calls<cr>"; # action = "<cmd>FzfLua lsp_outgoing_calls<cr>"; options = { noremap = true; }; } # Dynamically Lists LSP for all workspace symbols { mode = [ "n" ]; key = "<leader>fw"; action = "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>"; # action = "<cmd>FzfLua lsp_workspace_symbols<cr>"; options = { noremap = true; }; } # Goto the definition of the word under the cursor, if there's only one, otherwise show all options in Telescope { mode = [ "n" ]; key = "<leader>fd"; action = "<cmd>Telescope lsp_definitions<cr>"; options = { noremap = true; }; } # Got to previous error { mode = [ "n" ]; key = "[d"; action = "<cmd>lua vim.diagnostic.goto_prev()<CR>"; options = { noremap = true; silent = true; }; } { mode = [ "n" ]; key = ",k"; action = "<cmd>lua vim.diagnostic.goto_prev()<CR>"; options = { noremap = true; silent = true; }; } # Got to next error { mode = [ "n" ]; key = "]d"; action = "<cmd>lua vim.diagnostic.goto_next()<CR>"; options = { noremap = true; silent = true; }; } { mode = [ "n" ]; key = ",j"; action = "<cmd>lua vim.diagnostic.goto_next()<CR>"; options = { noremap = true; silent = true; }; } ## Other Telescope options: ## git_files search only files in git, respects .gitignore ## oldfiles previously opened files ## command_history ## search_history ## man_pages ## resume lists the results including multi-selections of the previous ## picker # ----------------------------------------------------- # Diff # ----------------------------------------------------- { mode = [ "n" ]; key = ",d"; ## @TODO: This doesn't work action = '' function() if next(require('diffview.lib').views) == nil then vim.cmd('DiffviewOpen origin') else vim.cmd('DiffviewClose') end end ''; options = { noremap = true; }; } # ----------------------------------------------------- # Bufferline # ----------------------------------------------------- { mode = [ "n" ]; key = "<A-h>"; action = ":BufferLineCyclePrev<CR>"; options = { noremap = true; silent = true; }; } { mode = [ "n" ]; key = "<A-l>"; action = ":BufferLineCycleNex<CR>"; options = { noremap = true; silent = true; }; } { mode = [ "n" ]; key = "<A-c>"; action = ":bdelete!<CR>"; options = { noremap = true; silent = true; }; } ]; }; }