{ pkgs, lib, inputs, config, ...}: let undoDir = "${config.home.homeDirectory}/.vim/undo"; in { programs.neovim = { enable = true; defaultEditor = true; viAlias = true; vimAlias = true; vimdiffAlias = true; plugins = with pkgs.vimPlugins; [ lightline-vim vim-lightline-coc vim-commentary vim-fugitive nerdtree nerdtree-git-plugin vim-devicons telescope-nvim nvim-lspconfig copilot-vim nvim-treesitter coc-css coc-go coc-html coc-json coc-nvim coc-pyright vim-nix ]; withNodeJs = true; extraConfig = '' let mapleader = ',' set number set shiftwidth=2 set tabstop=2 set expandtab set undofile set undodir=${undoDir} set undolevels=1000 set undoreload=10000 " Integrate status with lightline let g:lightline = { \ 'active': { \ 'left': [[ 'coc_info', 'coc_hints', 'coc_errors', 'coc_warnings', 'coc_ok' ], [ 'coc_status' ]] \ } \ } " register components: call lightline#coc#register() " GoTo code navigation. nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " Use K to show documentation in preview window. nnoremap K :call ShowDocumentation() function! ShowDocumentation() if CocAction('hasProvider', 'hover') call CocActionAsync('doHover') else call feedkeys('K', 'in') endif endfunction " Enable syntax folding with coc command! -nargs=* Fold :call CocAction('fold', ) inoremap coc#pum#visible() ? coc#pum#confirm() \: "\u\\=coc#on_enter()\" " Highlight the symbol and its references when holding the cursor. autocmd CursorHold * silent call CocActionAsync('highlight') " Symbol renaming. nmap rn (coc-rename) " Use CTRL-S for selections ranges. " Requires 'textDocument/selectionRange' support of language server. nmap (coc-range-select) xmap (coc-range-select) " Step through diagnostics nmap (coc-diagnostic-prev) nmap >g (coc-diagnostic-next) " Nerdtree-settings " Toggle nerdtree on Ctrl+t nmap :NERDTreeToggle autocmd VimEnter * NERDTree " Autostart nerdtree on vim startup autocmd VimEnter * wincmd p " Unselect nerdtree window " Close vim is Nerdtree is the only buffer left autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif " List and switch buffers on Ctrl+k " nnoremap :set nomore :ls :set more :b nnoremap !echo "Did you mean C-a?" " Telescope-settings nnoremap ff Telescope find_files nnoremap fg Telescope live_grep nnoremap fb Telescope buffers nnoremap fh Telescope help_tags nnoremap Telescope buffers nnoremap Telescope find_files nnoremap Telescope live_grep " Show trailing whitespace highlight ExtraWhitespace ctermbg=red guibg=red match ExtraWhitespace /\s\+$/ " Disable search highlights map :noh ''; }; # Create undo directory home.activation.vimUndoDir = lib.hm.dag.entryAfter ["writeBoundary"] "mkdir -p ${undoDir}"; }