Skip to content

Commit

Permalink
Fix NerdTreeFind issue
Browse files Browse the repository at this point in the history
With a new created file that is not yet on the NERDTree node.
When invoking NerdTreeFind on that file it will raise an error because
of that file not being located in node nerdtree. This issue was raised
in NERDTree repo but still not fixed. This is a temporary fix since it
just mitigates the error by refreshing the node.

preservim/nerdtree#779
  • Loading branch information
rhiroyuki committed Jun 12, 2019
1 parent 23c3b3e commit c4a2cd6
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion nvim/settings/nerdtree.vim
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,47 @@ if has_key(g:plugs, 'nerdtree')
NERDTreeFind
q
else
NERDTreeFind
try
NERDTreeFind
catch /^Vim\%((\a\+)\)\=:E716/
NERDTreeFocus | execute 'normal R' | wincmd p
NERDTreeFind
endtry
endif
endfunction

" Open the project tree and expose current file in the nerdtree with Ctrl-\
command! LocalNERDTreeToggle call NERDTreeFindToggle()
nnoremap <silent> <C-\> :LocalNERDTreeToggle<cr>
else
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_winsize = 20
let g:netrw_browse_split = 2

let g:NetrwIsOpen=0

function! ToggleNetrw()
if g:NetrwIsOpen
let i = bufnr("$")
while (i >= 1)
if (getbufvar(i, "&filetype") == "netrw")
silent exe "bwipeout " . i
endif
let i-=1
endwhile
let g:NetrwIsOpen=0
else
let g:NetrwIsOpen=1
let current_filename=expand('%:t')
silent Vexplore
execute '/' . current_filename
silent noh
endif
endfunction

command! LocalNetrwToggle call ToggleNetrw()

nnoremap <silent> <C-\> :LocalNetrwToggle<cr>
autocmd FileType netrw setl bufhidden=delete
endif

0 comments on commit c4a2cd6

Please sign in to comment.