{ ... }: { programs.nixvim = { keymaps = [ # ----------------------------------------------------- # nvim-tree # ----------------------------------------------------- ## Go to current buffer's file in nvim-tree { mode = [ "n" ]; key = ",n"; action = ":NvimTreeFindFile"; } ## Toggle nvim-tree visibility { mode = [ "n" ]; key = ",m"; action = ":NvimTreeToggle"; } # ----------------------------------------------------- # buffer manipulation # ----------------------------------------------------- ## Next Buffer { key = ""; action = ":bn"; options = { noremap = true; }; } ## Previous Buffer { key = ""; action = ":bp"; options = { noremap = true; }; } ## Close Buffer { key = ""; action = ":bd"; options = { noremap = true; }; } ## Force Close Buffer { key = ""; action = ":bd!"; options = { noremap = true; }; } ## New Tab { key = "t"; action = ":tabnew split"; options = { noremap = true; }; } # ----------------------------------------------------- # Telescope # ----------------------------------------------------- ## Lists files in your current working directory, respects .gitignore { mode = [ "n" ]; key = "ff"; action = "Telescope find_files"; options = { noremap = true; }; } ## Finds files by filename { mode = [ "n" ]; key = ""; action = "Telescope find_files"; # action = "FzfLua files"; 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 = "fg"; action = "Telescope live_grep"; # action = "FzfLua live_grep"; options = { noremap = true; }; } # Search file contents { mode = [ "n" ]; key = ""; action = "Telescope live_grep"; # action = "FzfLua live_grep"; options = { noremap = true; }; } # Lists open buffers in current neovim instance { mode = [ "n" ]; key = "db"; action = "Telescope buffers"; # action = "FzfLua buffers"; options = { noremap = true; }; } # Lists available help tags and opens a new window with the relevant help info on { mode = [ "n" ]; key = "fh"; action = "Telescope help_tags"; # action = "FzfLua helptags"; options = { noremap = true; }; } # Lists manpage entries, opens them in a help window on { mode = [ "n" ]; key = "fm"; action = "Telescope man_pages"; # action = "FzfLua manpages"; options = { noremap = true; }; } # Lists previously open files { mode = [ "n" ]; key = "fp"; action = "Telescope oldfiles"; # action = "FzfLua oldfiles"; options = { noremap = true; }; } # Lists previously open files, Maps to ctrl-/ { mode = [ "n" ]; key = ""; action = "Telescope oldfiles"; # action = "FzfLua oldfiles"; options = { noremap = true; }; } # Lists spelling suggestions for the current word under the cursor, replaces word with selected suggestion on { mode = [ "n" ]; key = "fs"; action = "Telescope spell_suggest"; # action = "FzfLua spell_suggest"; options = { noremap = true; }; } # Lists LSP references for iword under the cursor { mode = [ "n" ]; key = "fr"; action = "Telescope lsp_references"; # action = "FzfLua lsp_references"; options = { noremap = true; }; } # Lists LSP incoming calls for word under the cursor { mode = [ "n" ]; key = "fi"; action = "Telescope lsp_incoming_calls"; # action = "FzfLua lsp_incoming_calls"; options = { noremap = true; }; } # Lists LSP outgoing calls for word under the cursor { mode = [ "n" ]; key = "fo"; action = "Telescope lsp_outgoing_calls"; # action = "FzfLua lsp_outgoing_calls"; options = { noremap = true; }; } # Dynamically Lists LSP for all workspace symbols { mode = [ "n" ]; key = "fw"; action = "Telescope lsp_dynamic_workspace_symbols"; # action = "FzfLua lsp_workspace_symbols"; 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 = "fd"; action = "Telescope lsp_definitions"; options = { noremap = true; }; } # Got to previous error { mode = [ "n" ]; key = "[d"; action = "lua vim.diagnostic.goto_prev()"; options = { noremap = true; silent = true; }; } { mode = [ "n" ]; key = ",k"; action = "lua vim.diagnostic.goto_prev()"; options = { noremap = true; silent = true; }; } # Got to next error { mode = [ "n" ]; key = "]d"; action = "lua vim.diagnostic.goto_next()"; options = { noremap = true; silent = true; }; } { mode = [ "n" ]; key = ",j"; action = "lua vim.diagnostic.goto_next()"; 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 = ""; action = ":BufferLineCyclePrev"; options = { noremap = true; silent = true; }; } { mode = [ "n" ]; key = ""; action = ":BufferLineCycleNex"; options = { noremap = true; silent = true; }; } { mode = [ "n" ]; key = ""; action = ":bdelete!"; options = { noremap = true; silent = true; }; } ]; }; }