nixos/common/neovim/nerdtree.nix

27 lines
1.1 KiB
Nix

{ pkgs, ... }:
{
programs.neovim = {
plugins = with pkgs.vimPlugins; [
{
plugin = nerdtree;
config = ''
nnoremap <C-right> <C-W><C-l>
nnoremap <C-left> <C-W><C-h>
nnoremap <C-up> <C-W><C-k>
nnoremap <C-down> <C-W><C-j>
nnoremap <C-T> :NERDTreeToggle<CR>
nnoremap <C-R> :NERDTreeFocus<CR>
" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" Close the tab if NERDTree is the only window remaining in it.
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree.
autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
'';
}
nerdtree-git-plugin
];
};
}