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

Add flag to disable/enable bookmark sorting
This commit is contained in:
Martin Grenfell 2014-06-26 09:27:58 +01:00
commit 23d2d19846
3 changed files with 18 additions and 2 deletions

View File

@ -637,6 +637,9 @@ NERD tree. These options should be set in your vimrc.
|'NERDTreeBookmarksFile'| Where the bookmarks are stored. |'NERDTreeBookmarksFile'| Where the bookmarks are stored.
|'NERDTreeBookmarksSort'| Whether the bookmarks list is sorted on
display.
|'NERDTreeMouseMode'| Tells the NERD tree how to handle mouse |'NERDTreeMouseMode'| Tells the NERD tree how to handle mouse
clicks. clicks.
@ -828,6 +831,14 @@ Default: $HOME/.NERDTreeBookmarks
This is where bookmarks are saved. See |NERDTreeBookmarkCommands|. 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'* *'NERDTreeMouseMode'*
Values: 1, 2 or 3. Values: 1, 2 or 3.

View File

@ -19,7 +19,9 @@ function! s:Bookmark.AddBookmark(name, path)
endif endif
endfor endfor
call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path)) call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path))
if g:NERDTreeBookmarksSort ==# 1
call s:Bookmark.Sort() call s:Bookmark.Sort()
endif
endfunction endfunction
" FUNCTION: Bookmark.Bookmarks() {{{1 " FUNCTION: Bookmark.Bookmarks() {{{1
@ -101,8 +103,10 @@ function! s:Bookmark.CacheBookmarks(silent)
call nerdtree#echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.") call nerdtree#echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.")
endif endif
endif endif
if g:NERDTreeBookmarksSort ==# 1
call s:Bookmark.Sort() call s:Bookmark.Sort()
endif endif
endif
endfunction endfunction
" FUNCTION: Bookmark.compareTo(otherbookmark) {{{1 " FUNCTION: Bookmark.compareTo(otherbookmark) {{{1

View File

@ -56,6 +56,7 @@ if !exists("g:NERDTreeIgnore")
let g:NERDTreeIgnore = ['\~$'] let g:NERDTreeIgnore = ['\~$']
endif endif
call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks') call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks')
call s:initVariable("g:NERDTreeBookmarksSort", 1)
call s:initVariable("g:NERDTreeHighlightCursorline", 1) call s:initVariable("g:NERDTreeHighlightCursorline", 1)
call s:initVariable("g:NERDTreeHijackNetrw", 1) call s:initVariable("g:NERDTreeHijackNetrw", 1)
call s:initVariable("g:NERDTreeMouseMode", 1) call s:initVariable("g:NERDTreeMouseMode", 1)