nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 23d2d19846152effd8024e6fede7ad1f60092c38
parent 1da2890856613e47404c4d3fb722ff39134d2c6d
Author: Martin Grenfell <martin.grenfell@gmail.com>
Date:   Thu, 26 Jun 2014 09:27:58 +0100

Merge pull request #331 from jinnko/add-bookmarks-sort-flag

Add flag to disable/enable bookmark sorting
Diffstat:
Mdoc/NERD_tree.txt | 11+++++++++++
Mlib/nerdtree/bookmark.vim | 8++++++--
Mplugin/NERD_tree.vim | 1+
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt
@@ -637,6 +637,9 @@ NERD tree. These options should be set in your vimrc.
 
 |'NERDTreeBookmarksFile'|       Where the bookmarks are stored.
 
+|'NERDTreeBookmarksSort'|       Whether the bookmarks list is sorted on
+                                display.
+
 |'NERDTreeMouseMode'|           Tells the NERD tree how to handle mouse
                                 clicks.
 
@@ -829,6 +832,14 @@ Default: $HOME/.NERDTreeBookmarks
 This is where bookmarks are saved. See |NERDTreeBookmarkCommands|.
 
 ------------------------------------------------------------------------------
+                                                     *'NERDTreeBookmarksSort'*
+Values: 0 or 1
+Default: 1
+
+If set to 0 then the bookmarks list is not sorted.
+If set to 1 the bookmarks list is sorted.
+
+------------------------------------------------------------------------------
                                                        *'NERDTreeMouseMode'*
 Values: 1, 2 or 3.
 Default: 1.
diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim
@@ -19,7 +19,9 @@ function! s:Bookmark.AddBookmark(name, path)
         endif
     endfor
     call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path))
-    call s:Bookmark.Sort()
+    if g:NERDTreeBookmarksSort ==# 1
+        call s:Bookmark.Sort()
+    endif
 endfunction
 
 " FUNCTION: Bookmark.Bookmarks()   {{{1
@@ -101,7 +103,9 @@ function! s:Bookmark.CacheBookmarks(silent)
                 call nerdtree#echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.")
             endif
         endif
-        call s:Bookmark.Sort()
+        if g:NERDTreeBookmarksSort ==# 1
+            call s:Bookmark.Sort()
+        endif
     endif
 endfunction
 
diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim
@@ -56,6 +56,7 @@ if !exists("g:NERDTreeIgnore")
     let g:NERDTreeIgnore = ['\~$']
 endif
 call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks')
+call s:initVariable("g:NERDTreeBookmarksSort", 1)
 call s:initVariable("g:NERDTreeHighlightCursorline", 1)
 call s:initVariable("g:NERDTreeHijackNetrw", 1)
 call s:initVariable("g:NERDTreeMouseMode", 1)