{ pkgs , extraPlugins ? [] , extraOptions ? "" , ... }: # At first, largely adapted from: # https://www.mpscholten.de/nixos/2016/04/11/setting-up-vim-on-nixos.html # Changed quite a bit since with pkgs; let plugins = let inherit (vimUtils) buildVimPlugin; in { "systemd-syntax" = buildVimPlugin { # created by nix#NixDerivation pname = "systemd-syntax"; version = "git"; src = fetchFromGitHub { owner = "Matt-Deacalion"; repo = "vim-systemd-syntax"; rev = "394a516f524e74ac8808ede1496b25d8b9824827"; sha256 = "0fqk5fxrdf8nazic244ia4bi75midmpj896vdkdmxnv563lnhkcy"; }; dependencies = []; }; "opencl-syntax" = buildVimPlugin { # created by nix#NixDerivation pname = "opencl-syntax"; version = "git"; src = fetchFromGitHub { owner = "petRUShka"; repo = "vim-opencl"; rev = "7668b018fe9461c6b51e0b736ed84aa84d6bafce"; sha256 = "0z8qasymkkaa272bjxmkp4sgd8qr4ypcqxlyzxgh5imp3gmrc6n1"; }; dependencies = []; }; vim-timedot = buildVimPlugin { pname = "vim-timedot"; version = "git"; src = fetchFromGitHub { owner = "jpotier"; repo = "vim-timedot"; rev = "ab48ee1002e25ae705dd84bb3db8b88bb0c2dc93"; sha256 = "0vgga3fmppb71apd31bwji98d62vs1p77c1hssshmh2fc7yck6s8"; }; }; vim-selinux = buildVimPlugin { pname = "vim-selinux"; version = "git"; src = fetchFromGitHub { owner = "lzap"; repo = "vim-selinux"; rev = "ac5362b9b3ad32215136bda0b7d12bdfe02f3d2f"; sha256 = "kOKOpxLSMCEQ1mmoJrL72/1fAH9xPV21rReAXrr5f5g="; }; }; vim-lilypond = buildVimPlugin { # created by nix#NixDerivation pname = "vim-lilypond"; version = "git"; src = "${pkgs.lilypond.outPath}/share/lilypond/${pkgs.lilypond.version}/vim"; dependencies = []; }; vim-css-color = buildVimPlugin { pname = "vim-css-color"; version = "git"; src = fetchFromGitHub { owner = "jpotier"; repo = "vim-css-color"; rev = "bd7cac457b4459e3e60fec39c094832d233c6a7f"; sha256 = "08k1jh9n0kz9xwmy0ig03w9lx0r2m2rhmfwb0idy81madllcidjc"; }; }; vim-lsp-mats = buildVimPlugin { pname = "vim-lsp"; version = "git"; src = fetchFromGitHub { owner = "masser"; repo = "vim-lsp"; rev = "1e71d5b923ec2574f9b07fbebaf6af90491db31c"; sha256 = "1ZlXZo430WzagZ58PT34y/qnx9Qwf/qZJlY1m8ml56Q="; }; }; }; in vim_configurable.customize { name = "vim"; vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; with plugins; { # loaded on launch start = [ calendar-vim dhall-vim #editorconfig-vim fzf-vim fzfWrapper goyo-vim gundo-vim nerdtree opencl-syntax systemd-syntax vim-abolish vim-airline vim-airline-themes vim-better-whitespace vim-gnupg vim-hcl vim-ledger vim-lilypond vim-lsp-mats vim-nix vim-orgmode vim-repeat vim-selinux vim-speeddating vim-surround vim-terraform vim-timedot vimtex ] ++ extraPlugins; # manually loadable by calling `:packadd $plugin-name` opt = [ vim-css-color ]; # To automatically load a plugin when opening a filetype, add vimrc lines like: # autocmd FileType php :packadd phpCompletion }; vimrcConfig.customRC = '' " Must have for vim set nocompatible " Display nbsp set listchars=tab:\|\ ,nbsp:ยท set list " Remap ESC on ,, map ,, imap ,, scriptencoding utf-8 " Must be *after* pathogen (not using pathogen anymore) filetype plugin indent on " Leader let mapleader="," nnoremap a :echo("\ works! It is set to ") " let maplocalleader = "-" " Highlighting syntax enable if has('gui_running') " When gui is running, it pretty much sets its own colors set guifont=Iosevka\ Samae\ 14 set notitle set guioptions=a else " If we're in a terminal, then we stay default, terminal will choose " which colors it likes. endif " Set line numbering set number " Don't wrap lines, it's ugly set nowrap " Deal with tabs set softtabstop=2 set tabstop=2 " 1 tab = 2 spaces set shiftwidth=2 " Indent with 2 spaces set expandtab " Insert spaces instead of tabs " Set par as default wrapper set formatprg=${par.outPath}/bin/par\ -w80 " Set mouse on set mouse=a " Don't set timeout - this breaks the leader use set notimeout set ttimeout " Color lines in a different shade up to 80 columns let &colorcolumn=join(range(81,999),",") " automatically jump to the end of the text you just copied/pasted: xnoremap y y`] nnoremap yy yy`] xnoremap p p`] xnoremap P P`] nnoremap p p`] nnoremap P P`] " vimtex options let g:vimtex_fold_enabled=1 let g:vimtex_fold_manual=1 let g:vimtex_compiler_enabled=0 let g:tex_flavor = 'latex' " conceal to unicode symbols nnoremap l :silent let &conceallevel = (&conceallevel+1)%4 set conceallevel=0 set concealcursor=nvc let g:tex_conceal="abdmgs" " nice pluginless stuff set path+=** set wildmenu " Tag generation command! MakeTags !${universal-ctags}/bin/ctags -R . " Less noise in netrw let g:netrw_altv=1 let g:netrw_banner=0 let g:netrw_browse_split=4 let g:netrw_list_hide=netrw_gitignore#Hide() let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+' let g:netrw_liststyle=3 let g:netrw_winsize=25 " Normal backspace set backspace=indent,eol,start " Set filetype tex for tikz files au BufNewFile,BufRead *.tikz set filetype=tex " Thx Mats for the following :cnoremap :cnoremap :cnoremap :cnoremap " NERDTree when starting "autocmd vimenter * NERDTree let g:NERDTreeDirArrowExpandable = '+' let g:NERDTreeDirArrowCollapsible = '-' " SmartCase (only search by case if capital letter is used) set ignorecase set smartcase " Allow for more than 10 tabs to be opened at once set tabpagemax=40 " Help ledger let g:ledger_bin = '${hledger}/bin/hledger' let g:ledger_extra_options = '--pedantic --explicit --check-payees' " Virtual Edit maaan set ve=block " Read Vagrantfile as ruby source augroup vagrant au! au BufRead,BufNewFile Vagrantfile set filetype=ruby augroup END " Haskell Language Server if executable('dhall-lsp-server') au User lsp_setup call lsp#register_server({ \ 'name': 'dhall-lsp', \ 'cmd': {server_info->['dhall-lsp-server']}, \ 'allowlist': ['dhall'], \ }) endif if executable('haskell-language-server-wrapper') au User lsp_setup call lsp#register_server({ \ 'name': 'haskell-lsp', \ 'cmd': {server_info->['haskell-language-server-wrapper', '--lsp']}, \ 'allowlist': ['haskell'], \ }) endif function! s:on_lsp_buffer_enabled() abort setlocal omnifunc=lsp#complete setlocal signcolumn=yes if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif nmap gd (lsp-definition) nmap gr (lsp-references) nmap gi (lsp-implementation) nmap gt (lsp-type-definition) nmap rn (lsp-rename) nmap [g (lsp-previous-diagnostic) nmap ]g (lsp-next-diagnostic) nmap K (lsp-hover) nmap a (lsp-code-action) nmap dd (lsp-document-diagnostics) " refer to doc to add more commands endfunction augroup lsp_install au! " call s:on_lsp_buffer_enabled only for languages that has the server registered. autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() augroup END " Use down window FZF let g:fzf_layout = { 'down': '40%' } " Extra options ${extraOptions} ''; } # " vimwiki stuff # " let g:vimwiki_global_ext = 0 # " let g:vimwiki_conceallevel = 0 # " let g:vimwiki_auto_chdir = 1 # " let g:vimwiki_list = [ # " \{'path': '~/zk/'}, # " \{'path': '~/vimwiki/personal.wiki'} # " \] # " :autocmd FileType vimwiki map d :VimwikiMakeDiaryNote # " :autocmd FileType vimwiki Goyo 80x20 # " # " function! ToggleCalendar() # " execute ":Calendar" # " if exists("g:calendar_open") # " if g:calendar_open == 1 # " execute "q" # " unlet g:calendar_open # " else # " g:calendar_open = 1 # " end # " else # " let g:calendar_open = 1 # " end # " endfunction # " :autocmd FileType vimwiki map c :call ToggleCalendar()