Updated plugins
This commit is contained in:
parent
768c72a3ed
commit
3b37bba6cd
|
@ -5,7 +5,7 @@ if exists('g:ack_use_dispatch')
|
|||
endif
|
||||
else
|
||||
let g:ack_use_dispatch = 0
|
||||
end
|
||||
endif
|
||||
|
||||
"-----------------------------------------------------------------------------
|
||||
" Public API
|
||||
|
|
|
@ -21,13 +21,13 @@ Vim has various ways of installing plugins, the standard way is in [the document
|
|||
cd ~/.vim/bundle && git clone https://github.com/rking/ag.vim ag && echo "set runtimepath^=~/.vim/bundle/ag" >> ~/.vimrc
|
||||
```
|
||||
|
||||
Then open vim and rum `:helptags ~/.vim/bundle/ag/doc`.
|
||||
Then open vim and run `:helptags ~/.vim/bundle/ag/doc`.
|
||||
|
||||
### Configuration ###
|
||||
|
||||
You can specify a custom ag name and path in your .vimrc like so:
|
||||
|
||||
let g:agprg="<custom-ag-path-goes-here> --vimgrep"
|
||||
let g:ag_prg="<custom-ag-path-goes-here> --vimgrep"
|
||||
|
||||
You can configure ag.vim to always start searching from your project root
|
||||
instead of the cwd
|
||||
|
|
|
@ -1,17 +1,26 @@
|
|||
" NOTE: You must, of course, install ag / the_silver_searcher
|
||||
|
||||
" FIXME: Delete deprecated options below on or after 15-7 (6 months from when they were changed) {{{
|
||||
" FIXME: Delete deprecated options below on or after 2016-4 (6 months from when the deprecation warning was added) {{{
|
||||
|
||||
if exists("g:agprg")
|
||||
let g:ag_prg = g:agprg
|
||||
echohl WarningMsg
|
||||
call input('g:agprg is deprecated and will be removed. Please use g:ag_prg')
|
||||
echohl None
|
||||
endif
|
||||
|
||||
if exists("g:aghighlight")
|
||||
let g:ag_highlight = g:aghighlight
|
||||
echohl WarningMsg
|
||||
call input('g:aghighlight is deprecated and will be removed. Please use g:ag_highlight')
|
||||
echohl None
|
||||
endif
|
||||
|
||||
if exists("g:agformat")
|
||||
let g:ag_format = g:agformat
|
||||
echohl WarningMsg
|
||||
call input('g:agformat is deprecated and will be removed. Please use g:ag_format')
|
||||
echohl None
|
||||
endif
|
||||
|
||||
" }}} FIXME: Delete the deprecated options above on or after 15-7 (6 months from when they were changed)
|
||||
|
@ -79,6 +88,11 @@ function! ag#Ag(cmd, args)
|
|||
let l:grepargs = a:args . join(a:000, ' ')
|
||||
end
|
||||
|
||||
if empty(l:grepargs)
|
||||
echo "Usage: ':Ag {pattern}' (or just :Ag to search for the word under the cursor). See ':help :Ag' for more information."
|
||||
return
|
||||
endif
|
||||
|
||||
" Format, used to manage column jump
|
||||
if a:cmd =~# '-g$'
|
||||
let s:ag_format_backup=g:ag_format
|
||||
|
@ -169,8 +183,12 @@ function! ag#Ag(cmd, args)
|
|||
echom "ag.vim keys: q=quit <cr>/e/t/h/v=enter/edit/tab/split/vsplit go/T/H/gv=preview versions of same"
|
||||
endif
|
||||
endif
|
||||
else
|
||||
else " Close the split window automatically:
|
||||
cclose
|
||||
lclose
|
||||
echohl WarningMsg
|
||||
echom 'No matches for "'.a:args.'"'
|
||||
echohl None
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#**This project is unmaintained**
|
||||
**You should use [this fork](https://github.com/ctrlpvim/ctrlp.vim) instead.**
|
||||
|
||||
# ctrlp.vim
|
||||
Full path fuzzy __file__, __buffer__, __mru__, __tag__, __...__ finder for Vim.
|
||||
|
||||
|
|
|
@ -269,7 +269,9 @@ function! s:goyo_on(dim)
|
|||
if exists('g:goyo_callbacks[0]')
|
||||
call g:goyo_callbacks[0]()
|
||||
endif
|
||||
silent! doautocmd User GoyoEnter
|
||||
if exists('#User#GoyoEnter')
|
||||
doautocmd User GoyoEnter
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:goyo_off()
|
||||
|
@ -344,6 +346,9 @@ function! s:goyo_off()
|
|||
|
||||
if goyo_disabled_airline && !exists("#airline")
|
||||
AirlineToggle
|
||||
" For some reason, Airline requires two refreshes to avoid display
|
||||
" artifacts
|
||||
silent! AirlineRefresh
|
||||
silent! AirlineRefresh
|
||||
endif
|
||||
|
||||
|
@ -363,7 +368,9 @@ function! s:goyo_off()
|
|||
if exists('g:goyo_callbacks[1]')
|
||||
call g:goyo_callbacks[1]()
|
||||
endif
|
||||
silent! doautocmd User GoyoLeave
|
||||
if exists('#User#GoyoLeave')
|
||||
doautocmd User GoyoLeave
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:relsz(expr, limit)
|
||||
|
@ -414,6 +421,10 @@ function! goyo#execute(bang, dim)
|
|||
if exists('#goyo') == 0
|
||||
call s:goyo_on(a:dim)
|
||||
elseif !empty(a:dim)
|
||||
if winnr('$') < 5
|
||||
call s:goyo_off()
|
||||
return goyo#execute(a:bang, a:dim)
|
||||
endif
|
||||
let dim = s:parse_arg(a:dim)
|
||||
if !empty(dim)
|
||||
let t:goyo_dim = dim
|
||||
|
|
|
@ -0,0 +1,153 @@
|
|||
Next
|
||||
- Rename "primary" and "secondary" trees to "tab" and "window" trees.
|
||||
- Move a bunch of buffer level variables into the NERDTree and UI classes.
|
||||
- Display cascading dirs on one line to save vertical/horizontal space (@matt-gardner: brainstorming/testing)
|
||||
- Remove the old style UI - Remove 'NERDTreeDirArrows' option.
|
||||
- On windows default to + and ~ for expand/collapse directory symbols.
|
||||
- Lots more refactoring. Move a bunch of b: level vars into b:NERDTree and friends.
|
||||
|
||||
5.0.0
|
||||
- Refactor the code significantly:
|
||||
* Break the classes out into their own files.
|
||||
* Make the majority of the code OO - previously large parts were
|
||||
effectively a tangle of "global" methods.
|
||||
- Add an API to assign flags to nodes. This allows VCS plugins like
|
||||
https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to
|
||||
Xuyuanp for helping design/test/build said API.
|
||||
- add 'scope' argument to the key map API see :help NERDTreeAddKeyMap()
|
||||
- add magic [[dir]] and [[file]] flags to NERDTreeIgnore
|
||||
- add support for custom path filters. See :help NERDTreeAddPathFilter()
|
||||
- add path listener API. See :help NERDTreePathListenerAPI.
|
||||
- expand the fs menu functionality to list file properties (PhilRunninger,
|
||||
apbarrero, JESii)
|
||||
- make bookmarks work with `~` home shortcuts (hiberabyss)
|
||||
- show OSX specific fsmenu options in regular vim on mac (evindor)
|
||||
- make dir arrow icons configurable (PickRelated)
|
||||
- optimise node sorting performance when opening large dirs (vtsang)
|
||||
- make the root note render prettier by truncating it at a path slash (gcmt)
|
||||
- remove NERDChristmasTree option - its always christmas now
|
||||
- add "cascade" open and closing for dirs containing only another single
|
||||
dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm)
|
||||
|
||||
Many other fixes, doc updates and contributions from:
|
||||
actionshrimp
|
||||
SchDen
|
||||
egalpin
|
||||
cperl82 - many small fixes
|
||||
toiffel
|
||||
WoLpH
|
||||
handcraftedbits
|
||||
devmanhinton
|
||||
xiaodili
|
||||
zhangoose
|
||||
gastropoda
|
||||
mixvin
|
||||
alvan
|
||||
lucascaton
|
||||
kelaban
|
||||
shanesmith
|
||||
staeff
|
||||
pendulm
|
||||
stephenprater
|
||||
franksort
|
||||
agrussellknives
|
||||
AndrewRadev
|
||||
Twinside
|
||||
|
||||
4.2.0
|
||||
- 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!)
|
||||
|
||||
4.1.0
|
||||
features:
|
||||
- NERDTreeFind to reveal the node for the current buffer in the tree,
|
||||
see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by
|
||||
Doug McInnes) into the script.
|
||||
- make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan
|
||||
Ritter and Rémi Prévost.
|
||||
- truncate the root node if wider than the tree window. Thanks to Victor
|
||||
Gonzalez.
|
||||
|
||||
bugfixes:
|
||||
- really fix window state restoring
|
||||
- fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky,
|
||||
jfilip1024, and Chris Chambers
|
||||
|
||||
4.0.0
|
||||
- add a new programmable menu system (see :help NERDTreeMenu).
|
||||
- add new APIs to add menus/menu-items to the menu system as well as
|
||||
custom key mappings to the NERD tree buffer (see :help NERDTreeAPI).
|
||||
- removed the old API functions
|
||||
- added a mapping to maximize/restore the size of nerd tree window, thanks
|
||||
to Guillaume Duranceau for the patch. See :help NERDTree-A for details.
|
||||
|
||||
- fix a bug where secondary nerd trees (netrw hijacked trees) and
|
||||
NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey.
|
||||
- fix a bug where the script ignored directories whose name ended in a dot,
|
||||
thanks to Aggelos Orfanakos for the patch.
|
||||
- fix a bug when using the x mapping on the tree root, thanks to Bryan
|
||||
Venteicher for the patch.
|
||||
- fix a bug where the cursor position/window size of the nerd tree buffer
|
||||
wasnt being stored on closing the window, thanks to Richard Hart.
|
||||
- fix a bug where NERDTreeMirror would mirror the wrong tree
|
||||
|
||||
3.1.1
|
||||
- fix a bug where a non-listed no-name buffer was getting created every
|
||||
time the tree windows was created, thanks to Derek Wyatt and owen1
|
||||
- make <CR> behave the same as the 'o' mapping
|
||||
- some helptag fixes in the doc, thanks strull
|
||||
- fix a bug when using :set nohidden and opening a file where the previous
|
||||
buf was modified. Thanks iElectric
|
||||
- other minor fixes
|
||||
|
||||
3.1.0
|
||||
New features:
|
||||
- add mappings to open files in a vsplit, see :help NERDTree-s and :help
|
||||
NERDTree-gs
|
||||
- make the statusline for the nerd tree window default to something
|
||||
hopefully more useful. See :help 'NERDTreeStatusline'
|
||||
Bugfixes:
|
||||
- make the hijack netrw functionality work when vim is started with "vim
|
||||
<some dir>" (thanks to Alf Mikula for the patch).
|
||||
- fix a bug where the CWD wasnt being changed for some operations even when
|
||||
NERDTreeChDirMode==2 (thanks to Lucas S. Buchala)
|
||||
- add -bar to all the nerd tree :commands so they can chain with other
|
||||
:commands (thanks to tpope)
|
||||
- fix bugs when ignorecase was set (thanks to nach)
|
||||
- fix a bug with the relative path code (thanks to nach)
|
||||
- fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach)
|
||||
|
||||
|
||||
3.0.1
|
||||
Bugfixes:
|
||||
- fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden
|
||||
was not set
|
||||
- fix a bug where :NERDTree <path> would fail if <path> was relative and
|
||||
didnt start with a ./ or ../ Thanks to James Kanze.
|
||||
- make the q mapping work with secondary (:e <dir> style) trees,
|
||||
thanks to jamessan
|
||||
- fix a bunch of small bugs with secondary trees
|
||||
|
||||
More insane refactoring.
|
||||
|
||||
3.0.0
|
||||
- hijack netrw so that doing an :edit <directory> will put a NERD tree in
|
||||
the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw'
|
||||
- allow sharing of trees across tabs, see :help :NERDTreeMirror
|
||||
- remove "top" and "bottom" as valid settings for NERDTreeWinPos
|
||||
- change the '<tab>' mapping to 'i'
|
||||
- change the 'H' mapping to 'I'
|
||||
- lots of refactoring
|
|
@ -0,0 +1,13 @@
|
|||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
|
@ -55,7 +55,7 @@ The following features and functionality are provided by the NERD tree:
|
|||
Installation
|
||||
------------
|
||||
|
||||
[pathogen.vim](https://github.com/tpope/vim-pathogen) is the recommended way to install nerdtree.
|
||||
####[pathogen.vim](https://github.com/tpope/vim-pathogen)
|
||||
|
||||
cd ~/.vim/bundle
|
||||
git clone https://github.com/scrooloose/nerdtree.git
|
||||
|
@ -63,6 +63,12 @@ Installation
|
|||
Then reload vim, run `:Helptags`, and check out `:help NERD_tree.txt`.
|
||||
|
||||
|
||||
####[apt-vim](https://github.com/egalpin/apt-vim)
|
||||
|
||||
apt-vim install -y https://github.com/scrooloose/nerdtree.git
|
||||
|
||||
|
||||
|
||||
Faq
|
||||
---
|
||||
|
||||
|
@ -85,11 +91,13 @@ Stick this in your vimrc: `autocmd vimenter * NERDTree`
|
|||
|
||||
> How can I open a NERDTree automatically when vim starts up if no files were specified?
|
||||
|
||||
Stick this in your vimrc
|
||||
Stick this in your vimrc:
|
||||
|
||||
autocmd StdinReadPre * let s:std_in=1
|
||||
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
|
||||
|
||||
Note: Now start vim with plain `vim`, not `vim .`
|
||||
|
||||
> How can I map a specific key or shortcut to open NERDTree?
|
||||
|
||||
Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want):
|
||||
|
@ -100,8 +108,15 @@ Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever ke
|
|||
|
||||
Stick this in your vimrc:
|
||||
|
||||
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
|
||||
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
|
||||
|
||||
> Can I have different highlighting for different file extensions?
|
||||
|
||||
See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696
|
||||
|
||||
> How can I change default arrows?
|
||||
|
||||
Use these variables in your vimrc. Note that below are default arrow symbols
|
||||
|
||||
let g:NERDTreeDirArrowExpandable = '▸'
|
||||
let g:NERDTreeDirArrowCollapsible = '▾'
|
||||
|
|
|
@ -4,17 +4,17 @@ endif
|
|||
let g:loaded_nerdtree_autoload = 1
|
||||
|
||||
function! nerdtree#version()
|
||||
return '4.2.0'
|
||||
return '5.0.0'
|
||||
endfunction
|
||||
|
||||
" SECTION: General Functions {{{1
|
||||
"============================================================
|
||||
|
||||
"FUNCTION: nerdtree#checkForBrowse(dir) {{{2
|
||||
"inits a secondary nerd tree in the current buffer if appropriate
|
||||
"inits a window tree in the current buffer if appropriate
|
||||
function! nerdtree#checkForBrowse(dir)
|
||||
if a:dir != '' && isdirectory(a:dir)
|
||||
call g:NERDTreeCreator.CreateSecondary(a:dir)
|
||||
call g:NERDTreeCreator.CreateWindowTree(a:dir)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
@ -94,7 +94,7 @@ endfunction
|
|||
|
||||
" FUNCTION: nerdtree#postSourceActions() {{{2
|
||||
function! nerdtree#postSourceActions()
|
||||
call g:NERDTreeBookmark.CacheBookmarks(0)
|
||||
call g:NERDTreeBookmark.CacheBookmarks(1)
|
||||
call nerdtree#ui_glue#createDefaultBindings()
|
||||
|
||||
"load all nerdtree plugins
|
||||
|
|
|
@ -105,7 +105,7 @@ endfunction
|
|||
"FUNCTION: s:activateBookmark() {{{1
|
||||
"handle the user activating a bookmark
|
||||
function! s:activateBookmark(bm)
|
||||
call a:bm.activate(!a:bm.path.isDirectory ? {'where': 'p'} : {})
|
||||
call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p'} : {})
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1
|
||||
|
@ -140,9 +140,7 @@ endfunction
|
|||
" FUNCTION: s:chRoot(node) {{{1
|
||||
" changes the current root to the selected one
|
||||
function! s:chRoot(node)
|
||||
call a:node.makeRoot()
|
||||
call b:NERDTree.render()
|
||||
call b:NERDTreeRoot.putCursorHere(0, 0)
|
||||
call b:NERDTree.changeRoot(a:node)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1
|
||||
|
@ -157,7 +155,7 @@ function! nerdtree#ui_glue#chRootCwd()
|
|||
if cwd.str() == g:NERDTreeFileNode.GetRootForTab().path.str()
|
||||
return
|
||||
endif
|
||||
call s:chRoot(g:NERDTreeDirNode.New(cwd))
|
||||
call s:chRoot(g:NERDTreeDirNode.New(cwd, b:NERDTree))
|
||||
endfunction
|
||||
|
||||
" FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1
|
||||
|
@ -173,6 +171,7 @@ function! nerdtree#ui_glue#clearBookmarks(bookmarks)
|
|||
call bookmark.delete()
|
||||
endfor
|
||||
endif
|
||||
call b:NERDTree.root.refresh()
|
||||
call b:NERDTree.render()
|
||||
endfunction
|
||||
|
||||
|
@ -208,8 +207,8 @@ endfunction
|
|||
" FUNCTION: s:closeTreeWindow() {{{1
|
||||
" close the tree window
|
||||
function! s:closeTreeWindow()
|
||||
if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1
|
||||
exec "buffer " . b:NERDTreePreviousBuf
|
||||
if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() != -1
|
||||
exec "buffer " . b:NERDTree.previousBuf()
|
||||
else
|
||||
if winnr("$") > 1
|
||||
call g:NERDTree.Close()
|
||||
|
@ -227,6 +226,7 @@ function! s:deleteBookmark(bm)
|
|||
if nr2char(getchar()) ==# 'y'
|
||||
try
|
||||
call a:bm.delete()
|
||||
call b:NERDTree.root.refresh()
|
||||
call b:NERDTree.render()
|
||||
redraw
|
||||
catch /^NERDTree/
|
||||
|
@ -241,7 +241,7 @@ endfunction
|
|||
" FUNCTION: s:displayHelp() {{{1
|
||||
" toggles the help display
|
||||
function! s:displayHelp()
|
||||
let b:treeShowHelp = b:treeShowHelp ? 0 : 1
|
||||
call b:NERDTree.ui.toggleHelp()
|
||||
call b:NERDTree.render()
|
||||
call b:NERDTree.ui.centerView()
|
||||
endfunction
|
||||
|
@ -269,27 +269,29 @@ function! s:findAndRevealPath()
|
|||
endtry
|
||||
|
||||
if p.isUnder(cwd)
|
||||
call g:NERDTreeCreator.CreatePrimary(cwd.str())
|
||||
call g:NERDTreeCreator.CreateTabTree(cwd.str())
|
||||
else
|
||||
call g:NERDTreeCreator.CreatePrimary(p.getParent().str())
|
||||
call g:NERDTreeCreator.CreateTabTree(p.getParent().str())
|
||||
endif
|
||||
else
|
||||
if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path)
|
||||
if !g:NERDTree.IsOpen()
|
||||
call g:NERDTreeCreator.TogglePrimary('')
|
||||
call g:NERDTreeCreator.ToggleTabTree('')
|
||||
else
|
||||
call g:NERDTree.CursorToTreeWin()
|
||||
endif
|
||||
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
|
||||
call s:chRoot(g:NERDTreeDirNode.New(p.getParent()))
|
||||
call b:NERDTree.setShowHidden(g:NERDTreeShowHidden)
|
||||
call s:chRoot(g:NERDTreeDirNode.New(p.getParent(), b:NERDTree))
|
||||
else
|
||||
if !g:NERDTree.IsOpen()
|
||||
call g:NERDTreeCreator.TogglePrimary("")
|
||||
call g:NERDTreeCreator.ToggleTabTree("")
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
call g:NERDTree.CursorToTreeWin()
|
||||
call b:NERDTreeRoot.reveal(p)
|
||||
let node = b:NERDTree.root.reveal(p)
|
||||
call b:NERDTree.render()
|
||||
call node.putCursorHere(1,0)
|
||||
|
||||
if p.isUnixHiddenFile()
|
||||
let g:NERDTreeShowHidden = showhidden
|
||||
|
@ -312,7 +314,7 @@ function! s:handleLeftClick()
|
|||
endfor
|
||||
|
||||
if currentNode.path.isDirectory
|
||||
if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~▾▸] \?$'
|
||||
if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \?$'
|
||||
call currentNode.activate()
|
||||
return
|
||||
endif
|
||||
|
@ -409,7 +411,7 @@ endfunction
|
|||
" FUNCTION: s:jumpToRoot() {{{1
|
||||
" moves the cursor to the root node
|
||||
function! s:jumpToRoot()
|
||||
call b:NERDTreeRoot.putCursorHere(1, 0)
|
||||
call b:NERDTree.root.putCursorHere(1, 0)
|
||||
call b:NERDTree.ui.centerView()
|
||||
endfunction
|
||||
|
||||
|
@ -442,13 +444,13 @@ endfunction
|
|||
" put the cursor on the given bookmark and, if its a file, open it
|
||||
function! nerdtree#ui_glue#openBookmark(name)
|
||||
try
|
||||
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0)
|
||||
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree)
|
||||
call targetNode.putCursorHere(0, 1)
|
||||
redraw!
|
||||
catch /^NERDTree.BookmarkedNodeNotFoundError/
|
||||
call nerdtree#echo("note - target node is not cached")
|
||||
let bookmark = g:NERDTreeBookmark.BookmarkFor(a:name)
|
||||
let targetNode = g:NERDTreeFileNode.New(bookmark.path)
|
||||
let targetNode = g:NERDTreeFileNode.New(bookmark.path, b:NERDTree)
|
||||
endtry
|
||||
if targetNode.path.isDirectory
|
||||
call targetNode.openExplorer()
|
||||
|
@ -510,7 +512,7 @@ endfunction
|
|||
" put the cursor on the node associate with the given name
|
||||
function! nerdtree#ui_glue#revealBookmark(name)
|
||||
try
|
||||
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0)
|
||||
let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree)
|
||||
call targetNode.putCursorHere(0, 1)
|
||||
catch /^NERDTree.BookmarkNotFoundError/
|
||||
call nerdtree#echo("Bookmark isnt cached under the current root")
|
||||
|
@ -522,7 +524,7 @@ endfunction
|
|||
" will be reloaded.
|
||||
function! s:refreshRoot()
|
||||
call nerdtree#echo("Refreshing the root node. This could take a while...")
|
||||
call b:NERDTreeRoot.refresh()
|
||||
call b:NERDTree.root.refresh()
|
||||
call b:NERDTree.render()
|
||||
redraw
|
||||
call nerdtree#echo("Refreshing the root node. This could take a while... DONE")
|
||||
|
@ -545,10 +547,10 @@ endfunction
|
|||
|
||||
" FUNCTION: nerdtree#ui_glue#setupCommands() {{{1
|
||||
function! nerdtree#ui_glue#setupCommands()
|
||||
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('<args>')
|
||||
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('<args>')
|
||||
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('<args>')
|
||||
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('<args>')
|
||||
command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close()
|
||||
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('<args>')
|
||||
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('<args>')
|
||||
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
|
||||
command! -n=0 -bar NERDTreeFind call s:findAndRevealPath()
|
||||
command! -n=0 -bar NERDTreeFocus call NERDTreeFocus()
|
||||
|
@ -602,28 +604,28 @@ endfunction
|
|||
"keepState: 1 if the current root should be left open when the tree is
|
||||
"re-rendered
|
||||
function! nerdtree#ui_glue#upDir(keepState)
|
||||
let cwd = b:NERDTreeRoot.path.str({'format': 'UI'})
|
||||
let cwd = b:NERDTree.root.path.str({'format': 'UI'})
|
||||
if cwd ==# "/" || cwd =~# '^[^/]..$'
|
||||
call nerdtree#echo("already at top dir")
|
||||
else
|
||||
if !a:keepState
|
||||
call b:NERDTreeRoot.close()
|
||||
call b:NERDTree.root.close()
|
||||
endif
|
||||
|
||||
let oldRoot = b:NERDTreeRoot
|
||||
let oldRoot = b:NERDTree.root
|
||||
|
||||
if empty(b:NERDTreeRoot.parent)
|
||||
let path = b:NERDTreeRoot.path.getParent()
|
||||
let newRoot = g:NERDTreeDirNode.New(path)
|
||||
if empty(b:NERDTree.root.parent)
|
||||
let path = b:NERDTree.root.path.getParent()
|
||||
let newRoot = g:NERDTreeDirNode.New(path, b:NERDTree)
|
||||
call newRoot.open()
|
||||
call newRoot.transplantChild(b:NERDTreeRoot)
|
||||
let b:NERDTreeRoot = newRoot
|
||||
call newRoot.transplantChild(b:NERDTree.root)
|
||||
let b:NERDTree.root = newRoot
|
||||
else
|
||||
let b:NERDTreeRoot = b:NERDTreeRoot.parent
|
||||
let b:NERDTree.root = b:NERDTree.root.parent
|
||||
endif
|
||||
|
||||
if g:NERDTreeChDirMode ==# 2
|
||||
call b:NERDTreeRoot.path.changeToDir()
|
||||
call b:NERDTree.root.path.changeToDir()
|
||||
endif
|
||||
|
||||
call b:NERDTree.render()
|
||||
|
|
|
@ -37,9 +37,7 @@ CONTENTS *NERDTree-contents*
|
|||
4.3.Menu API..........................|NERDTreeAddPathFilter()|
|
||||
4.4.Path Listener API.................|NERDTreePathListenerAPI|
|
||||
5.About...................................|NERDTreeAbout|
|
||||
6.Changelog...............................|NERDTreeChangelog|
|
||||
7.Credits.................................|NERDTreeCredits|
|
||||
8.License.................................|NERDTreeLicense|
|
||||
6.License.................................|NERDTreeLicense|
|
||||
|
||||
==============================================================================
|
||||
1. Intro *NERDTree*
|
||||
|
@ -673,9 +671,6 @@ NERD tree. These options should be set in your vimrc.
|
|||
|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and
|
||||
'Press ? for help' text.
|
||||
|
||||
|'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of
|
||||
+ ~ chars when displaying directories.
|
||||
|
||||
|'NERDTreeCascadeOpenSingleChildDir'|
|
||||
Cascade open while selected directory has only
|
||||
one child that also is a directory.
|
||||
|
@ -778,13 +773,13 @@ Default: 1.
|
|||
If set to 1, doing a >
|
||||
:edit <some directory>
|
||||
<
|
||||
will open up a "secondary" NERD tree instead of a netrw in the target window.
|
||||
will open up a window level NERD tree instead of a netrw in the target window.
|
||||
|
||||
Secondary NERD trees behaves slightly different from a regular trees in the
|
||||
Window level trees behaves slightly different from a regular trees in the
|
||||
following respects:
|
||||
1. 'o' will open the selected file in the same window as the tree,
|
||||
replacing it.
|
||||
2. you can have as many secondary tree as you want in the same tab.
|
||||
2. you can have one tree per window - instead of per tab.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDTreeIgnore'*
|
||||
|
@ -947,7 +942,7 @@ Other examples: >
|
|||
------------------------------------------------------------------------------
|
||||
*'NERDTreeStatusline'*
|
||||
Values: Any valid statusline setting.
|
||||
Default: %{b:NERDTreeRoot.path.strForOS(0)}
|
||||
Default: %{b:NERDTree.root.path.strForOS(0)}
|
||||
|
||||
Tells the script what to use as the |'statusline'| setting for NERD tree
|
||||
windows.
|
||||
|
@ -988,19 +983,6 @@ of the following lines to set this option: >
|
|||
let NERDTreeMinimalUI=1
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDTreeDirArrows'*
|
||||
Values: 0 or 1
|
||||
Default: 0.
|
||||
|
||||
This option is used to change the default look of directory nodes displayed in
|
||||
the tree. When set to 0 it shows old-school bars (|), + and ~ chars. If set to
|
||||
1 it shows right and down arrows. Use one of the follow lines to set this
|
||||
option: >
|
||||
let NERDTreeDirArrows=0
|
||||
let NERDTreeDirArrows=1
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDTreeCascadeOpenSingleChildDir'*
|
||||
Values: 0 or 1
|
||||
|
@ -1205,7 +1187,7 @@ Use this API if you want to run a callback for events on Path objects. E.G >
|
|||
"This function will be called whenever a Path object is created.
|
||||
|
||||
"a:event is an object that contains a bunch of relevant info -
|
||||
"including the path in question. See lib/event.vim for details.
|
||||
"including the path in question. See lib/nerdtree/event.vim for details.
|
||||
endfunction
|
||||
<
|
||||
Current events supported:
|
||||
|
@ -1235,187 +1217,8 @@ The latest stable versions can be found at
|
|||
The latest dev versions are on github
|
||||
http://github.com/scrooloose/nerdtree
|
||||
|
||||
|
||||
==============================================================================
|
||||
6. Changelog *NERDTreeChangelog*
|
||||
|
||||
Next
|
||||
- add 'scope' argument to the key map API
|
||||
- add NERDTreeCustomIgnoreFilter hook - needs doc
|
||||
- add magic [[dir]] and [[file]] flags to NERDTreeIgnore
|
||||
- add support for custom path filters. See :help NERDTreeAddPathFilter()
|
||||
- add path listener API. See :help NERDTreePathListenerAPI.
|
||||
|
||||
4.2.0
|
||||
- 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!)
|
||||
|
||||
4.1.0
|
||||
features:
|
||||
- NERDTreeFind to reveal the node for the current buffer in the tree,
|
||||
see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by
|
||||
Doug McInnes) into the script.
|
||||
- make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan
|
||||
Ritter and Rémi Prévost.
|
||||
- truncate the root node if wider than the tree window. Thanks to Victor
|
||||
Gonzalez.
|
||||
|
||||
bugfixes:
|
||||
- really fix window state restoring
|
||||
- fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky,
|
||||
jfilip1024, and Chris Chambers
|
||||
|
||||
4.0.0
|
||||
- add a new programmable menu system (see :help NERDTreeMenu).
|
||||
- add new APIs to add menus/menu-items to the menu system as well as
|
||||
custom key mappings to the NERD tree buffer (see :help NERDTreeAPI).
|
||||
- removed the old API functions
|
||||
- added a mapping to maximize/restore the size of nerd tree window, thanks
|
||||
to Guillaume Duranceau for the patch. See :help NERDTree-A for details.
|
||||
|
||||
- fix a bug where secondary nerd trees (netrw hijacked trees) and
|
||||
NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey.
|
||||
- fix a bug where the script ignored directories whose name ended in a dot,
|
||||
thanks to Aggelos Orfanakos for the patch.
|
||||
- fix a bug when using the x mapping on the tree root, thanks to Bryan
|
||||
Venteicher for the patch.
|
||||
- fix a bug where the cursor position/window size of the nerd tree buffer
|
||||
wasnt being stored on closing the window, thanks to Richard Hart.
|
||||
- fix a bug where NERDTreeMirror would mirror the wrong tree
|
||||
|
||||
3.1.1
|
||||
- fix a bug where a non-listed no-name buffer was getting created every
|
||||
time the tree windows was created, thanks to Derek Wyatt and owen1
|
||||
- make <CR> behave the same as the 'o' mapping
|
||||
- some helptag fixes in the doc, thanks strull
|
||||
- fix a bug when using :set nohidden and opening a file where the previous
|
||||
buf was modified. Thanks iElectric
|
||||
- other minor fixes
|
||||
|
||||
3.1.0
|
||||
New features:
|
||||
- add mappings to open files in a vsplit, see :help NERDTree-s and :help
|
||||
NERDTree-gs
|
||||
- make the statusline for the nerd tree window default to something
|
||||
hopefully more useful. See :help 'NERDTreeStatusline'
|
||||
Bugfixes:
|
||||
- make the hijack netrw functionality work when vim is started with "vim
|
||||
<some dir>" (thanks to Alf Mikula for the patch).
|
||||
- fix a bug where the CWD wasnt being changed for some operations even when
|
||||
NERDTreeChDirMode==2 (thanks to Lucas S. Buchala)
|
||||
- add -bar to all the nerd tree :commands so they can chain with other
|
||||
:commands (thanks to tpope)
|
||||
- fix bugs when ignorecase was set (thanks to nach)
|
||||
- fix a bug with the relative path code (thanks to nach)
|
||||
- fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach)
|
||||
|
||||
|
||||
3.0.1
|
||||
Bugfixes:
|
||||
- fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden
|
||||
was not set
|
||||
- fix a bug where :NERDTree <path> would fail if <path> was relative and
|
||||
didnt start with a ./ or ../ Thanks to James Kanze.
|
||||
- make the q mapping work with secondary (:e <dir> style) trees,
|
||||
thanks to jamessan
|
||||
- fix a bunch of small bugs with secondary trees
|
||||
|
||||
More insane refactoring.
|
||||
|
||||
3.0.0
|
||||
- hijack netrw so that doing an :edit <directory> will put a NERD tree in
|
||||
the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw'
|
||||
- allow sharing of trees across tabs, see :help :NERDTreeMirror
|
||||
- remove "top" and "bottom" as valid settings for NERDTreeWinPos
|
||||
- change the '<tab>' mapping to 'i'
|
||||
- change the 'H' mapping to 'I'
|
||||
- lots of refactoring
|
||||
|
||||
==============================================================================
|
||||
7. Credits *NERDTreeCredits*
|
||||
|
||||
Thanks to the following people for testing, bug reports, ideas etc. Without
|
||||
you I probably would have got bored of the hacking the NERD tree and
|
||||
just downloaded pr0n instead.
|
||||
|
||||
Tim Carey-Smith (halorgium)
|
||||
Vigil
|
||||
Nick Brettell
|
||||
Thomas Scott Urban
|
||||
Terrance Cohen
|
||||
Yegappan Lakshmanan
|
||||
Jason Mills
|
||||
Michael Geddes (frogonwheels)
|
||||
Yu Jun
|
||||
Michael Madsen
|
||||
AOYAMA Shotaro
|
||||
Zhang Weiwu
|
||||
Niels Aan de Brugh
|
||||
Olivier Yiptong
|
||||
Zhang Shuhan
|
||||
Cory Echols
|
||||
Piotr Czachur
|
||||
Yuan Jiang
|
||||
Matan Nassau
|
||||
Maxim Kim
|
||||
Charlton Wang
|
||||
Matt Wozniski (godlygeek)
|
||||
knekk
|
||||
Sean Chou
|
||||
Ryan Penn
|
||||
Simon Peter Nicholls
|
||||
Michael Foobar
|
||||
Tomasz Chomiuk
|
||||
Denis Pokataev
|
||||
Tim Pope (tpope)
|
||||
James Kanze
|
||||
James Vega (jamessan)
|
||||
Frederic Chanal (nach)
|
||||
Alf Mikula
|
||||
Lucas S. Buchala
|
||||
Curtis Harvey
|
||||
Guillaume Duranceau
|
||||
Richard Hart (hates)
|
||||
Doug McInnes
|
||||
Stefan Ritter
|
||||
Rémi Prévost
|
||||
Victor Gonzalez
|
||||
Stephan Baumeister
|
||||
Ricky
|
||||
jfilip1024
|
||||
Chris Chambers
|
||||
Vitaly Bogdanov
|
||||
Patrick O'Loughlin (paddyoloughlin)
|
||||
Cam Thompson (camthompson)
|
||||
Marcin Kulik (sickill)
|
||||
Steve DeWald (sdewald)
|
||||
Ivan Necas (iNecas)
|
||||
George Ang (gnap)
|
||||
Evan Coury (EvanDotPro)
|
||||
Andrew Radev (AndrewRadev)
|
||||
Matt Gauger (mathias)
|
||||
Scott Stevenson (scottstvnsn)
|
||||
Anderson Freitas (andersonfreitas)
|
||||
Kamil K. Lemański (kml)
|
||||
Yehuda Katz (wycats)
|
||||
Min-Young Wu (minyoung)
|
||||
Benjamin Geiger (benjamingeiger)
|
||||
|
||||
==============================================================================
|
||||
8. License *NERDTreeLicense*
|
||||
6. License *NERDTreeLicense*
|
||||
|
||||
The NERD tree is released under the wtfpl.
|
||||
See http://sam.zoy.org/wtfpl/COPYING.
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
let s:Bookmark = {}
|
||||
let g:NERDTreeBookmark = s:Bookmark
|
||||
|
||||
" FUNCTION: Bookmark.activate() {{{1
|
||||
function! s:Bookmark.activate(...)
|
||||
call self.open(a:0 ? a:1 : {})
|
||||
" FUNCTION: Bookmark.activate(nerdtree) {{{1
|
||||
function! s:Bookmark.activate(nerdtree, ...)
|
||||
call self.open(a:nerdtree, a:0 ? a:1 : {})
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Bookmark.AddBookmark(name, path) {{{1
|
||||
|
@ -87,6 +87,7 @@ function! s:Bookmark.CacheBookmarks(silent)
|
|||
|
||||
let name = substitute(i, '^\(.\{-}\) .*$', '\1', '')
|
||||
let path = substitute(i, '^.\{-} \(.*\)$', '\1', '')
|
||||
let path = fnamemodify(path, ':p')
|
||||
|
||||
try
|
||||
let bookmark = s:Bookmark.New(name, g:NERDTreePath.New(path))
|
||||
|
@ -127,26 +128,18 @@ endfunction
|
|||
" Delete this bookmark. If the node for this bookmark is under the current
|
||||
" root, then recache bookmarks for its Path object
|
||||
function! s:Bookmark.delete()
|
||||
let node = {}
|
||||
try
|
||||
let node = self.getNode(1)
|
||||
catch /^NERDTree.BookmarkedNodeNotFoundError/
|
||||
endtry
|
||||
call remove(s:Bookmark.Bookmarks(), index(s:Bookmark.Bookmarks(), self))
|
||||
if !empty(node)
|
||||
call node.path.cacheDisplayString()
|
||||
endif
|
||||
call s:Bookmark.Write()
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Bookmark.getNode(searchFromAbsoluteRoot) {{{1
|
||||
" FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1
|
||||
" Gets the treenode for this bookmark
|
||||
"
|
||||
" Args:
|
||||
" searchFromAbsoluteRoot: specifies whether we should search from the current
|
||||
" tree root, or the highest cached node
|
||||
function! s:Bookmark.getNode(searchFromAbsoluteRoot)
|
||||
let searchRoot = a:searchFromAbsoluteRoot ? g:NERDTreeDirNode.AbsoluteTreeRoot() : b:NERDTreeRoot
|
||||
function! s:Bookmark.getNode(nerdtree, searchFromAbsoluteRoot)
|
||||
let searchRoot = a:searchFromAbsoluteRoot ? a:nerdtree.root.AbsoluteTreeRoot() : a:nerdtree.root
|
||||
let targetNode = searchRoot.findNode(self.path)
|
||||
if empty(targetNode)
|
||||
throw "NERDTree.BookmarkedNodeNotFoundError: no node was found for bookmark: " . self.name
|
||||
|
@ -154,12 +147,12 @@ function! s:Bookmark.getNode(searchFromAbsoluteRoot)
|
|||
return targetNode
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) {{{1
|
||||
" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) {{{1
|
||||
" Class method that finds the bookmark with the given name and returns the
|
||||
" treenode for it.
|
||||
function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot)
|
||||
function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree)
|
||||
let bookmark = s:Bookmark.BookmarkFor(a:name)
|
||||
return bookmark.getNode(a:searchFromAbsoluteRoot)
|
||||
return bookmark.getNode(nerdtree, a:searchFromAbsoluteRoot)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Bookmark.GetSelected() {{{1
|
||||
|
@ -209,8 +202,11 @@ function! s:Bookmark.New(name, path)
|
|||
return newBookmark
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Bookmark.open([options]) {{{1
|
||||
" FUNCTION: Bookmark.open(nerdtree, [options]) {{{1
|
||||
"Args:
|
||||
"
|
||||
"nerdtree: the tree to load open the bookmark in
|
||||
"
|
||||
"A dictionary containing the following keys (all optional):
|
||||
" 'where': Specifies whether the node should be opened in new split/tab or in
|
||||
" the previous window. Can be either 'v' (vertical split), 'h'
|
||||
|
@ -219,11 +215,11 @@ endfunction
|
|||
" 'keepopen': dont close the tree window
|
||||
" 'stay': open the file, but keep the cursor in the tree win
|
||||
"
|
||||
function! s:Bookmark.open(...)
|
||||
function! s:Bookmark.open(nerdtree, ...)
|
||||
let opts = a:0 ? a:1 : {}
|
||||
|
||||
if self.path.isDirectory && !has_key(opts, 'where')
|
||||
call self.toRoot()
|
||||
call self.toRoot(a:nerdtree)
|
||||
else
|
||||
let opener = g:NERDTreeOpener.New(self.path, opts)
|
||||
call opener.open(self)
|
||||
|
@ -265,26 +261,24 @@ function! s:Bookmark.str()
|
|||
return '>' . self.name . ' ' . pathStr
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Bookmark.toRoot() {{{1
|
||||
" FUNCTION: Bookmark.toRoot(nerdtree) {{{1
|
||||
" Make the node for this bookmark the new tree root
|
||||
function! s:Bookmark.toRoot()
|
||||
function! s:Bookmark.toRoot(nerdtree)
|
||||
if self.validate()
|
||||
try
|
||||
let targetNode = self.getNode(1)
|
||||
let targetNode = self.getNode(a:nerdtree, 1)
|
||||
catch /^NERDTree.BookmarkedNodeNotFoundError/
|
||||
let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path)
|
||||
let targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path, a:nerdtree)
|
||||
endtry
|
||||
call targetNode.makeRoot()
|
||||
call b:NERDTree.render()
|
||||
call targetNode.putCursorHere(0, 0)
|
||||
call a:nerdtree.changeRoot(targetNode)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Bookmark.ToRoot(name) {{{1
|
||||
" FUNCTION: Bookmark.ToRoot(name, nerdtree) {{{1
|
||||
" Make the node for this bookmark the new tree root
|
||||
function! s:Bookmark.ToRoot(name)
|
||||
function! s:Bookmark.ToRoot(name, nerdtree)
|
||||
let bookmark = s:Bookmark.BookmarkFor(a:name)
|
||||
call bookmark.toRoot()
|
||||
call bookmark.toRoot(a:nerdtree)
|
||||
endfunction
|
||||
|
||||
" FUNCTION: Bookmark.validate() {{{1
|
||||
|
@ -293,7 +287,6 @@ function! s:Bookmark.validate()
|
|||
return 1
|
||||
else
|
||||
call s:Bookmark.CacheBookmarks(1)
|
||||
call b:NERDTree.render()
|
||||
call nerdtree#echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.")
|
||||
return 0
|
||||
endif
|
||||
|
@ -304,7 +297,7 @@ endfunction
|
|||
function! s:Bookmark.Write()
|
||||
let bookmarkStrings = []
|
||||
for i in s:Bookmark.Bookmarks()
|
||||
call add(bookmarkStrings, i.name . ' ' . i.path.str())
|
||||
call add(bookmarkStrings, i.name . ' ' . fnamemodify(i.path.str(), ':~'))
|
||||
endfor
|
||||
|
||||
"add a blank line before the invalid ones
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"CLASS: Creator
|
||||
"Creates primary/secondary/mirror nerdtree windows. Sets up all the window and
|
||||
"Creates tab/window/mirror nerdtree windows. Sets up all the window and
|
||||
"buffer options and key mappings etc.
|
||||
"============================================================
|
||||
let s:Creator = {}
|
||||
|
@ -16,7 +16,7 @@ function! s:Creator._bindMappings()
|
|||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#ui_glue#revealBookmark('<args>')
|
||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark :call nerdtree#ui_glue#openBookmark('<args>')
|
||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('<args>')
|
||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('<args>')
|
||||
command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('<args>', b:NERDTree)
|
||||
command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() <bar> call b:NERDTree.render()
|
||||
command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) <bar> call b:NERDTree.render()
|
||||
command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write()
|
||||
|
@ -32,22 +32,26 @@ function! s:Creator.BufNamePrefix()
|
|||
return 'NERD_tree_'
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.CreatePrimary(a:name) {{{1
|
||||
function! s:Creator.CreatePrimary(name)
|
||||
"FUNCTION: s:Creator.CreateTabTree(a:name) {{{1
|
||||
function! s:Creator.CreateTabTree(name)
|
||||
let creator = s:Creator.New()
|
||||
call creator.createPrimary(a:name)
|
||||
call creator.createTabTree(a:name)
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.createPrimary(a:name) {{{1
|
||||
"FUNCTION: s:Creator.createTabTree(a:name) {{{1
|
||||
"name: the name of a bookmark or a directory
|
||||
function! s:Creator.createPrimary(name)
|
||||
function! s:Creator.createTabTree(name)
|
||||
let path = self._pathForString(a:name)
|
||||
|
||||
|
||||
"abort if exception was thrown (bookmark/dir doesn't exist)
|
||||
if empty(path)
|
||||
return
|
||||
endif
|
||||
|
||||
if path == {}
|
||||
return
|
||||
endif
|
||||
|
||||
"if instructed to, then change the vim CWD to the dir the NERDTree is
|
||||
"inited in
|
||||
if g:NERDTreeChDirMode != 0
|
||||
|
@ -58,32 +62,26 @@ function! s:Creator.createPrimary(name)
|
|||
if g:NERDTree.IsOpen()
|
||||
call g:NERDTree.Close()
|
||||
endif
|
||||
unlet t:NERDTreeBufName
|
||||
|
||||
call self._removeTreeBufForTab()
|
||||
endif
|
||||
|
||||
call self._createTreeWin()
|
||||
call self._createNERDTree(path)
|
||||
let b:NERDTreeType = "primary"
|
||||
let b:treeShowHelp = 0
|
||||
let b:NERDTreeIgnoreEnabled = 1
|
||||
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
|
||||
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
|
||||
let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
|
||||
|
||||
call self._createNERDTree(path, "tab")
|
||||
call b:NERDTree.render()
|
||||
call b:NERDTreeRoot.putCursorHere(0, 0)
|
||||
call b:NERDTree.root.putCursorHere(0, 0)
|
||||
|
||||
call self._broadcastInitEvent()
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.CreateSecondary(dir) {{{1
|
||||
function! s:Creator.CreateSecondary(dir)
|
||||
"FUNCTION: s:Creator.CreateWindowTree(dir) {{{1
|
||||
function! s:Creator.CreateWindowTree(dir)
|
||||
let creator = s:Creator.New()
|
||||
call creator.createSecondary(a:dir)
|
||||
call creator.createWindowTree(a:dir)
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.createSecondary(dir) {{{1
|
||||
function! s:Creator.createSecondary(dir)
|
||||
"FUNCTION: s:Creator.createWindowTree(dir) {{{1
|
||||
function! s:Creator.createWindowTree(dir)
|
||||
try
|
||||
let path = g:NERDTreePath.New(a:dir)
|
||||
catch /^NERDTree.InvalidArgumentsError/
|
||||
|
@ -96,14 +94,13 @@ function! s:Creator.createSecondary(dir)
|
|||
|
||||
let previousBuf = expand("#")
|
||||
|
||||
"we need a unique name for each secondary tree buffer to ensure they are
|
||||
"we need a unique name for each window tree buffer to ensure they are
|
||||
"all independent
|
||||
exec "silent edit " . self._nextBufferName()
|
||||
|
||||
let b:NERDTreePreviousBuf = bufnr(previousBuf)
|
||||
call self._createNERDTree(path)
|
||||
call self._createNERDTree(path, "window")
|
||||
let b:NERDTree._previousBuf = bufnr(previousBuf)
|
||||
call self._setCommonBufOptions()
|
||||
let b:NERDTreeType = "secondary"
|
||||
|
||||
call b:NERDTree.render()
|
||||
|
||||
|
@ -111,8 +108,8 @@ function! s:Creator.createSecondary(dir)
|
|||
endfunction
|
||||
|
||||
" FUNCTION: s:Creator._createNERDTree(path) {{{1
|
||||
function! s:Creator._createNERDTree(path)
|
||||
let b:NERDTree = g:NERDTree.New(a:path)
|
||||
function! s:Creator._createNERDTree(path, type)
|
||||
let b:NERDTree = g:NERDTree.New(a:path, a:type)
|
||||
"TODO: This is kept for compatability only since many things use
|
||||
"b:NERDTreeRoot instead of the new NERDTree.root
|
||||
"Remove this one day
|
||||
|
@ -145,7 +142,7 @@ function! s:Creator.createMirror()
|
|||
let i = 0
|
||||
while i < len(treeBufNames)
|
||||
let bufName = treeBufNames[i]
|
||||
let treeRoot = getbufvar(bufName, "NERDTreeRoot")
|
||||
let treeRoot = getbufvar(bufName, "NERDTree").root
|
||||
let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName
|
||||
let i = i + 1
|
||||
endwhile
|
||||
|
@ -201,6 +198,15 @@ function! s:Creator._createTreeWin()
|
|||
call self._setCommonBufOptions()
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator._isBufHidden(nr) {{{1
|
||||
function! s:Creator._isBufHidden(nr)
|
||||
redir => bufs
|
||||
silent ls!
|
||||
redir END
|
||||
|
||||
return bufs =~ a:nr . '..h'
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.New() {{{1
|
||||
function! s:Creator.New()
|
||||
let newCreator = copy(self)
|
||||
|
@ -245,7 +251,7 @@ function! s:Creator._pathForString(str)
|
|||
let path = g:NERDTreePath.New(dir)
|
||||
catch /^NERDTree.InvalidArgumentsError/
|
||||
call nerdtree#echo("No bookmark or directory found for: " . a:str)
|
||||
return
|
||||
return {}
|
||||
endtry
|
||||
endif
|
||||
if !path.isDirectory
|
||||
|
@ -255,6 +261,23 @@ function! s:Creator._pathForString(str)
|
|||
return path
|
||||
endfunction
|
||||
|
||||
" Function: s:Creator._removeTreeBufForTab() {{{1
|
||||
function! s:Creator._removeTreeBufForTab()
|
||||
let buf = bufnr(t:NERDTreeBufName)
|
||||
|
||||
"if &hidden is not set then it will already be gone
|
||||
if buf != -1
|
||||
|
||||
"nerdtree buf may be mirrored/displayed elsewhere
|
||||
if self._isBufHidden(buf)
|
||||
exec "bwipeout " . buf
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
unlet t:NERDTreeBufName
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator._setCommonBufOptions() {{{1
|
||||
function! s:Creator._setCommonBufOptions()
|
||||
"throwaway buffer options
|
||||
|
@ -283,12 +306,6 @@ function! s:Creator._setCommonBufOptions()
|
|||
endif
|
||||
|
||||
call self._setupStatusline()
|
||||
|
||||
let b:treeShowHelp = 0
|
||||
let b:NERDTreeIgnoreEnabled = 1
|
||||
let b:NERDTreeShowFiles = g:NERDTreeShowFiles
|
||||
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
|
||||
let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
|
||||
call self._bindMappings()
|
||||
setlocal filetype=nerdtree
|
||||
endfunction
|
||||
|
@ -318,20 +335,20 @@ function! s:Creator._tabpagevar(tabnr, var)
|
|||
return v
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.TogglePrimary(dir) {{{1
|
||||
function! s:Creator.TogglePrimary(dir)
|
||||
"FUNCTION: s:Creator.ToggleTabTree(dir) {{{1
|
||||
function! s:Creator.ToggleTabTree(dir)
|
||||
let creator = s:Creator.New()
|
||||
call creator.togglePrimary(a:dir)
|
||||
call creator.toggleTabTree(a:dir)
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:Creator.togglePrimary(dir) {{{1
|
||||
"FUNCTION: s:Creator.toggleTabTree(dir) {{{1
|
||||
"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is
|
||||
"closed it is restored or initialized (if it doesnt exist)
|
||||
"
|
||||
"Args:
|
||||
"dir: the full path for the root node (is only used if the NERD tree is being
|
||||
"initialized.
|
||||
function! s:Creator.togglePrimary(dir)
|
||||
function! s:Creator.toggleTabTree(dir)
|
||||
if g:NERDTree.ExistsForTab()
|
||||
if !g:NERDTree.IsOpen()
|
||||
call self._createTreeWin()
|
||||
|
@ -343,7 +360,7 @@ function! s:Creator.togglePrimary(dir)
|
|||
call g:NERDTree.Close()
|
||||
endif
|
||||
else
|
||||
call self.createPrimary(a:dir)
|
||||
call self.createTabTree(a:dir)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -8,8 +8,30 @@ function! s:NERDTree.AddPathFilter(callback)
|
|||
call add(s:NERDTree.PathFilters(), a:callback)
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.changeRoot(node) {{{1
|
||||
function! s:NERDTree.changeRoot(node)
|
||||
if a:node.path.isDirectory
|
||||
let self.root = a:node
|
||||
else
|
||||
call a:node.cacheParent()
|
||||
let self.root = a:node.parent
|
||||
endif
|
||||
|
||||
call self.root.open()
|
||||
|
||||
"change dir to the dir of the new root if instructed to
|
||||
if g:NERDTreeChDirMode ==# 2
|
||||
exec "cd " . self.root.path.str({'format': 'Edit'})
|
||||
endif
|
||||
|
||||
call self.render()
|
||||
call self.root.putCursorHere(0, 0)
|
||||
|
||||
silent doautocmd User NERDTreeNewRoot
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.Close() {{{1
|
||||
"Closes the primary NERD tree window for this tab
|
||||
"Closes the tab tree window for this tab
|
||||
function! s:NERDTree.Close()
|
||||
if !s:NERDTree.IsOpen()
|
||||
return
|
||||
|
@ -43,7 +65,7 @@ endfunction
|
|||
"FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1
|
||||
"Places the cursor at the top of the bookmarks table
|
||||
function! s:NERDTree.CursorToBookmarkTable()
|
||||
if !b:NERDTreeShowBookmarks
|
||||
if !b:NERDTree.ui.getShowBookmarks()
|
||||
throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active"
|
||||
endif
|
||||
|
||||
|
@ -73,13 +95,18 @@ endfunction
|
|||
" Function: s:NERDTree.ExistsForBuffer() {{{1
|
||||
" Returns 1 if a nerd tree root exists in the current buffer
|
||||
function! s:NERDTree.ExistsForBuf()
|
||||
return exists("b:NERDTreeRoot")
|
||||
return exists("b:NERDTree")
|
||||
endfunction
|
||||
|
||||
" Function: s:NERDTree.ExistsForTab() {{{1
|
||||
" Returns 1 if a nerd tree root exists in the current tab
|
||||
function! s:NERDTree.ExistsForTab()
|
||||
return exists("t:NERDTreeBufName")
|
||||
if !exists("t:NERDTreeBufName")
|
||||
return
|
||||
end
|
||||
|
||||
"check b:NERDTree is still there and hasn't been e.g. :bdeleted
|
||||
return !empty(getbufvar(bufnr(t:NERDTreeBufName), 'NERDTree'))
|
||||
endfunction
|
||||
|
||||
function! s:NERDTree.ForCurrentBuf()
|
||||
|
@ -90,14 +117,29 @@ function! s:NERDTree.ForCurrentBuf()
|
|||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.ForCurrentTab() {{{1
|
||||
function! s:NERDTree.ForCurrentTab()
|
||||
if !s:NERDTree.ExistsForTab()
|
||||
return
|
||||
endif
|
||||
|
||||
let bufnr = bufnr(t:NERDTreeBufName)
|
||||
return getbufvar(bufnr, "NERDTree")
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.getRoot() {{{1
|
||||
function! s:NERDTree.getRoot()
|
||||
return self.root
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.GetWinNum() {{{1
|
||||
"gets the nerd tree window number for this tab
|
||||
function! s:NERDTree.GetWinNum()
|
||||
if exists("t:NERDTreeBufName")
|
||||
return bufwinnr(t:NERDTreeBufName)
|
||||
else
|
||||
return -1
|
||||
endif
|
||||
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.IsOpen() {{{1
|
||||
|
@ -105,6 +147,16 @@ function! s:NERDTree.IsOpen()
|
|||
return s:NERDTree.GetWinNum() != -1
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.isTabTree() {{{1
|
||||
function! s:NERDTree.isTabTree()
|
||||
return self._type == "tab"
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.isWinTree() {{{1
|
||||
function! s:NERDTree.isWinTree()
|
||||
return self._type == "window"
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.MustBeOpen() {{{1
|
||||
function! s:NERDTree.MustBeOpen()
|
||||
if !s:NERDTree.IsOpen()
|
||||
|
@ -113,11 +165,11 @@ function! s:NERDTree.MustBeOpen()
|
|||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.New() {{{1
|
||||
function! s:NERDTree.New(path)
|
||||
function! s:NERDTree.New(path, type)
|
||||
let newObj = copy(self)
|
||||
let newObj.ui = g:NERDTreeUI.New(newObj)
|
||||
let newObj.root = g:NERDTreeDirNode.New(a:path)
|
||||
|
||||
let newObj.root = g:NERDTreeDirNode.New(a:path, newObj)
|
||||
let newObj._type = a:type
|
||||
return newObj
|
||||
endfunction
|
||||
|
||||
|
@ -129,6 +181,10 @@ function! s:NERDTree.PathFilters()
|
|||
return s:NERDTree._PathFilters
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.previousBuf() {{{1
|
||||
function! s:NERDTree.previousBuf()
|
||||
return self._previousBuf
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.render() {{{1
|
||||
"A convenience function - since this is called often
|
||||
|