{ pkgs, ... }: let vim-stabs = pkgs.vimUtils.buildVimPlugin { name = "vim-stabs"; src = pkgs.fetchFromGitHub { owner = "Thyrum"; repo = "vim-stabs"; rev = "4654d4e000680e1f608b40f155af08873446ed63"; sha256 = "0hi1c5zv38hwxbyrf11fz97r728jgbppz4is7fwzwhfrzhwbw0ga"; }; }; in { programs.vim = { enable = true; plugins = with pkgs.vimPlugins; [ bufexplorer ctrlp nerdtree vim-gitgutter vim-flake8 vim-fugitive vim-indent-guides #vim-stabs gruvbox syntastic ]; settings = { background = "dark"; copyindent = true; expandtab = false; hidden = true; ignorecase = true; mouse = "a"; number = true; relativenumber = true; shiftwidth = 4; smartcase = true; tabstop = 4; }; extraConfig = '' syntax enable set preserveindent set softtabstop=0 set nowrap set showcmd set cursorline set lazyredraw set showmatch set hlsearch " Shows non-printing characters set listchars=tab:→\ ,extends:→,precedes:←,trail:·,eol:¬ set list " Set filetype to the way I want it let g:nix_recommended_style = 0 " Highlights bad whitespace autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@ \be map :NERDTreeToggle map :CtrlP " Allows navigating splits map j map k map h map l colorscheme gruvbox " ============================================================================ " User functions to just make life easier " ============================================================================ " Toggle absolute line numbers when we don't have focus, and hybrid when " we do have it augroup numbertoggle autocmd! autocmd BufEnter,FocusGained,InsertLeave * set relativenumber autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber augroup END " syntax highlighting for Vagrantfiles augroup vagrant au! au BufRead,BufNewFile Vagrantfile set filetype=ruby augroup END " Creates the directory for a file if it doesn't already exist. function! s:MkNonExDir(file, buf) if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/' let dir=fnamemodify(a:file, ':h') if !isdirectory(dir) call mkdir(dir, 'p') endif endif endfunction augroup BWCCreateDir autocmd! autocmd BufWritePre * :call s:MkNonExDir(expand(''), +expand('')) augroup END " Return indent (all whitespace at start of a line), converted from " tabs to spaces if what = 1, or from spaces to tabs otherwise. " When converting to tabs, result has no redundant spaces. function! Indenting(indent, what, cols) let spccol = repeat(' ', a:cols) let result = substitute(a:indent, spccol, '\t', 'g') let result = substitute(result, ' \+\ze\t', ''', 'g') if a:what == 1 let result = substitute(result, '\t', spccol, 'g') endif return result endfunction " Convert whitespace used for indenting (before first non-whitespace). " what = 0 (convert spaces to tabs), or 1 (convert tabs to spaces). " cols = string with number of columns per tab, or empty to use 'tabstop'. " The cursor position is restored, but the cursor will be in a different " column when the number of characters in the indent of the line is changed. function! IndentConvert(line1, line2, what, cols) let savepos = getpos('.') let cols = empty(a:cols) ? &tabstop : a:cols execute a:line1 . ',' . a:line2 . 's/^\s\+/\=Indenting(submatch(0), a:what, cols)/e' call histdel('search', -1) call setpos('.', savepos) endfunction command! -nargs=? -range=% Space2Tab call IndentConvert(,,0,) command! -nargs=? -range=% Tab2Space call IndentConvert(,,1,) command! -nargs=? -range=% RetabIndent call IndentConvert(,,&et,) ''; }; }