diff --git a/home/code.nix b/home/code.nix index b4a3cce..059c982 100644 --- a/home/code.nix +++ b/home/code.nix @@ -9,7 +9,7 @@ ]; programs.neovim = { - enable = true; + enable = true; extraConfig = '' " syntax syntax enable @@ -34,19 +34,48 @@ " enable indent guides let g:indent_guides_enable_on_vim_startup = 1 + + " Exit Vim if NERDTree is the only window left. + autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | + \ quit | endif + + " Start NERDTree. If a file is specified, move the cursor to its window. + autocmd StdinReadPre * let s:std_in=1 + autocmd VimEnter * NERDTree | if argc() > 0 || exists("s:std_in") | wincmd p | endif + + " Start NERDTree when Vim starts with a directory argument. + autocmd StdinReadPre * let s:std_in=1 + autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | + \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif + + " Exit Vim if NERDTree is the only window left. + autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | + \ quit | endif + + " Start interactive EasyAlign in visual mode (e.g. vipga) + xmap ga (EasyAlign) + + " Start interactive EasyAlign for a motion/text object (e.g. gaip) + nmap ga (EasyAlign) + + " Highlight row and column + set cul + set cuc ''; - viAlias = true; + viAlias = true; vimAlias = true; - plugins = with pkgs.vimPlugins; [ - vim-nix + plugins = with pkgs.vimPlugins; [ + vim-nix molokai YouCompleteMe - vim-airline + vim-airline vim-airline-themes vim-lsp vim-indent-guides vim-signify + nerdtree + vim-easy-align ]; };