From e38d8a8340242cb33a5add2b1ff4270b04ed78de Mon Sep 17 00:00:00 2001 From: Jinn Koriech Date: Thu, 24 Apr 2014 15:51:55 +0100 Subject: [PATCH] Add flag to disable/enable bookmark sorting The bookmarks are normally sorted, however with a newly introduced flag this can be disabled. --- doc/NERD_tree.txt | 11 +++++++++++ lib/nerdtree/bookmark.vim | 8 ++++++-- plugin/NERD_tree.vim | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index bf03896..532dc43 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -633,6 +633,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. @@ -824,6 +827,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. diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 5b845d8..84a6099 100644 --- 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 index 5bee03a..fa25797 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -55,6 +55,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)