{ pkgs, lib, config, ... }: { # config = lib.mkIf config.programs.nixvim.enable { # Somehow this is infinite recursion? config = { home.sessionVariables = { EDITOR = "nvim"; } // lib.optionalAttrs config.frogeye.desktop.xorg { VISUAL = "nvim"; }; programs.bash.shellAliases = { vi = "nvim"; vim = "nvim"; }; programs.nixvim = { options = { ignorecase = true; smartcase = true; gdefault = true; tabstop = 4; shiftwidth = 4; expandtab = true; splitbelow = true; visualbell = true; updatetime = 250; undofile = true; wildmode = "longest:full,full"; wildmenu = true; }; globals = { netrw_fastbrowse = 0; # Close the file explorer once you select a file }; plugins = { # Go to whatever telescope = { enable = true; keymaps = { gF = "find_files"; gf = "git_files"; gB = "buffers"; gl = "current_buffer_fuzzy_find"; gL = "live_grep"; gT = "tags"; gt = "treesitter"; gm = "marks"; gh = "oldfiles"; gH = "command_history"; gS = "search_history"; gC = "commands"; gr = "lsp_references"; ge = "diagnostics"; gd = "lsp_definitions"; gs = "lsp_document_symbols"; }; defaults = { vimgrep_arguments = [ "${pkgs.ripgrep}/bin/rg" "--color=never" "--no-heading" "--with-filename" "--line-number" "--column" "--smart-case" ]; }; extensions.fzf-native = { enable = true; caseMode = "smart_case"; fuzzy = true; overrideFileSorter = true; overrideGenericSorter = true; }; }; # Surrounding pairs surround.enable = true; # Change surrounding pairs (e.g. brackets, quotes) undotree.enable = true; # Navigate edition history }; extraPlugins = with pkgs.vimPlugins; [ # Search/replace vim-abolish # Regex for words, with case in mind vim-easy-align # Aligning lines around a certain character # Surrounding pairs targets-vim # Better interaction with surrounding pairs # Language-specific tcomment_vim # Language-aware (un)commenting ] ++ lib.optionals config.programs.pandoc.enable [ vim-pandoc # Pandoc-specific stuff because there's no LSP for it vim-pandoc-syntax ] ++ lib.optionals config.frogeye.dev.ansible [ ansible-vim # Doesn't generate snippets, but those are for UltiSnip anyways ]; extraConfigVim = '' " GENERAL " Avoid showing message extra message when using completion set shortmess+=c command Reload source $MYVIMRC " PLUGINS '' + lib.optionalString config.programs.pandoc.enable '' " vim-pandox let g:pandoc#modules#disabled = ["folding"] let g:pandoc#spell#enabled = 0 let g:pandoc#syntax#conceal#use = 0 ''; autoCmd = [ # vim-easy-align: Align Markdown tables { event = "FileType"; pattern = "markdown"; command = "vmap :EasyAlign*"; } ]; userCommands = { # Reload = { command = "source $MYVIRMC"; }; # TODO Is not working, options is set to nil even though it shouldn't }; keymaps = [ # GENERAL # Allow saving of files as sudo when I forgot to start vim using sudo. # From https://stackoverflow.com/a/7078429 { mode = "c"; key = "w!!"; action = "w !sudo tee > /dev/null %"; } { mode = "i"; key = "jk"; action = ""; } { mode = "v"; key = ""; action = ""; } { key = ""; action = "o"; } # { key = ""; action = ":bp"; } # { key = ""; action = ":bn"; } { key = ""; action = "kkkkkkkkkkkkkkkkkkkkk"; } { key = ""; action = "jjjjjjjjjjjjjjjjjjjjj"; } # \s to replace globally the word under the cursor { key = "s"; action = ":%s/\\<\\>/"; } # PLUGINS # undotree { key = "u"; action = "UndotreeToggle"; options = { silent = true; }; } ]; }; }; imports = [ ./code.nix ./completion.nix ./decoration.nix ./git.nix ./lsp.nix ]; }