Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"Put this file in ~/.vim/nerdtree_plugin
"
"There are definitely more efficient ways to check a file to see if it
"is a class/interface/etc but this is really just a proof of concept.
if exists("loaded_nerdtree_ft_flags_plugin")
finish
endif
let g:loaded_nerdtree_ft_flags_plugin = 1
let s:flagNamespace = "filetype"
function! NERDTreeFtFlagsListener(event)
let path = a:event.subject
if path.isDirectory
return
endif
if s:IsClass(path)
call path.flagSet.addFlag(s:flagNamespace, 'C')
elseif s:IsInterface(path)
call path.flagSet.addFlag(s:flagNamespace, 'I')
endif
endfunction
call g:NERDTreePathNotifier.AddListener("init", "NERDTreeFtFlagsListener")
call g:NERDTreePathNotifier.AddListener("refreshFlags", "NERDTreeFtFlagsListener")
function! s:IsClass(path)
call system('grep -q ''^[ \t]*class '' ' . a:path.str())
return v:shell_error == 0
endfunction
function! s:IsInterface(path)
call system('grep -q ''^[ \t]*interface'' ' . a:path.str())
return v:shell_error == 0
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.