diff --git a/README.markdown b/README.markdown index bfae5c68..12dfc765 100644 --- a/README.markdown +++ b/README.markdown @@ -1,111 +1,63 @@ -The NERD Tree +The git-NERDTree ============= -Intro ------ +Notice +------ -The NERD tree allows you to explore your filesystem and to open files and -directories. It presents the filesystem to you in the form of a tree which you -manipulate with the keyboard and/or mouse. It also allows you to perform -simple filesystem operations. +This project **WILL NOT** be maintained any longer! -The following features and functionality are provided by the NERD tree: +The new repo [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin) does the same work and what's more it's not a fork version but a dependent plugin of NERDTree which means you should use it with NERDTree at the same time. - * Files and directories are displayed in a hierarchical tree structure - * Different highlighting is provided for the following types of nodes: - * files - * directories - * sym-links - * windows .lnk files - * read-only files - * executable files - * Many (customisable) mappings are provided to manipulate the tree: - * Mappings to open/close/explore directory nodes - * Mappings to open files in new/existing windows/tabs - * Mappings to change the current root of the tree - * Mappings to navigate around the tree - * ... - * Directories and files can be bookmarked. - * Most NERD tree navigation can also be done with the mouse - * Filtering of tree content (can be toggled at runtime) - * custom file filters to prevent e.g. vim backup files being displayed - * optional displaying of hidden files (. files) - * files can be "turned off" so that only directories are displayed - * The position and size of the NERD tree window can be customised - * The order in which the nodes in the tree are listed can be customised. - * A model of your filesystem is created/maintained as you explore it. This - has several advantages: - * All filesystem information is cached and is only re-read on demand - * If you revisit a part of the tree that you left earlier in your - session, the directory nodes will be opened/closed as you left them - * The script remembers the cursor position and window position in the NERD - tree so you can toggle it off (or just close the tree window) and then - reopen it (with NERDTreeToggle) the NERD tree window will appear exactly - as you left it - * You can have a separate NERD tree for each tab, share trees across tabs, - or a mix of both. - * By default the script overrides the default file browser (netrw), so if - you :edit a directory a (slightly modified) NERD tree will appear in the - current window - * A programmable menu system is provided (simulates right clicking on a node) - * one default menu plugin is provided to perform basic filesystem - operations (create/delete/move/copy files/directories) - * There's an API for adding your own keymappings +Thank you for your attention. -Installation ------------- +New Feature +---------- -[pathogen.vim](https://github.com/tpope/vim-pathogen) is the recommended way to install nerdtree. +Add git status support for NERDTree.You can indicate a file's git status, quickly see which files you have staged, unstaged and modified, or deleted in your project without any extra work. - cd ~/.vim/bundle - git clone https://github.com/scrooloose/nerdtree.git +![Imgur](http://i.imgur.com/jSCwGjU.gif?1) -Then reload vim, run `:Helptags`, and check out `:help NERD_tree.txt`. +Indicators +---------- +* `✭` / `*` : Untracked +* `✹` / `~` : Modified in the working tree +* `✚` / `+` : Staged in the index (Exclude Renamed status) +* `➜` / `»` : Renamed +* `═` / `=` : Unmerged +* `✖` / `-` : Deleted (This indicator can't be shown, as NERDTree doesn't display deleted files. I have no prefect idea to solve this problem currently.) +* `✗` / `×` : Dirty (Only for directory) +* `✔` / `ø` : Clean (Only for root directory) -Faq ---- +**Option** `let g:NERDTreeUseSimpleIndicator = 1` to show the simple indicator. -__Q. Can I have the nerdtree on every tab automatically?__ +Key mapping +----------- -A. Nope. If this is something you want then chances are you aren't using tabs - and buffers as they were intended to be used. Read this - http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers +As the same as [GitGutter](https://github.com/airblade/vim-gitgutter) plugin default. - If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) +* `]c` : Jump to next indicator +* `[c` : Jump to prev indicator -__Q. How can I open a NERDTree automatically when vim starts up?__ +You can set `g:NERDTreeMapNextHunk` and `g:NERDTreeMapPrevHunk` variables to your prefer keys. e.g. -A. Stick this in your vimrc: `autocmd vimenter * NERDTree` +`let g:NERDTreeMapNextHunk = ",n"` -__Q. How can I open a NERDTree automatically when vim starts up if no files were specified?__ +`let g:NERDTreeMapPrevHunk = ",p"` -A. Stick this in your vimrc +Status Refresh +-------------- - autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if !argc() == 0 && !exists("s:std_in") | NERDTree | endif +`Add`, `Delete`, `Move` and `Copy` actions through the `m` menu will refresh git status indicators automatically. -__Q. How can I map a specific key or shortcut to open NERDTree?__ +File modified, `stage` or `commit` actions through **vim-fugitive** plugin won't active the status refreshing, this is because that NERDTree itself doesn't support auto refreshing function. You should press `r` or `R` to refresh the tree view by yourself after these actions. -A. Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): `map :NERDTreeToggle` +Note +---- -__Q. How can I close vim if the only window left open is a NERDTree?__ +It's **NOT** a plugin of NERDTree, but an enhance version. -A. Stick this in your vimrc: - - `autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif` - - -Changelog +More Info --------- -4.2.0 (2011-12-28) - - * Add NERDTreeDirArrows option to make the UI use pretty arrow chars instead of the old +~| chars to define the tree structure (sickill) - * shift the syntax highlighting out into its own syntax file (gnap) * add some mac specific options to the filesystem menu - for macvim only (andersonfreitas) - * Add NERDTreeMinimalUI option to remove some non functional parts of the nerdtree ui (camthompson) - * tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the new behaviour (benjamingeiger) - * if no name is given to :Bookmark, make it default to the name of the target file/dir (minyoung) - * use 'file' completion when doing copying, create, and move operations (EvanDotPro) - * lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!) - +See details in https://github.com/scrooloose/nerdtree diff --git a/autoload/nerdtree.vim b/autoload/nerdtree.vim index 35919320..54bfa66e 100644 --- a/autoload/nerdtree.vim +++ b/autoload/nerdtree.vim @@ -447,6 +447,11 @@ function! nerdtree#dumpHelp() let @h=@h."\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n" let @h=@h."\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n" + let @h=@h."\"\n\" ----------------------------\n" + let @h=@h."\" Git status mappings~\n" + let @h=@h."\" ". g:NERDTreeMapNextHunk . ": next hunk\n" + let @h=@h."\" ". g:NERDTreeMapPrevHunk . ": prev hunk\n" + let @h=@h."\"\n\" ----------------------------\n" let @h=@h."\" Directory node mappings~\n" let @h=@h."\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n" @@ -841,8 +846,22 @@ function! nerdtree#renderView() call cursor(line(".")+1, col(".")) endif + "refresh git status + if g:NERDTreeShowGitStatus + call g:NERDTreeGitStatusRefresh() + endif + "draw the header line - let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)}) + let headerStatus = "" + if g:NERDTreeShowGitStatus + let headerStatus = g:NERDTreeGetCWDGitStatus() + endif + if headerStatus == "" + let fix = 0 + else + let fix = 3 + endif + let header = headerStatus . b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0) - fix}) call setline(line(".")+1, header) call cursor(line(".")+1, col(".")) @@ -941,6 +960,9 @@ function! nerdtree#stripMarkupFromLine(line, removeLeadingSpaces) "strip off any executable flags let line = substitute (line, '*\ze\($\| \)', "","") + "strip off any git status flags + let line = substitute(line, '\[[^{RO}]\]', "", "") + let wasdir = 0 if line =~# '/$' let wasdir = 1 diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index 4ddc2507..d80e8b24 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -229,6 +229,8 @@ O.......Recursively open the selected directory..................|NERDTree-O| x.......Close the current nodes parent...........................|NERDTree-x| X.......Recursively close all children of the current node.......|NERDTree-X| e.......Edit the current dir.....................................|NERDTree-e| +]c......Jump to the next hunk....................................|NERDTree-]c| +[c......Jump to the prev hunk....................................|NERDTree-[c| ...............same as |NERDTree-o|. double-click.......same as the |NERDTree-o| map. @@ -393,6 +395,22 @@ Applies to: files and directories. result in a NERD tree or a netrw being opened, depending on |'NERDTreeHijackNetrw'|. +------------------------------------------------------------------------------ + *NERDTree-]c* +Default key: ]c +Map option: NERDTreeMapNextHunk +Applies to: files and directories. + +Jump to the next hunk. + +------------------------------------------------------------------------------ + *NERDTree-[c* +Default key: [c +Map option: NERDTreeMapPrevHunk +Applies to: files and directories. + +Jump to the prev hunk. + ------------------------------------------------------------------------------ *NERDTree-D* Default key: D @@ -682,6 +700,17 @@ NERD tree. These options should be set in your vimrc. a buffer when a file is being deleted or renamed via a context menu command. +|'g:NERDTreeShowGitStatus'| Show git status of CWD. + +|'g:NERDTreeUseSimpleIndicator'| + Display simple git status indicator. + +|'g:NERDTreeUseGitToMove'| Use 'git mv ' for tracked files + and OS renaming otherwise + +|'g:NERDTreeUseGitToDelete'| Use 'git rm ' for tracked files + and OS deletion otherwise + ------------------------------------------------------------------------------ 3.2. Customisation details *NERDTreeOptionDetails* @@ -1027,6 +1056,31 @@ option: > let NERDTreeAutoDeleteBuffer=1 < +------------------------------------------------------------------------------ + *'g:NERDTreeShowGitStatus'* +Values: 0 or 1 +Default: 1. + +Show git status indicator at the front the files or directories. If you want to +disable this feature, then set this option to 0. Use one of the follow +lines to set this option: > + let g:NERDTreeShowGitStatus = 0 + let g:NERDTreeShowGitStatus = 1 +< + +------------------------------------------------------------------------------ + *'g:NERDTreeUseSimpleIndicator'* +Values: 0 or 1 +Default: 0. + +Show git status indicator in simple style, like '+' instad of '✚'. This option +is useful when the vim doesn't support complex character. If you want to +enable this feature, then set this option to 1. Use one of the follow +lines to set this option: > + let g:NERDTreeUseSimpleIndicator = 0 + let g:NERDTreeUseSimpleIndicator = 1 +< + ============================================================================== 4. The NERD tree API *NERDTreeAPI* diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim index 047a72a6..db7879b7 100644 --- a/lib/nerdtree/path.vim +++ b/lib/nerdtree/path.vim @@ -227,14 +227,24 @@ endfunction function! s:Path.delete() if self.isDirectory - let cmd = g:NERDTreeRemoveDirCmd . self.str({'escape': 1}) + let directoryTracked = system("git ls-files " . self.str() . " --error-unmatch") + if g:NERDTreeUseGitToDelete == 1 && v:shell_error == 0 + let cmd = "git rm -r " . self.str({'escape': 1}) + else + let cmd = g:NERDTreeRemoveDirCmd . self.str({'escape': 1}) + end let success = system(cmd) if v:shell_error != 0 throw "NERDTree.PathDeletionError: Could not delete directory: '" . self.str() . "'" endif else - let success = delete(self.str()) + let fileTracked = system("git ls-files " . self.str() . " --error-unmatch") + if g:NERDTreeUseGitToDelete == 1 && v:shell_error == 0 + let success = system("git rm " . self.str()) + else + let success = delete(self.str()) + endif if success != 0 throw "NERDTree.PathDeletionError: Could not delete file: '" . self.str() . "'" endif @@ -548,7 +558,12 @@ function! s:Path.rename(newPath) throw "NERDTree.InvalidArgumentsError: Invalid newPath for renaming = ". a:newPath endif - let success = rename(self.str(), a:newPath) + let fileTracked = system("git ls-files " . self.str() . " --error-unmatch") + if g:NERDTreeUseGitToMove == 1 && v:shell_error == 0 + let success = system("git mv " . self.str() . " " . a:newPath) + else + let success = rename(self.str(), a:newPath) + endif if success != 0 throw "NERDTree.PathRenameError: Could not rename: '" . self.str() . "'" . 'to:' . a:newPath endif diff --git a/lib/nerdtree/tree_file_node.vim b/lib/nerdtree/tree_file_node.vim index ab8d3719..50f2ab11 100644 --- a/lib/nerdtree/tree_file_node.vim +++ b/lib/nerdtree/tree_file_node.vim @@ -83,7 +83,11 @@ endfunction "Return: "a string that can be used in the view to represent this node function! s:TreeFileNode.displayString() - return self.path.displayString() + let ds = self.path.displayString() + if g:NERDTreeShowGitStatus + let ds = g:NERDTreeGetGitStatusPrefix(self.path) . ds + endif + return ds endfunction "FUNCTION: TreeFileNode.equals(treenode) {{{1 @@ -240,7 +244,7 @@ endfunction "gets the line number of the root node function! s:TreeFileNode.GetRootLineNum() let rootLine = 1 - while getline(rootLine) !~# '^\(/\|<\)' + while getline(rootLine) !~# '^\(\[.\]\)\?[/|<]' let rootLine = rootLine + 1 endwhile return rootLine diff --git a/nerdtree_plugin/git_status.vim b/nerdtree_plugin/git_status.vim new file mode 100644 index 00000000..327bdc70 --- /dev/null +++ b/nerdtree_plugin/git_status.vim @@ -0,0 +1,222 @@ +" ============================================================================ +" File: git_status.vim +" Description: plugin for NERD Tree that provides git status support +" Maintainer: Xuyuan Pang +" Last Change: 4 Apr 2014 +" License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" ============================================================================ +if exists('g:loaded_nerdtree_git_status') + finish +endif +let g:loaded_nerdtree_git_status = 1 + +if !exists('g:NERDTreeShowGitStatus') + let g:NERDTreeShowGitStatus = 1 +endif + +if !exists('g:NERDTreeMapNextHunk') + let g:NERDTreeMapNextHunk = "]c" +endif + +if !exists('g:NERDTreeMapPrevHunk') + let g:NERDTreeMapPrevHunk = "[c" +endif + +if !exists('g:NERDTreeUseSimpleIndicator') + let g:NERDTreeUseSimpleIndicator = 0 +endif + +if !exists("g:NERDTreeUseGitToMove") + let g:NERDTreeUseGitToMove = 1 +endif + +if !exists("g:NERDTreeUseGitToDelete") + let g:NERDTreeUseGitToDelete = 1 +endif + +if !exists('s:NERDTreeIndicatorMap') + let s:NERDTreeIndicatorMap = {} + if g:NERDTreeUseSimpleIndicator + let s:NERDTreeIndicatorMap = { + \ "Modified" : "~", + \ "Staged" : "+", + \ "Untracked" : "*", + \ "Renamed" : "»", + \ "Unmerged" : "=", + \ "Deleted" : "-", + \ "Dirty" : "×", + \ "Clean" : "ø", + \ "Unknown" : "?" + \ } + else + let s:NERDTreeIndicatorMap = { + \ "Modified" : "✹", + \ "Staged" : "✚", + \ "Untracked" : "✭", + \ "Renamed" : "➜", + \ "Unmerged" : "═", + \ "Deleted" : "✖", + \ "Dirty" : "✗", + \ "Clean" : "✔︎", + \ "Unknown" : "?" + \ } + endif +endif + +" FUNCTION: g:NERDTreeGitStatusRefresh() {{{2 +" refresh cached git status +function! g:NERDTreeGitStatusRefresh() + let g:NERDTreeCachedGitFileStatus = {} + let g:NERDTreeCachedGitDirtyDir = {} + let s:NOT_A_GIT_REPOSITORY = 1 + + " check if git command exists + if !executable('git') + call nerdtree#echo("Please install git command first.") + return + endif + + let root = b:NERDTreeRoot.path._str() + let statusesStr = system("cd " . root . " && git status -s") + let statusesSplit = split(statusesStr, '\n') + if statusesSplit != [] && statusesSplit[0] =~# "fatal:.*" + let statusesSplit = [] + return + endif + let s:NOT_A_GIT_REPOSITORY = 0 + + for statusLine in statusesSplit + " cache git status of files + let pathStr = substitute(statusLine, '...', "", "") + let pathSplit = split(pathStr, ' -> ') + if len(pathSplit) == 2 + call s:NERDTreeCacheDirtyDir(pathSplit[0]) + let pathStr = pathSplit[1] + else + let pathStr = pathSplit[0] + endif + let pathStr = s:NERDTreeTrimDoubleQuotes(pathStr) + if pathStr =~# '\.\./.*' + continue + endif + let statusKey = s:NERDTreeGetFileGitStatusKey(statusLine[0], statusLine[1]) + let g:NERDTreeCachedGitFileStatus[fnameescape(pathStr)] = statusKey + + call s:NERDTreeCacheDirtyDir(pathStr) + endfor +endfunction + +function! s:NERDTreeCacheDirtyDir(pathStr) + " cache dirty dir + let dirtyPath = s:NERDTreeTrimDoubleQuotes(a:pathStr) + if dirtyPath =~# '\.\./.*' + return + endif + let dirtyPath = dirtyPath + let dirtyPath = substitute(dirtyPath, '/[^/]*$', "/", "") + let cwd = fnameescape('./') + while dirtyPath =~# '.\+/.*' && has_key(g:NERDTreeCachedGitDirtyDir, fnameescape(dirtyPath)) == 0 + let g:NERDTreeCachedGitDirtyDir[fnameescape(dirtyPath)] = "Dirty" + let dirtyPath = substitute(dirtyPath, '/[^/]*/$', "/", "") + endwhile +endfunction + +function! s:NERDTreeTrimDoubleQuotes(pathStr) + let toReturn = substitute(a:pathStr, '^"', "", "") + let toReturn = substitute(toReturn, '"$', "", "") + return toReturn +endfunction + +" FUNCTION: g:NERDTreeGetGitStatusPrefix(path) {{{2 +" return the indicator of the path +" Args: path +function! g:NERDTreeGetGitStatusPrefix(path) + let pathStr = a:path._str() + let cwd = b:NERDTreeRoot.path._str() . a:path.Slash() + if nerdtree#runningWindows() + let pathStr = a:path.WinToUnixPath(pathStr) + let cwd = a:path.WinToUnixPath(cwd) + endif + let pathStr = substitute(pathStr, fnameescape(cwd), "", "") + let statusKey = "" + if a:path.isDirectory + let statusKey = get(g:NERDTreeCachedGitDirtyDir, fnameescape(pathStr . '/'), "") + else + let statusKey = get(g:NERDTreeCachedGitFileStatus, fnameescape(pathStr), "") + endif + return s:NERDTreeGetIndicator(statusKey) +endfunction + +" FUNCTION: s:NERDTreeGetCWDGitStatus() {{{2 +" return the indicator of cwd +function! g:NERDTreeGetCWDGitStatus() + if s:NOT_A_GIT_REPOSITORY + return "" + elseif g:NERDTreeCachedGitDirtyDir == {} && g:NERDTreeCachedGitFileStatus == {} + return s:NERDTreeGetIndicator("Clean") + endif + return s:NERDTreeGetIndicator("Dirty") +endfunction + +function! s:NERDTreeGetIndicator(statusKey) + let indicator = get(s:NERDTreeIndicatorMap, a:statusKey, "") + if indicator != "" + return '[' . indicator . ']' + endif + return '' +endfunction + +function! s:NERDTreeGetFileGitStatusKey(us, them) + if a:us == '?' && a:them == '?' + return "Untracked" + elseif a:us == ' ' && a:them == 'M' + return "Modified" + elseif a:us =~# '[MAC]' + return "Staged" + elseif a:us == 'R' + return "Renamed" + elseif a:us == 'U' || a:them == 'U' || a:us == 'A' && a:them == 'A' || a:us == 'D' && a:them == 'D' + return "Unmerged" + elseif a:them == 'D' + return "Deleted" + else + return "Unknown" + endif +endfunction + +" FUNCTION: s:jumpToNextHunk(node) {{{2 +function! s:jumpToNextHunk(node) + let position = search('\[[^{RO}]\+\]', "") + if position + call nerdtree#echo("Jump to next hunk ") + endif +endfunction + +" FUNCTION: s:jumpToPrevHunk(node) {{{2 +function! s:jumpToPrevHunk(node) + let position = search('\[[^{RO}]\+\]', "b") + if position + call nerdtree#echo("Jump to prev hunk ") + endif +endfunction + +" Function: s:SID() {{{2 +function s:SID() + if !exists("s:sid") + let s:sid = matchstr(expand(''), '\zs\d\+\ze_SID$') + endif + return s:sid +endfun + +" FUNCTION: s:NERDTreeGitStatusKeyMapping {{{2 +function! s:NERDTreeGitStatusKeyMapping() + let s = '' . s:SID() . '_' + call NERDTreeAddKeyMap({'key': g:NERDTreeMapNextHunk, 'scope': "Node", 'callback': s."jumpToNextHunk"}) + call NERDTreeAddKeyMap({'key': g:NERDTreeMapPrevHunk, 'scope': "Node", 'callback': s."jumpToPrevHunk"}) +endfunction + +call s:NERDTreeGitStatusKeyMapping() diff --git a/syntax/nerdtree.vim b/syntax/nerdtree.vim index 7cbba6ee..39efaeda 100644 --- a/syntax/nerdtree.vim +++ b/syntax/nerdtree.vim @@ -7,6 +7,36 @@ syn match NERDTreeFlag #\[RO\]# "highlighting for the .. (up dir) line at the top of the tree execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" +"highlighting for the ~/+ symbols for the directory nodes +syn match NERDTreeClosable #\~\<# +syn match NERDTreeClosable #\~\.# +syn match NERDTreeOpenable #+\<# +syn match NERDTreeOpenable #+\.#he=e-1 + +"highlighting for the tree structural parts +syn match NERDTreePart #|# +syn match NERDTreePart #`# +syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart + +"highlighing for the git status +syn match NERDTreeGitStatusModified #✹# +syn match NERDTreeGitStatusModified /\[\~\]/ms=s+1,me=e-1 +syn match NERDTreeGitStatusAdded #✚# +syn match NERDTreeGitStatusAdded /\[+\]/ms=s+1,me=e-1 +syn match NERDTreeGitStatusDeleted #✖# +syn match NERDTreeGitStatusDeleted /\[-\]/ms=s+1,me=e-1 +syn match NERDTreeGitStatusRenamed #➜# +syn match NERDTreeGitStatusRenamed /\[»\]/ms=s+1,me=e-1 +syn match NERDTreeGitStatusUnmerged #═# +syn match NERDTreeGitStatusUnmerged /\[=\]/ms=s+1,me=e-1 +syn match NERDTreeGitStatusUntracked #✭# +syn match NERDTreeGitStatusUntracked /\[\*\]/ms=s+1,me=e-1 +syn match NERDTreeGitStatusDirDirty #✗# +syn match NERDTreeGitStatusDirDirty /\[×\]/ms=s+1,me=e-1 +syn match NERDTreeGitStatusDirClean #✔︎# +syn match NERDTreeGitStatusDirClean /\[ø\]/ms=s+1,me=e-1 +syn match NERDTreeGitStatus #\[[^{RO}]\]# contains=NERDTreeGitStatusAdded,NERDTreeGitStatusModified,NERDTreeGitStatusUnmodified,NERDTreeGitStatusRenamed,NERDTreeGitStatusUnmerged,NERDTreeGitStatusUntracked,NERDTreeGitStatusDirDirty,NERDTreeGitStatusDirClean + "quickhelp syntax elements syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#ms=s+2,me=e-1 syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#ms=s+2,me=e-1 @@ -18,7 +48,7 @@ syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTr "highlighting for sym links syn match NERDTreeLinkTarget #->.*# containedin=NERDTreeDir,NERDTreeFile -syn match NERDTreeLinkFile #.* ->#me=e-3 containedin=NERDTreeFile +syn match NERDTreeLinkFile #.* ->#me=e-3 containedin=NERDTreeFile contains=NERDTreeGitStatus syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir "highlighing for directory nodes and file nodes @@ -28,12 +58,12 @@ if g:NERDTreeDirArrows syn match NERDTreeClosable #▾# containedin=NERDTreeDir,NERDTreeFile syn match NERDTreeOpenable #▸# containedin=NERDTreeDir,NERDTreeFile - syn match NERDTreeDir #[^▾▸ ].*/# - syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark - syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile + syn match NERDTreeDir #[^▾▸ ].*/# contains=NERDTreeGitStatus + syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark,NERDTreeGitStatus + syn match NERDTreeFile #^[^"\.▾▸] *[^▾▸]*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile,NERDTreeGitStatus "highlighting for readonly files - syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeFlag,NERDTreeBookmark,NERDTreeFile + syn match NERDTreeRO # *\zs.*\ze \[RO\]# contains=NERDTreeFlag,NERDTreeBookmark,NERDTreeFile,NERDTreeGitStatus else "highlighting for the ~/+ symbols for the directory nodes syn match NERDTreeClosable #\~\<# @@ -44,18 +74,19 @@ else "highlighting for the tree structural parts syn match NERDTreePart #|# syn match NERDTreePart #`# - syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart + syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart,NERDTreeGitStatus - syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeOpenable,NERDTreeClosable - syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark - syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile - syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile + syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeOpenable,NERDTreeClosable,NERDTreeGitStatus + syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeGitStatus + syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile,NERDTreeGitStatus + syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile,NERDTreeGitStatus "highlighting for readonly files - syn match NERDTreeRO #|-.*\[RO\]#he=e-5 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile + syn match NERDTreeRO #|-.*\[RO\]#he=e-5 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile,NERDTreeGitStatus endif -syn match NERDTreeCWD #^[-\+Bookmarks-\+$# contains=NERDTreeBookmark syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader +if exists("g:NERDChristmasTree") && g:NERDChristmasTree + hi def link NERDTreePart Special + hi def link NERDTreePartFile Type + hi def link NERDTreeFile Normal + hi def link NERDTreeExecFile Title + hi def link NERDTreeDirSlash Identifier + hi def link NERDTreeClosable Type +else + hi def link NERDTreePart Normal + hi def link NERDTreePartFile Normal + hi def link NERDTreeFile Normal + hi def link NERDTreeClosable Title +endif + hi def link NERDTreePart Special hi def link NERDTreePartFile Type hi def link NERDTreeExecFile Title @@ -98,3 +143,14 @@ hi def link NERDTreeRO WarningMsg hi def link NERDTreeBookmark Statement hi def link NERDTreeCurrentNode Search + +hi def link NERDTreeGitStatusModified Special +hi def link NERDTreeGitStatusAdded Function +hi def link NERDTreeGitStatusDeleted Keyword +hi def link NERDTreeGitStatusRenamed Title +hi def link NERDTreeGitStatusUnmerged Label +hi def link NERDTreeGitStatusUntracked Comment +" hi def link NERDTreeGitStatusUntracked Structure +hi def link NERDTreeGitStatusDirDirty Tag +hi def link NERDTreeGitStatusDirClean Type +hi def link NERDTreeGitStatus Number