{ pkgs, ... }: { programs.nixvim = { enable = true; options = { number = true; relativenumber = true; tabstop = 2; shiftwidth = 2; expandtab = true; }; colorschemes.catppuccin = { enable = true; flavour = "frappe"; }; extraPlugins = with pkgs.vimPlugins; [ vim-abolish vim-dispatch vim-repeat vim-sensible vim-rhubarb vim-sort-motion vim-textobj-user nerdtree ]; plugins = { surround.enable = true; commentary.enable = true; fugitive.enable = true; tmux-navigator.enable = true; nvim-autopairs = { enable = true; }; lsp = { enable = true; servers = { elixirls.enable = true; tsserver.enable = true; nil_ls.enable = true; }; }; telescope = { enable = true; defaults = { preview = false; }; extensions.fzf-native.enable = true; }; cmp = { enable = true; autoEnableSources = true; settings = { mapping.__raw = "cmp.mapping.preset.insert({})"; sources = [ { name = "nvim_lsp"; } { name = "path"; } { name = "buffer"; } ]; }; cmdline = { ":" = { mapping = { __raw = "cmp.mapping.preset.cmdline()"; }; sources = [ { name = "path"; } { name = "cmdline"; } ]; }; }; }; treesitter = { enable = true; indent = true; }; # rust rustaceanvim = { enable = true; }; }; plugins.which-key = { enable = true; keyLabels = { "" = "SPC"; "" = "RET"; "" = "TAB"; }; registrations = { "g" = "Git"; "f" = "Files"; }; }; globals.mapleader = " "; keymaps = [ { key = ";"; action = ":"; } { key = "q;"; action = "q:"; } { key = "y"; action = ''"+y''; } { key = "Y"; action = ''"+Y''; } { key = "p"; action = ''"+p''; } { key = "P"; action = ''"+P''; } { key = "w"; action = "w"; } { key = "q"; action = "q"; } { key = ""; action = "nohlsearch"; mode = "n"; } # root level leader commands { key = ""; action = "Telescope find_files"; options = { desc = "Find files in project"; }; } { key = "/"; action = "Telescope live_grep"; options = { desc = "Search project"; }; } { key = ""; action = "NERDTreeToggle"; options = { desc = "Toggle NERDTree"; }; } # file commands { key = "fl"; action = "NERDTreeFind"; options = { desc = "Locate file"; }; } # git { key = "gs"; action = "Git"; options = { desc = "Status"; }; } { key = "gp"; action = "Git push"; options = { desc = "Push"; }; } { key = "gP"; action = "Git push --force-with-lease"; options = { desc = "Push (force with lease)"; }; } { key = "gf"; action = "Git fetch"; options = { desc = "Fetch"; }; } # git rebase { key = "gro"; action = "Git rebase origin/main"; options = { desc = "origin/main"; }; } { key = "grO"; action = "Git rebase --interactive origin/main"; options = { desc = "-i origin/main"; }; } { key = "grm"; action = "Git rebase origin/master"; options = { desc = "origin/master"; }; } { key = "grM"; action = "Git rebase --interactive origin/master"; options = { desc = "-i origin/master"; }; } ]; # TODO: move this into Nix extraConfigLuaPost = '' vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('UserLspConfig', {}), callback = function(ev) -- Enable completion triggered by vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' local opts = { buffer = ev.buf } vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) end, }) ''; }; }