nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 43842e0de5edb6764dfb3e2aa5df61e450ed3b31
parent b0bb781fc73ef40365e4c996a16f04368d64fc9d
Author: Jaeho Shin <netj@sparcs.org>
Date:   Mon,  9 Jun 2014 03:06:59 -0700

Option for mixing dot files when sorting

NERDTree can now optionally ignore the dot at the beginning of hidden
filenames for sorting to show them next to normal files if
`g:NERDTreeSortHiddenFirst` is set to 0.  (By default it's set to 1 to
preserve the current behavior.)  This is just like what GNU ls does when
`LC_COLLATE` environment variable is set to `en_US`.

Diffstat:
Mdoc/NERD_tree.txt | 4++++
Mlib/nerdtree/path.vim | 4++++
Mplugin/NERD_tree.vim | 1+
3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt
@@ -620,6 +620,10 @@ NERD tree. These options should be set in your vimrc.
 |'NERDTreeCaseSensitiveSort'|   Tells the NERD tree whether to be case
                                 sensitive or not when sorting nodes.
 
+|'NERDTreeSortHiddenFirst'|     Tells the NERD tree whether to take the dot
+                                at the beginning of the hidden file names
+                                into account when sorting nodes.
+
 |'NERDTreeChDirMode'|           Tells the NERD tree if/when it should change
                                 vim's current working directory.
 
diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim
@@ -103,6 +103,10 @@ function! s:Path.compareTo(path)
     elseif thisSS > thatSS
         return 1
     else
+        if !g:NERDTreeSortHiddenFirst
+            let thisPath = substitute(thisPath, '^[._]', '', '')
+            let thatPath = substitute(thatPath, '^[._]', '', '')
+        endif
         "if the sort sequences are the same then compare the paths
         "alphabetically
         let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath <? thatPath
diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim
@@ -49,6 +49,7 @@ call s:initVariable("g:NERDChristmasTree", 1)
 call s:initVariable("g:NERDTreeAutoCenter", 1)
 call s:initVariable("g:NERDTreeAutoCenterThreshold", 3)
 call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
+call s:initVariable("g:NERDTreeSortHiddenFirst", 1)
 call s:initVariable("g:NERDTreeChDirMode", 0)
 call s:initVariable("g:NERDTreeMinimalUI", 0)
 if !exists("g:NERDTreeIgnore")