Last active
August 29, 2015 14:21
-
-
Save scrooloose/a60ebc0d685c6f5535a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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