first commit
David Blume

David Blume commited on 2015-11-27 14:48:06
Showing 63 changed files, with 17969 additions and 0 deletions.

... ...
@@ -0,0 +1,12 @@
1
+# ~/.bash_profile: executed by bash for login shells.
2
+
3
+# source the system wide bashrc if it exists
4
+if [ -e /etc/bash.bashrc ] ; then
5
+  source /etc/bash.bashrc
6
+fi
7
+
8
+# source the users bashrc if it exists
9
+if [ -e "${HOME}/.bashrc" ] ; then
10
+  source "${HOME}/.bashrc"
11
+fi
12
+
... ...
@@ -0,0 +1,39 @@
1
+export PS1="\W\$ "
2
+
3
+add_to_path() {
4
+    if [ -d "$1" ] && [[ ! $PATH =~ (^|:)$1(:|$) ]]; then
5
+        PATH+=:$1
6
+    fi
7
+}
8
+
9
+# if this is a CygWin .bashrc, then set CygWin's commands first in PATH
10
+# because link.exe and find.exe exist in Windows's path.
11
+# Add /usr/lib/lapack at the end so python's numpy can find lapack_lite
12
+# (Note: BSD bash, used by OS X doesn't have the "substr" test for expr.)
13
+if [[ $(uname -s) == CYGWIN* ]]; then
14
+        PATH=/usr/local/bin:/usr/bin:$PATH
15
+	PATH=${PATH//":/usr/local/bin:/usr/bin"/} # delete any instances in middle
16
+	add_to_path /usr/lib/lapack
17
+	ulimit -n 1024 # for "duplicity"
18
+	alias ls='ls --color=auto'
19
+elif [[ $(uname -s) == Darwin* ]]; then
20
+	export LSCOLORS=gxfxcxdxbxegedabagacad
21
+	export CLICOLOR=1
22
+fi
23
+
24
+# change the color of directories in the ls command 
25
+#
26
+# After executing: dircolors -p > .dircolors
27
+# And changing the following line in .dircolors:
28
+# DIR 00;36 # directory
29
+if [ "$TERM" != "dumb" ]; then
30
+	[ -e "$HOME/.dircolors" ] && DIR_COLORS="$HOME/.dircolors"
31
+	[ -e "$DIR_COLORS" ] || DIR_COLORS=""
32
+	eval "`dircolors -b $DIR_COLORS`"
33
+fi
34
+
35
+# Add to PATH only if not already in PATH.
36
+add_to_path $HOME/bin
37
+
38
+alias findinchppfiles="find . -type f \( -name \*.[ch]pp -or -name \*.[ch] \) -print0 | xargs -0 grep -nI"
39
+alias findinpyfiles="find . -name \*.py -print0 | xargs -0 grep -nI"
... ...
@@ -0,0 +1,5 @@
1
+[user]
2
+	name = David Blume
3
+	email = david.blume@gmail.com
4
+[push]
5
+	default = simple
... ...
@@ -0,0 +1,254 @@
1
+" pathogen.vim - path option manipulation
2
+" Maintainer:   Tim Pope <http://tpo.pe/>
3
+" Version:      2.0
4
+
5
+" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
6
+"
7
+" For management of individually installed plugins in ~/.vim/bundle (or
8
+" ~\vimfiles\bundle), adding `call pathogen#infect()` to your .vimrc
9
+" prior to `filetype plugin indent on` is the only other setup necessary.
10
+"
11
+" The API is documented inline below.  For maximum ease of reading,
12
+" :set foldmethod=marker
13
+
14
+if exists("g:loaded_pathogen") || &cp
15
+  finish
16
+endif
17
+let g:loaded_pathogen = 1
18
+
19
+" Point of entry for basic default usage.  Give a directory name to invoke
20
+" pathogen#runtime_append_all_bundles() (defaults to "bundle"), or a full path
21
+" to invoke pathogen#runtime_prepend_subdirectories().  Afterwards,
22
+" pathogen#cycle_filetype() is invoked.
23
+function! pathogen#infect(...) abort " {{{1
24
+  let source_path = a:0 ? a:1 : 'bundle'
25
+  if source_path =~# '[\\/]'
26
+    call pathogen#runtime_prepend_subdirectories(source_path)
27
+  else
28
+    call pathogen#runtime_append_all_bundles(source_path)
29
+  endif
30
+  call pathogen#cycle_filetype()
31
+endfunction " }}}1
32
+
33
+" Split a path into a list.
34
+function! pathogen#split(path) abort " {{{1
35
+  if type(a:path) == type([]) | return a:path | endif
36
+  let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
37
+  return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
38
+endfunction " }}}1
39
+
40
+" Convert a list to a path.
41
+function! pathogen#join(...) abort " {{{1
42
+  if type(a:1) == type(1) && a:1
43
+    let i = 1
44
+    let space = ' '
45
+  else
46
+    let i = 0
47
+    let space = ''
48
+  endif
49
+  let path = ""
50
+  while i < a:0
51
+    if type(a:000[i]) == type([])
52
+      let list = a:000[i]
53
+      let j = 0
54
+      while j < len(list)
55
+        let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
56
+        let path .= ',' . escaped
57
+        let j += 1
58
+      endwhile
59
+    else
60
+      let path .= "," . a:000[i]
61
+    endif
62
+    let i += 1
63
+  endwhile
64
+  return substitute(path,'^,','','')
65
+endfunction " }}}1
66
+
67
+" Convert a list to a path with escaped spaces for 'path', 'tag', etc.
68
+function! pathogen#legacyjoin(...) abort " {{{1
69
+  return call('pathogen#join',[1] + a:000)
70
+endfunction " }}}1
71
+
72
+" Remove duplicates from a list.
73
+function! pathogen#uniq(list) abort " {{{1
74
+  let i = 0
75
+  let seen = {}
76
+  while i < len(a:list)
77
+    if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i])
78
+      call remove(a:list,i)
79
+    elseif a:list[i] ==# ''
80
+      let i += 1
81
+      let empty = 1
82
+    else
83
+      let seen[a:list[i]] = 1
84
+      let i += 1
85
+    endif
86
+  endwhile
87
+  return a:list
88
+endfunction " }}}1
89
+
90
+" \ on Windows unless shellslash is set, / everywhere else.
91
+function! pathogen#separator() abort " {{{1
92
+  return !exists("+shellslash") || &shellslash ? '/' : '\'
93
+endfunction " }}}1
94
+
95
+" Convenience wrapper around glob() which returns a list.
96
+function! pathogen#glob(pattern) abort " {{{1
97
+  let files = split(glob(a:pattern),"\n")
98
+  return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")')
99
+endfunction "}}}1
100
+
101
+" Like pathogen#glob(), only limit the results to directories.
102
+function! pathogen#glob_directories(pattern) abort " {{{1
103
+  return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
104
+endfunction "}}}1
105
+
106
+" Turn filetype detection off and back on again if it was already enabled.
107
+function! pathogen#cycle_filetype() " {{{1
108
+  if exists('g:did_load_filetypes')
109
+    filetype off
110
+    filetype on
111
+  endif
112
+endfunction " }}}1
113
+
114
+" Checks if a bundle is 'disabled'. A bundle is considered 'disabled' if
115
+" its 'basename()' is included in g:pathogen_disabled[]' or ends in a tilde.
116
+function! pathogen#is_disabled(path) " {{{1
117
+  if a:path =~# '\~$'
118
+    return 1
119
+  elseif !exists("g:pathogen_disabled")
120
+    return 0
121
+  endif
122
+  let sep = pathogen#separator()
123
+  return index(g:pathogen_disabled, strpart(a:path, strridx(a:path, sep)+1)) != -1
124
+endfunction "}}}1
125
+
126
+" Prepend all subdirectories of path to the rtp, and append all 'after'
127
+" directories in those subdirectories.
128
+function! pathogen#runtime_prepend_subdirectories(path) " {{{1
129
+  let sep    = pathogen#separator()
130
+  let before = filter(pathogen#glob_directories(a:path.sep."*"), '!pathogen#is_disabled(v:val)')
131
+  let after  = filter(pathogen#glob_directories(a:path.sep."*".sep."after"), '!pathogen#is_disabled(v:val[0:-7])')
132
+  let rtp = pathogen#split(&rtp)
133
+  let path = expand(a:path)
134
+  call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
135
+  let &rtp = pathogen#join(pathogen#uniq(before + rtp + after))
136
+  return &rtp
137
+endfunction " }}}1
138
+
139
+" For each directory in rtp, check for a subdirectory named dir.  If it
140
+" exists, add all subdirectories of that subdirectory to the rtp, immediately
141
+" after the original directory.  If no argument is given, 'bundle' is used.
142
+" Repeated calls with the same arguments are ignored.
143
+function! pathogen#runtime_append_all_bundles(...) " {{{1
144
+  let sep = pathogen#separator()
145
+  let name = a:0 ? a:1 : 'bundle'
146
+  if "\n".s:done_bundles =~# "\\M\n".name."\n"
147
+    return ""
148
+  endif
149
+  let s:done_bundles .= name . "\n"
150
+  let list = []
151
+  for dir in pathogen#split(&rtp)
152
+    if dir =~# '\<after$'
153
+      let list +=  filter(pathogen#glob_directories(substitute(dir,'after$',name,'').sep.'*[^~]'.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])') + [dir]
154
+    else
155
+      let list +=  [dir] + filter(pathogen#glob_directories(dir.sep.name.sep.'*[^~]'), '!pathogen#is_disabled(v:val)')
156
+    endif
157
+  endfor
158
+  let &rtp = pathogen#join(pathogen#uniq(list))
159
+  return 1
160
+endfunction
161
+
162
+let s:done_bundles = ''
163
+" }}}1
164
+
165
+" Invoke :helptags on all non-$VIM doc directories in runtimepath.
166
+function! pathogen#helptags() " {{{1
167
+  let sep = pathogen#separator()
168
+  for dir in pathogen#split(&rtp)
169
+    if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.sep.'doc') == 2 && !empty(filter(split(glob(dir.sep.'doc'.sep.'*'),"\n>"),'!isdirectory(v:val)')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags'))
170
+      helptags `=dir.'/doc'`
171
+    endif
172
+  endfor
173
+endfunction " }}}1
174
+
175
+command! -bar Helptags :call pathogen#helptags()
176
+
177
+" Like findfile(), but hardcoded to use the runtimepath.
178
+function! pathogen#runtime_findfile(file,count) "{{{1
179
+  let rtp = pathogen#join(1,pathogen#split(&rtp))
180
+  let file = findfile(a:file,rtp,a:count)
181
+  if file ==# ''
182
+    return ''
183
+  else
184
+    return fnamemodify(file,':p')
185
+  endif
186
+endfunction " }}}1
187
+
188
+" Backport of fnameescape().
189
+function! pathogen#fnameescape(string) " {{{1
190
+  if exists('*fnameescape')
191
+    return fnameescape(a:string)
192
+  elseif a:string ==# '-'
193
+    return '\-'
194
+  else
195
+    return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
196
+  endif
197
+endfunction " }}}1
198
+
199
+if exists(':Vedit')
200
+  finish
201
+endif
202
+
203
+function! s:find(count,cmd,file,lcd) " {{{1
204
+  let rtp = pathogen#join(1,pathogen#split(&runtimepath))
205
+  let file = pathogen#runtime_findfile(a:file,a:count)
206
+  if file ==# ''
207
+    return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
208
+  elseif a:lcd
209
+    let path = file[0:-strlen(a:file)-2]
210
+    execute 'lcd `=path`'
211
+    return a:cmd.' '.pathogen#fnameescape(a:file)
212
+  else
213
+    return a:cmd.' '.pathogen#fnameescape(file)
214
+  endif
215
+endfunction " }}}1
216
+
217
+function! s:Findcomplete(A,L,P) " {{{1
218
+  let sep = pathogen#separator()
219
+  let cheats = {
220
+        \'a': 'autoload',
221
+        \'d': 'doc',
222
+        \'f': 'ftplugin',
223
+        \'i': 'indent',
224
+        \'p': 'plugin',
225
+        \'s': 'syntax'}
226
+  if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
227
+    let request = cheats[a:A[0]].a:A[1:-1]
228
+  else
229
+    let request = a:A
230
+  endif
231
+  let pattern = substitute(request,'/\|\'.sep,'*'.sep,'g').'*'
232
+  let found = {}
233
+  for path in pathogen#split(&runtimepath)
234
+    let path = expand(path, ':p')
235
+    let matches = split(glob(path.sep.pattern),"\n")
236
+    call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
237
+    call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]')
238
+    for match in matches
239
+      let found[match] = 1
240
+    endfor
241
+  endfor
242
+  return sort(keys(found))
243
+endfunction " }}}1
244
+
245
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve       :execute s:find(<count>,'edit<bang>',<q-args>,0)
246
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit    :execute s:find(<count>,'edit<bang>',<q-args>,0)
247
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen    :execute s:find(<count>,'edit<bang>',<q-args>,1)
248
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit   :execute s:find(<count>,'split',<q-args>,<bang>1)
249
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit  :execute s:find(<count>,'vsplit',<q-args>,<bang>1)
250
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit',<q-args>,<bang>1)
251
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit   :execute s:find(<count>,'pedit',<q-args>,<bang>1)
252
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread    :execute s:find(<count>,'read',<q-args>,<bang>1)
253
+
254
+" vim:set et sw=2:
... ...
@@ -0,0 +1,16 @@
1
+## 1.0.1 (Jul 23, 2013)
2
+- Fixes `:Bdelete`ing via buffer number. Finally, perfect!
3
+
4
+## 1.0.0 (Jul 23, 2013)
5
+- Hides the empty buffer from buffer explorers and tabbars.
6
+- Handles `:Bdelete!`ing buffers which are set to auto-delete via `&bufhidden`.
7
+- Wipes empty buffers after hiding to reduce the amount of unlisted buffers after using Bbye for a while.
8
+- Handles buffer explorers and tabbars better that remove or add windows mid-flight.
9
+- Improves an edge-case where the empty buffer might get listed and show up in buffer explorers.
10
+- Perfect for v1.0.0.
11
+
12
+## 0.9.1 (Jul 21, 2013)
13
+- Removes an innocent but forgotten debugging line. Now even more perfect.
14
+
15
+## 0.9.0 (Jul 21, 2013)
16
+- First release. It's perfect.
... ...
@@ -0,0 +1,20 @@
1
+Bbye
2
+Copyright (C) 2013 Andri Möll
3
+
4
+This program is free software: you can redistribute it and/or modify it under
5
+the terms of the GNU Affero General Public License as published by the Free
6
+Software Foundation, either version 3 of the License, or any later version.
7
+
8
+Additional permission under the GNU Affero GPL version 3 section 7:
9
+If you modify this Program, or any covered work, by linking or
10
+combining it with other code, such other code is not for that reason
11
+alone subject to any of the requirements of the GNU Affero GPL version 3.
12
+
13
+In summary:
14
+- You can use this program for no cost.
15
+- You can use this program for both personal and commercial reasons.
16
+- You do not have to share your own program's code which uses this program.
17
+- You have to share modifications (e.g bug-fixes) you've made to this program.
18
+
19
+For the full copy of the GNU Affero General Public License see:
20
+http://www.gnu.org/licenses.
... ...
@@ -0,0 +1,15 @@
1
+VERSION := 1.0.1
2
+
3
+love:
4
+	@echo "Feel like makin' love."
5
+
6
+pack:
7
+	zip -r "vim-bbye-$(VERSION).zip" * --exclude Makefile --exclude "*.zip"
8
+
9
+publish:
10
+	open "http://www.vim.org/scripts/add_script_version.php?script_id=4664"
11
+
12
+tag:
13
+	git tag "v$(VERSION)"
14
+	
15
+.PHONY: love pack publish tag
... ...
@@ -0,0 +1,85 @@
1
+Bbye (Buffer Bye) for Vim
2
+==========================
3
+Bbye allows you to do delete buffers (close files) without closing your windows or messing up your layout.
4
+
5
+Vim by default closes all windows that have the buffer (file) open when you do `:bdelete`.  If you've just got your splits and columns perfectly tuned, having them messed up equals a punch in the face and that's no way to tango.
6
+
7
+Bbye gives you a `:Bdelete` command that behaves like a well designed citizen:
8
+
9
+- Closes and removes the buffer.
10
+- Shows another file in that window.
11
+- Shows an empty file if you've got no other files open.
12
+- Does not leave useless `[no file]` buffers if you decide to edit another file in that window.
13
+- Works even if a file's open in multiple windows.
14
+- Works a-okay with various buffer explorers and tabbars.
15
+
16
+Regain your throne as king of buffers!
17
+
18
+
19
+Installing
20
+----------
21
+The easiest and most modular way is to download Bbye to `~/.vim/bundle`:
22
+```
23
+mkdir -p ~/.vim/bundle/bbye
24
+```
25
+
26
+Using Git:
27
+```
28
+git clone https://github.com/moll/vim-bbye.git ~/.vim/bundle/bbye
29
+```
30
+
31
+Using Wget:
32
+```
33
+wget https://github.com/moll/vim-bbye/archive/master.tar.gz -O- | tar -xf- --strip-components 1 -C ~/.vim/bundle/bbye
34
+```
35
+
36
+Then prepend that directory to Vim's `&runtimepath` (or use [Pathogen](https://github.com/tpope/vim-pathogen)):
37
+```
38
+set runtimepath^=~/.vim/bundle/bbye
39
+```
40
+
41
+
42
+Using
43
+-----
44
+Instead of using `:bdelete`, use `:Bdelete`.
45
+Fortunately autocomplete helps by sorting `:Bdelete` before its lowercase brother.
46
+
47
+As it's likely you'll be using `:Bdelete` often, make a shortcut to `\q`, for example, to save time. Throw this to your `vimrc`:
48
+```
49
+:nnoremap <Leader>q :Bdelete<CR>
50
+```
51
+
52
+### Closing all open buffers and files
53
+
54
+Occasionally you'll want to close all open buffers and files while leaving your pristine window setup as is. That's easy. Just do:
55
+```
56
+:bufdo :Bdelete
57
+```
58
+
59
+### Aliasing to :Bclose
60
+
61
+If you've used any `Bclose.vim` scripts before and for some reason need the `:Bclose` command to exist, you may make an alias:
62
+```
63
+command! -bang -complete=buffer -nargs=? Bclose Bdelete<bang> <args>
64
+```
65
+
66
+
67
+License
68
+-------
69
+Bbye is released under a *Lesser GNU Affero General Public License*, which in summary means:
70
+
71
+- You **can** use this program for **no cost**.
72
+- You **can** use this program for **both personal and commercial reasons**.
73
+- You **do not have to share your own program's code** which uses this program.
74
+- You **have to share modifications** (e.g bug-fixes) you've made to this program.
75
+
76
+For more convoluted language, see the `LICENSE` file.
77
+
78
+
79
+About
80
+-----
81
+**[Andri Möll](http://themoll.com)** authored this in SublemacslipseMate++.  
82
+[Monday Calendar](https://mondayapp.com) supported the engineering work.  
83
+Inspired by [Bclose.vim](http://vim.wikia.com/wiki/VimTip165), but rewritten to be perfect.
84
+
85
+If you find Bbye needs improving or you've got a question, please don't hesitate to email me anytime at andri@dot.ee or [create an issue online](https://github.com/moll/vim-bbye/issues).
... ...
@@ -0,0 +1,84 @@
1
+if exists("g:loaded_bbye") || &cp | finish | endif
2
+let g:loaded_bbye = 1
3
+
4
+function! s:bdelete(bang, buffer_name)
5
+	let buffer = s:str2bufnr(a:buffer_name)
6
+	let w:bbye_back = 1
7
+
8
+	if buffer < 0
9
+		return s:warn("E516: No buffers were deleted. No match for ".a:buffer_name)
10
+	endif
11
+
12
+	if getbufvar(buffer, "&modified") && empty(a:bang)
13
+		let error = "E89: No write since last change for buffer "
14
+		return s:warn(error . buffer . " (add ! to override)")
15
+	endif
16
+
17
+	" If the buffer is set to delete and it contains changes, we can't switch
18
+	" away from it. Hide it before eventual deleting:
19
+	if getbufvar(buffer, "&modified") && !empty(a:bang)
20
+		call setbufvar(buffer, "&bufhidden", "hide")
21
+	endif
22
+
23
+	" For cases where adding buffers causes new windows to appear or hiding some
24
+	" causes windows to disappear and thereby decrement, loop backwards.
25
+	for window in reverse(range(1, winnr("$")))
26
+		" For invalid window numbers, winbufnr returns -1.
27
+		if winbufnr(window) != buffer | continue | endif
28
+		execute window . "wincmd w"
29
+
30
+		" Bprevious also wraps around the buffer list, if necessary:
31
+		try | exe bufnr("#") > 0 && buflisted(bufnr("#")) ? "buffer #" : "bprevious"
32
+		catch /^Vim([^)]*):E85:/ " E85: There is no listed buffer
33
+		endtry
34
+
35
+		" If found a new buffer for this window, mission accomplished:
36
+		if bufnr("%") != buffer | continue | endif
37
+
38
+		call s:new(a:bang) 
39
+	endfor
40
+
41
+	" Because tabbars and other appearing/disappearing windows change
42
+	" the window numbers, find where we were manually:
43
+	let back = filter(range(1, winnr("$")), "getwinvar(v:val, 'bbye_back')")[0]
44
+	if back | exe back . "wincmd w" | unlet w:bbye_back | endif
45
+
46
+	" If it hasn't been already deleted by &bufhidden, end its pains now.
47
+	" Unless it previously was an unnamed buffer and :enew returned it again.
48
+	if bufexists(buffer) && buffer != bufnr("%")
49
+		exe "bdelete" . a:bang . " " . buffer
50
+	endif
51
+endfunction
52
+
53
+function! s:str2bufnr(buffer)
54
+	if empty(a:buffer)
55
+		return bufnr("%")
56
+	elseif a:buffer =~ '^\d\+$'
57
+		return bufnr(str2nr(a:buffer))
58
+	else
59
+		return bufnr(a:buffer)
60
+	endif
61
+endfunction
62
+
63
+function! s:new(bang)
64
+	exe "enew" . a:bang
65
+
66
+	setl noswapfile
67
+	" If empty and out of sight, delete it right away:
68
+	setl bufhidden=wipe
69
+	" Regular buftype warns people if they have unsaved text there.  Wouldn't
70
+	" want to lose someone's data:
71
+	setl buftype=
72
+	" Hide the buffer from buffer explorers and tabbars:
73
+	setl nobuflisted
74
+endfunction
75
+
76
+" Using the built-in :echoerr prints a stacktrace, which isn't that nice.
77
+function! s:warn(msg)
78
+	echohl ErrorMsg
79
+	echomsg a:msg
80
+	echohl NONE
81
+endfunction
82
+
83
+command! -bang -complete=buffer -nargs=? Bdelete
84
+	\ :call s:bdelete(<q-bang>, <q-args>)
... ...
@@ -0,0 +1,3 @@
1
+*~
2
+*.swp
3
+tags
... ...
@@ -0,0 +1,104 @@
1
+The NERD Tree
2
+=============
3
+
4
+Intro
5
+-----
6
+
7
+The NERD tree allows you to explore your filesystem and to open files and
8
+directories. It presents the filesystem to you in the form of a tree which you
9
+manipulate with the keyboard and/or mouse. It also allows you to perform
10
+simple filesystem operations.
11
+
12
+The following features and functionality are provided by the NERD tree:
13
+
14
+  * Files and directories are displayed in a hierarchical tree structure
15
+  * Different highlighting is provided for the following types of nodes:
16
+    * files
17
+    * directories
18
+    * sym-links
19
+    * windows .lnk files
20
+    * read-only files
21
+    * executable files
22
+  * Many (customisable) mappings are provided to manipulate the tree:
23
+    * Mappings to open/close/explore directory nodes
24
+    * Mappings to open files in new/existing windows/tabs
25
+    * Mappings to change the current root of the tree
26
+    * Mappings to navigate around the tree
27
+    * ...
28
+  * Directories and files can be bookmarked.
29
+  * Most NERD tree navigation can also be done with the mouse
30
+  * Filtering of tree content (can be toggled at runtime)
31
+    * custom file filters to prevent e.g. vim backup files being displayed
32
+    * optional displaying of hidden files (. files)
33
+    * files can be "turned off" so that only directories are displayed
34
+  * The position and size of the NERD tree window can be customised
35
+  * The order in which the nodes in the tree are listed can be customised.
36
+  * A model of your filesystem is created/maintained as you explore it. This
37
+    has several advantages:
38
+    * All filesystem information is cached and is only re-read on demand
39
+    * If you revisit a part of the tree that you left earlier in your
40
+      session, the directory nodes will be opened/closed as you left them
41
+  * The script remembers the cursor position and window position in the NERD
42
+    tree so you can toggle it off (or just close the tree window) and then
43
+    reopen it (with NERDTreeToggle) the NERD tree window will appear exactly
44
+    as you left it
45
+  * You can have a separate NERD tree for each tab, share trees across tabs,
46
+    or a mix of both.
47
+  * By default the script overrides the default file browser (netw), so if
48
+    you :edit a directory a (slighly modified) NERD tree will appear in the
49
+    current window
50
+  * A programmable menu system is provided (simulates right clicking on a node)
51
+    * one default menu plugin is provided to perform basic filesytem
52
+      operations (create/delete/move/copy files/directories)
53
+  * There's an API for adding your own keymappings
54
+
55
+Installation
56
+------------
57
+
58
+[pathogen.vim](https://github.com/tpope/vim-pathogen) is the recommended way to install nerdtree.
59
+
60
+    cd ~/.vim/bundle
61
+    git clone https://github.com/scrooloose/nerdtree.git
62
+
63
+Then reload vim, run `:helptags`, and check out `:help NERD_tree.txt`.
64
+
65
+
66
+Faq
67
+---
68
+
69
+__Q. Can I have the nerdtree on every tab automatically?__
70
+
71
+A. Nope. If this is something you want then chances are you aren't using tabs
72
+   and buffers as they were intended to be used. Read this
73
+   http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers
74
+
75
+   If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs)
76
+
77
+__Q. How can I open a NERDTree automatically when vim starts up?__
78
+
79
+A. Stick this in your vimrc: `autocmd vimenter * NERDTree`
80
+
81
+__Q. How can I open a NERDTree automatically when vim starts up if no files were specified?__
82
+
83
+A. Stick this in your vimrc `autocmd vimenter * if !argc() | NERDTree | endif`
84
+
85
+__Q. How can I close vim if the only window left open is a NERDTree?__
86
+
87
+A. Stick this in your vimrc:
88
+
89
+   `autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif`
90
+
91
+
92
+Changelog
93
+---------
94
+
95
+4.2.0 (2011-12-28)
96
+
97
+ * Add NERDTreeDirArrows option to make the UI use pretty arrow chars instead of the old +~| chars to define the tree structure (sickill)
98
+ * shift the syntax highlighting out into its own syntax file (gnap) * add some mac specific options to the filesystem menu - for macvim only (andersonfreitas)
99
+ * Add NERDTreeMinimalUI option to remove some non functional parts of the nerdtree ui (camthompson)
100
+ * tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the new behaviour (benjamingeiger)
101
+ * if no name is given to :Bookmark, make it default to the name of the target file/dir (minyoung)
102
+ * use 'file' completion when doing copying, create, and move operations (EvanDotPro)
103
+ * lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!)
104
+
... ...
@@ -0,0 +1,1362 @@
1
+*NERD_tree.txt*   A tree explorer plugin that owns your momma!
2
+
3
+
4
+
5
+    omg its ... ~
6
+
7
+    ________  ________   _   ____________  ____     __________  ____________~
8
+   /_  __/ / / / ____/  / | / / ____/ __ \/ __ \   /_  __/ __ \/ ____/ ____/~
9
+    / / / /_/ / __/    /  |/ / __/ / /_/ / / / /    / / / /_/ / __/ / __/   ~
10
+   / / / __  / /___   / /|  / /___/ _, _/ /_/ /    / / / _, _/ /___/ /___   ~
11
+  /_/ /_/ /_/_____/  /_/ |_/_____/_/ |_/_____/    /_/ /_/ |_/_____/_____/   ~
12
+
13
+
14
+                              Reference Manual~
15
+
16
+
17
+
18
+
19
+==============================================================================
20
+CONTENTS                                                   *NERDTree-contents*
21
+
22
+    1.Intro...................................|NERDTree|
23
+    2.Functionality provided..................|NERDTreeFunctionality|
24
+        2.1.Global commands...................|NERDTreeGlobalCommands|
25
+        2.2.Bookmarks.........................|NERDTreeBookmarks|
26
+            2.2.1.The bookmark table..........|NERDTreeBookmarkTable|
27
+            2.2.2.Bookmark commands...........|NERDTreeBookmarkCommands|
28
+            2.2.3.Invalid bookmarks...........|NERDTreeInvalidBookmarks|
29
+        2.3.NERD tree mappings................|NERDTreeMappings|
30
+        2.4.The NERD tree menu................|NERDTreeMenu|
31
+    3.Options.................................|NERDTreeOptions|
32
+        3.1.Option summary....................|NERDTreeOptionSummary|
33
+        3.2.Option details....................|NERDTreeOptionDetails|
34
+    4.The NERD tree API.......................|NERDTreeAPI|
35
+        4.1.Key map API.......................|NERDTreeKeymapAPI|
36
+        4.2.Menu API..........................|NERDTreeMenuAPI|
37
+    5.About...................................|NERDTreeAbout|
38
+    6.Changelog...............................|NERDTreeChangelog|
39
+    7.Credits.................................|NERDTreeCredits|
40
+    8.License.................................|NERDTreeLicense|
41
+
42
+==============================================================================
43
+1. Intro                                                            *NERDTree*
44
+
45
+What is this "NERD tree"??
46
+
47
+The NERD tree allows you to explore your filesystem and to open files and
48
+directories. It presents the filesystem to you in the form of a tree which you
49
+manipulate with the keyboard and/or mouse. It also allows you to perform
50
+simple filesystem operations.
51
+
52
+The following features and functionality are provided by the NERD tree:
53
+    * Files and directories are displayed in a hierarchical tree structure
54
+    * Different highlighting is provided for the following types of nodes:
55
+        * files
56
+        * directories
57
+        * sym-links
58
+        * windows .lnk files
59
+        * read-only files
60
+        * executable files
61
+    * Many (customisable) mappings are provided to manipulate the tree:
62
+        * Mappings to open/close/explore directory nodes
63
+        * Mappings to open files in new/existing windows/tabs
64
+        * Mappings to change the current root of the tree
65
+        * Mappings to navigate around the tree
66
+        * ...
67
+    * Directories and files can be bookmarked.
68
+    * Most NERD tree navigation can also be done with the mouse
69
+    * Filtering of tree content (can be toggled at runtime)
70
+        * custom file filters to prevent e.g. vim backup files being displayed
71
+        * optional displaying of hidden files (. files)
72
+        * files can be "turned off" so that only directories are displayed
73
+    * The position and size of the NERD tree window can be customised
74
+    * The order in which the nodes in the tree are listed can be customised.
75
+    * A model of your filesystem is created/maintained as you explore it. This
76
+      has several advantages:
77
+        * All filesystem information is cached and is only re-read on demand
78
+        * If you revisit a part of the tree that you left earlier in your
79
+          session, the directory nodes will be opened/closed as you left them
80
+    * The script remembers the cursor position and window position in the NERD
81
+      tree so you can toggle it off (or just close the tree window) and then
82
+      reopen it (with NERDTreeToggle) the NERD tree window will appear exactly
83
+      as you left it
84
+    * You can have a separate NERD tree for each tab, share trees across tabs,
85
+      or a mix of both.
86
+    * By default the script overrides the default file browser (netw), so if
87
+      you :edit a directory a (slighly modified) NERD tree will appear in the
88
+      current window
89
+    * A programmable menu system is provided (simulates right clicking on a
90
+      node)
91
+        * one default menu plugin is provided to perform basic filesytem
92
+          operations (create/delete/move/copy files/directories)
93
+    * There's an API for adding your own keymappings
94
+
95
+
96
+==============================================================================
97
+2. Functionality provided                              *NERDTreeFunctionality*
98
+
99
+------------------------------------------------------------------------------
100
+2.1. Global Commands                                  *NERDTreeGlobalCommands*
101
+
102
+:NERDTree [<start-directory> | <bookmark>]                         *:NERDTree*
103
+    Opens a fresh NERD tree. The root of the tree depends on the argument
104
+    given. There are 3 cases: If no argument is given, the current directory
105
+    will be used.  If a directory is given, that will be used. If a bookmark
106
+    name is given, the corresponding directory will be used.  For example: >
107
+        :NERDTree /home/marty/vim7/src
108
+        :NERDTree foo   (foo is the name of a bookmark)
109
+<
110
+:NERDTreeFromBookmark <bookmark>                       *:NERDTreeFromBookmark*
111
+    Opens a fresh NERD tree with the root initialized to the dir for
112
+    <bookmark>.  This only reason to use this command over :NERDTree is for
113
+    the completion (which is for bookmarks rather than directories).
114
+
115
+:NERDTreeToggle [<start-directory> | <bookmark>]             *:NERDTreeToggle*
116
+    If a NERD tree already exists for this tab, it is reopened and rendered
117
+    again.  If no NERD tree exists for this tab then this command acts the
118
+    same as the |:NERDTree| command.
119
+
120
+:NERDTreeMirror                                              *:NERDTreeMirror*
121
+    Shares an existing NERD tree, from another tab, in the current tab.
122
+    Changes made to one tree are reflected in both as they are actually the
123
+    same buffer.
124
+
125
+    If only one other NERD tree exists, that tree is automatically mirrored. If
126
+    more than one exists, the script will ask which tree to mirror.
127
+
128
+:NERDTreeClose                                                *:NERDTreeClose*
129
+    Close the NERD tree in this tab.
130
+
131
+:NERDTreeFind                                                  *:NERDTreeFind*
132
+    Find the current file in the tree.
133
+
134
+    If not tree exists and the current file is under vim's CWD, then init a
135
+    tree at the CWD and reveal the file. Otherwise init a tree in the current
136
+    file's directory.
137
+
138
+    In any case, the current file is revealed and the cursor is placed on it.
139
+
140
+:NERDTreeCWD                                                    *:NERDTreeCWD*
141
+    Change tree root to current directory. If no NERD tree exists for this
142
+    tab, a new tree will be opened.
143
+
144
+------------------------------------------------------------------------------
145
+2.2. Bookmarks                                             *NERDTreeBookmarks*
146
+
147
+Bookmarks in the NERD tree are a way to tag files or directories of interest.
148
+For example, you could use bookmarks to tag all of your project directories.
149
+
150
+------------------------------------------------------------------------------
151
+2.2.1. The Bookmark Table                              *NERDTreeBookmarkTable*
152
+
153
+If the bookmark table is active (see |NERDTree-B| and
154
+|'NERDTreeShowBookmarks'|), it will be rendered above the tree. You can double
155
+click bookmarks or use the |NERDTree-o| mapping to activate them. See also,
156
+|NERDTree-t| and |NERDTree-T|
157
+
158
+------------------------------------------------------------------------------
159
+2.2.2. Bookmark commands                            *NERDTreeBookmarkCommands*
160
+
161
+Note that the following commands are only available in the NERD tree buffer.
162
+
163
+:Bookmark <name>
164
+    Bookmark the current node as <name>. If there is already a <name>
165
+    bookmark, it is overwritten. <name> must not contain spaces.
166
+    If <name> is not provided, it defaults to the file or directory name.
167
+    For directories, a trailing slash is present.
168
+
169
+:BookmarkToRoot <bookmark>
170
+    Make the directory corresponding to <bookmark> the new root. If a treenode
171
+    corresponding to <bookmark> is already cached somewhere in the tree then
172
+    the current tree will be used, otherwise a fresh tree will be opened.
173
+    Note that if <bookmark> points to a file then its parent will be used
174
+    instead.
175
+
176
+:RevealBookmark <bookmark>
177
+    If the node is cached under the current root then it will be revealed
178
+    (i.e. directory nodes above it will be opened) and the cursor will be
179
+    placed on it.
180
+
181
+:OpenBookmark <bookmark>
182
+    <bookmark> must point to a file. The file is opened as though |NERDTree-o|
183
+    was applied. If the node is cached under the current root then it will be
184
+    revealed and the cursor will be placed on it.
185
+
186
+:ClearBookmarks [<bookmarks>]
187
+    Remove all the given bookmarks. If no bookmarks are given then remove all
188
+    bookmarks on the current node.
189
+
190
+:ClearAllBookmarks
191
+    Remove all bookmarks.
192
+
193
+:ReadBookmarks
194
+    Re-read the bookmarks in the |'NERDTreeBookmarksFile'|.
195
+
196
+See also |:NERDTree| and |:NERDTreeFromBookmark|.
197
+
198
+------------------------------------------------------------------------------
199
+2.2.3. Invalid Bookmarks                            *NERDTreeInvalidBookmarks*
200
+
201
+If invalid bookmarks are detected, the script will issue an error message and
202
+the invalid bookmarks will become unavailable for use.
203
+
204
+These bookmarks will still be stored in the bookmarks file (see
205
+|'NERDTreeBookmarksFile'|), down the bottom. There will always be a blank line
206
+after the valid bookmarks but before the invalid ones.
207
+
208
+Each line in the bookmarks file represents one bookmark. The proper format is:
209
+<bookmark name><space><full path to the bookmark location>
210
+
211
+After you have corrected any invalid bookmarks, either restart vim, or go
212
+:ReadBookmarks from the NERD tree window.
213
+
214
+------------------------------------------------------------------------------
215
+2.3. NERD tree Mappings                                     *NERDTreeMappings*
216
+
217
+Default  Description~                                             help-tag~
218
+Key~
219
+
220
+o.......Open files, directories and bookmarks....................|NERDTree-o|
221
+go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go|
222
+t.......Open selected node/bookmark in a new tab.................|NERDTree-t|
223
+T.......Same as 't' but keep the focus on the current tab........|NERDTree-T|
224
+i.......Open selected file in a split window.....................|NERDTree-i|
225
+gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi|
226
+s.......Open selected file in a new vsplit.......................|NERDTree-s|
227
+gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs|
228
+O.......Recursively open the selected directory..................|NERDTree-O|
229
+x.......Close the current nodes parent...........................|NERDTree-x|
230
+X.......Recursively close all children of the current node.......|NERDTree-X|
231
+e.......Edit the current dif.....................................|NERDTree-e|
232
+
233
+<CR>...............same as |NERDTree-o|.
234
+double-click.......same as the |NERDTree-o| map.
235
+middle-click.......same as |NERDTree-i| for files, same as
236
+                   |NERDTree-e| for dirs.
237
+
238
+D.......Delete the current bookmark .............................|NERDTree-D|
239
+
240
+P.......Jump to the root node....................................|NERDTree-P|
241
+p.......Jump to current nodes parent.............................|NERDTree-p|
242
+K.......Jump up inside directories at the current tree depth.....|NERDTree-K|
243
+J.......Jump down inside directories at the current tree depth...|NERDTree-J|
244
+<C-J>...Jump down to the next sibling of the current directory...|NERDTree-C-J|
245
+<C-K>...Jump up to the previous sibling of the current directory.|NERDTree-C-K|
246
+
247
+C.......Change the tree root to the selected dir.................|NERDTree-C|
248
+u.......Move the tree root up one directory......................|NERDTree-u|
249
+U.......Same as 'u' except the old root node is left open........|NERDTree-U|
250
+r.......Recursively refresh the current directory................|NERDTree-r|
251
+R.......Recursively refresh the current root.....................|NERDTree-R|
252
+m.......Display the NERD tree menu...............................|NERDTree-m|
253
+cd......Change the CWD to the dir of the selected node...........|NERDTree-cd|
254
+CD......Change tree root to the CWD..............................|NERDTree-CD|
255
+
256
+I.......Toggle whether hidden files displayed....................|NERDTree-I|
257
+f.......Toggle whether the file filters are used.................|NERDTree-f|
258
+F.......Toggle whether files are displayed.......................|NERDTree-F|
259
+B.......Toggle whether the bookmark table is displayed...........|NERDTree-B|
260
+
261
+q.......Close the NERDTree window................................|NERDTree-q|
262
+A.......Zoom (maximize/minimize) the NERDTree window.............|NERDTree-A|
263
+?.......Toggle the display of the quick help.....................|NERDTree-?|
264
+
265
+------------------------------------------------------------------------------
266
+                                                                  *NERDTree-o*
267
+Default key: o
268
+Map option: NERDTreeMapActivateNode
269
+Applies to: files and directories.
270
+
271
+If a file node is selected, it is opened in the previous window.
272
+
273
+If a directory is selected it is opened or closed depending on its current
274
+state.
275
+
276
+If a bookmark that links to a directory is selected then that directory
277
+becomes the new root.
278
+
279
+If a bookmark that links to a file is selected then that file is opened in the
280
+previous window.
281
+
282
+------------------------------------------------------------------------------
283
+                                                                 *NERDTree-go*
284
+Default key: go
285
+Map option: None
286
+Applies to: files.
287
+
288
+If a file node is selected, it is opened in the previous window, but the
289
+cursor does not move.
290
+
291
+The key combo for this mapping is always "g" + NERDTreeMapActivateNode (see
292
+|NERDTree-o|).
293
+
294
+------------------------------------------------------------------------------
295
+                                                                  *NERDTree-t*
296
+Default key: t
297
+Map option: NERDTreeMapOpenInTab
298
+Applies to: files and directories.
299
+
300
+Opens the selected file in a new tab. If a directory is selected, a fresh
301
+NERD Tree for that directory is opened in a new tab.
302
+
303
+If a bookmark which points to a directory is selected, open a NERD tree for
304
+that directory in a new tab. If the bookmark points to a file, open that file
305
+in a new tab.
306
+
307
+------------------------------------------------------------------------------
308
+                                                                  *NERDTree-T*
309
+Default key: T
310
+Map option: NERDTreeMapOpenInTabSilent
311
+Applies to: files and directories.
312
+
313
+The same as |NERDTree-t| except that the focus is kept in the current tab.
314
+
315
+------------------------------------------------------------------------------
316
+                                                                  *NERDTree-i*
317
+Default key: i
318
+Map option: NERDTreeMapOpenSplit
319
+Applies to: files.
320
+
321
+Opens the selected file in a new split window and puts the cursor in the new
322
+window.
323
+
324
+------------------------------------------------------------------------------
325
+                                                                 *NERDTree-gi*
326
+Default key: gi
327
+Map option: None
328
+Applies to: files.
329
+
330
+The same as |NERDTree-i| except that the cursor is not moved.
331
+
332
+The key combo for this mapping is always "g" + NERDTreeMapOpenSplit (see
333
+|NERDTree-i|).
334
+
335
+------------------------------------------------------------------------------
336
+                                                                  *NERDTree-s*
337
+Default key: s
338
+Map option: NERDTreeMapOpenVSplit
339
+Applies to: files.
340
+
341
+Opens the selected file in a new vertically split window and puts the cursor in
342
+the new window.
343
+
344
+------------------------------------------------------------------------------
345
+                                                                 *NERDTree-gs*
346
+Default key: gs
347
+Map option: None
348
+Applies to: files.
349
+
350
+The same as |NERDTree-s| except that the cursor is not moved.
351
+
352
+The key combo for this mapping is always "g" + NERDTreeMapOpenVSplit (see
353
+|NERDTree-s|).
354
+
355
+------------------------------------------------------------------------------
356
+                                                                  *NERDTree-O*
357
+Default key: O
358
+Map option: NERDTreeMapOpenRecursively
359
+Applies to: directories.
360
+
361
+Recursively opens the selelected directory.
362
+
363
+All files and directories are cached, but if a directory would not be
364
+displayed due to file filters (see |'NERDTreeIgnore'| |NERDTree-f|) or the
365
+hidden file filter (see |'NERDTreeShowHidden'|) then its contents are not
366
+cached. This is handy, especially if you have .svn directories.
367
+
368
+------------------------------------------------------------------------------
369
+                                                                  *NERDTree-x*
370
+Default key: x
371
+Map option: NERDTreeMapCloseDir
372
+Applies to: files and directories.
373
+
374
+Closes the parent of the selected node.
375
+
376
+------------------------------------------------------------------------------
377
+                                                                  *NERDTree-X*
378
+Default key: X
379
+Map option: NERDTreeMapCloseChildren
380
+Applies to: directories.
381
+
382
+Recursively closes all children of the selected directory.
383
+
384
+Tip: To quickly "reset" the tree, use |NERDTree-P| with this mapping.
385
+
386
+------------------------------------------------------------------------------
387
+                                                                  *NERDTree-e*
388
+Default key: e
389
+Map option: NERDTreeMapOpenExpl
390
+Applies to: files and directories.
391
+
392
+|:edit|s the selected directory, or the selected file's directory. This could
393
+result in a NERD tree or a netrw being opened, depending on
394
+|'NERDTreeHijackNetrw'|.
395
+
396
+------------------------------------------------------------------------------
397
+                                                                  *NERDTree-D*
398
+Default key: D
399
+Map option: NERDTreeMapDeleteBookmark
400
+Applies to: lines in the bookmarks table
401
+
402
+Deletes the currently selected bookmark.
403
+
404
+------------------------------------------------------------------------------
405
+                                                                  *NERDTree-P*
406
+Default key: P
407
+Map option: NERDTreeMapJumpRoot
408
+Applies to: no restrictions.
409
+
410
+Jump to the tree root.
411
+
412
+------------------------------------------------------------------------------
413
+                                                                  *NERDTree-p*
414
+Default key: p
415
+Map option: NERDTreeMapJumpParent
416
+Applies to: files and directories.
417
+
418
+Jump to the parent node of the selected node.
419
+
420
+------------------------------------------------------------------------------
421
+                                                                  *NERDTree-K*
422
+Default key: K
423
+Map option: NERDTreeMapJumpFirstChild
424
+Applies to: files and directories.
425
+
426
+Jump to the first child of the current nodes parent.
427
+
428
+If the cursor is already on the first node then do the following:
429
+    * loop back thru the siblings of the current nodes parent until we find an
430
+      open dir with children
431
+    * go to the first child of that node
432
+
433
+------------------------------------------------------------------------------
434
+                                                                  *NERDTree-J*
435
+Default key: J
436
+Map option: NERDTreeMapJumpLastChild
437
+Applies to: files and directories.
438
+
439
+Jump to the last child of the current nodes parent.
440
+
441
+If the cursor is already on the last node then do the following:
442
+    * loop forward thru the siblings of the current nodes parent until we find
443
+      an open dir with children
444
+    * go to the last child of that node
445
+
446
+------------------------------------------------------------------------------
447
+                                                                *NERDTree-C-J*
448
+Default key: <C-J>
449
+Map option: NERDTreeMapJumpNextSibling
450
+Applies to: files and directories.
451
+
452
+Jump to the next sibling of the selected node.
453
+
454
+------------------------------------------------------------------------------
455
+                                                                *NERDTree-C-K*
456
+Default key: <C-K>
457
+Map option: NERDTreeMapJumpPrevSibling
458
+Applies to: files and directories.
459
+
460
+Jump to the previous sibling of the selected node.
461
+
462
+------------------------------------------------------------------------------
463
+                                                                  *NERDTree-C*
464
+Default key: C
465
+Map option: NERDTreeMapChdir
466
+Applies to: directories.
467
+
468
+Make the selected directory node the new tree root. If a file is selected, its
469
+parent is used.
470
+
471
+------------------------------------------------------------------------------
472
+                                                                  *NERDTree-u*
473
+Default key: u
474
+Map option: NERDTreeMapUpdir
475
+Applies to: no restrictions.
476
+
477
+Move the tree root up a dir (like doing a "cd ..").
478
+
479
+------------------------------------------------------------------------------
480
+                                                                  *NERDTree-U*
481
+Default key: U
482
+Map option: NERDTreeMapUpdirKeepOpen
483
+Applies to: no restrictions.
484
+
485
+Like |NERDTree-u| except that the old tree root is kept open.
486
+
487
+------------------------------------------------------------------------------
488
+                                                                  *NERDTree-r*
489
+Default key: r
490
+Map option: NERDTreeMapRefresh
491
+Applies to: files and directories.
492
+
493
+If a dir is selected, recursively refresh that dir, i.e. scan the filesystem
494
+for changes and represent them in the tree.
495
+
496
+If a file node is selected then the above is done on it's parent.
497
+
498
+------------------------------------------------------------------------------
499
+                                                                  *NERDTree-R*
500
+Default key: R
501
+Map option: NERDTreeMapRefreshRoot
502
+Applies to: no restrictions.
503
+
504
+Recursively refresh the tree root.
505
+
506
+------------------------------------------------------------------------------
507
+                                                                  *NERDTree-m*
508
+Default key: m
509
+Map option: NERDTreeMapMenu
510
+Applies to: files and directories.
511
+
512
+Display the NERD tree menu. See |NERDTreeMenu| for details.
513
+
514
+------------------------------------------------------------------------------
515
+                                                                 *NERDTree-cd*
516
+Default key: cd
517
+Map option: NERDTreeMapChdir
518
+Applies to: files and directories.
519
+
520
+Change vims current working directory to that of the selected node.
521
+
522
+------------------------------------------------------------------------------
523
+                                                                 *NERDTree-CD*
524
+Default key: CD
525
+Map option: NERDTreeMapCWD
526
+Applies to: no restrictions.
527
+
528
+Change tree root to vims current working directory.
529
+
530
+------------------------------------------------------------------------------
531
+                                                                  *NERDTree-I*
532
+Default key: I
533
+Map option: NERDTreeMapToggleHidden
534
+Applies to: no restrictions.
535
+
536
+Toggles whether hidden files (i.e. "dot files") are displayed.
537
+
538
+------------------------------------------------------------------------------
539
+                                                                  *NERDTree-f*
540
+Default key: f
541
+Map option: NERDTreeMapToggleFilters
542
+Applies to: no restrictions.
543
+
544
+Toggles whether file filters are used. See |'NERDTreeIgnore'| for details.
545
+
546
+------------------------------------------------------------------------------
547
+                                                                  *NERDTree-F*
548
+Default key: F
549
+Map option: NERDTreeMapToggleFiles
550
+Applies to: no restrictions.
551
+
552
+Toggles whether file nodes are displayed.
553
+
554
+------------------------------------------------------------------------------
555
+                                                                  *NERDTree-B*
556
+Default key: B
557
+Map option: NERDTreeMapToggleBookmarks
558
+Applies to: no restrictions.
559
+
560
+Toggles whether the bookmarks table is displayed.
561
+
562
+------------------------------------------------------------------------------
563
+                                                                  *NERDTree-q*
564
+Default key: q
565
+Map option: NERDTreeMapQuit
566
+Applies to: no restrictions.
567
+
568
+Closes the NERDtree window.
569
+
570
+------------------------------------------------------------------------------
571
+                                                                  *NERDTree-A*
572
+Default key: A
573
+Map option: NERDTreeMapToggleZoom
574
+Applies to: no restrictions.
575
+
576
+Maximize (zoom) and minimize the NERDtree window.
577
+
578
+------------------------------------------------------------------------------
579
+                                                                  *NERDTree-?*
580
+Default key: ?
581
+Map option: NERDTreeMapHelp
582
+Applies to: no restrictions.
583
+
584
+Toggles whether the quickhelp is displayed.
585
+
586
+------------------------------------------------------------------------------
587
+2.3. The NERD tree menu                                         *NERDTreeMenu*
588
+
589
+The NERD tree has a menu that can be programmed via the an API (see
590
+|NERDTreeMenuAPI|). The idea is to simulate the "right click" menus that most
591
+file explorers have.
592
+
593
+The script comes with two default menu plugins: exec_menuitem.vim and
594
+fs_menu.vim. fs_menu.vim adds some basic filesystem operations to the menu for
595
+creating/deleting/moving/copying files and dirs. exec_menuitem.vim provides a
596
+menu item to execute executable files.
597
+
598
+Related tags: |NERDTree-m| |NERDTreeApi|
599
+
600
+==============================================================================
601
+3. Customisation                                             *NERDTreeOptions*
602
+
603
+
604
+------------------------------------------------------------------------------
605
+3.1. Customisation summary                             *NERDTreeOptionSummary*
606
+
607
+The script provides the following options that can customise the behaviour the
608
+NERD tree. These options should be set in your vimrc.
609
+
610
+|'loaded_nerd_tree'|            Turns off the script.
611
+
612
+|'NERDChristmasTree'|           Tells the NERD tree to make itself colourful
613
+                                and pretty.
614
+
615
+|'NERDTreeAutoCenter'|          Controls whether the NERD tree window centers
616
+                                when the cursor moves within a specified
617
+                                distance to the top/bottom of the window.
618
+|'NERDTreeAutoCenterThreshold'| Controls the sensitivity of autocentering.
619
+
620
+|'NERDTreeCaseSensitiveSort'|   Tells the NERD tree whether to be case
621
+                                sensitive or not when sorting nodes.
622
+
623
+|'NERDTreeChDirMode'|           Tells the NERD tree if/when it should change
624
+                                vim's current working directory.
625
+
626
+|'NERDTreeHighlightCursorline'| Tell the NERD tree whether to highlight the
627
+                                current cursor line.
628
+
629
+|'NERDTreeHijackNetrw'|         Tell the NERD tree whether to replace the netrw
630
+                                autocommands for exploring local directories.
631
+
632
+|'NERDTreeIgnore'|              Tells the NERD tree which files to ignore.
633
+
634
+|'NERDTreeBookmarksFile'|       Where the bookmarks are stored.
635
+
636
+|'NERDTreeMouseMode'|           Tells the NERD tree how to handle mouse
637
+                                clicks.
638
+
639
+|'NERDTreeQuitOnOpen'|          Closes the tree window after opening a file.
640
+
641
+|'NERDTreeShowBookmarks'|       Tells the NERD tree whether to display the
642
+                                bookmarks table on startup.
643
+
644
+|'NERDTreeShowFiles'|           Tells the NERD tree whether to display files
645
+                                in the tree on startup.
646
+
647
+|'NERDTreeShowHidden'|          Tells the NERD tree whether to display hidden
648
+                                files on startup.
649
+
650
+|'NERDTreeShowLineNumbers'|     Tells the NERD tree whether to display line
651
+                                numbers in the tree window.
652
+
653
+|'NERDTreeSortOrder'|           Tell the NERD tree how to sort the nodes in
654
+                                the tree.
655
+
656
+|'NERDTreeStatusline'|          Set a statusline for NERD tree windows.
657
+
658
+|'NERDTreeWinPos'|              Tells the script where to put the NERD tree
659
+                                window.
660
+
661
+|'NERDTreeWinSize'|             Sets the window size when the NERD tree is
662
+                                opened.
663
+
664
+|'NERDTreeMinimalUI'|           Disables display of the 'Bookmarks' label and 
665
+                                'Press ? for help' text.
666
+
667
+|'NERDTreeDirArrows'|           Tells the NERD tree to use arrows instead of
668
+                                + ~ chars when displaying directories.
669
+
670
+|'NERDTreeCasadeOpenSingleChildDir'|
671
+                                Casade open while selected directory has only
672
+                                one child that also is a directory.
673
+
674
+|'NERDTreeAutoDeleteBuffer'|    Tells the NERD tree to automatically remove 
675
+                                a buffer when a file is being deleted or renamed
676
+                                via a context menu command.
677
+
678
+------------------------------------------------------------------------------
679
+3.2. Customisation details                             *NERDTreeOptionDetails*
680
+
681
+To enable any of the below options you should put the given line in your
682
+~/.vimrc
683
+
684
+                                                          *'loaded_nerd_tree'*
685
+If this plugin is making you feel homicidal, it may be a good idea to turn it
686
+off with this line in your vimrc: >
687
+    let loaded_nerd_tree=1
688
+<
689
+------------------------------------------------------------------------------
690
+                                                         *'NERDChristmasTree'*
691
+Values: 0 or 1.
692
+Default: 1.
693
+
694
+If this option is set to 1 then some extra syntax highlighting elements are
695
+added to the nerd tree to make it more colourful.
696
+
697
+Set it to 0 for a more vanilla looking tree.
698
+
699
+------------------------------------------------------------------------------
700
+                                                        *'NERDTreeAutoCenter'*
701
+Values: 0 or 1.
702
+Default: 1
703
+
704
+If set to 1, the NERD tree window will center around the cursor if it moves to
705
+within |'NERDTreeAutoCenterThreshold'| lines of the top/bottom of the window.
706
+
707
+This is ONLY done in response to tree navigation mappings,
708
+i.e. |NERDTree-J| |NERDTree-K| |NERDTree-C-J| |NERDTree-C-K| |NERDTree-p|
709
+|NERDTree-P|
710
+
711
+The centering is done with a |zz| operation.
712
+
713
+------------------------------------------------------------------------------
714
+                                               *'NERDTreeAutoCenterThreshold'*
715
+Values: Any natural number.
716
+Default: 3
717
+
718
+This option controls the "sensitivity" of the NERD tree auto centering. See
719
+|'NERDTreeAutoCenter'| for details.
720
+
721
+------------------------------------------------------------------------------
722
+                                                 *'NERDTreeCaseSensitiveSort'*
723
+Values: 0 or 1.
724
+Default: 0.
725
+
726
+By default the NERD tree does not sort nodes case sensitively, i.e. nodes
727
+could appear like this: >
728
+    bar.c
729
+    Baz.c
730
+    blarg.c
731
+    boner.c
732
+    Foo.c
733
+<
734
+But, if you set this option to 1 then the case of the nodes will be taken into
735
+account. The above nodes would then be sorted like this: >
736
+    Baz.c
737
+    Foo.c
738
+    bar.c
739
+    blarg.c
740
+    boner.c
741
+<
742
+------------------------------------------------------------------------------
743
+                                                         *'NERDTreeChDirMode'*
744
+
745
+Values: 0, 1 or 2.
746
+Default: 0.
747
+
748
+Use this option to tell the script when (if at all) to change the current
749
+working directory (CWD) for vim.
750
+
751
+If it is set to 0 then the CWD is never changed by the NERD tree.
752
+
753
+If set to 1 then the CWD is changed when the NERD tree is first loaded to the
754
+directory it is initialized in. For example, if you start the NERD tree with >
755
+    :NERDTree /home/marty/foobar
756
+<
757
+then the CWD will be changed to /home/marty/foobar and will not be changed
758
+again unless you init another NERD tree with a similar command.
759
+
760
+If the option is set to 2 then it behaves the same as if set to 1 except that
761
+the CWD is changed whenever the tree root is changed. For example, if the CWD
762
+is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new
763
+root then the CWD will become /home/marty/foobar/baz.
764
+
765
+------------------------------------------------------------------------------
766
+                                               *'NERDTreeHighlightCursorline'*
767
+Values: 0 or 1.
768
+Default: 1.
769
+
770
+If set to 1, the current cursor line in the NERD tree buffer will be
771
+highlighted. This is done using the |'cursorline'| option.
772
+
773
+------------------------------------------------------------------------------
774
+                                                       *'NERDTreeHijackNetrw'*
775
+Values: 0 or 1.
776
+Default: 1.
777
+
778
+If set to 1, doing a >
779
+    :edit <some directory>
780
+<
781
+will open up a "secondary" NERD tree instead of a netrw in the target window.
782
+
783
+Secondary NERD trees behaves slighly different from a regular trees in the
784
+following respects:
785
+    1. 'o' will open the selected file in the same window as the tree,
786
+       replacing it.
787
+    2. you can have as many secondary tree as you want in the same tab.
788
+
789
+------------------------------------------------------------------------------
790
+                                                            *'NERDTreeIgnore'*
791
+Values: a list of regular expressions.
792
+Default: ['\~$'].
793
+
794
+This option is used to specify which files the NERD tree should ignore.  It
795
+must be a list of regular expressions. When the NERD tree is rendered, any
796
+files/dirs that match any of the regex's in 'NERDTreeIgnore' wont be
797
+displayed.
798
+
799
+For example if you put the following line in your vimrc: >
800
+    let NERDTreeIgnore=['\.vim$', '\~$']
801
+<
802
+then all files ending in .vim or ~ will be ignored.
803
+
804
+There are 2 magic flags that can be appended to the end of each regular
805
+expression to specify that the regex should match only files or only dirs.
806
+These flags are "[[dir]]" and "[[file]]". Example: >
807
+    let NERDTreeIgnore=['.d$[[dir]]', '.o$[[file]]']
808
+<
809
+This will cause all dirs ending in ".d" to be ignored and all files ending in
810
+".o" to be ignored.
811
+
812
+Note: to tell the NERD tree not to ignore any files you must use the following
813
+line: >
814
+    let NERDTreeIgnore=[]
815
+<
816
+
817
+The file filters can be turned on and off dynamically with the |NERDTree-f|
818
+mapping.
819
+
820
+------------------------------------------------------------------------------
821
+                                                     *'NERDTreeBookmarksFile'*
822
+Values: a path
823
+Default: $HOME/.NERDTreeBookmarks
824
+
825
+This is where bookmarks are saved. See |NERDTreeBookmarkCommands|.
826
+
827
+------------------------------------------------------------------------------
828
+                                                       *'NERDTreeMouseMode'*
829
+Values: 1, 2 or 3.
830
+Default: 1.
831
+
832
+If set to 1 then a double click on a node is required to open it.
833
+If set to 2 then a single click will open directory nodes, while a double
834
+click will still be required for file nodes.
835
+If set to 3 then a single click will open any node.
836
+
837
+Note: a double click anywhere on a line that a tree node is on will
838
+activate it, but all single-click activations must be done on name of the node
839
+itself. For example, if you have the following node: >
840
+    | | |-application.rb
841
+<
842
+then (to single click activate it) you must click somewhere in
843
+'application.rb'.
844
+
845
+------------------------------------------------------------------------------
846
+                                                        *'NERDTreeQuitOnOpen'*
847
+
848
+Values: 0 or 1.
849
+Default: 0
850
+
851
+If set to 1, the NERD tree window will close after opening a file with the
852
+|NERDTree-o|, |NERDTree-i|, |NERDTree-t| and |NERDTree-T| mappings.
853
+
854
+------------------------------------------------------------------------------
855
+                                                     *'NERDTreeShowBookmarks'*
856
+Values: 0 or 1.
857
+Default: 0.
858
+
859
+If this option is set to 1 then the bookmarks table will be displayed.
860
+
861
+This option can be toggled dynamically, per tree, with the |NERDTree-B|
862
+mapping.
863
+
864
+------------------------------------------------------------------------------
865
+                                                         *'NERDTreeShowFiles'*
866
+Values: 0 or 1.
867
+Default: 1.
868
+
869
+If this option is set to 1 then files are displayed in the NERD tree. If it is
870
+set to 0 then only directories are displayed.
871
+
872
+This option can be toggled dynamically, per tree, with the |NERDTree-F|
873
+mapping and is useful for drastically shrinking the tree when you are
874
+navigating to a different part of the tree.
875
+
876
+------------------------------------------------------------------------------
877
+                                                        *'NERDTreeShowHidden'*
878
+Values: 0 or 1.
879
+Default: 0.
880
+
881
+This option tells vim whether to display hidden files by default. This option
882
+can be dynamically toggled, per tree, with the |NERDTree-I| mapping.  Use one
883
+of the follow lines to set this option: >
884
+    let NERDTreeShowHidden=0
885
+    let NERDTreeShowHidden=1
886
+<
887
+
888
+------------------------------------------------------------------------------
889
+                                                   *'NERDTreeShowLineNumbers'*
890
+Values: 0 or 1.
891
+Default: 0.
892
+
893
+This option tells vim whether to display line numbers for the NERD tree
894
+window.  Use one of the follow lines to set this option: >
895
+    let NERDTreeShowLineNumbers=0
896
+    let NERDTreeShowLineNumbers=1
897
+<
898
+
899
+------------------------------------------------------------------------------
900
+                                                         *'NERDTreeSortOrder'*
901
+Values: a list of regular expressions.
902
+Default: ['\/$', '*', '\.swp$',  '\.bak$', '\~$']
903
+
904
+This option is set to a list of regular expressions which are used to
905
+specify the order of nodes under their parent.
906
+
907
+For example, if the option is set to: >
908
+    ['\.vim$', '\.c$', '\.h$', '*', 'foobar']
909
+<
910
+then all .vim files will be placed at the top, followed by all .c files then
911
+all .h files. All files containing the string 'foobar' will be placed at the
912
+end.  The star is a special flag: it tells the script that every node that
913
+doesnt match any of the other regexps should be placed here.
914
+
915
+If no star is present in 'NERDTreeSortOrder' then one is automatically
916
+appended to the array.
917
+
918
+The regex '\/$' should be used to match directory nodes.
919
+
920
+After this sorting is done, the files in each group are sorted alphabetically.
921
+
922
+Other examples: >
923
+    (1) ['*', '\/$']
924
+    (2) []
925
+    (3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$',  '\.bak$', '\~$']
926
+<
927
+1. Directories will appear last, everything else will appear above.
928
+2. Everything will simply appear in alphabetical order.
929
+3. Dirs will appear first, then ruby and php. Swap files, bak files and vim
930
+   backup files will appear last with everything else preceding them.
931
+
932
+------------------------------------------------------------------------------
933
+                                                        *'NERDTreeStatusline'*
934
+Values: Any valid statusline setting.
935
+Default: %{b:NERDTreeRoot.path.strForOS(0)}
936
+
937
+Tells the script what to use as the |'statusline'| setting for NERD tree
938
+windows.
939
+
940
+Note that the statusline is set using |:let-&| not |:set| so escaping spaces
941
+isn't necessary.
942
+
943
+Setting this option to -1 will will deactivate it so that your global
944
+statusline setting is used instead.
945
+
946
+------------------------------------------------------------------------------
947
+                                                            *'NERDTreeWinPos'*
948
+Values: "left" or "right"
949
+Default: "left".
950
+
951
+This option is used to determine where NERD tree window is placed on the
952
+screen.
953
+
954
+This option makes it possible to use two different explorer plugins
955
+simultaneously. For example, you could have the taglist plugin on the left of
956
+the window and the NERD tree on the right.
957
+
958
+------------------------------------------------------------------------------
959
+                                                           *'NERDTreeWinSize'*
960
+Values: a positive integer.
961
+Default: 31.
962
+
963
+This option is used to change the size of the NERD tree when it is loaded.
964
+
965
+------------------------------------------------------------------------------
966
+                                                         *'NERDTreeMinimalUI'*
967
+Values: 0 or 1
968
+Default: 0
969
+
970
+This options disables the 'Bookmarks' label 'Press ? for help' text. Use one
971
+of the following lines to set this option: >
972
+    let NERDTreeMinimalUI=0
973
+    let NERDTreeMinimalUI=1
974
+<
975
+
976
+------------------------------------------------------------------------------
977
+                                                           *'NERDTreeDirArrows'*
978
+Values: 0 or 1
979
+Default: 0.
980
+
981
+This option is used to change the default look of directory nodes displayed in
982
+the tree. When set to 0 it shows old-school bars (|), + and ~ chars. If set to
983
+1 it shows right and down arrows.  Use one of the follow lines to set this
984
+option: >
985
+    let NERDTreeDirArrows=0
986
+    let NERDTreeDirArrows=1
987
+<
988
+
989
+------------------------------------------------------------------------------
990
+                                          *'NERDTreeCasadeOpenSingleChildDir'*
991
+Values: 0 or 1
992
+Default: 1.
993
+
994
+When opening dir nodes, this option tells NERDTree to recursively open dirs
995
+that have only one child which is also a dir. NERDTree will stop when it finds
996
+a dir that contains anything but another single dir. This option may be useful
997
+for Java projects.  Use one of the follow lines to set this option: >
998
+    let NERDTreeCasadeOpenSingleChildDir=0
999
+    let NERDTreeCasadeOpenSingleChildDir=1
1000
+<
1001
+
1002
+------------------------------------------------------------------------------
1003
+                                          *'NERDTreeAutoDeleteBuffer'*
1004
+Values: 0 or 1
1005
+Default: 0.
1006
+
1007
+When using a context menu to delete or rename a file you may also want to delete
1008
+the buffer which is no more valid. If the option is not set you will see a
1009
+confirmation if you really want to delete an old buffer. If you always press 'y'
1010
+then it worths to set this option to 1. Use one of the follow lines to set this
1011
+option: >
1012
+    let NERDTreeAutoDeleteBuffer=0
1013
+    let NERDTreeAutoDeleteBuffer=1
1014
+<
1015
+
1016
+==============================================================================
1017
+4. The NERD tree API                                             *NERDTreeAPI*
1018
+
1019
+The NERD tree script allows you to add custom key mappings and menu items via
1020
+a set of API calls. Any scripts that use this API should be placed in
1021
+~/.vim/nerdtree_plugin/ (*nix) or ~/vimfiles/nerdtree_plugin (windows).
1022
+
1023
+The script exposes some prototype objects that can be used to manipulate the
1024
+tree and/or get information from it: >
1025
+    g:NERDTreePath
1026
+    g:NERDTreeDirNode
1027
+    g:NERDTreeFileNode
1028
+    g:NERDTreeBookmark
1029
+<
1030
+See the code/comments in NERD_tree.vim to find how to use these objects. The
1031
+following code conventions are used:
1032
+    * class members start with a capital letter
1033
+    * instance members start with a lower case letter
1034
+    * private members start with an underscore
1035
+
1036
+See this blog post for more details:
1037
+ http://got-ravings.blogspot.com/2008/09/vim-pr0n-prototype-based-objects.html
1038
+
1039
+------------------------------------------------------------------------------
1040
+4.1. Key map API                                           *NERDTreeKeymapAPI*
1041
+
1042
+NERDTreeAddKeyMap({options})                             *NERDTreeAddKeyMap()*
1043
+    Adds a new keymapping for all NERD tree buffers.
1044
+    {options} must be a dictionary, and must contain the following keys:
1045
+    "key" - the trigger key for the new mapping
1046
+    "callback" - the function the new mapping will be bound to
1047
+    "quickhelpText" - the text that will appear in the quickhelp (see
1048
+    |NERDTree-?|)
1049
+
1050
+    Additionally, a "scope" argument may be supplied. This constrains the
1051
+    mapping so that it is only activated if the cursor is on a certain object.
1052
+    That object is then passed into the handling method. Possible values are:
1053
+        "FileNode" - a file node
1054
+        "DirNode" - a directory node
1055
+        "Node" - a file or directory node
1056
+        "Bookmark" - A bookmark
1057
+        "all" - the keymap is not constrained to any scope (default). When
1058
+        thei is used, the handling function is not passed any arguments.
1059
+
1060
+
1061
+    Example: >
1062
+        call NERDTreeAddKeyMap({
1063
+               \ 'key': 'foo',
1064
+               \ 'callback': 'NERDTreeCDHandler',
1065
+               \ 'quickhelpText': 'echo full path of current node' })
1066
+               \ 'scope': 'DirNode'
1067
+
1068
+        function! NERDTreeCDHandler(dirnode)
1069
+            call a:dirnode.changeToDir()
1070
+        endfunction
1071
+<
1072
+    This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim.
1073
+    It adds a (redundant) mapping on 'foo' which changes vim's CWD to that of
1074
+    the current dir node. Note this mapping will only fire when the cursor is
1075
+    on a directory node.
1076
+
1077
+------------------------------------------------------------------------------
1078
+4.2. Menu API                                                *NERDTreeMenuAPI*
1079
+
1080
+NERDTreeAddSubmenu({options})                           *NERDTreeAddSubmenu()*
1081
+    Creates and returns a new submenu.
1082
+
1083
+    {options} must be a dictionary and must contain the following keys:
1084
+    "text" - the text of the submenu that the user will see
1085
+    "shortcut" - a shortcut key for the submenu (need not be unique)
1086
+
1087
+    The following keys are optional:
1088
+    "isActiveCallback" - a function that will be called to determine whether
1089
+    this submenu item will be displayed or not. The callback function must return
1090
+    0 or 1.
1091
+    "parent" - the parent submenu of the new submenu (returned from a previous
1092
+    invocation of NERDTreeAddSubmenu()). If this key is left out then the new
1093
+    submenu will sit under the top level menu.
1094
+
1095
+    See below for an example.
1096
+
1097
+NERDTreeAddMenuItem({options})                         *NERDTreeAddMenuItem()*
1098
+    Adds a new menu item to the NERD tree menu (see |NERDTreeMenu|).
1099
+
1100
+    {options} must be a dictionary and must contain the
1101
+    following keys:
1102
+    "text" - the text of the menu item which the user will see
1103
+    "shortcut" - a shortcut key for the menu item (need not be unique)
1104
+    "callback" - the function that will be called when the user activates the
1105
+    menu item.
1106
+
1107
+    The following keys are optional:
1108
+    "isActiveCallback" - a function that will be called to determine whether
1109
+    this menu item will be displayed or not. The callback function must return
1110
+    0 or 1.
1111
+    "parent" - if the menu item belongs under a submenu then this key must be
1112
+    specified. This value for this key will be the object that
1113
+    was returned when the submenu was created with |NERDTreeAddSubmenu()|.
1114
+
1115
+    See below for an example.
1116
+
1117
+NERDTreeAddMenuSeparator([{options}])             *NERDTreeAddMenuSeparator()*
1118
+    Adds a menu separator (a row of dashes).
1119
+
1120
+    {options} is an optional dictionary that may contain the following keys:
1121
+    "isActiveCallback" - see description in |NERDTreeAddMenuItem()|.
1122
+
1123
+Below is an example of the menu API in action. >
1124
+    call NERDTreeAddMenuSeparator()
1125
+
1126
+    call NERDTreeAddMenuItem({
1127
+                \ 'text': 'a (t)op level menu item',
1128
+                \ 'shortcut': 't',
1129
+                \ 'callback': 'SomeFunction' })
1130
+
1131
+    let submenu = NERDTreeAddSubmenu({
1132
+                \ 'text': 'a (s)ub menu',
1133
+                \ 'shortcut': 's' })
1134
+
1135
+    call NERDTreeAddMenuItem({
1136
+                \ 'text': '(n)ested item 1',
1137
+                \ 'shortcut': 'n',
1138
+                \ 'callback': 'SomeFunction',
1139
+                \ 'parent': submenu })
1140
+
1141
+    call NERDTreeAddMenuItem({
1142
+                \ 'text': '(n)ested item 2',
1143
+                \ 'shortcut': 'n',
1144
+                \ 'callback': 'SomeFunction',
1145
+                \ 'parent': submenu })
1146
+<
1147
+This will create the following menu: >
1148
+  --------------------
1149
+  a (t)op level menu item
1150
+  a (s)ub menu
1151
+<
1152
+Where selecting "a (s)ub menu" will lead to a second menu: >
1153
+  (n)ested item 1
1154
+  (n)ested item 2
1155
+<
1156
+When any of the 3 concrete menu items are selected the function "SomeFunction"
1157
+will be called.
1158
+
1159
+------------------------------------------------------------------------------
1160
+NERDTreeRender()                                            *NERDTreeRender()*
1161
+    Re-renders the NERD tree buffer. Useful if you change the state of the
1162
+    tree and you want to it to be reflected in the UI.
1163
+
1164
+==============================================================================
1165
+5. About                                                       *NERDTreeAbout*
1166
+
1167
+The author of the NERD tree is a terrible terrible monster called Martyzilla
1168
+who gobbles up small children with milk and sugar for breakfast.
1169
+
1170
+He can be reached at martin.grenfell at gmail dot com. He would love to hear
1171
+from you, so feel free to send him suggestions and/or comments about this
1172
+plugin.  Don't be shy --- the worst he can do is slaughter you and stuff you in
1173
+the fridge for later ;)
1174
+
1175
+The latest stable versions can be found at
1176
+    http://www.vim.org/scripts/script.php?script_id=1658
1177
+
1178
+The latest dev versions are on github
1179
+    http://github.com/scrooloose/nerdtree
1180
+
1181
+
1182
+==============================================================================
1183
+6. Changelog                                               *NERDTreeChangelog*
1184
+
1185
+Next
1186
+    - add 'scope' argument to the key map API
1187
+    - add NERDTreeCustomIgnoreFilter hook - needs doc
1188
+    - add magic [[dir]] and [[file]] flags to NERDTreeIgnore
1189
+
1190
+4.2.0
1191
+    - Add NERDTreeDirArrows option to make the UI use pretty arrow chars
1192
+      instead of the old +~| chars to define the tree structure (sickill)
1193
+    - shift the syntax highlighting out into its own syntax file (gnap)
1194
+    - add some mac specific options to the filesystem menu - for macvim
1195
+      only (andersonfreitas)
1196
+    - Add NERDTreeMinimalUI option to remove some non functional parts of the
1197
+      nerdtree ui (camthompson)
1198
+    - tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the
1199
+      new behaviour (benjamingeiger)
1200
+    - if no name is given to :Bookmark, make it default to the name of the
1201
+      target file/dir (minyoung)
1202
+    - use 'file' completion when doing copying, create, and move
1203
+      operations (EvanDotPro)
1204
+    - lots of misc bug fixes (paddyoloughlin, sdewald, camthompson, Vitaly
1205
+      Bogdanov, AndrewRadev, mathias, scottstvnsn, kml, wycats, me RAWR!)
1206
+
1207
+4.1.0
1208
+    features:
1209
+    - NERDTreeFind to reveal the node for the current buffer in the tree,
1210
+      see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by
1211
+      Doug McInnes) into the script.
1212
+    - make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan
1213
+      Ritter and Rémi Prévost.
1214
+    - truncate the root node if wider than the tree window. Thanks to Victor
1215
+      Gonzalez.
1216
+
1217
+    bugfixes:
1218
+    - really fix window state restoring
1219
+    - fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky,
1220
+      jfilip1024, and Chris Chambers
1221
+
1222
+4.0.0
1223
+    - add a new programmable menu system (see :help NERDTreeMenu).
1224
+    - add new APIs to add menus/menu-items to the menu system as well as
1225
+      custom key mappings to the NERD tree buffer (see :help NERDTreeAPI).
1226
+    - removed the old API functions
1227
+    - added a mapping to maximize/restore the size of nerd tree window, thanks
1228
+      to Guillaume Duranceau for the patch. See :help NERDTree-A for details.
1229
+
1230
+    - fix a bug where secondary nerd trees (netrw hijacked trees) and
1231
+      NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey.
1232
+    - fix a bug where the script ignored directories whose name ended in a dot,
1233
+      thanks to Aggelos Orfanakos for the patch.
1234
+    - fix a bug when using the x mapping on the tree root, thanks to Bryan
1235
+      Venteicher for the patch.
1236
+    - fix a bug where the cursor position/window size of the nerd tree buffer
1237
+      wasnt being stored on closing the window, thanks to Richard Hart.
1238
+    - fix a bug where NERDTreeMirror would mirror the wrong tree
1239
+
1240
+3.1.1
1241
+    - fix a bug where a non-listed no-name buffer was getting created every
1242
+      time the tree windows was created, thanks to Derek Wyatt and owen1
1243
+    - make <CR> behave the same as the 'o' mapping
1244
+    - some helptag fixes in the doc, thanks strull
1245
+    - fix a bug when using :set nohidden and opening a file where the previous
1246
+      buf was modified. Thanks iElectric
1247
+    - other minor fixes
1248
+
1249
+3.1.0
1250
+    New features:
1251
+    - add mappings to open files in a vsplit, see :help NERDTree-s and :help
1252
+      NERDTree-gs
1253
+    - make the statusline for the nerd tree window default to something
1254
+      hopefully more useful. See :help 'NERDTreeStatusline'
1255
+    Bugfixes:
1256
+    - make the hijack netrw functionality work when vim is started with "vim
1257
+      <some dir>" (thanks to Alf Mikula for the patch).
1258
+    - fix a bug where the CWD wasnt being changed for some operations even when
1259
+      NERDTreeChDirMode==2 (thanks to Lucas S. Buchala)
1260
+    - add -bar to all the nerd tree :commands so they can chain with other
1261
+      :commands (thanks to tpope)
1262
+    - fix bugs when ignorecase was set (thanks to nach)
1263
+    - fix a bug with the relative path code (thanks to nach)
1264
+    - fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach)
1265
+
1266
+
1267
+3.0.1
1268
+    Bugfixes:
1269
+    - fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden
1270
+      was not set
1271
+    - fix a bug where :NERDTree <path> would fail if <path> was relative and
1272
+      didnt start with a ./ or ../  Thanks to James Kanze.
1273
+    - make the q mapping work with secondary (:e <dir>  style) trees,
1274
+      thanks to jamessan
1275
+    - fix a bunch of small bugs with secondary trees
1276
+
1277
+    More insane refactoring.
1278
+
1279
+3.0.0
1280
+    - hijack netrw so that doing an :edit <directory>  will put a NERD tree in
1281
+      the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw'
1282
+    - allow sharing of trees across tabs, see :help :NERDTreeMirror
1283
+    - remove "top" and "bottom" as valid settings for NERDTreeWinPos
1284
+    - change the '<tab>' mapping to 'i'
1285
+    - change the 'H' mapping to 'I'
1286
+    - lots of refactoring
1287
+
1288
+==============================================================================
1289
+7. Credits                                                   *NERDTreeCredits*
1290
+
1291
+Thanks to the following people for testing, bug reports, ideas etc. Without
1292
+you I probably would have got bored of the hacking the NERD tree and
1293
+just downloaded pr0n instead.
1294
+
1295
+    Tim Carey-Smith (halorgium)
1296
+    Vigil
1297
+    Nick Brettell
1298
+    Thomas Scott Urban
1299
+    Terrance Cohen
1300
+    Yegappan Lakshmanan
1301
+    Jason Mills
1302
+    Michael Geddes (frogonwheels)
1303
+    Yu Jun
1304
+    Michael Madsen
1305
+    AOYAMA Shotaro
1306
+    Zhang Weiwu
1307
+    Niels Aan de Brugh
1308
+    Olivier Yiptong
1309
+    Zhang Shuhan
1310
+    Cory Echols
1311
+    Piotr Czachur
1312
+    Yuan Jiang
1313
+    Matan Nassau
1314
+    Maxim Kim
1315
+    Charlton Wang
1316
+    Matt Wozniski (godlygeek)
1317
+    knekk
1318
+    Sean Chou
1319
+    Ryan Penn
1320
+    Simon Peter Nicholls
1321
+    Michael Foobar
1322
+    Tomasz Chomiuk
1323
+    Denis Pokataev
1324
+    Tim Pope (tpope)
1325
+    James Kanze
1326
+    James Vega (jamessan)
1327
+    Frederic Chanal (nach)
1328
+    Alf Mikula
1329
+    Lucas S. Buchala
1330
+    Curtis Harvey
1331
+    Guillaume Duranceau
1332
+    Richard Hart (hates)
1333
+    Doug McInnes
1334
+    Stefan Ritter
1335
+    Rémi Prévost
1336
+    Victor Gonzalez
1337
+    Stephan Baumeister
1338
+    Ricky
1339
+    jfilip1024
1340
+    Chris Chambers
1341
+    Vitaly Bogdanov
1342
+    Patrick O'Loughlin (paddyoloughlin)
1343
+    Cam Thompson (camthompson)
1344
+    Marcin Kulik (sickill)
1345
+    Steve DeWald (sdewald)
1346
+    Ivan Necas (iNecas)
1347
+    George Ang (gnap)
1348
+    Evan Coury (EvanDotPro)
1349
+    Andrew Radev (AndrewRadev)
1350
+    Matt Gauger (mathias)
1351
+    Scott Stevenson (scottstvnsn)
1352
+    Anderson Freitas (andersonfreitas)
1353
+    Kamil K. Lemański (kml)
1354
+    Yehuda Katz (wycats)
1355
+    Min-Young Wu (minyoung)
1356
+    Benjamin Geiger (benjamingeiger)
1357
+
1358
+==============================================================================
1359
+8. License                                                   *NERDTreeLicense*
1360
+
1361
+The NERD tree is released under the wtfpl.
1362
+See http://sam.zoy.org/wtfpl/COPYING.
... ...
@@ -0,0 +1,41 @@
1
+" ============================================================================
2
+" File:        exec_menuitem.vim
3
+" Description: plugin for NERD Tree that provides an execute file menu item
4
+" Maintainer:  Martin Grenfell <martin.grenfell at gmail dot com>
5
+" Last Change: 22 July, 2009
6
+" License:     This program is free software. It comes without any warranty,
7
+"              to the extent permitted by applicable law. You can redistribute
8
+"              it and/or modify it under the terms of the Do What The Fuck You
9
+"              Want To Public License, Version 2, as published by Sam Hocevar.
10
+"              See http://sam.zoy.org/wtfpl/COPYING for more details.
11
+"
12
+" ============================================================================
13
+if exists("g:loaded_nerdtree_exec_menuitem")
14
+    finish
15
+endif
16
+let g:loaded_nerdtree_exec_menuitem = 1
17
+
18
+call NERDTreeAddMenuItem({
19
+            \ 'text': '(!)Execute file',
20
+            \ 'shortcut': '!',
21
+            \ 'callback': 'NERDTreeExecFile',
22
+            \ 'isActiveCallback': 'NERDTreeExecFileActive' })
23
+
24
+function! NERDTreeExecFileActive()
25
+    let node = g:NERDTreeFileNode.GetSelected()
26
+    return !node.path.isDirectory && node.path.isExecutable
27
+endfunction
28
+
29
+function! NERDTreeExecFile()
30
+    let treenode = g:NERDTreeFileNode.GetSelected()
31
+    echo "==========================================================\n"
32
+    echo "Complete the command to execute (add arguments etc):\n"
33
+    let cmd = treenode.path.str({'escape': 1})
34
+    let cmd = input(':!', cmd . ' ')
35
+
36
+    if cmd != ''
37
+        exec ':!' . cmd
38
+    else
39
+        echo "Aborted"
40
+    endif
41
+endfunction
... ...
@@ -0,0 +1,262 @@
1
+" ============================================================================
2
+" File:        fs_menu.vim
3
+" Description: plugin for the NERD Tree that provides a file system menu
4
+" Maintainer:  Martin Grenfell <martin.grenfell at gmail dot com>
5
+" Last Change: 17 July, 2009
6
+" License:     This program is free software. It comes without any warranty,
7
+"              to the extent permitted by applicable law. You can redistribute
8
+"              it and/or modify it under the terms of the Do What The Fuck You
9
+"              Want To Public License, Version 2, as published by Sam Hocevar.
10
+"              See http://sam.zoy.org/wtfpl/COPYING for more details.
11
+"
12
+" ============================================================================
13
+if exists("g:loaded_nerdtree_fs_menu")
14
+    finish
15
+endif
16
+let g:loaded_nerdtree_fs_menu = 1
17
+
18
+"Automatically delete the buffer after deleting or renaming a file
19
+if !exists("g:NERDTreeAutoDeleteBuffer")
20
+    let g:NERDTreeAutoDeleteBuffer = 0
21
+endif
22
+
23
+call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'})
24
+call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
25
+call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
26
+
27
+if has("gui_mac") || has("gui_macvim") 
28
+    call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'})
29
+    call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'})
30
+    call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'})
31
+endif
32
+
33
+if g:NERDTreePath.CopyingSupported()
34
+    call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
35
+endif
36
+
37
+"FUNCTION: s:echo(msg){{{1
38
+function! s:echo(msg)
39
+    redraw
40
+    echomsg "NERDTree: " . a:msg
41
+endfunction
42
+
43
+"FUNCTION: s:echoWarning(msg){{{1
44
+function! s:echoWarning(msg)
45
+    echohl warningmsg
46
+    call s:echo(a:msg)
47
+    echohl normal
48
+endfunction
49
+
50
+"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1
51
+"prints out the given msg and, if the user responds by pushing 'y' then the
52
+"buffer with the given bufnum is deleted
53
+"
54
+"Args:
55
+"bufnum: the buffer that may be deleted
56
+"msg: a message that will be echoed to the user asking them if they wish to
57
+"     del the buffer
58
+function! s:promptToDelBuffer(bufnum, msg)
59
+    echo a:msg
60
+    if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y'
61
+        " 1. ensure that all windows which display the just deleted filename
62
+        " now display an empty buffer (so a layout is preserved).
63
+        " Is not it better to close single tabs with this file only ?
64
+        let s:originalTabNumber = tabpagenr()
65
+        let s:originalWindowNumber = winnr()
66
+        exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':enew! ' | endif"
67
+        exec "tabnext " . s:originalTabNumber
68
+        exec s:originalWindowNumber . "wincmd w"
69
+        " 3. We don't need a previous buffer anymore
70
+        exec "bwipeout! " . a:bufnum
71
+    endif
72
+endfunction
73
+
74
+"FUNCTION: s:promptToRenameBuffer(bufnum, msg){{{1
75
+"prints out the given msg and, if the user responds by pushing 'y' then the
76
+"buffer with the given bufnum is replaced with a new one
77
+"
78
+"Args:
79
+"bufnum: the buffer that may be deleted
80
+"msg: a message that will be echoed to the user asking them if they wish to
81
+"     del the buffer
82
+function! s:promptToRenameBuffer(bufnum, msg, newFileName)
83
+    echo a:msg
84
+    if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y'
85
+        " 1. ensure that a new buffer is loaded
86
+        exec "badd " . a:newFileName
87
+        " 2. ensure that all windows which display the just deleted filename
88
+        " display a buffer for a new filename. 
89
+        let s:originalTabNumber = tabpagenr()
90
+        let s:originalWindowNumber = winnr()
91
+        exec "tabdo windo if winbufnr(0) == " . a:bufnum . " | exec ':e! " . a:newFileName . "' | endif"
92
+        exec "tabnext " . s:originalTabNumber
93
+        exec s:originalWindowNumber . "wincmd w"
94
+        " 3. We don't need a previous buffer anymore
95
+        exec "bwipeout! " . a:bufnum
96
+    endif
97
+endfunction
98
+"FUNCTION: NERDTreeAddNode(){{{1
99
+function! NERDTreeAddNode()
100
+    let curDirNode = g:NERDTreeDirNode.GetSelected()
101
+
102
+    let newNodeName = input("Add a childnode\n".
103
+                          \ "==========================================================\n".
104
+                          \ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
105
+                          \ "", curDirNode.path.str() . g:NERDTreePath.Slash(), "file")
106
+
107
+    if newNodeName ==# ''
108
+        call s:echo("Node Creation Aborted.")
109
+        return
110
+    endif
111
+
112
+    try
113
+        let newPath = g:NERDTreePath.Create(newNodeName)
114
+        let parentNode = b:NERDTreeRoot.findNode(newPath.getParent())
115
+
116
+        let newTreeNode = g:NERDTreeFileNode.New(newPath)
117
+        if parentNode.isOpen || !empty(parentNode.children)
118
+            call parentNode.addChild(newTreeNode, 1)
119
+            call NERDTreeRender()
120
+            call newTreeNode.putCursorHere(1, 0)
121
+        endif
122
+    catch /^NERDTree/
123
+        call s:echoWarning("Node Not Created.")
124
+    endtry
125
+endfunction
126
+
127
+"FUNCTION: NERDTreeMoveNode(){{{1
128
+function! NERDTreeMoveNode()
129
+    let curNode = g:NERDTreeFileNode.GetSelected()
130
+    let newNodePath = input("Rename the current node\n" .
131
+                          \ "==========================================================\n" .
132
+                          \ "Enter the new path for the node:                          \n" .
133
+                          \ "", curNode.path.str(), "file")
134
+
135
+    if newNodePath ==# ''
136
+        call s:echo("Node Renaming Aborted.")
137
+        return
138
+    endif
139
+
140
+    try
141
+        let bufnum = bufnr(curNode.path.str())
142
+
143
+        call curNode.rename(newNodePath)
144
+        call NERDTreeRender()
145
+
146
+        "if the node is open in a buffer, ask the user if they want to
147
+        "close that buffer
148
+        if bufnum != -1
149
+            let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Replace this buffer with a new file? (yN)"
150
+            call s:promptToRenameBuffer(bufnum,  prompt, newNodePath)
151
+        endif
152
+
153
+        call curNode.putCursorHere(1, 0)
154
+
155
+        redraw
156
+    catch /^NERDTree/
157
+        call s:echoWarning("Node Not Renamed.")
158
+    endtry
159
+endfunction
160
+
161
+" FUNCTION: NERDTreeDeleteNode() {{{1
162
+function! NERDTreeDeleteNode()
163
+    let currentNode = g:NERDTreeFileNode.GetSelected()
164
+    let confirmed = 0
165
+
166
+    if currentNode.path.isDirectory
167
+        let choice =input("Delete the current node\n" .
168
+                         \ "==========================================================\n" .
169
+                         \ "STOP! To delete this entire directory, type 'yes'\n" .
170
+                         \ "" . currentNode.path.str() . ": ")
171
+        let confirmed = choice ==# 'yes'
172
+    else
173
+        echo "Delete the current node\n" .
174
+           \ "==========================================================\n".
175
+           \ "Are you sure you wish to delete the node:\n" .
176
+           \ "" . currentNode.path.str() . " (yN):"
177
+        let choice = nr2char(getchar())
178
+        let confirmed = choice ==# 'y'
179
+    endif
180
+
181
+
182
+    if confirmed
183
+        try
184
+            call currentNode.delete()
185
+            call NERDTreeRender()
186
+
187
+            "if the node is open in a buffer, ask the user if they want to
188
+            "close that buffer
189
+            let bufnum = bufnr(currentNode.path.str())
190
+            if buflisted(bufnum)
191
+                let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
192
+                call s:promptToDelBuffer(bufnum, prompt)
193
+            endif
194
+
195
+            redraw
196
+        catch /^NERDTree/
197
+            call s:echoWarning("Could not remove node")
198
+        endtry
199
+    else
200
+        call s:echo("delete aborted")
201
+    endif
202
+
203
+endfunction
204
+
205
+" FUNCTION: NERDTreeCopyNode() {{{1
206
+function! NERDTreeCopyNode()
207
+    let currentNode = g:NERDTreeFileNode.GetSelected()
208
+    let newNodePath = input("Copy the current node\n" .
209
+                          \ "==========================================================\n" .
210
+                          \ "Enter the new path to copy the node to:                   \n" .
211
+                          \ "", currentNode.path.str(), "file")
212
+
213
+    if newNodePath != ""
214
+        "strip trailing slash
215
+        let newNodePath = substitute(newNodePath, '\/$', '', '')
216
+
217
+        let confirmed = 1
218
+        if currentNode.path.copyingWillOverwrite(newNodePath)
219
+            call s:echo("Warning: copying may overwrite files! Continue? (yN)")
220
+            let choice = nr2char(getchar())
221
+            let confirmed = choice ==# 'y'
222
+        endif
223
+
224
+        if confirmed
225
+            try
226
+                let newNode = currentNode.copy(newNodePath)
227
+                if !empty(newNode)
228
+                    call NERDTreeRender()
229
+                    call newNode.putCursorHere(0, 0)
230
+                endif
231
+            catch /^NERDTree/
232
+                call s:echoWarning("Could not copy node")
233
+            endtry
234
+        endif
235
+    else
236
+        call s:echo("Copy aborted.")
237
+    endif
238
+    redraw
239
+endfunction
240
+
241
+function! NERDTreeQuickLook()
242
+    let treenode = g:NERDTreeFileNode.GetSelected()
243
+    if treenode != {}
244
+        call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'")
245
+    endif
246
+endfunction
247
+
248
+function! NERDTreeRevealInFinder()
249
+    let treenode = g:NERDTreeFileNode.GetSelected()
250
+    if treenode != {}
251
+        let x = system("open -R '" . treenode.path.str() . "'")
252
+    endif
253
+endfunction
254
+
255
+function! NERDTreeExecuteFile()
256
+    let treenode = g:NERDTreeFileNode.GetSelected()
257
+    if treenode != {}
258
+        let x = system("open '" . treenode.path.str() . "'")
259
+    endif
260
+endfunction
261
+
262
+" vim: set sw=4 sts=4 et fdm=marker:
... ...
@@ -0,0 +1,4444 @@
1
+" ============================================================================
2
+" File:        NERD_tree.vim
3
+" Description: vim global plugin that provides a nice tree explorer
4
+" Maintainer:  Martin Grenfell <martin.grenfell at gmail dot com>
5
+" Last Change: 28 December, 2011
6
+" License:     This program is free software. It comes without any warranty,
7
+"              to the extent permitted by applicable law. You can redistribute
8
+"              it and/or modify it under the terms of the Do What The Fuck You
9
+"              Want To Public License, Version 2, as published by Sam Hocevar.
10
+"              See http://sam.zoy.org/wtfpl/COPYING for more details.
11
+"
12
+" ============================================================================
13
+let s:NERD_tree_version = '4.2.0'
14
+
15
+" SECTION: Script init stuff {{{1
16
+"============================================================
17
+if exists("loaded_nerd_tree")
18
+    finish
19
+endif
20
+if v:version < 700
21
+    echoerr "NERDTree: this plugin requires vim >= 7. DOWNLOAD IT! You'll thank me later!"
22
+    finish
23
+endif
24
+let loaded_nerd_tree = 1
25
+
26
+"for line continuation - i.e dont want C in &cpo
27
+let s:old_cpo = &cpo
28
+set cpo&vim
29
+
30
+let s:running_windows = has("win16") || has("win32") || has("win64")
31
+
32
+"Function: s:initVariable() function {{{2
33
+"This function is used to initialise a given variable to a given value. The
34
+"variable is only initialised if it does not exist prior
35
+"
36
+"Args:
37
+"var: the name of the var to be initialised
38
+"value: the value to initialise var to
39
+"
40
+"Returns:
41
+"1 if the var is set, 0 otherwise
42
+function! s:initVariable(var, value)
43
+    if !exists(a:var)
44
+        exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", "g") . "'"
45
+        return 1
46
+    endif
47
+    return 0
48
+endfunction
49
+
50
+"SECTION: Init variable calls and other random constants {{{2
51
+call s:initVariable("g:NERDChristmasTree", 1)
52
+call s:initVariable("g:NERDTreeAutoCenter", 1)
53
+call s:initVariable("g:NERDTreeAutoCenterThreshold", 3)
54
+call s:initVariable("g:NERDTreeCaseSensitiveSort", 0)
55
+call s:initVariable("g:NERDTreeChDirMode", 0)
56
+call s:initVariable("g:NERDTreeMinimalUI", 0)
57
+if !exists("g:NERDTreeIgnore")
58
+    let g:NERDTreeIgnore = ['\~$']
59
+endif
60
+call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks')
61
+call s:initVariable("g:NERDTreeHighlightCursorline", 1)
62
+call s:initVariable("g:NERDTreeHijackNetrw", 1)
63
+call s:initVariable("g:NERDTreeMouseMode", 1)
64
+call s:initVariable("g:NERDTreeNotificationThreshold", 100)
65
+call s:initVariable("g:NERDTreeQuitOnOpen", 0)
66
+call s:initVariable("g:NERDTreeShowBookmarks", 0)
67
+call s:initVariable("g:NERDTreeShowFiles", 1)
68
+call s:initVariable("g:NERDTreeShowHidden", 0)
69
+call s:initVariable("g:NERDTreeShowLineNumbers", 0)
70
+call s:initVariable("g:NERDTreeSortDirs", 1)
71
+call s:initVariable("g:NERDTreeDirArrows", !s:running_windows)
72
+call s:initVariable("g:NERDTreeCasadeOpenSingleChildDir", 1)
73
+
74
+if !exists("g:NERDTreeSortOrder")
75
+    let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$',  '\.bak$', '\~$']
76
+else
77
+    "if there isnt a * in the sort sequence then add one
78
+    if count(g:NERDTreeSortOrder, '*') < 1
79
+        call add(g:NERDTreeSortOrder, '*')
80
+    endif
81
+endif
82
+
83
+"we need to use this number many times for sorting... so we calculate it only
84
+"once here
85
+let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*')
86
+
87
+if !exists('g:NERDTreeStatusline')
88
+
89
+    "the exists() crap here is a hack to stop vim spazzing out when
90
+    "loading a session that was created with an open nerd tree. It spazzes
91
+    "because it doesnt store b:NERDTreeRoot (its a b: var, and its a hash)
92
+    let g:NERDTreeStatusline = "%{exists('b:NERDTreeRoot')?b:NERDTreeRoot.path.str():''}"
93
+
94
+endif
95
+call s:initVariable("g:NERDTreeWinPos", "left")
96
+call s:initVariable("g:NERDTreeWinSize", 31)
97
+
98
+"init the shell commands that will be used to copy nodes, and remove dir trees
99
+"
100
+"Note: the space after the command is important
101
+if s:running_windows
102
+    call s:initVariable("g:NERDTreeRemoveDirCmd", 'rmdir /s /q ')
103
+else
104
+    call s:initVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ')
105
+    call s:initVariable("g:NERDTreeCopyCmd", 'cp -r ')
106
+endif
107
+
108
+
109
+"SECTION: Init variable calls for key mappings {{{2
110
+call s:initVariable("g:NERDTreeMapActivateNode", "o")
111
+call s:initVariable("g:NERDTreeMapChangeRoot", "C")
112
+call s:initVariable("g:NERDTreeMapChdir", "cd")
113
+call s:initVariable("g:NERDTreeMapCloseChildren", "X")
114
+call s:initVariable("g:NERDTreeMapCloseDir", "x")
115
+call s:initVariable("g:NERDTreeMapDeleteBookmark", "D")
116
+call s:initVariable("g:NERDTreeMapMenu", "m")
117
+call s:initVariable("g:NERDTreeMapHelp", "?")
118
+call s:initVariable("g:NERDTreeMapJumpFirstChild", "K")
119
+call s:initVariable("g:NERDTreeMapJumpLastChild", "J")
120
+call s:initVariable("g:NERDTreeMapJumpNextSibling", "<C-j>")
121
+call s:initVariable("g:NERDTreeMapJumpParent", "p")
122
+call s:initVariable("g:NERDTreeMapJumpPrevSibling", "<C-k>")
123
+call s:initVariable("g:NERDTreeMapJumpRoot", "P")
124
+call s:initVariable("g:NERDTreeMapOpenExpl", "e")
125
+call s:initVariable("g:NERDTreeMapOpenInTab", "t")
126
+call s:initVariable("g:NERDTreeMapOpenInTabSilent", "T")
127
+call s:initVariable("g:NERDTreeMapOpenRecursively", "O")
128
+call s:initVariable("g:NERDTreeMapOpenSplit", "i")
129
+call s:initVariable("g:NERDTreeMapOpenVSplit", "s")
130
+call s:initVariable("g:NERDTreeMapPreview", "g" . NERDTreeMapActivateNode)
131
+call s:initVariable("g:NERDTreeMapPreviewSplit", "g" . NERDTreeMapOpenSplit)
132
+call s:initVariable("g:NERDTreeMapPreviewVSplit", "g" . NERDTreeMapOpenVSplit)
133
+call s:initVariable("g:NERDTreeMapQuit", "q")
134
+call s:initVariable("g:NERDTreeMapRefresh", "r")
135
+call s:initVariable("g:NERDTreeMapRefreshRoot", "R")
136
+call s:initVariable("g:NERDTreeMapToggleBookmarks", "B")
137
+call s:initVariable("g:NERDTreeMapToggleFiles", "F")
138
+call s:initVariable("g:NERDTreeMapToggleFilters", "f")
139
+call s:initVariable("g:NERDTreeMapToggleHidden", "I")
140
+call s:initVariable("g:NERDTreeMapToggleZoom", "A")
141
+call s:initVariable("g:NERDTreeMapUpdir", "u")
142
+call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U")
143
+call s:initVariable("g:NERDTreeMapCWD", "CD")
144
+
145
+"SECTION: Script level variable declaration{{{2
146
+if s:running_windows
147
+    let s:escape_chars =  " `\|\"#%&,?()\*^<>"
148
+else
149
+    let s:escape_chars =  " \\`\|\"#%&,?()\*^<>[]"
150
+endif
151
+let s:NERDTreeBufName = 'NERD_tree_'
152
+
153
+let s:tree_wid = 2
154
+
155
+if g:NERDTreeDirArrows
156
+    let s:tree_markup_reg = '^\([▾▸] \| \+[▾▸] \| \+\)'
157
+else
158
+    let s:tree_markup_reg = '^[ `|]*[\-+~]'
159
+endif
160
+let s:tree_up_dir_line = '.. (up a dir)'
161
+
162
+"the number to add to the nerd tree buffer name to make the buf name unique
163
+let s:next_buffer_number = 1
164
+
165
+" SECTION: Commands {{{1
166
+"============================================================
167
+"init the command that users start the nerd tree with
168
+command! -n=? -complete=dir -bar NERDTree :call s:initNerdTree('<args>')
169
+command! -n=? -complete=dir -bar NERDTreeToggle :call s:toggle('<args>')
170
+command! -n=0 -bar NERDTreeClose :call s:closeTreeIfOpen()
171
+command! -n=1 -complete=customlist,s:completeBookmarks -bar NERDTreeFromBookmark call s:initNerdTree('<args>')
172
+command! -n=0 -bar NERDTreeMirror call s:initNerdTreeMirror()
173
+command! -n=0 -bar NERDTreeFind call s:findAndRevealPath()
174
+command! -n=0 -bar NERDTreeFocus call NERDTreeFocus()
175
+command! -n=0 -bar NERDTreeCWD call NERDTreeCWD()
176
+" SECTION: Auto commands {{{1
177
+"============================================================
178
+augroup NERDTree
179
+    "Save the cursor position whenever we close the nerd tree
180
+    exec "autocmd BufWinLeave ". s:NERDTreeBufName ."* call <SID>saveScreenState()"
181
+
182
+    "disallow insert mode in the NERDTree
183
+    exec "autocmd BufEnter ". s:NERDTreeBufName ."* stopinsert"
184
+augroup END
185
+
186
+if g:NERDTreeHijackNetrw
187
+    augroup NERDTreeHijackNetrw
188
+        autocmd VimEnter * silent! autocmd! FileExplorer
189
+        au BufEnter,VimEnter * call s:checkForBrowse(expand("<amatch>"))
190
+    augroup END
191
+endif
192
+
193
+"SECTION: Classes {{{1
194
+"============================================================
195
+"CLASS: Bookmark {{{2
196
+"============================================================
197
+let s:Bookmark = {}
198
+" FUNCTION: Bookmark.activate() {{{3
199
+function! s:Bookmark.activate(...)
200
+    call self.open(a:0 ? a:1 : {})
201
+endfunction
202
+" FUNCTION: Bookmark.AddBookmark(name, path) {{{3
203
+" Class method to add a new bookmark to the list, if a previous bookmark exists
204
+" with the same name, just update the path for that bookmark
205
+function! s:Bookmark.AddBookmark(name, path)
206
+    for i in s:Bookmark.Bookmarks()
207
+        if i.name ==# a:name
208
+            let i.path = a:path
209
+            return
210
+        endif
211
+    endfor
212
+    call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path))
213
+    call s:Bookmark.Sort()
214
+endfunction
215
+" Function: Bookmark.Bookmarks()   {{{3
216
+" Class method to get all bookmarks. Lazily initializes the bookmarks global
217
+" variable
218
+function! s:Bookmark.Bookmarks()
219
+    if !exists("g:NERDTreeBookmarks")
220
+        let g:NERDTreeBookmarks = []
221
+    endif
222
+    return g:NERDTreeBookmarks
223
+endfunction
224
+" Function: Bookmark.BookmarkExistsFor(name)   {{{3
225
+" class method that returns 1 if a bookmark with the given name is found, 0
226
+" otherwise
227
+function! s:Bookmark.BookmarkExistsFor(name)
228
+    try
229
+        call s:Bookmark.BookmarkFor(a:name)
230
+        return 1
231
+    catch /^NERDTree.BookmarkNotFoundError/
232
+        return 0
233
+    endtry
234
+endfunction
235
+" Function: Bookmark.BookmarkFor(name)   {{{3
236
+" Class method to get the bookmark that has the given name. {} is return if no
237
+" bookmark is found
238
+function! s:Bookmark.BookmarkFor(name)
239
+    for i in s:Bookmark.Bookmarks()
240
+        if i.name ==# a:name
241
+            return i
242
+        endif
243
+    endfor
244
+    throw "NERDTree.BookmarkNotFoundError: no bookmark found for name: \"". a:name  .'"'
245
+endfunction
246
+" Function: Bookmark.BookmarkNames()   {{{3
247
+" Class method to return an array of all bookmark names
248
+function! s:Bookmark.BookmarkNames()
249
+    let names = []
250
+    for i in s:Bookmark.Bookmarks()
251
+        call add(names, i.name)
252
+    endfor
253
+    return names
254
+endfunction
255
+" FUNCTION: Bookmark.CacheBookmarks(silent) {{{3
256
+" Class method to read all bookmarks from the bookmarks file intialize
257
+" bookmark objects for each one.
258
+"
259
+" Args:
260
+" silent - dont echo an error msg if invalid bookmarks are found
261
+function! s:Bookmark.CacheBookmarks(silent)
262
+    if filereadable(g:NERDTreeBookmarksFile)
263
+        let g:NERDTreeBookmarks = []
264
+        let g:NERDTreeInvalidBookmarks = []
265
+        let bookmarkStrings = readfile(g:NERDTreeBookmarksFile)
266
+        let invalidBookmarksFound = 0
267
+        for i in bookmarkStrings
268
+
269
+            "ignore blank lines
270
+            if i != ''
271
+
272
+                let name = substitute(i, '^\(.\{-}\) .*$', '\1', '')
273
+                let path = substitute(i, '^.\{-} \(.*\)$', '\1', '')
274
+
275
+                try
276
+                    let bookmark = s:Bookmark.New(name, s:Path.New(path))
277
+                    call add(g:NERDTreeBookmarks, bookmark)
278
+                catch /^NERDTree.InvalidArgumentsError/
279
+                    call add(g:NERDTreeInvalidBookmarks, i)
280
+                    let invalidBookmarksFound += 1
281
+                endtry
282
+            endif
283
+        endfor
284
+        if invalidBookmarksFound
285
+            call s:Bookmark.Write()
286
+            if !a:silent
287
+                call s:echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.")
288
+            endif
289
+        endif
290
+        call s:Bookmark.Sort()
291
+    endif
292
+endfunction
293
+" FUNCTION: Bookmark.compareTo(otherbookmark) {{{3
294
+" Compare these two bookmarks for sorting purposes
295
+function! s:Bookmark.compareTo(otherbookmark)
296
+    return a:otherbookmark.name < self.name
297
+endfunction
298
+" FUNCTION: Bookmark.ClearAll() {{{3
299
+" Class method to delete all bookmarks.
300
+function! s:Bookmark.ClearAll()
301
+    for i in s:Bookmark.Bookmarks()
302
+        call i.delete()
303
+    endfor
304
+    call s:Bookmark.Write()
305
+endfunction
306
+" FUNCTION: Bookmark.delete() {{{3
307
+" Delete this bookmark. If the node for this bookmark is under the current
308
+" root, then recache bookmarks for its Path object
309
+function! s:Bookmark.delete()
310
+    let node = {}
311
+    try
312
+        let node = self.getNode(1)
313
+    catch /^NERDTree.BookmarkedNodeNotFoundError/
314
+    endtry
315
+    call remove(s:Bookmark.Bookmarks(), index(s:Bookmark.Bookmarks(), self))
316
+    if !empty(node)
317
+        call node.path.cacheDisplayString()
318
+    endif
319
+    call s:Bookmark.Write()
320
+endfunction
321
+" FUNCTION: Bookmark.getNode(searchFromAbsoluteRoot) {{{3
322
+" Gets the treenode for this bookmark
323
+"
324
+" Args:
325
+" searchFromAbsoluteRoot: specifies whether we should search from the current
326
+" tree root, or the highest cached node
327
+function! s:Bookmark.getNode(searchFromAbsoluteRoot)
328
+    let searchRoot = a:searchFromAbsoluteRoot ? s:TreeDirNode.AbsoluteTreeRoot() : b:NERDTreeRoot
329
+    let targetNode = searchRoot.findNode(self.path)
330
+    if empty(targetNode)
331
+        throw "NERDTree.BookmarkedNodeNotFoundError: no node was found for bookmark: " . self.name
332
+    endif
333
+    return targetNode
334
+endfunction
335
+" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) {{{3
336
+" Class method that finds the bookmark with the given name and returns the
337
+" treenode for it.
338
+function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot)
339
+    let bookmark = s:Bookmark.BookmarkFor(a:name)
340
+    return bookmark.getNode(a:searchFromAbsoluteRoot)
341
+endfunction
342
+" FUNCTION: Bookmark.GetSelected() {{{3
343
+" returns the Bookmark the cursor is over, or {}
344
+function! s:Bookmark.GetSelected()
345
+    let line = getline(".")
346
+    let name = substitute(line, '^>\(.\{-}\) .\+$', '\1', '')
347
+    if name != line
348
+        try
349
+            return s:Bookmark.BookmarkFor(name)
350
+        catch /^NERDTree.BookmarkNotFoundError/
351
+            return {}
352
+        endtry
353
+    endif
354
+    return {}
355
+endfunction
356
+
357
+" Function: Bookmark.InvalidBookmarks()   {{{3
358
+" Class method to get all invalid bookmark strings read from the bookmarks
359
+" file
360
+function! s:Bookmark.InvalidBookmarks()
361
+    if !exists("g:NERDTreeInvalidBookmarks")
362
+        let g:NERDTreeInvalidBookmarks = []
363
+    endif
364
+    return g:NERDTreeInvalidBookmarks
365
+endfunction
366
+" FUNCTION: Bookmark.mustExist() {{{3
367
+function! s:Bookmark.mustExist()
368
+    if !self.path.exists()
369
+        call s:Bookmark.CacheBookmarks(1)
370
+        throw "NERDTree.BookmarkPointsToInvalidLocationError: the bookmark \"".
371
+            \ self.name ."\" points to a non existing location: \"". self.path.str()
372
+    endif
373
+endfunction
374
+" FUNCTION: Bookmark.New(name, path) {{{3
375
+" Create a new bookmark object with the given name and path object
376
+function! s:Bookmark.New(name, path)
377
+    if a:name =~# ' '
378
+        throw "NERDTree.IllegalBookmarkNameError: illegal name:" . a:name
379
+    endif
380
+
381
+    let newBookmark = copy(self)
382
+    let newBookmark.name = a:name
383
+    let newBookmark.path = a:path
384
+    return newBookmark
385
+endfunction
386
+" FUNCTION: Bookmark.open([options]) {{{3
387
+"Args:
388
+"A dictionary containing the following keys (all optional):
389
+"  'where': Specifies whether the node should be opened in new split/tab or in
390
+"           the previous window. Can be either 'v' (vertical split), 'h'
391
+"           (horizontal split), 't' (new tab) or 'p' (previous window).
392
+"  'reuse': if a window is displaying the file then jump the cursor there
393
+"  'keepopen': dont close the tree window
394
+"  'stay': open the file, but keep the cursor in the tree win
395
+"
396
+function! s:Bookmark.open(...)
397
+    let opts = a:0 ? a:1 : {}
398
+
399
+    if self.path.isDirectory && !has_key(opts, 'where')
400
+        call self.toRoot()
401
+    else
402
+        let opener = s:Opener.New(self.path, opts)
403
+        call opener.open(self)
404
+    endif
405
+endfunction
406
+" FUNCTION: Bookmark.openInNewTab(options) {{{3
407
+" Create a new bookmark object with the given name and path object
408
+function! s:Bookmark.openInNewTab(options)
409
+    call s:deprecated('Bookmark.openInNewTab', 'is deprecated, use open() instead')
410
+    call self.open(a:options)
411
+endfunction
412
+" Function: Bookmark.setPath(path)   {{{3
413
+" makes this bookmark point to the given path
414
+function! s:Bookmark.setPath(path)
415
+    let self.path = a:path
416
+endfunction
417
+" Function: Bookmark.Sort()   {{{3
418
+" Class method that sorts all bookmarks
419
+function! s:Bookmark.Sort()
420
+    let CompareFunc = function("s:compareBookmarks")
421
+    call sort(s:Bookmark.Bookmarks(), CompareFunc)
422
+endfunction
423
+" Function: Bookmark.str()   {{{3
424
+" Get the string that should be rendered in the view for this bookmark
425
+function! s:Bookmark.str()
426
+    let pathStrMaxLen = winwidth(s:getTreeWinNum()) - 4 - len(self.name)
427
+    if &nu
428
+        let pathStrMaxLen = pathStrMaxLen - &numberwidth
429
+    endif
430
+
431
+    let pathStr = self.path.str({'format': 'UI'})
432
+    if len(pathStr) > pathStrMaxLen
433
+        let pathStr = '<' . strpart(pathStr, len(pathStr) - pathStrMaxLen)
434
+    endif
435
+    return '>' . self.name . ' ' . pathStr
436
+endfunction
437
+" FUNCTION: Bookmark.toRoot() {{{3
438
+" Make the node for this bookmark the new tree root
439
+function! s:Bookmark.toRoot()
440
+    if self.validate()
441
+        try
442
+            let targetNode = self.getNode(1)
443
+        catch /^NERDTree.BookmarkedNodeNotFoundError/
444
+            let targetNode = s:TreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path)
445
+        endtry
446
+        call targetNode.makeRoot()
447
+        call s:renderView()
448
+        call targetNode.putCursorHere(0, 0)
449
+    endif
450
+endfunction
451
+" FUNCTION: Bookmark.ToRoot(name) {{{3
452
+" Make the node for this bookmark the new tree root
453
+function! s:Bookmark.ToRoot(name)
454
+    let bookmark = s:Bookmark.BookmarkFor(a:name)
455
+    call bookmark.toRoot()
456
+endfunction
457
+
458
+
459
+"FUNCTION: Bookmark.validate() {{{3
460
+function! s:Bookmark.validate()
461
+    if self.path.exists()
462
+        return 1
463
+    else
464
+        call s:Bookmark.CacheBookmarks(1)
465
+        call s:renderView()
466
+        call s:echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.")
467
+        return 0
468
+    endif
469
+endfunction
470
+
471
+" Function: Bookmark.Write()   {{{3
472
+" Class method to write all bookmarks to the bookmarks file
473
+function! s:Bookmark.Write()
474
+    let bookmarkStrings = []
475
+    for i in s:Bookmark.Bookmarks()
476
+        call add(bookmarkStrings, i.name . ' ' . i.path.str())
477
+    endfor
478
+
479
+    "add a blank line before the invalid ones
480
+    call add(bookmarkStrings, "")
481
+
482
+    for j in s:Bookmark.InvalidBookmarks()
483
+        call add(bookmarkStrings, j)
484
+    endfor
485
+    call writefile(bookmarkStrings, g:NERDTreeBookmarksFile)
486
+endfunction
487
+"CLASS: KeyMap {{{2
488
+"============================================================
489
+let s:KeyMap = {}
490
+"FUNCTION: KeyMap.All() {{{3
491
+function! s:KeyMap.All()
492
+    if !exists("s:keyMaps")
493
+        let s:keyMaps = []
494
+    endif
495
+    return s:keyMaps
496
+endfunction
497
+
498
+"FUNCTION: KeyMap.FindFor(key, scope) {{{3
499
+function! s:KeyMap.FindFor(key, scope)
500
+    for i in s:KeyMap.All()
501
+         if i.key ==# a:key && i.scope ==# a:scope
502
+            return i
503
+        endif
504
+    endfor
505
+    return {}
506
+endfunction
507
+
508
+"FUNCTION: KeyMap.BindAll() {{{3
509
+function! s:KeyMap.BindAll()
510
+    for i in s:KeyMap.All()
511
+        call i.bind()
512
+    endfor
513
+endfunction
514
+
515
+"FUNCTION: KeyMap.bind() {{{3
516
+function! s:KeyMap.bind()
517
+    " If the key sequence we're trying to map contains any '<>' notation, we
518
+    " must replace each of the '<' characters with '<lt>' to ensure the string
519
+    " is not translated into its corresponding keycode during the later part
520
+    " of the map command below
521
+    " :he <>
522
+    let specialNotationRegex = '\m<\([[:alnum:]_-]\+>\)'
523
+    if self.key =~# specialNotationRegex
524
+        let keymapInvokeString = substitute(self.key, specialNotationRegex, '<lt>\1', 'g')
525
+    else
526
+        let keymapInvokeString = self.key
527
+    endif
528
+
529
+    let premap = self.key == "<LeftRelease>" ? " <LeftRelease>" : " "
530
+
531
+    exec 'nnoremap <buffer> <silent> '. self.key . premap . ':call <SID>KeyMap_Invoke("'. keymapInvokeString .'")<cr>'
532
+endfunction
533
+
534
+"FUNCTION: KeyMap.Remove(key, scope) {{{3
535
+function! s:KeyMap.Remove(key, scope)
536
+    let maps = s:KeyMap.All()
537
+    for i in range(len(maps))
538
+         if maps[i].key ==# a:key && maps[i].scope ==# a:scope
539
+            return remove(maps, i)
540
+        endif
541
+    endfor
542
+endfunction
543
+"FUNCTION: KeyMap.invoke() {{{3
544
+"Call the KeyMaps callback function
545
+function! s:KeyMap.invoke(...)
546
+    let Callback = function(self.callback)
547
+    if a:0
548
+        call Callback(a:1)
549
+    else
550
+        call Callback()
551
+    endif
552
+endfunction
553
+
554
+
555
+"FUNCTION: KeyMap.Invoke() {{{3
556
+"Find a keymapping for a:key and the current scope invoke it.
557
+"
558
+"Scope is determined as follows:
559
+"   * if the cursor is on a dir node then "DirNode"
560
+"   * if the cursor is on a file node then "FileNode"
561
+"   * if the cursor is on a bookmark then "Bookmark"
562
+"
563
+"If a keymap has the scope of "all" then it will be called if no other keymap
564
+"is found for a:key and the scope.
565
+function! s:KeyMap.Invoke(key)
566
+    let node = s:TreeFileNode.GetSelected()
567
+    if !empty(node)
568
+
569
+        "try file node
570
+        if !node.path.isDirectory
571
+            let km = s:KeyMap.FindFor(a:key, "FileNode")
572
+            if !empty(km)
573
+                return km.invoke(node)
574
+            endif
575
+        endif
576
+
577
+        "try dir node
578
+        if node.path.isDirectory
579
+            let km = s:KeyMap.FindFor(a:key, "DirNode")
580
+            if !empty(km)
581
+                return km.invoke(node)
582
+            endif
583
+        endif
584
+
585
+        "try generic node
586
+        let km = s:KeyMap.FindFor(a:key, "Node")
587
+        if !empty(km)
588
+            return km.invoke(node)
589
+        endif
590
+
591
+    endif
592
+
593
+    "try bookmark
594
+    let bm = s:Bookmark.GetSelected()
595
+    if !empty(bm)
596
+        let km = s:KeyMap.FindFor(a:key, "Bookmark")
597
+        if !empty(km)
598
+            return km.invoke(bm)
599
+        endif
600
+    endif
601
+
602
+    "try all
603
+    let km = s:KeyMap.FindFor(a:key, "all")
604
+    if !empty(km)
605
+        return km.invoke()
606
+    endif
607
+endfunction
608
+
609
+"this is needed since I cant figure out how to invoke dict functions from a
610
+"key map
611
+function! s:KeyMap_Invoke(key)
612
+    call s:KeyMap.Invoke(a:key)
613
+endfunction
614
+
615
+"FUNCTION: KeyMap.Create(options) {{{3
616
+function! s:KeyMap.Create(options)
617
+    let newKeyMap = copy(self)
618
+    let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options))
619
+    let newKeyMap.key = opts['key']
620
+    let newKeyMap.quickhelpText = opts['quickhelpText']
621
+    let newKeyMap.callback = opts['callback']
622
+    let newKeyMap.scope = opts['scope']
623
+
624
+    call s:KeyMap.Add(newKeyMap)
625
+endfunction
626
+
627
+"FUNCTION: KeyMap.Add(keymap) {{{3
628
+function! s:KeyMap.Add(keymap)
629
+    call s:KeyMap.Remove(a:keymap.key, a:keymap.scope)
630
+    call add(s:KeyMap.All(), a:keymap)
631
+endfunction
632
+
633
+"CLASS: MenuController {{{2
634
+"============================================================
635
+let s:MenuController = {}
636
+"FUNCTION: MenuController.New(menuItems) {{{3
637
+"create a new menu controller that operates on the given menu items
638
+function! s:MenuController.New(menuItems)
639
+    let newMenuController =  copy(self)
640
+    if a:menuItems[0].isSeparator()
641
+        let newMenuController.menuItems = a:menuItems[1:-1]
642
+    else
643
+        let newMenuController.menuItems = a:menuItems
644
+    endif
645
+    return newMenuController
646
+endfunction
647
+
648
+"FUNCTION: MenuController.showMenu() {{{3
649
+"start the main loop of the menu and get the user to choose/execute a menu
650
+"item
651
+function! s:MenuController.showMenu()
652
+    call self._saveOptions()
653
+
654
+    try
655
+        let self.selection = 0
656
+
657
+        let done = 0
658
+        while !done
659
+            redraw!
660
+            call self._echoPrompt()
661
+            let key = nr2char(getchar())
662
+            let done = self._handleKeypress(key)
663
+        endwhile
664
+    finally
665
+        call self._restoreOptions()
666
+    endtry
667
+
668
+    if self.selection != -1
669
+        let m = self._current()
670
+        call m.execute()
671
+    endif
672
+endfunction
673
+
674
+"FUNCTION: MenuController._echoPrompt() {{{3
675
+function! s:MenuController._echoPrompt()
676
+    echo "NERDTree Menu. Use j/k/enter and the shortcuts indicated"
677
+    echo "=========================================================="
678
+
679
+    for i in range(0, len(self.menuItems)-1)
680
+        if self.selection == i
681
+            echo "> " . self.menuItems[i].text
682
+        else
683
+            echo "  " . self.menuItems[i].text
684
+        endif
685
+    endfor
686
+endfunction
687
+
688
+"FUNCTION: MenuController._current(key) {{{3
689
+"get the MenuItem that is currently selected
690
+function! s:MenuController._current()
691
+    return self.menuItems[self.selection]
692
+endfunction
693
+
694
+"FUNCTION: MenuController._handleKeypress(key) {{{3
695
+"change the selection (if appropriate) and return 1 if the user has made
696
+"their choice, 0 otherwise
697
+function! s:MenuController._handleKeypress(key)
698
+    if a:key == 'j'
699
+        call self._cursorDown()
700
+    elseif a:key == 'k'
701
+        call self._cursorUp()
702
+    elseif a:key == nr2char(27) "escape
703
+        let self.selection = -1
704
+        return 1
705
+    elseif a:key == "\r" || a:key == "\n" "enter and ctrl-j
706
+        return 1
707
+    else
708
+        let index = self._nextIndexFor(a:key)
709
+        if index != -1
710
+            let self.selection = index
711
+            if len(self._allIndexesFor(a:key)) == 1
712
+                return 1
713
+            endif
714
+        endif
715
+    endif
716
+
717
+    return 0
718
+endfunction
719
+
720
+"FUNCTION: MenuController._allIndexesFor(shortcut) {{{3
721
+"get indexes to all menu items with the given shortcut
722
+function! s:MenuController._allIndexesFor(shortcut)
723
+    let toReturn = []
724
+
725
+    for i in range(0, len(self.menuItems)-1)
726
+        if self.menuItems[i].shortcut == a:shortcut
727
+            call add(toReturn, i)
728
+        endif
729
+    endfor
730
+
731
+    return toReturn
732
+endfunction
733
+
734
+"FUNCTION: MenuController._nextIndexFor(shortcut) {{{3
735
+"get the index to the next menu item with the given shortcut, starts from the
736
+"current cursor location and wraps around to the top again if need be
737
+function! s:MenuController._nextIndexFor(shortcut)
738
+    for i in range(self.selection+1, len(self.menuItems)-1)
739
+        if self.menuItems[i].shortcut == a:shortcut
740
+            return i
741
+        endif
742
+    endfor
743
+
744
+    for i in range(0, self.selection)
745
+        if self.menuItems[i].shortcut == a:shortcut
746
+            return i
747
+        endif
748
+    endfor
749
+
750
+    return -1
751
+endfunction
752
+
753
+"FUNCTION: MenuController._setCmdheight() {{{3
754
+"sets &cmdheight to whatever is needed to display the menu
755
+function! s:MenuController._setCmdheight()
756
+    let &cmdheight = len(self.menuItems) + 3
757
+endfunction
758
+
759
+"FUNCTION: MenuController._saveOptions() {{{3
760
+"set any vim options that are required to make the menu work (saving their old
761
+"values)
762
+function! s:MenuController._saveOptions()
763
+    let self._oldLazyredraw = &lazyredraw
764
+    let self._oldCmdheight = &cmdheight
765
+    set nolazyredraw
766
+    call self._setCmdheight()
767
+endfunction
768
+
769
+"FUNCTION: MenuController._restoreOptions() {{{3
770
+"restore the options we saved in _saveOptions()
771
+function! s:MenuController._restoreOptions()
772
+    let &cmdheight = self._oldCmdheight
773
+    let &lazyredraw = self._oldLazyredraw
774
+endfunction
775
+
776
+"FUNCTION: MenuController._cursorDown() {{{3
777
+"move the cursor to the next menu item, skipping separators
778
+function! s:MenuController._cursorDown()
779
+    let done = 0
780
+    while !done
781
+        if self.selection < len(self.menuItems)-1
782
+            let self.selection += 1
783
+        else
784
+            let self.selection = 0
785
+        endif
786
+
787
+        if !self._current().isSeparator()
788
+            let done = 1
789
+        endif
790
+    endwhile
791
+endfunction
792
+
793
+"FUNCTION: MenuController._cursorUp() {{{3
794
+"move the cursor to the previous menu item, skipping separators
795
+function! s:MenuController._cursorUp()
796
+    let done = 0
797
+    while !done
798
+        if self.selection > 0
799
+            let self.selection -= 1
800
+        else
801
+            let self.selection = len(self.menuItems)-1
802
+        endif
803
+
804
+        if !self._current().isSeparator()
805
+            let done = 1
806
+        endif
807
+    endwhile
808
+endfunction
809
+
810
+"CLASS: MenuItem {{{2
811
+"============================================================
812
+let s:MenuItem = {}
813
+"FUNCTION: MenuItem.All() {{{3
814
+"get all top level menu items
815
+function! s:MenuItem.All()
816
+    if !exists("s:menuItems")
817
+        let s:menuItems = []
818
+    endif
819
+    return s:menuItems
820
+endfunction
821
+
822
+"FUNCTION: MenuItem.AllEnabled() {{{3
823
+"get all top level menu items that are currently enabled
824
+function! s:MenuItem.AllEnabled()
825
+    let toReturn = []
826
+    for i in s:MenuItem.All()
827
+        if i.enabled()
828
+            call add(toReturn, i)
829
+        endif
830
+    endfor
831
+    return toReturn
832
+endfunction
833
+
834
+"FUNCTION: MenuItem.Create(options) {{{3
835
+"make a new menu item and add it to the global list
836
+function! s:MenuItem.Create(options)
837
+    let newMenuItem = copy(self)
838
+
839
+    let newMenuItem.text = a:options['text']
840
+    let newMenuItem.shortcut = a:options['shortcut']
841
+    let newMenuItem.children = []
842
+
843
+    let newMenuItem.isActiveCallback = -1
844
+    if has_key(a:options, 'isActiveCallback')
845
+        let newMenuItem.isActiveCallback = a:options['isActiveCallback']
846
+    endif
847
+
848
+    let newMenuItem.callback = -1
849
+    if has_key(a:options, 'callback')
850
+        let newMenuItem.callback = a:options['callback']
851
+    endif
852
+
853
+    if has_key(a:options, 'parent')
854
+        call add(a:options['parent'].children, newMenuItem)
855
+    else
856
+        call add(s:MenuItem.All(), newMenuItem)
857
+    endif
858
+
859
+    return newMenuItem
860
+endfunction
861
+
862
+"FUNCTION: MenuItem.CreateSeparator(options) {{{3
863
+"make a new separator menu item and add it to the global list
864
+function! s:MenuItem.CreateSeparator(options)
865
+    let standard_options = { 'text': '--------------------',
866
+                \ 'shortcut': -1,
867
+                \ 'callback': -1 }
868
+    let options = extend(a:options, standard_options, "force")
869
+
870
+    return s:MenuItem.Create(options)
871
+endfunction
872
+
873
+"FUNCTION: MenuItem.CreateSubmenu(options) {{{3
874
+"make a new submenu and add it to global list
875
+function! s:MenuItem.CreateSubmenu(options)
876
+    let standard_options = { 'callback': -1 }
877
+    let options = extend(a:options, standard_options, "force")
878
+
879
+    return s:MenuItem.Create(options)
880
+endfunction
881
+
882
+"FUNCTION: MenuItem.enabled() {{{3
883
+"return 1 if this menu item should be displayed
884
+"
885
+"delegates off to the isActiveCallback, and defaults to 1 if no callback was
886
+"specified
887
+function! s:MenuItem.enabled()
888
+    if self.isActiveCallback != -1
889
+        return {self.isActiveCallback}()
890
+    endif
891
+    return 1
892
+endfunction
893
+
894
+"FUNCTION: MenuItem.execute() {{{3
895
+"perform the action behind this menu item, if this menuitem has children then
896
+"display a new menu for them, otherwise deletegate off to the menuitem's
897
+"callback
898
+function! s:MenuItem.execute()
899
+    if len(self.children)
900
+        let mc = s:MenuController.New(self.children)
901
+        call mc.showMenu()
902
+    else
903
+        if self.callback != -1
904
+            call {self.callback}()
905
+        endif
906
+    endif
907
+endfunction
908
+
909
+"FUNCTION: MenuItem.isSeparator() {{{3
910
+"return 1 if this menuitem is a separator
911
+function! s:MenuItem.isSeparator()
912
+    return self.callback == -1 && self.children == []
913
+endfunction
914
+
915
+"FUNCTION: MenuItem.isSubmenu() {{{3
916
+"return 1 if this menuitem is a submenu
917
+function! s:MenuItem.isSubmenu()
918
+    return self.callback == -1 && !empty(self.children)
919
+endfunction
920
+
921
+"CLASS: TreeFileNode {{{2
922
+"This class is the parent of the TreeDirNode class and constitures the
923
+"'Component' part of the composite design pattern between the treenode
924
+"classes.
925
+"============================================================
926
+let s:TreeFileNode = {}
927
+"FUNCTION: TreeFileNode.activate(...) {{{3
928
+function! s:TreeFileNode.activate(...)
929
+    call self.open(a:0 ? a:1 : {})
930
+endfunction
931
+"FUNCTION: TreeFileNode.bookmark(name) {{{3
932
+"bookmark this node with a:name
933
+function! s:TreeFileNode.bookmark(name)
934
+
935
+    "if a bookmark exists with the same name and the node is cached then save
936
+    "it so we can update its display string
937
+    let oldMarkedNode = {}
938
+    try
939
+        let oldMarkedNode = s:Bookmark.GetNodeForName(a:name, 1)
940
+    catch /^NERDTree.BookmarkNotFoundError/
941
+    catch /^NERDTree.BookmarkedNodeNotFoundError/
942
+    endtry
943
+
944
+    call s:Bookmark.AddBookmark(a:name, self.path)
945
+    call self.path.cacheDisplayString()
946
+    call s:Bookmark.Write()
947
+
948
+    if !empty(oldMarkedNode)
949
+        call oldMarkedNode.path.cacheDisplayString()
950
+    endif
951
+endfunction
952
+"FUNCTION: TreeFileNode.cacheParent() {{{3
953
+"initializes self.parent if it isnt already
954
+function! s:TreeFileNode.cacheParent()
955
+    if empty(self.parent)
956
+        let parentPath = self.path.getParent()
957
+        if parentPath.equals(self.path)
958
+            throw "NERDTree.CannotCacheParentError: already at root"
959
+        endif
960
+        let self.parent = s:TreeFileNode.New(parentPath)
961
+    endif
962
+endfunction
963
+"FUNCTION: TreeFileNode.compareNodes {{{3
964
+"This is supposed to be a class level method but i cant figure out how to
965
+"get func refs to work from a dict..
966
+"
967
+"A class level method that compares two nodes
968
+"
969
+"Args:
970
+"n1, n2: the 2 nodes to compare
971
+function! s:compareNodes(n1, n2)
972
+    return a:n1.path.compareTo(a:n2.path)
973
+endfunction
974
+
975
+"FUNCTION: TreeFileNode.clearBookmarks() {{{3
976
+function! s:TreeFileNode.clearBookmarks()
977
+    for i in s:Bookmark.Bookmarks()
978
+        if i.path.equals(self.path)
979
+            call i.delete()
980
+        end
981
+    endfor
982
+    call self.path.cacheDisplayString()
983
+endfunction
984
+"FUNCTION: TreeFileNode.copy(dest) {{{3
985
+function! s:TreeFileNode.copy(dest)
986
+    call self.path.copy(a:dest)
987
+    let newPath = s:Path.New(a:dest)
988
+    let parent = b:NERDTreeRoot.findNode(newPath.getParent())
989
+    if !empty(parent)
990
+        call parent.refresh()
991
+        return parent.findNode(newPath)
992
+    else
993
+        return {}
994
+    endif
995
+endfunction
996
+
997
+"FUNCTION: TreeFileNode.delete {{{3
998
+"Removes this node from the tree and calls the Delete method for its path obj
999
+function! s:TreeFileNode.delete()
1000
+    call self.path.delete()
1001
+    call self.parent.removeChild(self)
1002
+endfunction
1003
+
1004
+"FUNCTION: TreeFileNode.displayString() {{{3
1005
+"
1006
+"Returns a string that specifies how the node should be represented as a
1007
+"string
1008
+"
1009
+"Return:
1010
+"a string that can be used in the view to represent this node
1011
+function! s:TreeFileNode.displayString()
1012
+    return self.path.displayString()
1013
+endfunction
1014
+
1015
+"FUNCTION: TreeFileNode.equals(treenode) {{{3
1016
+"
1017
+"Compares this treenode to the input treenode and returns 1 if they are the
1018
+"same node.
1019
+"
1020
+"Use this method instead of ==  because sometimes when the treenodes contain
1021
+"many children, vim seg faults when doing ==
1022
+"
1023
+"Args:
1024
+"treenode: the other treenode to compare to
1025
+function! s:TreeFileNode.equals(treenode)
1026
+    return self.path.str() ==# a:treenode.path.str()
1027
+endfunction
1028
+
1029
+"FUNCTION: TreeFileNode.findNode(path) {{{3
1030
+"Returns self if this node.path.Equals the given path.
1031
+"Returns {} if not equal.
1032
+"
1033
+"Args:
1034
+"path: the path object to compare against
1035
+function! s:TreeFileNode.findNode(path)
1036
+    if a:path.equals(self.path)
1037
+        return self
1038
+    endif
1039
+    return {}
1040
+endfunction
1041
+"FUNCTION: TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) {{{3
1042
+"
1043
+"Finds the next sibling for this node in the indicated direction. This sibling
1044
+"must be a directory and may/may not have children as specified.
1045
+"
1046
+"Args:
1047
+"direction: 0 if you want to find the previous sibling, 1 for the next sibling
1048
+"
1049
+"Return:
1050
+"a treenode object or {} if no appropriate sibling could be found
1051
+function! s:TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction)
1052
+    "if we have no parent then we can have no siblings
1053
+    if self.parent != {}
1054
+        let nextSibling = self.findSibling(a:direction)
1055
+
1056
+        while nextSibling != {}
1057
+            if nextSibling.path.isDirectory && nextSibling.hasVisibleChildren() && nextSibling.isOpen
1058
+                return nextSibling
1059
+            endif
1060
+            let nextSibling = nextSibling.findSibling(a:direction)
1061
+        endwhile
1062
+    endif
1063
+
1064
+    return {}
1065
+endfunction
1066
+"FUNCTION: TreeFileNode.findSibling(direction) {{{3
1067
+"
1068
+"Finds the next sibling for this node in the indicated direction
1069
+"
1070
+"Args:
1071
+"direction: 0 if you want to find the previous sibling, 1 for the next sibling
1072
+"
1073
+"Return:
1074
+"a treenode object or {} if no sibling could be found
1075
+function! s:TreeFileNode.findSibling(direction)
1076
+    "if we have no parent then we can have no siblings
1077
+    if self.parent != {}
1078
+
1079
+        "get the index of this node in its parents children
1080
+        let siblingIndx = self.parent.getChildIndex(self.path)
1081
+
1082
+        if siblingIndx != -1
1083
+            "move a long to the next potential sibling node
1084
+            let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1
1085
+
1086
+            "keep moving along to the next sibling till we find one that is valid
1087
+            let numSiblings = self.parent.getChildCount()
1088
+            while siblingIndx >= 0 && siblingIndx < numSiblings
1089
+
1090
+                "if the next node is not an ignored node (i.e. wont show up in the
1091
+                "view) then return it
1092
+                if self.parent.children[siblingIndx].path.ignore() ==# 0
1093
+                    return self.parent.children[siblingIndx]
1094
+                endif
1095
+
1096
+                "go to next node
1097
+                let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1
1098
+            endwhile
1099
+        endif
1100
+    endif
1101
+
1102
+    return {}
1103
+endfunction
1104
+
1105
+"FUNCTION: TreeFileNode.getLineNum(){{{3
1106
+"returns the line number this node is rendered on, or -1 if it isnt rendered
1107
+function! s:TreeFileNode.getLineNum()
1108
+    "if the node is the root then return the root line no.
1109
+    if self.isRoot()
1110
+        return s:TreeFileNode.GetRootLineNum()
1111
+    endif
1112
+
1113
+    let totalLines = line("$")
1114
+
1115
+    "the path components we have matched so far
1116
+    let pathcomponents = [substitute(b:NERDTreeRoot.path.str({'format': 'UI'}), '/ *$', '', '')]
1117
+    "the index of the component we are searching for
1118
+    let curPathComponent = 1
1119
+
1120
+    let fullpath = self.path.str({'format': 'UI'})
1121
+
1122
+
1123
+    let lnum = s:TreeFileNode.GetRootLineNum()
1124
+    while lnum > 0
1125
+        let lnum = lnum + 1
1126
+        "have we reached the bottom of the tree?
1127
+        if lnum ==# totalLines+1
1128
+            return -1
1129
+        endif
1130
+
1131
+        let curLine = getline(lnum)
1132
+
1133
+        let indent = s:indentLevelFor(curLine)
1134
+        if indent ==# curPathComponent
1135
+            let curLine = s:stripMarkupFromLine(curLine, 1)
1136
+
1137
+            let curPath =  join(pathcomponents, '/') . '/' . curLine
1138
+            if stridx(fullpath, curPath, 0) ==# 0
1139
+                if fullpath ==# curPath || strpart(fullpath, len(curPath)-1,1) ==# '/'
1140
+                    let curLine = substitute(curLine, '/ *$', '', '')
1141
+                    call add(pathcomponents, curLine)
1142
+                    let curPathComponent = curPathComponent + 1
1143
+
1144
+                    if fullpath ==# curPath
1145
+                        return lnum
1146
+                    endif
1147
+                endif
1148
+            endif
1149
+        endif
1150
+    endwhile
1151
+    return -1
1152
+endfunction
1153
+
1154
+"FUNCTION: TreeFileNode.GetRootForTab(){{{3
1155
+"get the root node for this tab
1156
+function! s:TreeFileNode.GetRootForTab()
1157
+    if s:treeExistsForTab()
1158
+        return getbufvar(t:NERDTreeBufName, 'NERDTreeRoot')
1159
+    end
1160
+    return {}
1161
+endfunction
1162
+"FUNCTION: TreeFileNode.GetRootLineNum(){{{3
1163
+"gets the line number of the root node
1164
+function! s:TreeFileNode.GetRootLineNum()
1165
+    let rootLine = 1
1166
+    while getline(rootLine) !~# '^\(/\|<\)'
1167
+        let rootLine = rootLine + 1
1168
+    endwhile
1169
+    return rootLine
1170
+endfunction
1171
+
1172
+"FUNCTION: TreeFileNode.GetSelected() {{{3
1173
+"gets the treenode that the cursor is currently over
1174
+function! s:TreeFileNode.GetSelected()
1175
+    try
1176
+        let path = s:getPath(line("."))
1177
+        if path ==# {}
1178
+            return {}
1179
+        endif
1180
+        return b:NERDTreeRoot.findNode(path)
1181
+    catch /NERDTree/
1182
+        return {}
1183
+    endtry
1184
+endfunction
1185
+"FUNCTION: TreeFileNode.isVisible() {{{3
1186
+"returns 1 if this node should be visible according to the tree filters and
1187
+"hidden file filters (and their on/off status)
1188
+function! s:TreeFileNode.isVisible()
1189
+    return !self.path.ignore()
1190
+endfunction
1191
+"FUNCTION: TreeFileNode.isRoot() {{{3
1192
+"returns 1 if this node is b:NERDTreeRoot
1193
+function! s:TreeFileNode.isRoot()
1194
+    if !s:treeExistsForBuf()
1195
+        throw "NERDTree.NoTreeError: No tree exists for the current buffer"
1196
+    endif
1197
+
1198
+    return self.equals(b:NERDTreeRoot)
1199
+endfunction
1200
+
1201
+"FUNCTION: TreeFileNode.makeRoot() {{{3
1202
+"Make this node the root of the tree
1203
+function! s:TreeFileNode.makeRoot()
1204
+    if self.path.isDirectory
1205
+        let b:NERDTreeRoot = self
1206
+    else
1207
+        call self.cacheParent()
1208
+        let b:NERDTreeRoot = self.parent
1209
+    endif
1210
+
1211
+    call b:NERDTreeRoot.open()
1212
+
1213
+    "change dir to the dir of the new root if instructed to
1214
+    if g:NERDTreeChDirMode ==# 2
1215
+        exec "cd " . b:NERDTreeRoot.path.str({'format': 'Edit'})
1216
+    endif
1217
+
1218
+    silent doautocmd User NERDTreeNewRoot
1219
+endfunction
1220
+"FUNCTION: TreeFileNode.New(path) {{{3
1221
+"Returns a new TreeNode object with the given path and parent
1222
+"
1223
+"Args:
1224
+"path: a path object representing the full filesystem path to the file/dir that the node represents
1225
+function! s:TreeFileNode.New(path)
1226
+    if a:path.isDirectory
1227
+        return s:TreeDirNode.New(a:path)
1228
+    else
1229
+        let newTreeNode = copy(self)
1230
+        let newTreeNode.path = a:path
1231
+        let newTreeNode.parent = {}
1232
+        return newTreeNode
1233
+    endif
1234
+endfunction
1235
+
1236
+"FUNCTION: TreeFileNode.open() {{{3
1237
+function! s:TreeFileNode.open(...)
1238
+    let opts = a:0 ? a:1 : {}
1239
+    let opener = s:Opener.New(self.path, opts)
1240
+    call opener.open(self)
1241
+endfunction
1242
+
1243
+"FUNCTION: TreeFileNode.openSplit() {{{3
1244
+"Open this node in a new window
1245
+function! s:TreeFileNode.openSplit()
1246
+    call s:deprecated('TreeFileNode.openSplit', 'is deprecated, use .open() instead.')
1247
+    call self.open({'where': 'h'})
1248
+endfunction
1249
+"FUNCTION: TreeFileNode.openVSplit() {{{3
1250
+"Open this node in a new vertical window
1251
+function! s:TreeFileNode.openVSplit()
1252
+    call s:deprecated('TreeFileNode.openVSplit', 'is deprecated, use .open() instead.')
1253
+    call self.open({'where': 'v'})
1254
+endfunction
1255
+"FUNCTION: TreeFileNode.openInNewTab(options) {{{3
1256
+function! s:TreeFileNode.openInNewTab(options)
1257
+    echomsg 'TreeFileNode.openInNewTab is deprecated'
1258
+    call self.open(extend({'where': 't'}, a:options))
1259
+endfunction
1260
+"FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{3
1261
+"Places the cursor on the line number this node is rendered on
1262
+"
1263
+"Args:
1264
+"isJump: 1 if this cursor movement should be counted as a jump by vim
1265
+"recurseUpward: try to put the cursor on the parent if the this node isnt
1266
+"visible
1267
+function! s:TreeFileNode.putCursorHere(isJump, recurseUpward)
1268
+    let ln = self.getLineNum()
1269
+    if ln != -1
1270
+        if a:isJump
1271
+            mark '
1272
+        endif
1273
+        call cursor(ln, col("."))
1274
+    else
1275
+        if a:recurseUpward
1276
+            let node = self
1277
+            while node != {} && node.getLineNum() ==# -1
1278
+                let node = node.parent
1279
+                call node.open()
1280
+            endwhile
1281
+            call s:renderView()
1282
+            call node.putCursorHere(a:isJump, 0)
1283
+        endif
1284
+    endif
1285
+endfunction
1286
+
1287
+"FUNCTION: TreeFileNode.refresh() {{{3
1288
+function! s:TreeFileNode.refresh()
1289
+    call self.path.refresh()
1290
+endfunction
1291
+"FUNCTION: TreeFileNode.rename() {{{3
1292
+"Calls the rename method for this nodes path obj
1293
+function! s:TreeFileNode.rename(newName)
1294
+    let newName = substitute(a:newName, '\(\\\|\/\)$', '', '')
1295
+    call self.path.rename(newName)
1296
+    call self.parent.removeChild(self)
1297
+
1298
+    let parentPath = self.path.getParent()
1299
+    let newParent = b:NERDTreeRoot.findNode(parentPath)
1300
+
1301
+    if newParent != {}
1302
+        call newParent.createChild(self.path, 1)
1303
+        call newParent.refresh()
1304
+    endif
1305
+endfunction
1306
+"FUNCTION: TreeFileNode.renderToString {{{3
1307
+"returns a string representation for this tree to be rendered in the view
1308
+function! s:TreeFileNode.renderToString()
1309
+    return self._renderToString(0, 0, [], self.getChildCount() ==# 1)
1310
+endfunction
1311
+
1312
+
1313
+"Args:
1314
+"depth: the current depth in the tree for this call
1315
+"drawText: 1 if we should actually draw the line for this node (if 0 then the
1316
+"child nodes are rendered only)
1317
+"vertMap: a binary array that indicates whether a vertical bar should be draw
1318
+"for each depth in the tree
1319
+"isLastChild:true if this curNode is the last child of its parent
1320
+function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild)
1321
+    let output = ""
1322
+    if a:drawText ==# 1
1323
+
1324
+        let treeParts = ''
1325
+
1326
+        "get all the leading spaces and vertical tree parts for this line
1327
+        if a:depth > 1
1328
+            for j in a:vertMap[0:-2]
1329
+                if g:NERDTreeDirArrows
1330
+                    let treeParts = treeParts . '  '
1331
+                else
1332
+                    if j ==# 1
1333
+                        let treeParts = treeParts . '| '
1334
+                    else
1335
+                        let treeParts = treeParts . '  '
1336
+                    endif
1337
+                endif
1338
+            endfor
1339
+        endif
1340
+
1341
+        "get the last vertical tree part for this line which will be different
1342
+        "if this node is the last child of its parent
1343
+        if !g:NERDTreeDirArrows
1344
+            if a:isLastChild
1345
+                let treeParts = treeParts . '`'
1346
+            else
1347
+                let treeParts = treeParts . '|'
1348
+            endif
1349
+        endif
1350
+
1351
+        "smack the appropriate dir/file symbol on the line before the file/dir
1352
+        "name itself
1353
+        if self.path.isDirectory
1354
+            if self.isOpen
1355
+                if g:NERDTreeDirArrows
1356
+                    let treeParts = treeParts . 'â–¾ '
1357
+                else
1358
+                    let treeParts = treeParts . '~'
1359
+                endif
1360
+            else
1361
+                if g:NERDTreeDirArrows
1362
+                    let treeParts = treeParts . 'â–¸ '
1363
+                else
1364
+                    let treeParts = treeParts . '+'
1365
+                endif
1366
+            endif
1367
+        else
1368
+            if g:NERDTreeDirArrows
1369
+                let treeParts = treeParts . '  '
1370
+            else
1371
+                let treeParts = treeParts . '-'
1372
+            endif
1373
+        endif
1374
+        let line = treeParts . self.displayString()
1375
+
1376
+        let output = output . line . "\n"
1377
+    endif
1378
+
1379
+    "if the node is an open dir, draw its children
1380
+    if self.path.isDirectory ==# 1 && self.isOpen ==# 1
1381
+
1382
+        let childNodesToDraw = self.getVisibleChildren()
1383
+        if len(childNodesToDraw) > 0
1384
+
1385
+            "draw all the nodes children except the last
1386
+            let lastIndx = len(childNodesToDraw)-1
1387
+            if lastIndx > 0
1388
+                for i in childNodesToDraw[0:lastIndx-1]
1389
+                    let output = output . i._renderToString(a:depth + 1, 1, add(copy(a:vertMap), 1), 0)
1390
+                endfor
1391
+            endif
1392
+
1393
+            "draw the last child, indicating that it IS the last
1394
+            let output = output . childNodesToDraw[lastIndx]._renderToString(a:depth + 1, 1, add(copy(a:vertMap), 0), 1)
1395
+        endif
1396
+    endif
1397
+
1398
+    return output
1399
+endfunction
1400
+"CLASS: TreeDirNode {{{2
1401
+"This class is a child of the TreeFileNode class and constitutes the
1402
+"'Composite' part of the composite design pattern between the treenode
1403
+"classes.
1404
+"============================================================
1405
+let s:TreeDirNode = copy(s:TreeFileNode)
1406
+"FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{3
1407
+"class method that returns the highest cached ancestor of the current root
1408
+function! s:TreeDirNode.AbsoluteTreeRoot()
1409
+    let currentNode = b:NERDTreeRoot
1410
+    while currentNode.parent != {}
1411
+        let currentNode = currentNode.parent
1412
+    endwhile
1413
+    return currentNode
1414
+endfunction
1415
+"FUNCTION: TreeDirNode.activate([options]) {{{3
1416
+unlet s:TreeDirNode.activate
1417
+function! s:TreeDirNode.activate(...)
1418
+    let opts = a:0 ? a:1 : {}
1419
+    call self.toggleOpen(opts)
1420
+    call s:renderView()
1421
+    call self.putCursorHere(0, 0)
1422
+endfunction
1423
+"FUNCTION: TreeDirNode.addChild(treenode, inOrder) {{{3
1424
+"Adds the given treenode to the list of children for this node
1425
+"
1426
+"Args:
1427
+"-treenode: the node to add
1428
+"-inOrder: 1 if the new node should be inserted in sorted order
1429
+function! s:TreeDirNode.addChild(treenode, inOrder)
1430
+    call add(self.children, a:treenode)
1431
+    let a:treenode.parent = self
1432
+
1433
+    if a:inOrder
1434
+        call self.sortChildren()
1435
+    endif
1436
+endfunction
1437
+
1438
+"FUNCTION: TreeDirNode.close() {{{3
1439
+"Closes this directory
1440
+function! s:TreeDirNode.close()
1441
+    let self.isOpen = 0
1442
+endfunction
1443
+
1444
+"FUNCTION: TreeDirNode.closeChildren() {{{3
1445
+"Closes all the child dir nodes of this node
1446
+function! s:TreeDirNode.closeChildren()
1447
+    for i in self.children
1448
+        if i.path.isDirectory
1449
+            call i.close()
1450
+            call i.closeChildren()
1451
+        endif
1452
+    endfor
1453
+endfunction
1454
+
1455
+"FUNCTION: TreeDirNode.createChild(path, inOrder) {{{3
1456
+"Instantiates a new child node for this node with the given path. The new
1457
+"nodes parent is set to this node.
1458
+"
1459
+"Args:
1460
+"path: a Path object that this node will represent/contain
1461
+"inOrder: 1 if the new node should be inserted in sorted order
1462
+"
1463
+"Returns:
1464
+"the newly created node
1465
+function! s:TreeDirNode.createChild(path, inOrder)
1466
+    let newTreeNode = s:TreeFileNode.New(a:path)
1467
+    call self.addChild(newTreeNode, a:inOrder)
1468
+    return newTreeNode
1469
+endfunction
1470
+
1471
+"FUNCTION: TreeDirNode.findNode(path) {{{3
1472
+"Will find one of the children (recursively) that has the given path
1473
+"
1474
+"Args:
1475
+"path: a path object
1476
+unlet s:TreeDirNode.findNode
1477
+function! s:TreeDirNode.findNode(path)
1478
+    if a:path.equals(self.path)
1479
+        return self
1480
+    endif
1481
+    if stridx(a:path.str(), self.path.str(), 0) ==# -1
1482
+        return {}
1483
+    endif
1484
+
1485
+    if self.path.isDirectory
1486
+        for i in self.children
1487
+            let retVal = i.findNode(a:path)
1488
+            if retVal != {}
1489
+                return retVal
1490
+            endif
1491
+        endfor
1492
+    endif
1493
+    return {}
1494
+endfunction
1495
+"FUNCTION: TreeDirNode.getChildCount() {{{3
1496
+"Returns the number of children this node has
1497
+function! s:TreeDirNode.getChildCount()
1498
+    return len(self.children)
1499
+endfunction
1500
+
1501
+"FUNCTION: TreeDirNode.getChild(path) {{{3
1502
+"Returns child node of this node that has the given path or {} if no such node
1503
+"exists.
1504
+"
1505
+"This function doesnt not recurse into child dir nodes
1506
+"
1507
+"Args:
1508
+"path: a path object
1509
+function! s:TreeDirNode.getChild(path)
1510
+    if stridx(a:path.str(), self.path.str(), 0) ==# -1
1511
+        return {}
1512
+    endif
1513
+
1514
+    let index = self.getChildIndex(a:path)
1515
+    if index ==# -1
1516
+        return {}
1517
+    else
1518
+        return self.children[index]
1519
+    endif
1520
+
1521
+endfunction
1522
+
1523
+"FUNCTION: TreeDirNode.getChildByIndex(indx, visible) {{{3
1524
+"returns the child at the given index
1525
+"Args:
1526
+"indx: the index to get the child from
1527
+"visible: 1 if only the visible children array should be used, 0 if all the
1528
+"children should be searched.
1529
+function! s:TreeDirNode.getChildByIndex(indx, visible)
1530
+    let array_to_search = a:visible? self.getVisibleChildren() : self.children
1531
+    if a:indx > len(array_to_search)
1532
+        throw "NERDTree.InvalidArgumentsError: Index is out of bounds."
1533
+    endif
1534
+    return array_to_search[a:indx]
1535
+endfunction
1536
+
1537
+"FUNCTION: TreeDirNode.getChildIndex(path) {{{3
1538
+"Returns the index of the child node of this node that has the given path or
1539
+"-1 if no such node exists.
1540
+"
1541
+"This function doesnt not recurse into child dir nodes
1542
+"
1543
+"Args:
1544
+"path: a path object
1545
+function! s:TreeDirNode.getChildIndex(path)
1546
+    if stridx(a:path.str(), self.path.str(), 0) ==# -1
1547
+        return -1
1548
+    endif
1549
+
1550
+    "do a binary search for the child
1551
+    let a = 0
1552
+    let z = self.getChildCount()
1553
+    while a < z
1554
+        let mid = (a+z)/2
1555
+        let diff = a:path.compareTo(self.children[mid].path)
1556
+
1557
+        if diff ==# -1
1558
+            let z = mid
1559
+        elseif diff ==# 1
1560
+            let a = mid+1
1561
+        else
1562
+            return mid
1563
+        endif
1564
+    endwhile
1565
+    return -1
1566
+endfunction
1567
+
1568
+"FUNCTION: TreeDirNode.GetSelected() {{{3
1569
+"Returns the current node if it is a dir node, or else returns the current
1570
+"nodes parent
1571
+unlet s:TreeDirNode.GetSelected
1572
+function! s:TreeDirNode.GetSelected()
1573
+    let currentDir = s:TreeFileNode.GetSelected()
1574
+    if currentDir != {} && !currentDir.isRoot()
1575
+        if currentDir.path.isDirectory ==# 0
1576
+            let currentDir = currentDir.parent
1577
+        endif
1578
+    endif
1579
+    return currentDir
1580
+endfunction
1581
+"FUNCTION: TreeDirNode.getVisibleChildCount() {{{3
1582
+"Returns the number of visible children this node has
1583
+function! s:TreeDirNode.getVisibleChildCount()
1584
+    return len(self.getVisibleChildren())
1585
+endfunction
1586
+
1587
+"FUNCTION: TreeDirNode.getVisibleChildren() {{{3
1588
+"Returns a list of children to display for this node, in the correct order
1589
+"
1590
+"Return:
1591
+"an array of treenodes
1592
+function! s:TreeDirNode.getVisibleChildren()
1593
+    let toReturn = []
1594
+    for i in self.children
1595
+        if i.path.ignore() ==# 0
1596
+            call add(toReturn, i)
1597
+        endif
1598
+    endfor
1599
+    return toReturn
1600
+endfunction
1601
+
1602
+"FUNCTION: TreeDirNode.hasVisibleChildren() {{{3
1603
+"returns 1 if this node has any childre, 0 otherwise..
1604
+function! s:TreeDirNode.hasVisibleChildren()
1605
+    return self.getVisibleChildCount() != 0
1606
+endfunction
1607
+
1608
+"FUNCTION: TreeDirNode._initChildren() {{{3
1609
+"Removes all childen from this node and re-reads them
1610
+"
1611
+"Args:
1612
+"silent: 1 if the function should not echo any "please wait" messages for
1613
+"large directories
1614
+"
1615
+"Return: the number of child nodes read
1616
+function! s:TreeDirNode._initChildren(silent)
1617
+    "remove all the current child nodes
1618
+    let self.children = []
1619
+
1620
+    "get an array of all the files in the nodes dir
1621
+    let dir = self.path
1622
+    let globDir = dir.str({'format': 'Glob'})
1623
+
1624
+    if version >= 703
1625
+        let filesStr = globpath(globDir, '*', 1) . "\n" . globpath(globDir, '.*', 1)
1626
+    else
1627
+        let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*')
1628
+    endif
1629
+
1630
+    let files = split(filesStr, "\n")
1631
+
1632
+    if !a:silent && len(files) > g:NERDTreeNotificationThreshold
1633
+        call s:echo("Please wait, caching a large dir ...")
1634
+    endif
1635
+
1636
+    let invalidFilesFound = 0
1637
+    for i in files
1638
+
1639
+        "filter out the .. and . directories
1640
+        "Note: we must match .. AND ../ cos sometimes the globpath returns
1641
+        "../ for path with strange chars (eg $)
1642
+        if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$'
1643
+
1644
+            "put the next file in a new node and attach it
1645
+            try
1646
+                let path = s:Path.New(i)
1647
+                call self.createChild(path, 0)
1648
+            catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/
1649
+                let invalidFilesFound += 1
1650
+            endtry
1651
+        endif
1652
+    endfor
1653
+
1654
+    call self.sortChildren()
1655
+
1656
+    if !a:silent && len(files) > g:NERDTreeNotificationThreshold
1657
+        call s:echo("Please wait, caching a large dir ... DONE (". self.getChildCount() ." nodes cached).")
1658
+    endif
1659
+
1660
+    if invalidFilesFound
1661
+        call s:echoWarning(invalidFilesFound . " file(s) could not be loaded into the NERD tree")
1662
+    endif
1663
+    return self.getChildCount()
1664
+endfunction
1665
+"FUNCTION: TreeDirNode.New(path) {{{3
1666
+"Returns a new TreeNode object with the given path and parent
1667
+"
1668
+"Args:
1669
+"path: a path object representing the full filesystem path to the file/dir that the node represents
1670
+unlet s:TreeDirNode.New
1671
+function! s:TreeDirNode.New(path)
1672
+    if a:path.isDirectory != 1
1673
+        throw "NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object."
1674
+    endif
1675
+
1676
+    let newTreeNode = copy(self)
1677
+    let newTreeNode.path = a:path
1678
+
1679
+    let newTreeNode.isOpen = 0
1680
+    let newTreeNode.children = []
1681
+
1682
+    let newTreeNode.parent = {}
1683
+
1684
+    return newTreeNode
1685
+endfunction
1686
+"FUNCTION: TreeDirNode.open([opts]) {{{3
1687
+"Open the dir in the current tree or in a new tree elsewhere.
1688
+"
1689
+"If opening in the current tree, return the number of cached nodes.
1690
+unlet s:TreeDirNode.open
1691
+function! s:TreeDirNode.open(...)
1692
+    let opts = a:0 ? a:1 : {}
1693
+
1694
+    if has_key(opts, 'where') && !empty(opts['where'])
1695
+        let opener = s:Opener.New(self.path, opts)
1696
+        call opener.open(self)
1697
+    else
1698
+        let self.isOpen = 1
1699
+        if self.children ==# []
1700
+            return self._initChildren(0)
1701
+        else
1702
+            return 0
1703
+        endif
1704
+    endif
1705
+endfunction
1706
+"FUNCTION: TreeDirNode.openAlong([opts]) {{{3
1707
+"recursive open the dir if it has only one directory child.
1708
+"
1709
+"return the level of opened directories.
1710
+function! s:TreeDirNode.openAlong(...)
1711
+    let opts = a:0 ? a:1 : {}
1712
+    let level = 0
1713
+
1714
+    let node = self
1715
+    while node.path.isDirectory
1716
+        call node.open(opts)
1717
+        let level += 1
1718
+        if node.getVisibleChildCount() == 1
1719
+            let node = node.getChildByIndex(0, 1)
1720
+        else
1721
+            break
1722
+        endif
1723
+    endwhile
1724
+    return level
1725
+endfunction
1726
+" FUNCTION: TreeDirNode.openExplorer() {{{3
1727
+" opens an explorer window for this node in the previous window (could be a
1728
+" nerd tree or a netrw)
1729
+function! s:TreeDirNode.openExplorer()
1730
+    call self.open({'where': 'p'})
1731
+endfunction
1732
+"FUNCTION: TreeDirNode.openInNewTab(options) {{{3
1733
+unlet s:TreeDirNode.openInNewTab
1734
+function! s:TreeDirNode.openInNewTab(options)
1735
+    call s:deprecated('TreeDirNode.openInNewTab', 'is deprecated, use open() instead')
1736
+    call self.open({'where': 't'})
1737
+endfunction
1738
+"FUNCTION: TreeDirNode._openInNewTab() {{{3
1739
+function! s:TreeDirNode._openInNewTab()
1740
+    tabnew
1741
+    call s:initNerdTree(self.path.str())
1742
+endfunction
1743
+"FUNCTION: TreeDirNode.openRecursively() {{{3
1744
+"Opens this treenode and all of its children whose paths arent 'ignored'
1745
+"because of the file filters.
1746
+"
1747
+"This method is actually a wrapper for the OpenRecursively2 method which does
1748
+"the work.
1749
+function! s:TreeDirNode.openRecursively()
1750
+    call self._openRecursively2(1)
1751
+endfunction
1752
+
1753
+"FUNCTION: TreeDirNode._openRecursively2() {{{3
1754
+"Opens this all children of this treenode recursively if either:
1755
+"   *they arent filtered by file filters
1756
+"   *a:forceOpen is 1
1757
+"
1758
+"Args:
1759
+"forceOpen: 1 if this node should be opened regardless of file filters
1760
+function! s:TreeDirNode._openRecursively2(forceOpen)
1761
+    if self.path.ignore() ==# 0 || a:forceOpen
1762
+        let self.isOpen = 1
1763
+        if self.children ==# []
1764
+            call self._initChildren(1)
1765
+        endif
1766
+
1767
+        for i in self.children
1768
+            if i.path.isDirectory ==# 1
1769
+                call i._openRecursively2(0)
1770
+            endif
1771
+        endfor
1772
+    endif
1773
+endfunction
1774
+
1775
+"FUNCTION: TreeDirNode.refresh() {{{3
1776
+unlet s:TreeDirNode.refresh
1777
+function! s:TreeDirNode.refresh()
1778
+    call self.path.refresh()
1779
+
1780
+    "if this node was ever opened, refresh its children
1781
+    if self.isOpen || !empty(self.children)
1782
+        "go thru all the files/dirs under this node
1783
+        let newChildNodes = []
1784
+        let invalidFilesFound = 0
1785
+        let dir = self.path
1786
+        let globDir = dir.str({'format': 'Glob'})
1787
+        let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*')
1788
+        let files = split(filesStr, "\n")
1789
+        for i in files
1790
+            "filter out the .. and . directories
1791
+            "Note: we must match .. AND ../ cos sometimes the globpath returns
1792
+            "../ for path with strange chars (eg $)
1793
+            if i !~# '\/\.\.\/\?$' && i !~# '\/\.\/\?$'
1794
+
1795
+                try
1796
+                    "create a new path and see if it exists in this nodes children
1797
+                    let path = s:Path.New(i)
1798
+                    let newNode = self.getChild(path)
1799
+                    if newNode != {}
1800
+                        call newNode.refresh()
1801
+                        call add(newChildNodes, newNode)
1802
+
1803
+                    "the node doesnt exist so create it
1804
+                    else
1805
+                        let newNode = s:TreeFileNode.New(path)
1806
+                        let newNode.parent = self
1807
+                        call add(newChildNodes, newNode)
1808
+                    endif
1809
+
1810
+
1811
+                catch /^NERDTree.InvalidArgumentsError/
1812
+                    let invalidFilesFound = 1
1813
+                endtry
1814
+            endif
1815
+        endfor
1816
+
1817
+        "swap this nodes children out for the children we just read/refreshed
1818
+        let self.children = newChildNodes
1819
+        call self.sortChildren()
1820
+
1821
+        if invalidFilesFound
1822
+            call s:echoWarning("some files could not be loaded into the NERD tree")
1823
+        endif
1824
+    endif
1825
+endfunction
1826
+
1827
+"FUNCTION: TreeDirNode.reveal(path) {{{3
1828
+"reveal the given path, i.e. cache and open all treenodes needed to display it
1829
+"in the UI
1830
+function! s:TreeDirNode.reveal(path)
1831
+    if !a:path.isUnder(self.path)
1832
+        throw "NERDTree.InvalidArgumentsError: " . a:path.str() . " should be under " . self.path.str()
1833
+    endif
1834
+
1835
+    call self.open()
1836
+
1837
+    if self.path.equals(a:path.getParent())
1838
+        let n = self.findNode(a:path)
1839
+        call s:renderView()
1840
+        call n.putCursorHere(1,0)
1841
+        return
1842
+    endif
1843
+
1844
+    let p = a:path
1845
+    while !p.getParent().equals(self.path)
1846
+        let p = p.getParent()
1847
+    endwhile
1848
+
1849
+    let n = self.findNode(p)
1850
+    call n.reveal(a:path)
1851
+endfunction
1852
+"FUNCTION: TreeDirNode.removeChild(treenode) {{{3
1853
+"
1854
+"Removes the given treenode from this nodes set of children
1855
+"
1856
+"Args:
1857
+"treenode: the node to remove
1858
+"
1859
+"Throws a NERDTree.ChildNotFoundError if the given treenode is not found
1860
+function! s:TreeDirNode.removeChild(treenode)
1861
+    for i in range(0, self.getChildCount()-1)
1862
+        if self.children[i].equals(a:treenode)
1863
+            call remove(self.children, i)
1864
+            return
1865
+        endif
1866
+    endfor
1867
+
1868
+    throw "NERDTree.ChildNotFoundError: child node was not found"
1869
+endfunction
1870
+
1871
+"FUNCTION: TreeDirNode.sortChildren() {{{3
1872
+"
1873
+"Sorts the children of this node according to alphabetical order and the
1874
+"directory priority.
1875
+"
1876
+function! s:TreeDirNode.sortChildren()
1877
+    let CompareFunc = function("s:compareNodes")
1878
+    call sort(self.children, CompareFunc)
1879
+endfunction
1880
+
1881
+"FUNCTION: TreeDirNode.toggleOpen([options]) {{{3
1882
+"Opens this directory if it is closed and vice versa
1883
+function! s:TreeDirNode.toggleOpen(...)
1884
+    let opts = a:0 ? a:1 : {}
1885
+    if self.isOpen ==# 1
1886
+        call self.close()
1887
+    else
1888
+        if g:NERDTreeCasadeOpenSingleChildDir == 0
1889
+            call self.open(opts)
1890
+        else
1891
+            call self.openAlong(opts)
1892
+        endif
1893
+    endif
1894
+endfunction
1895
+"FUNCTION: TreeDirNode.transplantChild(newNode) {{{3
1896
+"Replaces the child of this with the given node (where the child node's full
1897
+"path matches a:newNode's fullpath). The search for the matching node is
1898
+"non-recursive
1899
+"
1900
+"Arg:
1901
+"newNode: the node to graft into the tree
1902
+function! s:TreeDirNode.transplantChild(newNode)
1903
+    for i in range(0, self.getChildCount()-1)
1904
+        if self.children[i].equals(a:newNode)
1905
+            let self.children[i] = a:newNode
1906
+            let a:newNode.parent = self
1907
+            break
1908
+        endif
1909
+    endfor
1910
+endfunction
1911
+"============================================================
1912
+"CLASS: Opener {{{2
1913
+"============================================================
1914
+let s:Opener = {}
1915
+
1916
+"FUNCTION: Opener._checkToCloseTree(newtab) {{{3
1917
+"Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see
1918
+"if the tree should be closed now.
1919
+"
1920
+"Args:
1921
+"a:newtab - boolean. If set, only close the tree now if we are opening the
1922
+"target in a new tab. This is needed because we have to close tree before we
1923
+"leave the tab
1924
+function! s:Opener._checkToCloseTree(newtab)
1925
+    if self._keepopen
1926
+        return
1927
+    endif
1928
+
1929
+    if (a:newtab && self._where == 't') || !a:newtab
1930
+        call s:closeTreeIfQuitOnOpen()
1931
+    endif
1932
+endfunction
1933
+
1934
+"FUNCTION: Opener._gotoTargetWin() {{{3
1935
+function! s:Opener._gotoTargetWin()
1936
+    if b:NERDTreeType ==# "secondary"
1937
+        if self._where == 'v'
1938
+            vsplit
1939
+        elseif self._where == 'h'
1940
+            split
1941
+        elseif self._where == 't'
1942
+            tabnew
1943
+        endif
1944
+    else
1945
+        call self._checkToCloseTree(1)
1946
+
1947
+        if self._where == 'v'
1948
+            call self._newVSplit()
1949
+        elseif self._where == 'h'
1950
+            call self._newSplit()
1951
+        elseif self._where == 't'
1952
+            tabnew
1953
+        elseif self._where == 'p'
1954
+            call self._previousWindow()
1955
+        endif
1956
+
1957
+        call self._checkToCloseTree(0)
1958
+    endif
1959
+endfunction
1960
+
1961
+"FUNCTION: Opener.New(path, opts) {{{3
1962
+"Args:
1963
+"
1964
+"a:path: The path object that is to be opened.
1965
+"
1966
+"a:opts:
1967
+"
1968
+"A dictionary containing the following keys (all optional):
1969
+"  'where': Specifies whether the node should be opened in new split/tab or in
1970
+"           the previous window. Can be either 'v' or 'h' or 't' (for open in
1971
+"           new tab)
1972
+"  'reuse': if a window is displaying the file then jump the cursor there
1973
+"  'keepopen': dont close the tree window
1974
+"  'stay': open the file, but keep the cursor in the tree win
1975
+function! s:Opener.New(path, opts)
1976
+    let newObj = copy(self)
1977
+
1978
+    let newObj._path = a:path
1979
+    let newObj._stay = s:has_opt(a:opts, 'stay')
1980
+    let newObj._reuse = s:has_opt(a:opts, 'reuse')
1981
+    let newObj._keepopen = s:has_opt(a:opts, 'keepopen')
1982
+    let newObj._where = has_key(a:opts, 'where') ? a:opts['where'] : ''
1983
+    let newObj._treetype = b:NERDTreeType
1984
+    call newObj._saveCursorPos()
1985
+
1986
+    return newObj
1987
+endfunction
1988
+
1989
+"FUNCTION: Opener._newSplit() {{{3
1990
+function! s:Opener._newSplit()
1991
+    " Save the user's settings for splitbelow and splitright
1992
+    let savesplitbelow=&splitbelow
1993
+    let savesplitright=&splitright
1994
+
1995
+    " 'there' will be set to a command to move from the split window
1996
+    " back to the explorer window
1997
+    "
1998
+    " 'back' will be set to a command to move from the explorer window
1999
+    " back to the newly split window
2000
+    "
2001
+    " 'right' and 'below' will be set to the settings needed for
2002
+    " splitbelow and splitright IF the explorer is the only window.
2003
+    "
2004
+    let there= g:NERDTreeWinPos ==# "left" ? "wincmd h" : "wincmd l"
2005
+    let back = g:NERDTreeWinPos ==# "left" ? "wincmd l" : "wincmd h"
2006
+    let right= g:NERDTreeWinPos ==# "left"
2007
+    let below=0
2008
+
2009
+    " Attempt to go to adjacent window
2010
+    call s:exec(back)
2011
+
2012
+    let onlyOneWin = (winnr("$") ==# 1)
2013
+
2014
+    " If no adjacent window, set splitright and splitbelow appropriately
2015
+    if onlyOneWin
2016
+        let &splitright=right
2017
+        let &splitbelow=below
2018
+    else
2019
+        " found adjacent window - invert split direction
2020
+        let &splitright=!right
2021
+        let &splitbelow=!below
2022
+    endif
2023
+
2024
+    let splitMode = onlyOneWin ? "vertical" : ""
2025
+
2026
+    " Open the new window
2027
+    try
2028
+        exec(splitMode." sp ")
2029
+    catch /^Vim\%((\a\+)\)\=:E37/
2030
+        call s:putCursorInTreeWin()
2031
+        throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified."
2032
+    catch /^Vim\%((\a\+)\)\=:/
2033
+        "do nothing
2034
+    endtry
2035
+
2036
+    "resize the tree window if no other window was open before
2037
+    if onlyOneWin
2038
+        let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
2039
+        call s:exec(there)
2040
+        exec("silent ". splitMode ." resize ". size)
2041
+        call s:exec('wincmd p')
2042
+    endif
2043
+
2044
+    " Restore splitmode settings
2045
+    let &splitbelow=savesplitbelow
2046
+    let &splitright=savesplitright
2047
+endfunction
2048
+
2049
+"FUNCTION: Opener._newVSplit() {{{3
2050
+function! s:Opener._newVSplit()
2051
+    let winwidth = winwidth(".")
2052
+    if winnr("$")==#1
2053
+        let winwidth = g:NERDTreeWinSize
2054
+    endif
2055
+
2056
+    call s:exec("wincmd p")
2057
+    vnew
2058
+
2059
+    "resize the nerd tree back to the original size
2060
+    call s:putCursorInTreeWin()
2061
+    exec("silent vertical resize ". winwidth)
2062
+    call s:exec('wincmd p')
2063
+endfunction
2064
+
2065
+"FUNCTION: Opener.open(target) {{{3
2066
+function! s:Opener.open(target)
2067
+    if self._path.isDirectory
2068
+        call self._openDirectory(a:target)
2069
+    else
2070
+        call self._openFile()
2071
+    endif
2072
+endfunction
2073
+
2074
+"FUNCTION: Opener._openFile() {{{3
2075
+function! s:Opener._openFile()
2076
+    if self._reuse && self._reuseWindow()
2077
+        return
2078
+    endif
2079
+
2080
+    call self._gotoTargetWin()
2081
+
2082
+    if self._treetype ==# "secondary"
2083
+        call self._path.edit()
2084
+    else
2085
+        call self._path.edit()
2086
+
2087
+
2088
+        if self._stay
2089
+            call self._restoreCursorPos()
2090
+        endif
2091
+    endif
2092
+endfunction
2093
+
2094
+"FUNCTION: Opener._openDirectory(node) {{{3
2095
+function! s:Opener._openDirectory(node)
2096
+    if self._treetype ==# "secondary"
2097
+        call self._gotoTargetWin()
2098
+        call s:initNerdTreeInPlace(a:node.path.str())
2099
+    else
2100
+        call self._gotoTargetWin()
2101
+        if empty(self._where)
2102
+            call a:node.makeRoot()
2103
+            call s:renderView()
2104
+            call a:node.putCursorHere(0, 0)
2105
+        elseif self._where == 't'
2106
+            call s:initNerdTree(a:node.path.str())
2107
+        else
2108
+            call s:initNerdTreeInPlace(a:node.path.str())
2109
+        endif
2110
+    endif
2111
+
2112
+    if self._stay
2113
+        call self._restoreCursorPos()
2114
+    endif
2115
+endfunction
2116
+
2117
+"FUNCTION: Opener._previousWindow() {{{3
2118
+function! s:Opener._previousWindow()
2119
+    if !s:isWindowUsable(winnr("#")) && s:firstUsableWindow() ==# -1
2120
+        call self._newSplit()
2121
+    else
2122
+        try
2123
+            if !s:isWindowUsable(winnr("#"))
2124
+                call s:exec(s:firstUsableWindow() . "wincmd w")
2125
+            else
2126
+                call s:exec('wincmd p')
2127
+            endif
2128
+        catch /^Vim\%((\a\+)\)\=:E37/
2129
+            call s:putCursorInTreeWin()
2130
+            throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self._path.str() ." is already open and modified."
2131
+        catch /^Vim\%((\a\+)\)\=:/
2132
+            echo v:exception
2133
+        endtry
2134
+    endif
2135
+endfunction
2136
+
2137
+"FUNCTION: Opener._restoreCursorPos(){{{3
2138
+function! s:Opener._restoreCursorPos()
2139
+    call s:exec('normal ' . self._tabnr . 'gt')
2140
+    call s:exec(bufwinnr(self._bufnr) . 'wincmd w')
2141
+endfunction
2142
+
2143
+"FUNCTION: Opener._reuseWindow(){{{3
2144
+"put the cursor in the first window we find for this file
2145
+"
2146
+"return 1 if we were successful
2147
+function! s:Opener._reuseWindow()
2148
+    "check the current tab for the window
2149
+    let winnr = bufwinnr('^' . self._path.str() . '$')
2150
+    if winnr != -1
2151
+        call s:exec(winnr . "wincmd w")
2152
+        call self._checkToCloseTree(0)
2153
+        return 1
2154
+    else
2155
+        "check other tabs
2156
+        let tabnr = self._path.tabnr()
2157
+        if tabnr
2158
+            call self._checkToCloseTree(1)
2159
+            call s:exec('normal! ' . tabnr . 'gt')
2160
+            let winnr = bufwinnr('^' . self._path.str() . '$')
2161
+            call s:exec(winnr . "wincmd w")
2162
+            return 1
2163
+        endif
2164
+    endif
2165
+    return 0
2166
+endfunction
2167
+
2168
+"FUNCTION: Opener._saveCursorPos(){{{3
2169
+function! s:Opener._saveCursorPos()
2170
+    let self._bufnr = bufnr("")
2171
+    let self._tabnr = tabpagenr()
2172
+endfunction
2173
+
2174
+"CLASS: Path {{{2
2175
+"============================================================
2176
+let s:Path = {}
2177
+"FUNCTION: Path.AbsolutePathFor(str) {{{3
2178
+function! s:Path.AbsolutePathFor(str)
2179
+    let prependCWD = 0
2180
+    if s:running_windows
2181
+        let prependCWD = a:str !~# '^.:\(\\\|\/\)' && a:str !~# '^\(\\\\\|\/\/\)'
2182
+    else
2183
+        let prependCWD = a:str !~# '^/'
2184
+    endif
2185
+
2186
+    let toReturn = a:str
2187
+    if prependCWD
2188
+        let toReturn = getcwd() . s:Path.Slash() . a:str
2189
+    endif
2190
+
2191
+    return toReturn
2192
+endfunction
2193
+"FUNCTION: Path.bookmarkNames() {{{3
2194
+function! s:Path.bookmarkNames()
2195
+    if !exists("self._bookmarkNames")
2196
+        call self.cacheDisplayString()
2197
+    endif
2198
+    return self._bookmarkNames
2199
+endfunction
2200
+"FUNCTION: Path.cacheDisplayString() {{{3
2201
+function! s:Path.cacheDisplayString()
2202
+    let self.cachedDisplayString = self.getLastPathComponent(1)
2203
+
2204
+    if self.isExecutable
2205
+        let self.cachedDisplayString = self.cachedDisplayString . '*'
2206
+    endif
2207
+
2208
+    let self._bookmarkNames = []
2209
+    for i in s:Bookmark.Bookmarks()
2210
+        if i.path.equals(self)
2211
+            call add(self._bookmarkNames, i.name)
2212
+        endif
2213
+    endfor
2214
+    if !empty(self._bookmarkNames)
2215
+        let self.cachedDisplayString .= ' {' . join(self._bookmarkNames) . '}'
2216
+    endif
2217
+
2218
+    if self.isSymLink
2219
+        let self.cachedDisplayString .=  ' -> ' . self.symLinkDest
2220
+    endif
2221
+
2222
+    if self.isReadOnly
2223
+        let self.cachedDisplayString .=  ' [RO]'
2224
+    endif
2225
+endfunction
2226
+"FUNCTION: Path.changeToDir() {{{3
2227
+function! s:Path.changeToDir()
2228
+    let dir = self.str({'format': 'Cd'})
2229
+    if self.isDirectory ==# 0
2230
+        let dir = self.getParent().str({'format': 'Cd'})
2231
+    endif
2232
+
2233
+    try
2234
+        execute "cd " . dir
2235
+        call s:echo("CWD is now: " . getcwd())
2236
+    catch
2237
+        throw "NERDTree.PathChangeError: cannot change CWD to " . dir
2238
+    endtry
2239
+endfunction
2240
+
2241
+"FUNCTION: Path.compareTo() {{{3
2242
+"
2243
+"Compares this Path to the given path and returns 0 if they are equal, -1 if
2244
+"this Path is "less than" the given path, or 1 if it is "greater".
2245
+"
2246
+"Args:
2247
+"path: the path object to compare this to
2248
+"
2249
+"Return:
2250
+"1, -1 or 0
2251
+function! s:Path.compareTo(path)
2252
+    let thisPath = self.getLastPathComponent(1)
2253
+    let thatPath = a:path.getLastPathComponent(1)
2254
+
2255
+    "if the paths are the same then clearly we return 0
2256
+    if thisPath ==# thatPath
2257
+        return 0
2258
+    endif
2259
+
2260
+    let thisSS = self.getSortOrderIndex()
2261
+    let thatSS = a:path.getSortOrderIndex()
2262
+
2263
+    "compare the sort sequences, if they are different then the return
2264
+    "value is easy
2265
+    if thisSS < thatSS
2266
+        return -1
2267
+    elseif thisSS > thatSS
2268
+        return 1
2269
+    else
2270
+        "if the sort sequences are the same then compare the paths
2271
+        "alphabetically
2272
+        let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath <? thatPath
2273
+        if pathCompare
2274
+            return -1
2275
+        else
2276
+            return 1
2277
+        endif
2278
+    endif
2279
+endfunction
2280
+
2281
+"FUNCTION: Path.Create(fullpath) {{{3
2282
+"
2283
+"Factory method.
2284
+"
2285
+"Creates a path object with the given path. The path is also created on the
2286
+"filesystem. If the path already exists, a NERDTree.Path.Exists exception is
2287
+"thrown. If any other errors occur, a NERDTree.Path exception is thrown.
2288
+"
2289
+"Args:
2290
+"fullpath: the full filesystem path to the file/dir to create
2291
+function! s:Path.Create(fullpath)
2292
+    "bail if the a:fullpath already exists
2293
+    if isdirectory(a:fullpath) || filereadable(a:fullpath)
2294
+        throw "NERDTree.CreatePathError: Directory Exists: '" . a:fullpath . "'"
2295
+    endif
2296
+
2297
+    try
2298
+
2299
+        "if it ends with a slash, assume its a dir create it
2300
+        if a:fullpath =~# '\(\\\|\/\)$'
2301
+            "whack the trailing slash off the end if it exists
2302
+            let fullpath = substitute(a:fullpath, '\(\\\|\/\)$', '', '')
2303
+
2304
+            call mkdir(fullpath, 'p')
2305
+
2306
+        "assume its a file and create
2307
+        else
2308
+            call writefile([], a:fullpath)
2309
+        endif
2310
+    catch
2311
+        throw "NERDTree.CreatePathError: Could not create path: '" . a:fullpath . "'"
2312
+    endtry
2313
+
2314
+    return s:Path.New(a:fullpath)
2315
+endfunction
2316
+
2317
+"FUNCTION: Path.copy(dest) {{{3
2318
+"
2319
+"Copies the file/dir represented by this Path to the given location
2320
+"
2321
+"Args:
2322
+"dest: the location to copy this dir/file to
2323
+function! s:Path.copy(dest)
2324
+    if !s:Path.CopyingSupported()
2325
+        throw "NERDTree.CopyingNotSupportedError: Copying is not supported on this OS"
2326
+    endif
2327
+
2328
+    let dest = s:Path.WinToUnixPath(a:dest)
2329
+
2330
+    let cmd = g:NERDTreeCopyCmd . " " . escape(self.str(), s:escape_chars) . " " . escape(dest, s:escape_chars)
2331
+    let success = system(cmd)
2332
+    if success != 0
2333
+        throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'"
2334
+    endif
2335
+endfunction
2336
+
2337
+"FUNCTION: Path.CopyingSupported() {{{3
2338
+"
2339
+"returns 1 if copying is supported for this OS
2340
+function! s:Path.CopyingSupported()
2341
+    return exists('g:NERDTreeCopyCmd')
2342
+endfunction
2343
+
2344
+
2345
+"FUNCTION: Path.copyingWillOverwrite(dest) {{{3
2346
+"
2347
+"returns 1 if copy this path to the given location will cause files to
2348
+"overwritten
2349
+"
2350
+"Args:
2351
+"dest: the location this path will be copied to
2352
+function! s:Path.copyingWillOverwrite(dest)
2353
+    if filereadable(a:dest)
2354
+        return 1
2355
+    endif
2356
+
2357
+    if isdirectory(a:dest)
2358
+        let path = s:Path.JoinPathStrings(a:dest, self.getLastPathComponent(0))
2359
+        if filereadable(path)
2360
+            return 1
2361
+        endif
2362
+    endif
2363
+endfunction
2364
+
2365
+"FUNCTION: Path.delete() {{{3
2366
+"
2367
+"Deletes the file represented by this path.
2368
+"Deletion of directories is not supported
2369
+"
2370
+"Throws NERDTree.Path.Deletion exceptions
2371
+function! s:Path.delete()
2372
+    if self.isDirectory
2373
+
2374
+        let cmd = g:NERDTreeRemoveDirCmd . self.str({'escape': 1})
2375
+        let success = system(cmd)
2376
+
2377
+        if v:shell_error != 0
2378
+            throw "NERDTree.PathDeletionError: Could not delete directory: '" . self.str() . "'"
2379
+        endif
2380
+    else
2381
+        let success = delete(self.str())
2382
+        if success != 0
2383
+            throw "NERDTree.PathDeletionError: Could not delete file: '" . self.str() . "'"
2384
+        endif
2385
+    endif
2386
+
2387
+    "delete all bookmarks for this path
2388
+    for i in self.bookmarkNames()
2389
+        let bookmark = s:Bookmark.BookmarkFor(i)
2390
+        call bookmark.delete()
2391
+    endfor
2392
+endfunction
2393
+
2394
+"FUNCTION: Path.displayString() {{{3
2395
+"
2396
+"Returns a string that specifies how the path should be represented as a
2397
+"string
2398
+function! s:Path.displayString()
2399
+    if self.cachedDisplayString ==# ""
2400
+        call self.cacheDisplayString()
2401
+    endif
2402
+
2403
+    return self.cachedDisplayString
2404
+endfunction
2405
+"FUNCTION: Path.edit() {{{3
2406
+function! s:Path.edit()
2407
+    exec "edit " . self.str({'format': 'Edit'})
2408
+endfunction
2409
+"FUNCTION: Path.extractDriveLetter(fullpath) {{{3
2410
+"
2411
+"If running windows, cache the drive letter for this path
2412
+function! s:Path.extractDriveLetter(fullpath)
2413
+    if s:running_windows
2414
+        if a:fullpath =~ '^\(\\\\\|\/\/\)'
2415
+            "For network shares, the 'drive' consists of the first two parts of the path, i.e. \\boxname\share
2416
+            let self.drive = substitute(a:fullpath, '^\(\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\).*', '\1', '')
2417
+            let self.drive = substitute(self.drive, '/', '\', "g")
2418
+        else
2419
+            let self.drive = substitute(a:fullpath, '\(^[a-zA-Z]:\).*', '\1', '')
2420
+        endif
2421
+    else
2422
+        let self.drive = ''
2423
+    endif
2424
+
2425
+endfunction
2426
+"FUNCTION: Path.exists() {{{3
2427
+"return 1 if this path points to a location that is readable or is a directory
2428
+function! s:Path.exists()
2429
+    let p = self.str()
2430
+    return filereadable(p) || isdirectory(p)
2431
+endfunction
2432
+"FUNCTION: Path.getDir() {{{3
2433
+"
2434
+"Returns this path if it is a directory, else this paths parent.
2435
+"
2436
+"Return:
2437
+"a Path object
2438
+function! s:Path.getDir()
2439
+    if self.isDirectory
2440
+        return self
2441
+    else
2442
+        return self.getParent()
2443
+    endif
2444
+endfunction
2445
+"FUNCTION: Path.getParent() {{{3
2446
+"
2447
+"Returns a new path object for this paths parent
2448
+"
2449
+"Return:
2450
+"a new Path object
2451
+function! s:Path.getParent()
2452
+    if s:running_windows
2453
+        let path = self.drive . '\' . join(self.pathSegments[0:-2], '\')
2454
+    else
2455
+        let path = '/'. join(self.pathSegments[0:-2], '/')
2456
+    endif
2457
+
2458
+    return s:Path.New(path)
2459
+endfunction
2460
+"FUNCTION: Path.getLastPathComponent(dirSlash) {{{3
2461
+"
2462
+"Gets the last part of this path.
2463
+"
2464
+"Args:
2465
+"dirSlash: if 1 then a trailing slash will be added to the returned value for
2466
+"directory nodes.
2467
+function! s:Path.getLastPathComponent(dirSlash)
2468
+    if empty(self.pathSegments)
2469
+        return ''
2470
+    endif
2471
+    let toReturn = self.pathSegments[-1]
2472
+    if a:dirSlash && self.isDirectory
2473
+        let toReturn = toReturn . '/'
2474
+    endif
2475
+    return toReturn
2476
+endfunction
2477
+
2478
+"FUNCTION: Path.getSortOrderIndex() {{{3
2479
+"returns the index of the pattern in g:NERDTreeSortOrder that this path matches
2480
+function! s:Path.getSortOrderIndex()
2481
+    let i = 0
2482
+    while i < len(g:NERDTreeSortOrder)
2483
+        if  self.getLastPathComponent(1) =~# g:NERDTreeSortOrder[i]
2484
+            return i
2485
+        endif
2486
+        let i = i + 1
2487
+    endwhile
2488
+    return s:NERDTreeSortStarIndex
2489
+endfunction
2490
+
2491
+
2492
+"FUNCTION: Path.isUnixHiddenFile() {{{3
2493
+"check for unix hidden files
2494
+function! s:Path.isUnixHiddenFile()
2495
+    return self.getLastPathComponent(0) =~# '^\.'
2496
+endfunction
2497
+
2498
+"FUNCTION: Path.ignore() {{{3
2499
+"returns true if this path should be ignored
2500
+function! s:Path.ignore()
2501
+    "filter out the user specified paths to ignore
2502
+    if b:NERDTreeIgnoreEnabled
2503
+        for i in g:NERDTreeIgnore
2504
+            if self._ignorePatternMatches(i)
2505
+                return 1
2506
+            endif
2507
+        endfor
2508
+    endif
2509
+
2510
+    "dont show hidden files unless instructed to
2511
+    if b:NERDTreeShowHidden ==# 0 && self.isUnixHiddenFile()
2512
+        return 1
2513
+    endif
2514
+
2515
+    if b:NERDTreeShowFiles ==# 0 && self.isDirectory ==# 0
2516
+        return 1
2517
+    endif
2518
+
2519
+    if exists("*NERDTreeCustomIgnoreFilter") && NERDTreeCustomIgnoreFilter(self)
2520
+        return 1
2521
+    endif
2522
+
2523
+    return 0
2524
+endfunction
2525
+
2526
+"FUNCTION: Path._ignorePatternMatches(pattern) {{{3
2527
+"returns true if this path matches the given ignore pattern
2528
+function! s:Path._ignorePatternMatches(pattern)
2529
+    let pat = a:pattern
2530
+    if strpart(pat,len(pat)-7) == '[[dir]]'
2531
+        if !self.isDirectory
2532
+            return 0
2533
+        endif
2534
+        let pat = strpart(pat,0, len(pat)-7)
2535
+    elseif strpart(pat,len(pat)-8) == '[[file]]'
2536
+        if self.isDirectory
2537
+            return 0
2538
+        endif
2539
+        let pat = strpart(pat,0, len(pat)-8)
2540
+    endif
2541
+
2542
+    return self.getLastPathComponent(0) =~# pat
2543
+endfunction
2544
+"FUNCTION: Path.isUnder(path) {{{3
2545
+"return 1 if this path is somewhere under the given path in the filesystem.
2546
+"
2547
+"a:path should be a dir
2548
+function! s:Path.isUnder(path)
2549
+    if a:path.isDirectory == 0
2550
+        return 0
2551
+    endif
2552
+
2553
+    let this = self.str()
2554
+    let that = a:path.str()
2555
+    return stridx(this, that . s:Path.Slash()) == 0
2556
+endfunction
2557
+
2558
+"FUNCTION: Path.JoinPathStrings(...) {{{3
2559
+function! s:Path.JoinPathStrings(...)
2560
+    let components = []
2561
+    for i in a:000
2562
+        let components = extend(components, split(i, '/'))
2563
+    endfor
2564
+    return '/' . join(components, '/')
2565
+endfunction
2566
+
2567
+"FUNCTION: Path.equals() {{{3
2568
+"
2569
+"Determines whether 2 path objects are "equal".
2570
+"They are equal if the paths they represent are the same
2571
+"
2572
+"Args:
2573
+"path: the other path obj to compare this with
2574
+function! s:Path.equals(path)
2575
+    return self.str() ==# a:path.str()
2576
+endfunction
2577
+
2578
+"FUNCTION: Path.New() {{{3
2579
+"The Constructor for the Path object
2580
+function! s:Path.New(path)
2581
+    let newPath = copy(self)
2582
+
2583
+    call newPath.readInfoFromDisk(s:Path.AbsolutePathFor(a:path))
2584
+
2585
+    let newPath.cachedDisplayString = ""
2586
+
2587
+    return newPath
2588
+endfunction
2589
+
2590
+"FUNCTION: Path.Slash() {{{3
2591
+"return the slash to use for the current OS
2592
+function! s:Path.Slash()
2593
+    return s:running_windows ? '\' : '/'
2594
+endfunction
2595
+
2596
+"FUNCTION: Path.Resolve() {{{3
2597
+"Invoke the vim resolve() function and return the result
2598
+"This is necessary because in some versions of vim resolve() removes trailing
2599
+"slashes while in other versions it doesn't.  This always removes the trailing
2600
+"slash
2601
+function! s:Path.Resolve(path)
2602
+    let tmp = resolve(a:path)
2603
+    return tmp =~# '.\+/$' ? substitute(tmp, '/$', '', '') : tmp
2604
+endfunction
2605
+
2606
+"FUNCTION: Path.readInfoFromDisk(fullpath) {{{3
2607
+"
2608
+"
2609
+"Throws NERDTree.Path.InvalidArguments exception.
2610
+function! s:Path.readInfoFromDisk(fullpath)
2611
+    call self.extractDriveLetter(a:fullpath)
2612
+
2613
+    let fullpath = s:Path.WinToUnixPath(a:fullpath)
2614
+
2615
+    if getftype(fullpath) ==# "fifo"
2616
+        throw "NERDTree.InvalidFiletypeError: Cant handle FIFO files: " . a:fullpath
2617
+    endif
2618
+
2619
+    let self.pathSegments = split(fullpath, '/')
2620
+
2621
+    let self.isReadOnly = 0
2622
+    if isdirectory(a:fullpath)
2623
+        let self.isDirectory = 1
2624
+    elseif filereadable(a:fullpath)
2625
+        let self.isDirectory = 0
2626
+        let self.isReadOnly = filewritable(a:fullpath) ==# 0
2627
+    else
2628
+        throw "NERDTree.InvalidArgumentsError: Invalid path = " . a:fullpath
2629
+    endif
2630
+
2631
+    let self.isExecutable = 0
2632
+    if !self.isDirectory
2633
+        let self.isExecutable = getfperm(a:fullpath) =~# 'x'
2634
+    endif
2635
+
2636
+    "grab the last part of the path (minus the trailing slash)
2637
+    let lastPathComponent = self.getLastPathComponent(0)
2638
+
2639
+    "get the path to the new node with the parent dir fully resolved
2640
+    let hardPath = s:Path.Resolve(self.strTrunk()) . '/' . lastPathComponent
2641
+
2642
+    "if  the last part of the path is a symlink then flag it as such
2643
+    let self.isSymLink = (s:Path.Resolve(hardPath) != hardPath)
2644
+    if self.isSymLink
2645
+        let self.symLinkDest = s:Path.Resolve(fullpath)
2646
+
2647
+        "if the link is a dir then slap a / on the end of its dest
2648
+        if isdirectory(self.symLinkDest)
2649
+
2650
+            "we always wanna treat MS windows shortcuts as files for
2651
+            "simplicity
2652
+            if hardPath !~# '\.lnk$'
2653
+
2654
+                let self.symLinkDest = self.symLinkDest . '/'
2655
+            endif
2656
+        endif
2657
+    endif
2658
+endfunction
2659
+
2660
+"FUNCTION: Path.refresh() {{{3
2661
+function! s:Path.refresh()
2662
+    call self.readInfoFromDisk(self.str())
2663
+    call self.cacheDisplayString()
2664
+endfunction
2665
+
2666
+"FUNCTION: Path.rename() {{{3
2667
+"
2668
+"Renames this node on the filesystem
2669
+function! s:Path.rename(newPath)
2670
+    if a:newPath ==# ''
2671
+        throw "NERDTree.InvalidArgumentsError: Invalid newPath for renaming = ". a:newPath
2672
+    endif
2673
+
2674
+    let success =  rename(self.str(), a:newPath)
2675
+    if success != 0
2676
+        throw "NERDTree.PathRenameError: Could not rename: '" . self.str() . "'" . 'to:' . a:newPath
2677
+    endif
2678
+    call self.readInfoFromDisk(a:newPath)
2679
+
2680
+    for i in self.bookmarkNames()
2681
+        let b = s:Bookmark.BookmarkFor(i)
2682
+        call b.setPath(copy(self))
2683
+    endfor
2684
+    call s:Bookmark.Write()
2685
+endfunction
2686
+
2687
+"FUNCTION: Path.str() {{{3
2688
+"
2689
+"Returns a string representation of this Path
2690
+"
2691
+"Takes an optional dictionary param to specify how the output should be
2692
+"formatted.
2693
+"
2694
+"The dict may have the following keys:
2695
+"  'format'
2696
+"  'escape'
2697
+"  'truncateTo'
2698
+"
2699
+"The 'format' key may have a value of:
2700
+"  'Cd' - a string to be used with the :cd command
2701
+"  'Edit' - a string to be used with :e :sp :new :tabedit etc
2702
+"  'UI' - a string used in the NERD tree UI
2703
+"
2704
+"The 'escape' key, if specified will cause the output to be escaped with
2705
+"shellescape()
2706
+"
2707
+"The 'truncateTo' key causes the resulting string to be truncated to the value
2708
+"'truncateTo' maps to. A '<' char will be prepended.
2709
+function! s:Path.str(...)
2710
+    let options = a:0 ? a:1 : {}
2711
+    let toReturn = ""
2712
+
2713
+    if has_key(options, 'format')
2714
+        let format = options['format']
2715
+        if has_key(self, '_strFor' . format)
2716
+            exec 'let toReturn = self._strFor' . format . '()'
2717
+        else
2718
+            raise 'NERDTree.UnknownFormatError: unknown format "'. format .'"'
2719
+        endif
2720
+    else
2721
+        let toReturn = self._str()
2722
+    endif
2723
+
2724
+    if s:has_opt(options, 'escape')
2725
+        let toReturn = shellescape(toReturn)
2726
+    endif
2727
+
2728
+    if has_key(options, 'truncateTo')
2729
+        let limit = options['truncateTo']
2730
+        if len(toReturn) > limit
2731
+            let toReturn = "<" . strpart(toReturn, len(toReturn) - limit + 1)
2732
+        endif
2733
+    endif
2734
+
2735
+    return toReturn
2736
+endfunction
2737
+
2738
+"FUNCTION: Path._strForUI() {{{3
2739
+function! s:Path._strForUI()
2740
+    let toReturn = '/' . join(self.pathSegments, '/')
2741
+    if self.isDirectory && toReturn != '/'
2742
+        let toReturn  = toReturn . '/'
2743
+    endif
2744
+    return toReturn
2745
+endfunction
2746
+
2747
+"FUNCTION: Path._strForCd() {{{3
2748
+"
2749
+" returns a string that can be used with :cd
2750
+function! s:Path._strForCd()
2751
+    return escape(self.str(), s:escape_chars)
2752
+endfunction
2753
+"FUNCTION: Path._strForEdit() {{{3
2754
+"
2755
+"Return: the string for this path that is suitable to be used with the :edit
2756
+"command
2757
+function! s:Path._strForEdit()
2758
+    let p = escape(self.str({'format': 'UI'}), s:escape_chars)
2759
+    let cwd = getcwd() . s:Path.Slash()
2760
+
2761
+    "return a relative path if we can
2762
+    let isRelative = 0
2763
+    if s:running_windows
2764
+        let isRelative = stridx(tolower(p), tolower(cwd)) == 0
2765
+    else
2766
+        let isRelative = stridx(p, cwd) == 0
2767
+    endif
2768
+
2769
+    if isRelative
2770
+        let p = strpart(p, strlen(cwd))
2771
+
2772
+        "handle the edge case where the file begins with a + (vim interprets
2773
+        "the +foo in `:e +foo` as an option to :edit)
2774
+        if p[0] == "+"
2775
+            let p = '\' . p
2776
+        endif
2777
+    endif
2778
+
2779
+    if p ==# ''
2780
+        let p = '.'
2781
+    endif
2782
+
2783
+    return p
2784
+endfunction
2785
+"FUNCTION: Path._strForGlob() {{{3
2786
+function! s:Path._strForGlob()
2787
+    let lead = s:Path.Slash()
2788
+
2789
+    "if we are running windows then slap a drive letter on the front
2790
+    if s:running_windows
2791
+        let lead = self.drive . '\'
2792
+    endif
2793
+
2794
+    let toReturn = lead . join(self.pathSegments, s:Path.Slash())
2795
+
2796
+    if !s:running_windows
2797
+        let toReturn = escape(toReturn, s:escape_chars)
2798
+    endif
2799
+    return toReturn
2800
+endfunction
2801
+"FUNCTION: Path._str() {{{3
2802
+"
2803
+"Gets the string path for this path object that is appropriate for the OS.
2804
+"EG, in windows c:\foo\bar
2805
+"    in *nix  /foo/bar
2806
+function! s:Path._str()
2807
+    let lead = s:Path.Slash()
2808
+
2809
+    "if we are running windows then slap a drive letter on the front
2810
+    if s:running_windows
2811
+        let lead = self.drive . '\'
2812
+    endif
2813
+
2814
+    return lead . join(self.pathSegments, s:Path.Slash())
2815
+endfunction
2816
+
2817
+"FUNCTION: Path.strTrunk() {{{3
2818
+"Gets the path without the last segment on the end.
2819
+function! s:Path.strTrunk()
2820
+    return self.drive . '/' . join(self.pathSegments[0:-2], '/')
2821
+endfunction
2822
+
2823
+" FUNCTION: Path.tabnr() {{{3
2824
+" return the number of the first tab that is displaying this file
2825
+"
2826
+" return 0 if no tab was found
2827
+function! s:Path.tabnr()
2828
+    let str = self.str()
2829
+    for t in range(tabpagenr('$'))
2830
+        for b in tabpagebuflist(t+1)
2831
+            if str == expand('#' . b . ':p')
2832
+                return t+1
2833
+            endif
2834
+        endfor
2835
+    endfor
2836
+    return 0
2837
+endfunction
2838
+"FUNCTION: Path.WinToUnixPath(pathstr){{{3
2839
+"Takes in a windows path and returns the unix equiv
2840
+"
2841
+"A class level method
2842
+"
2843
+"Args:
2844
+"pathstr: the windows path to convert
2845
+function! s:Path.WinToUnixPath(pathstr)
2846
+    if !s:running_windows
2847
+        return a:pathstr
2848
+    endif
2849
+
2850
+    let toReturn = a:pathstr
2851
+
2852
+    "remove the x:\ of the front
2853
+    let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', "")
2854
+
2855
+    "remove the \\ network share from the front
2856
+    let toReturn = substitute(toReturn, '^\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\(\\\|\/\)\?', '/', "")
2857
+
2858
+    "convert all \ chars to /
2859
+    let toReturn = substitute(toReturn, '\', '/', "g")
2860
+
2861
+    return toReturn
2862
+endfunction
2863
+
2864
+" SECTION: General Functions {{{1
2865
+"============================================================
2866
+"FUNCTION: s:bufInWindows(bnum){{{2
2867
+"[[STOLEN FROM VTREEEXPLORER.VIM]]
2868
+"Determine the number of windows open to this buffer number.
2869
+"Care of Yegappan Lakshman.  Thanks!
2870
+"
2871
+"Args:
2872
+"bnum: the subject buffers buffer number
2873
+function! s:bufInWindows(bnum)
2874
+    let cnt = 0
2875
+    let winnum = 1
2876
+    while 1
2877
+        let bufnum = winbufnr(winnum)
2878
+        if bufnum < 0
2879
+            break
2880
+        endif
2881
+        if bufnum ==# a:bnum
2882
+            let cnt = cnt + 1
2883
+        endif
2884
+        let winnum = winnum + 1
2885
+    endwhile
2886
+
2887
+    return cnt
2888
+endfunction " >>>
2889
+"FUNCTION: s:checkForBrowse(dir) {{{2
2890
+"inits a secondary nerd tree in the current buffer if appropriate
2891
+function! s:checkForBrowse(dir)
2892
+    if a:dir != '' && isdirectory(a:dir)
2893
+        call s:initNerdTreeInPlace(a:dir)
2894
+    endif
2895
+endfunction
2896
+"FUNCTION: s:compareBookmarks(first, second) {{{2
2897
+"Compares two bookmarks
2898
+function! s:compareBookmarks(first, second)
2899
+    return a:first.compareTo(a:second)
2900
+endfunction
2901
+
2902
+" FUNCTION: s:completeBookmarks(A,L,P) {{{2
2903
+" completion function for the bookmark commands
2904
+function! s:completeBookmarks(A,L,P)
2905
+    return filter(s:Bookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"')
2906
+endfunction
2907
+" FUNCTION: s:createDefaultBindings() {{{2
2908
+function! s:createDefaultBindings()
2909
+    let s = '<SNR>' . s:SID() . '_'
2910
+
2911
+    call NERDTreeAddKeyMap({ 'key': '<MiddleRelease>', 'scope': "all", 'callback': s."handleMiddleMouse" })
2912
+    call NERDTreeAddKeyMap({ 'key': '<LeftRelease>', 'scope': "all", 'callback': s."handleLeftClick" })
2913
+    call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "DirNode", 'callback': s."activateDirNode" })
2914
+    call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "FileNode", 'callback': s."activateFileNode" })
2915
+    call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "Bookmark", 'callback': s."activateBookmark" })
2916
+    call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': "all", 'callback': s."activateAll" })
2917
+
2918
+
2919
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "DirNode", 'callback': s."activateDirNode" })
2920
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "FileNode", 'callback': s."activateFileNode" })
2921
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "Bookmark", 'callback': s."activateBookmark" })
2922
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': "all", 'callback': s."activateAll" })
2923
+
2924
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Node", 'callback': s."openHSplit" })
2925
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Node", 'callback': s."openVSplit" })
2926
+
2927
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': "Bookmark", 'callback': s."openHSplit" })
2928
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': "Bookmark", 'callback': s."openVSplit" })
2929
+
2930
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Node", 'callback': s."previewNodeCurrent" })
2931
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Node", 'callback': s."previewNodeVSplit" })
2932
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Node", 'callback': s."previewNodeHSplit" })
2933
+
2934
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': "Bookmark", 'callback': s."previewNodeCurrent" })
2935
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': "Bookmark", 'callback': s."previewNodeVSplit" })
2936
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': "Bookmark", 'callback': s."previewNodeHSplit" })
2937
+
2938
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': "DirNode", 'callback': s."openNodeRecursively" })
2939
+
2940
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': "all", 'callback': s."upDirCurrentRootClosed" })
2941
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': "all", 'callback': s."upDirCurrentRootOpen" })
2942
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': "Node", 'callback': s."chRoot" })
2943
+
2944
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': "Node", 'callback': s."chCwd" })
2945
+
2946
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': "all", 'callback': s."closeTreeWindow" })
2947
+
2948
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': "all", 'callback': s."chRootCwd" })
2949
+
2950
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': "all", 'callback': s."refreshRoot" })
2951
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': "Node", 'callback': s."refreshCurrent" })
2952
+
2953
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': "all", 'callback': s."displayHelp" })
2954
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': "all", 'callback': s."toggleZoom" })
2955
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': "all", 'callback': s."toggleShowHidden" })
2956
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': "all", 'callback': s."toggleIgnoreFilter" })
2957
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': "all", 'callback': s."toggleShowFiles" })
2958
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': "all", 'callback': s."toggleShowBookmarks" })
2959
+
2960
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': "Node", 'callback': s."closeCurrentDir" })
2961
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': "DirNode", 'callback': s."closeChildren" })
2962
+
2963
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': "Node", 'callback': s."showMenu" })
2964
+
2965
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': "Node", 'callback': s."jumpToParent" })
2966
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': "Node", 'callback': s."jumpToFirstChild" })
2967
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': "Node", 'callback': s."jumpToLastChild" })
2968
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': "all", 'callback': s."jumpToRoot" })
2969
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': "Node", 'callback': s."jumpToNextSibling" })
2970
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': "Node", 'callback': s."jumpToPrevSibling" })
2971
+
2972
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Node", 'callback': s."openInNewTab" })
2973
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Node", 'callback': s."openInNewTabSilent" })
2974
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': "Bookmark", 'callback': s."openInNewTab" })
2975
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': "Bookmark", 'callback': s."openInNewTabSilent" })
2976
+
2977
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': "DirNode", 'callback': s."openExplorer" })
2978
+
2979
+    call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': "Bookmark", 'callback': s."deleteBookmark" })
2980
+
2981
+endfunction
2982
+" FUNCTION: s:deprecated(func, [msg]) {{{2
2983
+" Issue a deprecation warning for a:func. If a second arg is given, use this
2984
+" as the deprecation message
2985
+function! s:deprecated(func, ...)
2986
+    let msg = a:0 ? a:func . ' ' . a:1 : a:func . ' is deprecated'
2987
+
2988
+    if !exists('s:deprecationWarnings')
2989
+        let s:deprecationWarnings = {}
2990
+    endif
2991
+    if !has_key(s:deprecationWarnings, a:func)
2992
+        let s:deprecationWarnings[a:func] = 1
2993
+        echomsg msg
2994
+    endif
2995
+endfunction
2996
+" FUNCTION: s:exec(cmd) {{{2
2997
+" same as :exec cmd  but eventignore=all is set for the duration
2998
+function! s:exec(cmd)
2999
+    let old_ei = &ei
3000
+    set ei=all
3001
+    exec a:cmd
3002
+    let &ei = old_ei
3003
+endfunction
3004
+" FUNCTION: s:findAndRevealPath() {{{2
3005
+function! s:findAndRevealPath()
3006
+    try
3007
+        let p = s:Path.New(expand("%:p"))
3008
+    catch /^NERDTree.InvalidArgumentsError/
3009
+        call s:echo("no file for the current buffer")
3010
+        return
3011
+    endtry
3012
+
3013
+    if p.isUnixHiddenFile()
3014
+        let showhidden=g:NERDTreeShowHidden
3015
+        let g:NERDTreeShowHidden = 1
3016
+    endif
3017
+
3018
+    if !s:treeExistsForTab()
3019
+        try
3020
+            let cwd = s:Path.New(getcwd())
3021
+        catch /^NERDTree.InvalidArgumentsError/
3022
+            call s:echo("current directory does not exist.")
3023
+            let cwd = p.getParent()
3024
+        endtry
3025
+
3026
+        if p.isUnder(cwd)
3027
+            call s:initNerdTree(cwd.str())
3028
+        else
3029
+            call s:initNerdTree(p.getParent().str())
3030
+        endif
3031
+    else
3032
+        if !p.isUnder(s:TreeFileNode.GetRootForTab().path)
3033
+            if !s:isTreeOpen()
3034
+                call s:createTreeWin()
3035
+            else
3036
+                call s:putCursorInTreeWin()
3037
+            endif
3038
+            let b:NERDTreeShowHidden = g:NERDTreeShowHidden
3039
+            call s:chRoot(s:TreeDirNode.New(p.getParent()))
3040
+        else
3041
+            if !s:isTreeOpen()
3042
+                call s:toggle("")
3043
+            endif
3044
+        endif
3045
+    endif
3046
+    call s:putCursorInTreeWin()
3047
+    call b:NERDTreeRoot.reveal(p)
3048
+
3049
+    if p.isUnixHiddenFile()
3050
+        let g:NERDTreeShowHidden = showhidden
3051
+    endif
3052
+endfunction
3053
+
3054
+" FUNCTION: s:has_opt(options, name) {{{2
3055
+function! s:has_opt(options, name)
3056
+    return has_key(a:options, a:name) && a:options[a:name] == 1
3057
+endfunction
3058
+
3059
+"FUNCTION: s:initNerdTree(name) {{{2
3060
+"Initialise the nerd tree for this tab. The tree will start in either the
3061
+"given directory, or the directory associated with the given bookmark
3062
+"
3063
+"Args:
3064
+"name: the name of a bookmark or a directory
3065
+function! s:initNerdTree(name)
3066
+    let path = {}
3067
+    if s:Bookmark.BookmarkExistsFor(a:name)
3068
+        let path = s:Bookmark.BookmarkFor(a:name).path
3069
+    else
3070
+        let dir = a:name ==# '' ? getcwd() : a:name
3071
+
3072
+        "hack to get an absolute path if a relative path is given
3073
+        if dir =~# '^\.'
3074
+            let dir = getcwd() . s:Path.Slash() . dir
3075
+        endif
3076
+        let dir = s:Path.Resolve(dir)
3077
+
3078
+        try
3079
+            let path = s:Path.New(dir)
3080
+        catch /^NERDTree.InvalidArgumentsError/
3081
+            call s:echo("No bookmark or directory found for: " . a:name)
3082
+            return
3083
+        endtry
3084
+    endif
3085
+    if !path.isDirectory
3086
+        let path = path.getParent()
3087
+    endif
3088
+
3089
+    "if instructed to, then change the vim CWD to the dir the NERDTree is
3090
+    "inited in
3091
+    if g:NERDTreeChDirMode != 0
3092
+        call path.changeToDir()
3093
+    endif
3094
+
3095
+    if s:treeExistsForTab()
3096
+        if s:isTreeOpen()
3097
+            call s:closeTree()
3098
+        endif
3099
+        unlet t:NERDTreeBufName
3100
+    endif
3101
+
3102
+    let newRoot = s:TreeDirNode.New(path)
3103
+    call newRoot.open()
3104
+
3105
+    call s:createTreeWin()
3106
+    let b:treeShowHelp = 0
3107
+    let b:NERDTreeIgnoreEnabled = 1
3108
+    let b:NERDTreeShowFiles = g:NERDTreeShowFiles
3109
+    let b:NERDTreeShowHidden = g:NERDTreeShowHidden
3110
+    let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
3111
+    let b:NERDTreeRoot = newRoot
3112
+    let b:NERDTreeType = "primary"
3113
+
3114
+    call s:renderView()
3115
+    call b:NERDTreeRoot.putCursorHere(0, 0)
3116
+
3117
+    silent doautocmd User NERDTreeInit
3118
+endfunction
3119
+
3120
+"FUNCTION: s:initNerdTreeInPlace(dir) {{{2
3121
+function! s:initNerdTreeInPlace(dir)
3122
+    try
3123
+        let path = s:Path.New(a:dir)
3124
+    catch /^NERDTree.InvalidArgumentsError/
3125
+        call s:echo("Invalid directory name:" . a:name)
3126
+        return
3127
+    endtry
3128
+
3129
+    "we want the directory buffer to disappear when we do the :edit below
3130
+    setlocal bufhidden=wipe
3131
+
3132
+    let previousBuf = expand("#")
3133
+
3134
+    "we need a unique name for each secondary tree buffer to ensure they are
3135
+    "all independent
3136
+    exec "silent edit " . s:nextBufferName()
3137
+
3138
+    let b:NERDTreePreviousBuf = bufnr(previousBuf)
3139
+
3140
+    let b:NERDTreeRoot = s:TreeDirNode.New(path)
3141
+    call b:NERDTreeRoot.open()
3142
+
3143
+    call s:setCommonBufOptions()
3144
+    let b:NERDTreeType = "secondary"
3145
+
3146
+    call s:renderView()
3147
+
3148
+    silent doautocmd User NERDTreeInit
3149
+endfunction
3150
+" FUNCTION: s:initNerdTreeMirror() {{{2
3151
+function! s:initNerdTreeMirror()
3152
+
3153
+    "get the names off all the nerd tree buffers
3154
+    let treeBufNames = []
3155
+    for i in range(1, tabpagenr("$"))
3156
+        let nextName = s:tabpagevar(i, 'NERDTreeBufName')
3157
+        if nextName != -1 && (!exists("t:NERDTreeBufName") || nextName != t:NERDTreeBufName)
3158
+            call add(treeBufNames, nextName)
3159
+        endif
3160
+    endfor
3161
+    let treeBufNames = s:unique(treeBufNames)
3162
+
3163
+    "map the option names (that the user will be prompted with) to the nerd
3164
+    "tree buffer names
3165
+    let options = {}
3166
+    let i = 0
3167
+    while i < len(treeBufNames)
3168
+        let bufName = treeBufNames[i]
3169
+        let treeRoot = getbufvar(bufName, "NERDTreeRoot")
3170
+        let options[i+1 . '. ' . treeRoot.path.str() . '  (buf name: ' . bufName . ')'] = bufName
3171
+        let i = i + 1
3172
+    endwhile
3173
+
3174
+    "work out which tree to mirror, if there is more than 1 then ask the user
3175
+    let bufferName = ''
3176
+    if len(keys(options)) > 1
3177
+        let choices = ["Choose a tree to mirror"]
3178
+        let choices = extend(choices, sort(keys(options)))
3179
+        let choice = inputlist(choices)
3180
+        if choice < 1 || choice > len(options) || choice ==# ''
3181
+            return
3182
+        endif
3183
+
3184
+        let bufferName = options[sort(keys(options))[choice-1]]
3185
+    elseif len(keys(options)) ==# 1
3186
+        let bufferName = values(options)[0]
3187
+    else
3188
+        call s:echo("No trees to mirror")
3189
+        return
3190
+    endif
3191
+
3192
+    if s:treeExistsForTab() && s:isTreeOpen()
3193
+        call s:closeTree()
3194
+    endif
3195
+
3196
+    let t:NERDTreeBufName = bufferName
3197
+    call s:createTreeWin()
3198
+    exec 'buffer ' .  bufferName
3199
+    if !&hidden
3200
+        call s:renderView()
3201
+    endif
3202
+endfunction
3203
+" FUNCTION: s:nextBufferName() {{{2
3204
+" returns the buffer name for the next nerd tree
3205
+function! s:nextBufferName()
3206
+    let name = s:NERDTreeBufName . s:next_buffer_number
3207
+    let s:next_buffer_number += 1
3208
+    return name
3209
+endfunction
3210
+" FUNCTION: s:postSourceActions() {{{2
3211
+function! s:postSourceActions()
3212
+    call s:Bookmark.CacheBookmarks(0)
3213
+    call s:createDefaultBindings()
3214
+
3215
+    "load all nerdtree plugins
3216
+    runtime! nerdtree_plugin/**/*.vim
3217
+endfunction
3218
+" FUNCTION: s:tabpagevar(tabnr, var) {{{2
3219
+function! s:tabpagevar(tabnr, var)
3220
+    let currentTab = tabpagenr()
3221
+    let old_ei = &ei
3222
+    set ei=all
3223
+
3224
+    exec "tabnext " . a:tabnr
3225
+    let v = -1
3226
+    if exists('t:' . a:var)
3227
+        exec 'let v = t:' . a:var
3228
+    endif
3229
+    exec "tabnext " . currentTab
3230
+
3231
+    let &ei = old_ei
3232
+
3233
+    return v
3234
+endfunction
3235
+" Function: s:treeExistsForBuffer()   {{{2
3236
+" Returns 1 if a nerd tree root exists in the current buffer
3237
+function! s:treeExistsForBuf()
3238
+    return exists("b:NERDTreeRoot")
3239
+endfunction
3240
+" Function: s:treeExistsForTab()   {{{2
3241
+" Returns 1 if a nerd tree root exists in the current tab
3242
+function! s:treeExistsForTab()
3243
+    return exists("t:NERDTreeBufName")
3244
+endfunction
3245
+" Function: s:SID()   {{{2
3246
+function s:SID()
3247
+    if !exists("s:sid")
3248
+        let s:sid = matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')
3249
+    endif
3250
+    return s:sid
3251
+endfun
3252
+"FUNCTION: s:upDir(keepState) {{{2
3253
+"moves the tree up a level
3254
+"
3255
+"Args:
3256
+"keepState: 1 if the current root should be left open when the tree is
3257
+"re-rendered
3258
+function! s:upDir(keepState)
3259
+    let cwd = b:NERDTreeRoot.path.str({'format': 'UI'})
3260
+    if cwd ==# "/" || cwd =~# '^[^/]..$'
3261
+        call s:echo("already at top dir")
3262
+    else
3263
+        if !a:keepState
3264
+            call b:NERDTreeRoot.close()
3265
+        endif
3266
+
3267
+        let oldRoot = b:NERDTreeRoot
3268
+
3269
+        if empty(b:NERDTreeRoot.parent)
3270
+            let path = b:NERDTreeRoot.path.getParent()
3271
+            let newRoot = s:TreeDirNode.New(path)
3272
+            call newRoot.open()
3273
+            call newRoot.transplantChild(b:NERDTreeRoot)
3274
+            let b:NERDTreeRoot = newRoot
3275
+        else
3276
+            let b:NERDTreeRoot = b:NERDTreeRoot.parent
3277
+        endif
3278
+
3279
+        if g:NERDTreeChDirMode ==# 2
3280
+            call b:NERDTreeRoot.path.changeToDir()
3281
+        endif
3282
+
3283
+        call s:renderView()
3284
+        call oldRoot.putCursorHere(0, 0)
3285
+    endif
3286
+endfunction
3287
+" Function: s:unique(list)   {{{2
3288
+" returns a:list without duplicates
3289
+function! s:unique(list)
3290
+  let uniqlist = []
3291
+  for elem in a:list
3292
+    if index(uniqlist, elem) ==# -1
3293
+      let uniqlist += [elem]
3294
+    endif
3295
+  endfor
3296
+  return uniqlist
3297
+endfunction
3298
+" SECTION: Public API {{{1
3299
+"============================================================
3300
+let g:NERDTreePath = s:Path
3301
+let g:NERDTreeDirNode = s:TreeDirNode
3302
+let g:NERDTreeFileNode = s:TreeFileNode
3303
+let g:NERDTreeBookmark = s:Bookmark
3304
+
3305
+function! NERDTreeAddMenuItem(options)
3306
+    call s:MenuItem.Create(a:options)
3307
+endfunction
3308
+
3309
+function! NERDTreeAddMenuSeparator(...)
3310
+    let opts = a:0 ? a:1 : {}
3311
+    call s:MenuItem.CreateSeparator(opts)
3312
+endfunction
3313
+
3314
+function! NERDTreeAddSubmenu(options)
3315
+    return s:MenuItem.Create(a:options)
3316
+endfunction
3317
+
3318
+function! NERDTreeAddKeyMap(options)
3319
+    call s:KeyMap.Create(a:options)
3320
+endfunction
3321
+
3322
+function! NERDTreeRender()
3323
+    call s:renderView()
3324
+endfunction
3325
+
3326
+function! NERDTreeFocus()
3327
+    if s:isTreeOpen()
3328
+        call s:putCursorInTreeWin()
3329
+    else
3330
+        call s:toggle("")
3331
+    endif
3332
+endfunction
3333
+
3334
+function! NERDTreeCWD()
3335
+    call NERDTreeFocus()
3336
+    call s:chRootCwd()
3337
+endfunction
3338
+
3339
+" SECTION: View Functions {{{1
3340
+"============================================================
3341
+"FUNCTION: s:centerView() {{{2
3342
+"centers the nerd tree window around the cursor (provided the nerd tree
3343
+"options permit)
3344
+function! s:centerView()
3345
+    if g:NERDTreeAutoCenter
3346
+        let current_line = winline()
3347
+        let lines_to_top = current_line
3348
+        let lines_to_bottom = winheight(s:getTreeWinNum()) - current_line
3349
+        if lines_to_top < g:NERDTreeAutoCenterThreshold || lines_to_bottom < g:NERDTreeAutoCenterThreshold
3350
+            normal! zz
3351
+        endif
3352
+    endif
3353
+endfunction
3354
+"FUNCTION: s:closeTree() {{{2
3355
+"Closes the primary NERD tree window for this tab
3356
+function! s:closeTree()
3357
+    if !s:isTreeOpen()
3358
+        throw "NERDTree.NoTreeFoundError: no NERDTree is open"
3359
+    endif
3360
+
3361
+    if winnr("$") != 1
3362
+        if winnr() == s:getTreeWinNum()
3363
+            call s:exec("wincmd p")
3364
+            let bufnr = bufnr("")
3365
+            call s:exec("wincmd p")
3366
+        else
3367
+            let bufnr = bufnr("")
3368
+        endif
3369
+
3370
+        call s:exec(s:getTreeWinNum() . " wincmd w")
3371
+        close
3372
+        call s:exec(bufwinnr(bufnr) . " wincmd w")
3373
+    else
3374
+        close
3375
+    endif
3376
+endfunction
3377
+
3378
+"FUNCTION: s:closeTreeIfOpen() {{{2
3379
+"Closes the NERD tree window if it is open
3380
+function! s:closeTreeIfOpen()
3381
+   if s:isTreeOpen()
3382
+      call s:closeTree()
3383
+   endif
3384
+endfunction
3385
+"FUNCTION: s:closeTreeIfQuitOnOpen() {{{2
3386
+"Closes the NERD tree window if the close on open option is set
3387
+function! s:closeTreeIfQuitOnOpen()
3388
+    if g:NERDTreeQuitOnOpen && s:isTreeOpen()
3389
+        call s:closeTree()
3390
+    endif
3391
+endfunction
3392
+"FUNCTION: s:createTreeWin() {{{2
3393
+"Inits the NERD tree window. ie. opens it, sizes it, sets all the local
3394
+"options etc
3395
+function! s:createTreeWin()
3396
+    "create the nerd tree window
3397
+    let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright "
3398
+    let splitSize = g:NERDTreeWinSize
3399
+
3400
+    if !exists('t:NERDTreeBufName')
3401
+        let t:NERDTreeBufName = s:nextBufferName()
3402
+        silent! exec splitLocation . 'vertical ' . splitSize . ' new'
3403
+        silent! exec "edit " . t:NERDTreeBufName
3404
+    else
3405
+        silent! exec splitLocation . 'vertical ' . splitSize . ' split'
3406
+        silent! exec "buffer " . t:NERDTreeBufName
3407
+    endif
3408
+
3409
+    setlocal winfixwidth
3410
+    call s:setCommonBufOptions()
3411
+endfunction
3412
+
3413
+"FUNCTION: s:dumpHelp  {{{2
3414
+"prints out the quick help
3415
+function! s:dumpHelp()
3416
+    let old_h = @h
3417
+    if b:treeShowHelp ==# 1
3418
+        let @h=   "\" NERD tree (" . s:NERD_tree_version . ") quickhelp~\n"
3419
+        let @h=@h."\" ============================\n"
3420
+        let @h=@h."\" File node mappings~\n"
3421
+        let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n"
3422
+        let @h=@h."\" <CR>,\n"
3423
+        if b:NERDTreeType ==# "primary"
3424
+            let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n"
3425
+        else
3426
+            let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n"
3427
+        endif
3428
+        if b:NERDTreeType ==# "primary"
3429
+            let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n"
3430
+        endif
3431
+        let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
3432
+        let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n"
3433
+        let @h=@h."\" middle-click,\n"
3434
+        let @h=@h."\" ". g:NERDTreeMapOpenSplit .": open split\n"
3435
+        let @h=@h."\" ". g:NERDTreeMapPreviewSplit .": preview split\n"
3436
+        let @h=@h."\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n"
3437
+        let @h=@h."\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n"
3438
+
3439
+        let @h=@h."\"\n\" ----------------------------\n"
3440
+        let @h=@h."\" Directory node mappings~\n"
3441
+        let @h=@h."\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n"
3442
+        let @h=@h."\" ". g:NERDTreeMapActivateNode .": open & close node\n"
3443
+        let @h=@h."\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n"
3444
+        let @h=@h."\" ". g:NERDTreeMapCloseDir .": close parent of node\n"
3445
+        let @h=@h."\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n"
3446
+        let @h=@h."\"    current node recursively\n"
3447
+        let @h=@h."\" middle-click,\n"
3448
+        let @h=@h."\" ". g:NERDTreeMapOpenExpl.": explore selected dir\n"
3449
+
3450
+        let @h=@h."\"\n\" ----------------------------\n"
3451
+        let @h=@h."\" Bookmark table mappings~\n"
3452
+        let @h=@h."\" double-click,\n"
3453
+        let @h=@h."\" ". g:NERDTreeMapActivateNode .": open bookmark\n"
3454
+        let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
3455
+        let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n"
3456
+        let @h=@h."\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n"
3457
+
3458
+        let @h=@h."\"\n\" ----------------------------\n"
3459
+        let @h=@h."\" Tree navigation mappings~\n"
3460
+        let @h=@h."\" ". g:NERDTreeMapJumpRoot .": go to root\n"
3461
+        let @h=@h."\" ". g:NERDTreeMapJumpParent .": go to parent\n"
3462
+        let @h=@h."\" ". g:NERDTreeMapJumpFirstChild  .": go to first child\n"
3463
+        let @h=@h."\" ". g:NERDTreeMapJumpLastChild   .": go to last child\n"
3464
+        let @h=@h."\" ". g:NERDTreeMapJumpNextSibling .": go to next sibling\n"
3465
+        let @h=@h."\" ". g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n"
3466
+
3467
+        let @h=@h."\"\n\" ----------------------------\n"
3468
+        let @h=@h."\" Filesystem mappings~\n"
3469
+        let @h=@h."\" ". g:NERDTreeMapChangeRoot .": change tree root to the\n"
3470
+        let @h=@h."\"    selected dir\n"
3471
+        let @h=@h."\" ". g:NERDTreeMapUpdir .": move tree root up a dir\n"
3472
+        let @h=@h."\" ". g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n"
3473
+        let @h=@h."\"    but leave old root open\n"
3474
+        let @h=@h."\" ". g:NERDTreeMapRefresh .": refresh cursor dir\n"
3475
+        let @h=@h."\" ". g:NERDTreeMapRefreshRoot .": refresh current root\n"
3476
+        let @h=@h."\" ". g:NERDTreeMapMenu .": Show menu\n"
3477
+        let @h=@h."\" ". g:NERDTreeMapChdir .":change the CWD to the\n"
3478
+        let @h=@h."\"    selected dir\n"
3479
+        let @h=@h."\" ". g:NERDTreeMapCWD .":change tree root to CWD\n"
3480
+
3481
+        let @h=@h."\"\n\" ----------------------------\n"
3482
+        let @h=@h."\" Tree filtering mappings~\n"
3483
+        let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (b:NERDTreeShowHidden ? "on" : "off") . ")\n"
3484
+        let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (b:NERDTreeIgnoreEnabled ? "on" : "off") . ")\n"
3485
+        let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (b:NERDTreeShowFiles ? "on" : "off") . ")\n"
3486
+        let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (b:NERDTreeShowBookmarks ? "on" : "off") . ")\n"
3487
+
3488
+        "add quickhelp entries for each custom key map
3489
+        let @h=@h."\"\n\" ----------------------------\n"
3490
+        let @h=@h."\" Custom mappings~\n"
3491
+        for i in s:KeyMap.All()
3492
+            if !empty(i.quickhelpText)
3493
+                let @h=@h."\" ". i.key .": ". i.quickhelpText ."\n"
3494
+            endif
3495
+        endfor
3496
+
3497
+        let @h=@h."\"\n\" ----------------------------\n"
3498
+        let @h=@h."\" Other mappings~\n"
3499
+        let @h=@h."\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n"
3500
+        let @h=@h."\" ". g:NERDTreeMapToggleZoom .": Zoom (maximize-minimize)\n"
3501
+        let @h=@h."\"    the NERDTree window\n"
3502
+        let @h=@h."\" ". g:NERDTreeMapHelp .": toggle help\n"
3503
+        let @h=@h."\"\n\" ----------------------------\n"
3504
+        let @h=@h."\" Bookmark commands~\n"
3505
+        let @h=@h."\" :Bookmark <name>\n"
3506
+        let @h=@h."\" :BookmarkToRoot <name>\n"
3507
+        let @h=@h."\" :RevealBookmark <name>\n"
3508
+        let @h=@h."\" :OpenBookmark <name>\n"
3509
+        let @h=@h."\" :ClearBookmarks [<names>]\n"
3510
+        let @h=@h."\" :ClearAllBookmarks\n"
3511
+        silent! put h
3512
+    elseif g:NERDTreeMinimalUI == 0
3513
+        let @h="\" Press ". g:NERDTreeMapHelp ." for help\n"
3514
+        silent! put h
3515
+    endif
3516
+
3517
+    let @h = old_h
3518
+endfunction
3519
+"FUNCTION: s:echo  {{{2
3520
+"A wrapper for :echo. Appends 'NERDTree:' on the front of all messages
3521
+"
3522
+"Args:
3523
+"msg: the message to echo
3524
+function! s:echo(msg)
3525
+    redraw
3526
+    echomsg "NERDTree: " . a:msg
3527
+endfunction
3528
+"FUNCTION: s:echoWarning {{{2
3529
+"Wrapper for s:echo, sets the message type to warningmsg for this message
3530
+"Args:
3531
+"msg: the message to echo
3532
+function! s:echoWarning(msg)
3533
+    echohl warningmsg
3534
+    call s:echo(a:msg)
3535
+    echohl normal
3536
+endfunction
3537
+"FUNCTION: s:echoError {{{2
3538
+"Wrapper for s:echo, sets the message type to errormsg for this message
3539
+"Args:
3540
+"msg: the message to echo
3541
+function! s:echoError(msg)
3542
+    echohl errormsg
3543
+    call s:echo(a:msg)
3544
+    echohl normal
3545
+endfunction
3546
+"FUNCTION: s:firstUsableWindow(){{{2
3547
+"find the window number of the first normal window
3548
+function! s:firstUsableWindow()
3549
+    let i = 1
3550
+    while i <= winnr("$")
3551
+        let bnum = winbufnr(i)
3552
+        if bnum != -1 && getbufvar(bnum, '&buftype') ==# ''
3553
+                    \ && !getwinvar(i, '&previewwindow')
3554
+                    \ && (!getbufvar(bnum, '&modified') || &hidden)
3555
+            return i
3556
+        endif
3557
+
3558
+        let i += 1
3559
+    endwhile
3560
+    return -1
3561
+endfunction
3562
+"FUNCTION: s:getPath(ln) {{{2
3563
+"Gets the full path to the node that is rendered on the given line number
3564
+"
3565
+"Args:
3566
+"ln: the line number to get the path for
3567
+"
3568
+"Return:
3569
+"A path if a node was selected, {} if nothing is selected.
3570
+"If the 'up a dir' line was selected then the path to the parent of the
3571
+"current root is returned
3572
+function! s:getPath(ln)
3573
+    let line = getline(a:ln)
3574
+
3575
+    let rootLine = s:TreeFileNode.GetRootLineNum()
3576
+
3577
+    "check to see if we have the root node
3578
+    if a:ln == rootLine
3579
+        return b:NERDTreeRoot.path
3580
+    endif
3581
+
3582
+    if !g:NERDTreeDirArrows
3583
+        " in case called from outside the tree
3584
+        if line !~# '^ *[|`▸▾ ]' || line =~# '^$'
3585
+            return {}
3586
+        endif
3587
+    endif
3588
+
3589
+    if line ==# s:tree_up_dir_line
3590
+        return b:NERDTreeRoot.path.getParent()
3591
+    endif
3592
+
3593
+    let indent = s:indentLevelFor(line)
3594
+
3595
+    "remove the tree parts and the leading space
3596
+    let curFile = s:stripMarkupFromLine(line, 0)
3597
+
3598
+    let wasdir = 0
3599
+    if curFile =~# '/$'
3600
+        let wasdir = 1
3601
+        let curFile = substitute(curFile, '/\?$', '/', "")
3602
+    endif
3603
+
3604
+    let dir = ""
3605
+    let lnum = a:ln
3606
+    while lnum > 0
3607
+        let lnum = lnum - 1
3608
+        let curLine = getline(lnum)
3609
+        let curLineStripped = s:stripMarkupFromLine(curLine, 1)
3610
+
3611
+        "have we reached the top of the tree?
3612
+        if lnum == rootLine
3613
+            let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir
3614
+            break
3615
+        endif
3616
+        if curLineStripped =~# '/$'
3617
+            let lpindent = s:indentLevelFor(curLine)
3618
+            if lpindent < indent
3619
+                let indent = indent - 1
3620
+
3621
+                let dir = substitute (curLineStripped,'^\\', "", "") . dir
3622
+                continue
3623
+            endif
3624
+        endif
3625
+    endwhile
3626
+    let curFile = b:NERDTreeRoot.path.drive . dir . curFile
3627
+    let toReturn = s:Path.New(curFile)
3628
+    return toReturn
3629
+endfunction
3630
+
3631
+"FUNCTION: s:getTreeWinNum() {{{2
3632
+"gets the nerd tree window number for this tab
3633
+function! s:getTreeWinNum()
3634
+    if exists("t:NERDTreeBufName")
3635
+        return bufwinnr(t:NERDTreeBufName)
3636
+    else
3637
+        return -1
3638
+    endif
3639
+endfunction
3640
+"FUNCTION: s:indentLevelFor(line) {{{2
3641
+function! s:indentLevelFor(line)
3642
+    let level = match(a:line, '[^ \-+~▸▾`|]') / s:tree_wid
3643
+    " check if line includes arrows
3644
+    if match(a:line, '[▸▾]') > -1
3645
+        " decrement level as arrow uses 3 ascii chars
3646
+        let level = level - 1
3647
+    endif
3648
+    return level
3649
+endfunction
3650
+"FUNCTION: s:isTreeOpen() {{{2
3651
+function! s:isTreeOpen()
3652
+    return s:getTreeWinNum() != -1
3653
+endfunction
3654
+"FUNCTION: s:isWindowUsable(winnumber) {{{2
3655
+"Returns 0 if opening a file from the tree in the given window requires it to
3656
+"be split, 1 otherwise
3657
+"
3658
+"Args:
3659
+"winnumber: the number of the window in question
3660
+function! s:isWindowUsable(winnumber)
3661
+    "gotta split if theres only one window (i.e. the NERD tree)
3662
+    if winnr("$") ==# 1
3663
+        return 0
3664
+    endif
3665
+
3666
+    let oldwinnr = winnr()
3667
+    call s:exec(a:winnumber . "wincmd p")
3668
+    let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow')
3669
+    let modified = &modified
3670
+    call s:exec(oldwinnr . "wincmd p")
3671
+
3672
+    "if its a special window e.g. quickfix or another explorer plugin then we
3673
+    "have to split
3674
+    if specialWindow
3675
+        return 0
3676
+    endif
3677
+
3678
+    if &hidden
3679
+        return 1
3680
+    endif
3681
+
3682
+    return !modified || s:bufInWindows(winbufnr(a:winnumber)) >= 2
3683
+endfunction
3684
+
3685
+" FUNCTION: s:jumpToChild(direction) {{{2
3686
+" Args:
3687
+" direction: 0 if going to first child, 1 if going to last
3688
+function! s:jumpToChild(currentNode, direction)
3689
+    if a:currentNode.isRoot()
3690
+        return s:echo("cannot jump to " . (a:direction ? "last" : "first") .  " child")
3691
+    end
3692
+    let dirNode = a:currentNode.parent
3693
+    let childNodes = dirNode.getVisibleChildren()
3694
+
3695
+    let targetNode = childNodes[0]
3696
+    if a:direction
3697
+        let targetNode = childNodes[len(childNodes) - 1]
3698
+    endif
3699
+
3700
+    if targetNode.equals(a:currentNode)
3701
+        let siblingDir = a:currentNode.parent.findOpenDirSiblingWithVisibleChildren(a:direction)
3702
+        if siblingDir != {}
3703
+            let indx = a:direction ? siblingDir.getVisibleChildCount()-1 : 0
3704
+            let targetNode = siblingDir.getChildByIndex(indx, 1)
3705
+        endif
3706
+    endif
3707
+
3708
+    call targetNode.putCursorHere(1, 0)
3709
+
3710
+    call s:centerView()
3711
+endfunction
3712
+
3713
+
3714
+" FUNCTION: s:jumpToSibling(currentNode, forward) {{{2
3715
+" moves the cursor to the sibling of the current node in the given direction
3716
+"
3717
+" Args:
3718
+" forward: 1 if the cursor should move to the next sibling, 0 if it should
3719
+" move back to the previous sibling
3720
+function! s:jumpToSibling(currentNode, forward)
3721
+    let sibling = a:currentNode.findSibling(a:forward)
3722
+
3723
+    if !empty(sibling)
3724
+        call sibling.putCursorHere(1, 0)
3725
+        call s:centerView()
3726
+    endif
3727
+endfunction
3728
+
3729
+"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{2
3730
+"prints out the given msg and, if the user responds by pushing 'y' then the
3731
+"buffer with the given bufnum is deleted
3732
+"
3733
+"Args:
3734
+"bufnum: the buffer that may be deleted
3735
+"msg: a message that will be echoed to the user asking them if they wish to
3736
+"     del the buffer
3737
+function! s:promptToDelBuffer(bufnum, msg)
3738
+    echo a:msg
3739
+    if nr2char(getchar()) ==# 'y'
3740
+        exec "silent bdelete! " . a:bufnum
3741
+    endif
3742
+endfunction
3743
+
3744
+"FUNCTION: s:putCursorOnBookmarkTable(){{{2
3745
+"Places the cursor at the top of the bookmarks table
3746
+function! s:putCursorOnBookmarkTable()
3747
+    if !b:NERDTreeShowBookmarks
3748
+        throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active"
3749
+    endif
3750
+
3751
+    if g:NERDTreeMinimalUI
3752
+        return cursor(1, 2)
3753
+    endif
3754
+
3755
+    let rootNodeLine = s:TreeFileNode.GetRootLineNum()
3756
+
3757
+    let line = 1
3758
+    while getline(line) !~# '^>-\+Bookmarks-\+$'
3759
+        let line = line + 1
3760
+        if line >= rootNodeLine
3761
+            throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table"
3762
+        endif
3763
+    endwhile
3764
+    call cursor(line, 2)
3765
+endfunction
3766
+
3767
+"FUNCTION: s:putCursorInTreeWin(){{{2
3768
+"Places the cursor in the nerd tree window
3769
+function! s:putCursorInTreeWin()
3770
+    if !s:isTreeOpen()
3771
+        throw "NERDTree.InvalidOperationError: cant put cursor in NERD tree window, no window exists"
3772
+    endif
3773
+
3774
+    call s:exec(s:getTreeWinNum() . "wincmd w")
3775
+endfunction
3776
+
3777
+"FUNCTION: s:renderBookmarks {{{2
3778
+function! s:renderBookmarks()
3779
+
3780
+    if g:NERDTreeMinimalUI == 0
3781
+        call setline(line(".")+1, ">----------Bookmarks----------")
3782
+        call cursor(line(".")+1, col("."))
3783
+    endif
3784
+
3785
+    for i in s:Bookmark.Bookmarks()
3786
+        call setline(line(".")+1, i.str())
3787
+        call cursor(line(".")+1, col("."))
3788
+    endfor
3789
+
3790
+    call setline(line(".")+1, '')
3791
+    call cursor(line(".")+1, col("."))
3792
+endfunction
3793
+"FUNCTION: s:renderView {{{2
3794
+"The entry function for rendering the tree
3795
+function! s:renderView()
3796
+    setlocal modifiable
3797
+
3798
+    "remember the top line of the buffer and the current line so we can
3799
+    "restore the view exactly how it was
3800
+    let curLine = line(".")
3801
+    let curCol = col(".")
3802
+    let topLine = line("w0")
3803
+
3804
+    "delete all lines in the buffer (being careful not to clobber a register)
3805
+    silent 1,$delete _
3806
+
3807
+    call s:dumpHelp()
3808
+
3809
+    "delete the blank line before the help and add one after it
3810
+    if g:NERDTreeMinimalUI == 0
3811
+        call setline(line(".")+1, "")
3812
+        call cursor(line(".")+1, col("."))
3813
+    endif
3814
+
3815
+    if b:NERDTreeShowBookmarks
3816
+        call s:renderBookmarks()
3817
+    endif
3818
+
3819
+    "add the 'up a dir' line
3820
+    if !g:NERDTreeMinimalUI
3821
+        call setline(line(".")+1, s:tree_up_dir_line)
3822
+        call cursor(line(".")+1, col("."))
3823
+    endif
3824
+
3825
+    "draw the header line
3826
+    let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)})
3827
+    call setline(line(".")+1, header)
3828
+    call cursor(line(".")+1, col("."))
3829
+
3830
+    "draw the tree
3831
+    let old_o = @o
3832
+    let @o = b:NERDTreeRoot.renderToString()
3833
+    silent put o
3834
+    let @o = old_o
3835
+
3836
+    "delete the blank line at the top of the buffer
3837
+    silent 1,1delete _
3838
+
3839
+    "restore the view
3840
+    let old_scrolloff=&scrolloff
3841
+    let &scrolloff=0
3842
+    call cursor(topLine, 1)
3843
+    normal! zt
3844
+    call cursor(curLine, curCol)
3845
+    let &scrolloff = old_scrolloff
3846
+
3847
+    setlocal nomodifiable
3848
+endfunction
3849
+
3850
+"FUNCTION: s:renderViewSavingPosition {{{2
3851
+"Renders the tree and ensures the cursor stays on the current node or the
3852
+"current nodes parent if it is no longer available upon re-rendering
3853
+function! s:renderViewSavingPosition()
3854
+    let currentNode = s:TreeFileNode.GetSelected()
3855
+
3856
+    "go up the tree till we find a node that will be visible or till we run
3857
+    "out of nodes
3858
+    while currentNode != {} && !currentNode.isVisible() && !currentNode.isRoot()
3859
+        let currentNode = currentNode.parent
3860
+    endwhile
3861
+
3862
+    call s:renderView()
3863
+
3864
+    if currentNode != {}
3865
+        call currentNode.putCursorHere(0, 0)
3866
+    endif
3867
+endfunction
3868
+"FUNCTION: s:restoreScreenState() {{{2
3869
+"
3870
+"Sets the screen state back to what it was when s:saveScreenState was last
3871
+"called.
3872
+"
3873
+"Assumes the cursor is in the NERDTree window
3874
+function! s:restoreScreenState()
3875
+    if !exists("b:NERDTreeOldTopLine") || !exists("b:NERDTreeOldPos") || !exists("b:NERDTreeOldWindowSize")
3876
+        return
3877
+    endif
3878
+    exec("silent vertical resize ".b:NERDTreeOldWindowSize)
3879
+
3880
+    let old_scrolloff=&scrolloff
3881
+    let &scrolloff=0
3882
+    call cursor(b:NERDTreeOldTopLine, 0)
3883
+    normal! zt
3884
+    call setpos(".", b:NERDTreeOldPos)
3885
+    let &scrolloff=old_scrolloff
3886
+endfunction
3887
+
3888
+"FUNCTION: s:saveScreenState() {{{2
3889
+"Saves the current cursor position in the current buffer and the window
3890
+"scroll position
3891
+function! s:saveScreenState()
3892
+    let win = winnr()
3893
+    try
3894
+        call s:putCursorInTreeWin()
3895
+        let b:NERDTreeOldPos = getpos(".")
3896
+        let b:NERDTreeOldTopLine = line("w0")
3897
+        let b:NERDTreeOldWindowSize = winwidth("")
3898
+        call s:exec(win . "wincmd w")
3899
+    catch /^NERDTree.InvalidOperationError/
3900
+    endtry
3901
+endfunction
3902
+
3903
+"FUNCTION: s:setCommonBufOptions() {{{2
3904
+function! s:setCommonBufOptions()
3905
+    "throwaway buffer options
3906
+    setlocal noswapfile
3907
+    setlocal buftype=nofile
3908
+    setlocal bufhidden=hide
3909
+    setlocal nowrap
3910
+    setlocal foldcolumn=0
3911
+    setlocal foldmethod=manual
3912
+    setlocal nofoldenable
3913
+    setlocal nobuflisted
3914
+    setlocal nospell
3915
+    if g:NERDTreeShowLineNumbers
3916
+        setlocal nu
3917
+    else
3918
+        setlocal nonu
3919
+        if v:version >= 703
3920
+            setlocal nornu
3921
+        endif
3922
+    endif
3923
+
3924
+    iabc <buffer>
3925
+
3926
+    if g:NERDTreeHighlightCursorline
3927
+        setlocal cursorline
3928
+    endif
3929
+
3930
+    call s:setupStatusline()
3931
+
3932
+
3933
+    let b:treeShowHelp = 0
3934
+    let b:NERDTreeIgnoreEnabled = 1
3935
+    let b:NERDTreeShowFiles = g:NERDTreeShowFiles
3936
+    let b:NERDTreeShowHidden = g:NERDTreeShowHidden
3937
+    let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks
3938
+    setfiletype nerdtree
3939
+    call s:bindMappings()
3940
+endfunction
3941
+
3942
+"FUNCTION: s:setupStatusline() {{{2
3943
+function! s:setupStatusline()
3944
+    if g:NERDTreeStatusline != -1
3945
+        let &l:statusline = g:NERDTreeStatusline
3946
+    endif
3947
+endfunction
3948
+"FUNCTION: s:stripMarkupFromLine(line, removeLeadingSpaces){{{2
3949
+"returns the given line with all the tree parts stripped off
3950
+"
3951
+"Args:
3952
+"line: the subject line
3953
+"removeLeadingSpaces: 1 if leading spaces are to be removed (leading spaces =
3954
+"any spaces before the actual text of the node)
3955
+function! s:stripMarkupFromLine(line, removeLeadingSpaces)
3956
+    let line = a:line
3957
+    "remove the tree parts and the leading space
3958
+    let line = substitute (line, s:tree_markup_reg,"","")
3959
+
3960
+    "strip off any read only flag
3961
+    let line = substitute (line, ' \[RO\]', "","")
3962
+
3963
+    "strip off any bookmark flags
3964
+    let line = substitute (line, ' {[^}]*}', "","")
3965
+
3966
+    "strip off any executable flags
3967
+    let line = substitute (line, '*\ze\($\| \)', "","")
3968
+
3969
+    let wasdir = 0
3970
+    if line =~# '/$'
3971
+        let wasdir = 1
3972
+    endif
3973
+    let line = substitute (line,' -> .*',"","") " remove link to
3974
+    if wasdir ==# 1
3975
+        let line = substitute (line, '/\?$', '/', "")
3976
+    endif
3977
+
3978
+    if a:removeLeadingSpaces
3979
+        let line = substitute (line, '^ *', '', '')
3980
+    endif
3981
+
3982
+    return line
3983
+endfunction
3984
+
3985
+"FUNCTION: s:toggle(dir) {{{2
3986
+"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is
3987
+"closed it is restored or initialized (if it doesnt exist)
3988
+"
3989
+"Args:
3990
+"dir: the full path for the root node (is only used if the NERD tree is being
3991
+"initialized.
3992
+function! s:toggle(dir)
3993
+    if s:treeExistsForTab()
3994
+        if !s:isTreeOpen()
3995
+            call s:createTreeWin()
3996
+            if !&hidden
3997
+                call s:renderView()
3998
+            endif
3999
+            call s:restoreScreenState()
4000
+        else
4001
+            call s:closeTree()
4002
+        endif
4003
+    else
4004
+        call s:initNerdTree(a:dir)
4005
+    endif
4006
+endfunction
4007
+"SECTION: Interface bindings {{{1
4008
+"============================================================
4009
+
4010
+"FUNCTION: s:activateAll() {{{2
4011
+"handle the user activating the updir line
4012
+function! s:activateAll()
4013
+    if getline(".") ==# s:tree_up_dir_line
4014
+        return s:upDir(0)
4015
+    endif
4016
+endfunction
4017
+
4018
+"FUNCTION: s:activateDirNode() {{{2
4019
+"handle the user activating a tree node
4020
+function! s:activateDirNode(node)
4021
+    call a:node.activate({'reuse': 1})
4022
+endfunction
4023
+
4024
+"FUNCTION: s:activateFileNode() {{{2
4025
+"handle the user activating a tree node
4026
+function! s:activateFileNode(node)
4027
+    call a:node.activate({'reuse': 1, 'where': 'p'})
4028
+endfunction
4029
+
4030
+"FUNCTION: s:activateBookmark() {{{2
4031
+"handle the user activating a bookmark
4032
+function! s:activateBookmark(bm)
4033
+    call a:bm.activate(!a:bm.path.isDirectory ? {'where': 'p'} : {})
4034
+endfunction
4035
+
4036
+"FUNCTION: s:bindMappings() {{{2
4037
+function! s:bindMappings()
4038
+    "make <cr> do the same as the default 'o' mapping
4039
+    exec "nnoremap <silent> <buffer> <cr> :call <SID>KeyMap_Invoke('". g:NERDTreeMapActivateNode ."')<cr>"
4040
+
4041
+    call s:KeyMap.BindAll()
4042
+
4043
+    command! -buffer -nargs=? Bookmark :call <SID>bookmarkNode('<args>')
4044
+    command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 RevealBookmark :call <SID>revealBookmark('<args>')
4045
+    command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 OpenBookmark :call <SID>openBookmark('<args>')
4046
+    command! -buffer -complete=customlist,s:completeBookmarks -nargs=* ClearBookmarks call <SID>clearBookmarks('<args>')
4047
+    command! -buffer -complete=customlist,s:completeBookmarks -nargs=+ BookmarkToRoot call s:Bookmark.ToRoot('<args>')
4048
+    command! -buffer -nargs=0 ClearAllBookmarks call s:Bookmark.ClearAll() <bar> call <SID>renderView()
4049
+    command! -buffer -nargs=0 ReadBookmarks call s:Bookmark.CacheBookmarks(0) <bar> call <SID>renderView()
4050
+    command! -buffer -nargs=0 WriteBookmarks call s:Bookmark.Write()
4051
+endfunction
4052
+
4053
+" FUNCTION: s:bookmarkNode(name) {{{2
4054
+" Associate the current node with the given name
4055
+function! s:bookmarkNode(...)
4056
+    let currentNode = s:TreeFileNode.GetSelected()
4057
+    if currentNode != {}
4058
+        let name = a:1
4059
+        if empty(name)
4060
+            let name = currentNode.path.getLastPathComponent(0)
4061
+        endif
4062
+        try
4063
+            call currentNode.bookmark(name)
4064
+            call s:renderView()
4065
+        catch /^NERDTree.IllegalBookmarkNameError/
4066
+            call s:echo("bookmark names must not contain spaces")
4067
+        endtry
4068
+    else
4069
+        call s:echo("select a node first")
4070
+    endif
4071
+endfunction
4072
+
4073
+" FUNCTION: s:chCwd(node) {{{2
4074
+function! s:chCwd(node)
4075
+    try
4076
+        call a:node.path.changeToDir()
4077
+    catch /^NERDTree.PathChangeError/
4078
+        call s:echoWarning("could not change cwd")
4079
+    endtry
4080
+endfunction
4081
+
4082
+" FUNCTION: s:chRoot(node) {{{2
4083
+" changes the current root to the selected one
4084
+function! s:chRoot(node)
4085
+    call a:node.makeRoot()
4086
+    call s:renderView()
4087
+    call b:NERDTreeRoot.putCursorHere(0, 0)
4088
+endfunction
4089
+
4090
+" FUNCTION: s:chRootCwd() {{{2
4091
+" changes the current root to CWD
4092
+function! s:chRootCwd()
4093
+    try
4094
+        let cwd = s:Path.New(getcwd())
4095
+    catch /^NERDTree.InvalidArgumentsError/
4096
+        call s:echo("current directory does not exist.")
4097
+        return
4098
+    endtry
4099
+    if cwd.str() == s:TreeFileNode.GetRootForTab().path.str()
4100
+       return
4101
+    endif
4102
+    call s:chRoot(s:TreeDirNode.New(cwd))
4103
+endfunction
4104
+
4105
+" FUNCTION: s:clearBookmarks(bookmarks) {{{2
4106
+function! s:clearBookmarks(bookmarks)
4107
+    if a:bookmarks ==# ''
4108
+        let currentNode = s:TreeFileNode.GetSelected()
4109
+        if currentNode != {}
4110
+            call currentNode.clearBookmarks()
4111
+        endif
4112
+    else
4113
+        for name in split(a:bookmarks, ' ')
4114
+            let bookmark = s:Bookmark.BookmarkFor(name)
4115
+            call bookmark.delete()
4116
+        endfor
4117
+    endif
4118
+    call s:renderView()
4119
+endfunction
4120
+" FUNCTION: s:closeChildren(node) {{{2
4121
+" closes all childnodes of the current node
4122
+function! s:closeChildren(node)
4123
+    call a:node.closeChildren()
4124
+    call s:renderView()
4125
+    call a:node.putCursorHere(0, 0)
4126
+endfunction
4127
+" FUNCTION: s:closeCurrentDir(node) {{{2
4128
+" closes the parent dir of the current node
4129
+function! s:closeCurrentDir(node)
4130
+    let parent = a:node.parent
4131
+    if parent ==# {} || parent.isRoot()
4132
+        call s:echo("cannot close tree root")
4133
+    else
4134
+        call a:node.parent.close()
4135
+        call s:renderView()
4136
+        call a:node.parent.putCursorHere(0, 0)
4137
+    endif
4138
+endfunction
4139
+" FUNCTION: s:closeTreeWindow() {{{2
4140
+" close the tree window
4141
+function! s:closeTreeWindow()
4142
+    if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1
4143
+        exec "buffer " . b:NERDTreePreviousBuf
4144
+    else
4145
+        if winnr("$") > 1
4146
+            call s:closeTree()
4147
+        else
4148
+            call s:echo("Cannot close last window")
4149
+        endif
4150
+    endif
4151
+endfunction
4152
+" FUNCTION: s:deleteBookmark(bm) {{{2
4153
+" if the cursor is on a bookmark, prompt to delete
4154
+function! s:deleteBookmark(bm)
4155
+    echo  "Are you sure you wish to delete the bookmark:\n\"" . a:bm.name . "\" (yN):"
4156
+
4157
+    if  nr2char(getchar()) ==# 'y'
4158
+        try
4159
+            call a:bm.delete()
4160
+            call s:renderView()
4161
+            redraw
4162
+        catch /^NERDTree/
4163
+            call s:echoWarning("Could not remove bookmark")
4164
+        endtry
4165
+    else
4166
+        call s:echo("delete aborted" )
4167
+    endif
4168
+
4169
+endfunction
4170
+
4171
+" FUNCTION: s:displayHelp() {{{2
4172
+" toggles the help display
4173
+function! s:displayHelp()
4174
+    let b:treeShowHelp = b:treeShowHelp ? 0 : 1
4175
+    call s:renderView()
4176
+    call s:centerView()
4177
+endfunction
4178
+
4179
+"FUNCTION: s:handleLeftClick() {{{2
4180
+"Checks if the click should open the current node
4181
+function! s:handleLeftClick()
4182
+    let currentNode = s:TreeFileNode.GetSelected()
4183
+    if currentNode != {}
4184
+
4185
+        "the dir arrows are multibyte chars, and vim's string functions only
4186
+        "deal with single bytes - so split the line up with the hack below and
4187
+        "take the line substring manually
4188
+        let line = split(getline(line(".")), '\zs')
4189
+        let startToCur = ""
4190
+        for i in range(0,len(line)-1)
4191
+            let startToCur .= line[i]
4192
+        endfor
4193
+
4194
+        if currentNode.path.isDirectory
4195
+            if startToCur =~# s:tree_markup_reg && startToCur =~# '[+~▾▸] \?$'
4196
+                call currentNode.activate()
4197
+                return
4198
+            endif
4199
+        endif
4200
+
4201
+        if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3
4202
+            let char = strpart(startToCur, strlen(startToCur)-1, 1)
4203
+            if char !~# s:tree_markup_reg
4204
+                if currentNode.path.isDirectory
4205
+                    call currentNode.activate()
4206
+                else
4207
+                    call currentNode.activate({'reuse': 1, 'where': 'p'})
4208
+                endif
4209
+                return
4210
+            endif
4211
+        endif
4212
+    endif
4213
+endfunction
4214
+
4215
+" FUNCTION: s:handleMiddleMouse() {{{2
4216
+function! s:handleMiddleMouse()
4217
+    let curNode = s:TreeFileNode.GetSelected()
4218
+    if curNode ==# {}
4219
+        call s:echo("Put the cursor on a node first" )
4220
+        return
4221
+    endif
4222
+
4223
+    if curNode.path.isDirectory
4224
+        call s:openExplorer(curNode)
4225
+    else
4226
+        call curNode.open({'where': 'h'})
4227
+    endif
4228
+endfunction
4229
+
4230
+" FUNCTION: s:jumpToFirstChild() {{{2
4231
+" wrapper for the jump to child method
4232
+function! s:jumpToFirstChild(node)
4233
+    call s:jumpToChild(a:node, 0)
4234
+endfunction
4235
+
4236
+" FUNCTION: s:jumpToLastChild() {{{2
4237
+" wrapper for the jump to child method
4238
+function! s:jumpToLastChild(node)
4239
+    call s:jumpToChild(a:node, 1)
4240
+endfunction
4241
+
4242
+" FUNCTION: s:jumpToParent(node) {{{2
4243
+" moves the cursor to the parent of the current node
4244
+function! s:jumpToParent(node)
4245
+    if !empty(a:node.parent)
4246
+        call a:node.parent.putCursorHere(1, 0)
4247
+        call s:centerView()
4248
+    else
4249
+        call s:echo("cannot jump to parent")
4250
+    endif
4251
+endfunction
4252
+
4253
+" FUNCTION: s:jumpToRoot() {{{2
4254
+" moves the cursor to the root node
4255
+function! s:jumpToRoot()
4256
+    call b:NERDTreeRoot.putCursorHere(1, 0)
4257
+    call s:centerView()
4258
+endfunction
4259
+
4260
+" FUNCTION: s:jumpToNextSibling(node) {{{2
4261
+function! s:jumpToNextSibling(node)
4262
+    call s:jumpToSibling(a:node, 1)
4263
+endfunction
4264
+
4265
+" FUNCTION: s:jumpToPrevSibling(node) {{{2
4266
+function! s:jumpToPrevSibling(node)
4267
+    call s:jumpToSibling(a:node, 0)
4268
+endfunction
4269
+
4270
+" FUNCTION: s:openBookmark(name) {{{2
4271
+" put the cursor on the given bookmark and, if its a file, open it
4272
+function! s:openBookmark(name)
4273
+    try
4274
+        let targetNode = s:Bookmark.GetNodeForName(a:name, 0)
4275
+        call targetNode.putCursorHere(0, 1)
4276
+        redraw!
4277
+    catch /^NERDTree.BookmarkedNodeNotFoundError/
4278
+        call s:echo("note - target node is not cached")
4279
+        let bookmark = s:Bookmark.BookmarkFor(a:name)
4280
+        let targetNode = s:TreeFileNode.New(bookmark.path)
4281
+    endtry
4282
+    if targetNode.path.isDirectory
4283
+        call targetNode.openExplorer()
4284
+    else
4285
+        call targetNode.open({'where': 'p'})
4286
+    endif
4287
+endfunction
4288
+
4289
+" FUNCTION: s:openHSplit(target) {{{2
4290
+function! s:openHSplit(target)
4291
+    call a:target.activate({'where': 'h'})
4292
+endfunction
4293
+
4294
+" FUNCTION: s:openVSplit(target) {{{2
4295
+function! s:openVSplit(target)
4296
+    call a:target.activate({'where': 'v'})
4297
+endfunction
4298
+
4299
+" FUNCTION: s:openExplorer(node) {{{2
4300
+function! s:openExplorer(node)
4301
+    call a:node.openExplorer()
4302
+endfunction
4303
+
4304
+" FUNCTION: s:openInNewTab(target) {{{2
4305
+function! s:openInNewTab(target)
4306
+    call a:target.activate({'where': 't'})
4307
+endfunction
4308
+
4309
+" FUNCTION: s:openInNewTabSilent(target) {{{2
4310
+function! s:openInNewTabSilent(target)
4311
+    call a:target.activate({'where': 't', 'stay': 1})
4312
+endfunction
4313
+
4314
+" FUNCTION: s:openNodeRecursively(node) {{{2
4315
+function! s:openNodeRecursively(node)
4316
+    call s:echo("Recursively opening node. Please wait...")
4317
+    call a:node.openRecursively()
4318
+    call s:renderView()
4319
+    redraw
4320
+    call s:echo("Recursively opening node. Please wait... DONE")
4321
+endfunction
4322
+
4323
+"FUNCTION: s:previewNodeCurrent(node) {{{2
4324
+function! s:previewNodeCurrent(node)
4325
+    call a:node.open({'stay': 1, 'where': 'p', 'keepopen': 1})
4326
+endfunction
4327
+
4328
+"FUNCTION: s:previewNodeHSplit(node) {{{2
4329
+function! s:previewNodeHSplit(node)
4330
+    call a:node.open({'stay': 1, 'where': 'h', 'keepopen': 1})
4331
+endfunction
4332
+
4333
+"FUNCTION: s:previewNodeVSplit(node) {{{2
4334
+function! s:previewNodeVSplit(node)
4335
+    call a:node.open({'stay': 1, 'where': 'v', 'keepopen': 1})
4336
+endfunction
4337
+
4338
+" FUNCTION: s:revealBookmark(name) {{{2
4339
+" put the cursor on the node associate with the given name
4340
+function! s:revealBookmark(name)
4341
+    try
4342
+        let targetNode = s:Bookmark.GetNodeForName(a:name, 0)
4343
+        call targetNode.putCursorHere(0, 1)
4344
+    catch /^NERDTree.BookmarkNotFoundError/
4345
+        call s:echo("Bookmark isnt cached under the current root")
4346
+    endtry
4347
+endfunction
4348
+" FUNCTION: s:refreshRoot() {{{2
4349
+" Reloads the current root. All nodes below this will be lost and the root dir
4350
+" will be reloaded.
4351
+function! s:refreshRoot()
4352
+    call s:echo("Refreshing the root node. This could take a while...")
4353
+    call b:NERDTreeRoot.refresh()
4354
+    call s:renderView()
4355
+    redraw
4356
+    call s:echo("Refreshing the root node. This could take a while... DONE")
4357
+endfunction
4358
+
4359
+" FUNCTION: s:refreshCurrent(node) {{{2
4360
+" refreshes the root for the current node
4361
+function! s:refreshCurrent(node)
4362
+    let node = a:node
4363
+    if !node.path.isDirectory
4364
+        let node = node.parent
4365
+    endif
4366
+
4367
+    call s:echo("Refreshing node. This could take a while...")
4368
+    call node.refresh()
4369
+    call s:renderView()
4370
+    redraw
4371
+    call s:echo("Refreshing node. This could take a while... DONE")
4372
+endfunction
4373
+" FUNCTION: s:showMenu(node) {{{2
4374
+function! s:showMenu(node)
4375
+    let mc = s:MenuController.New(s:MenuItem.AllEnabled())
4376
+    call mc.showMenu()
4377
+endfunction
4378
+
4379
+" FUNCTION: s:toggleIgnoreFilter() {{{2
4380
+" toggles the use of the NERDTreeIgnore option
4381
+function! s:toggleIgnoreFilter()
4382
+    let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled
4383
+    call s:renderViewSavingPosition()
4384
+    call s:centerView()
4385
+endfunction
4386
+
4387
+" FUNCTION: s:toggleShowBookmarks() {{{2
4388
+" toggles the display of bookmarks
4389
+function! s:toggleShowBookmarks()
4390
+    let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks
4391
+    if b:NERDTreeShowBookmarks
4392
+        call s:renderView()
4393
+        call s:putCursorOnBookmarkTable()
4394
+    else
4395
+        call s:renderViewSavingPosition()
4396
+    endif
4397
+    call s:centerView()
4398
+endfunction
4399
+" FUNCTION: s:toggleShowFiles() {{{2
4400
+" toggles the display of hidden files
4401
+function! s:toggleShowFiles()
4402
+    let b:NERDTreeShowFiles = !b:NERDTreeShowFiles
4403
+    call s:renderViewSavingPosition()
4404
+    call s:centerView()
4405
+endfunction
4406
+
4407
+" FUNCTION: s:toggleShowHidden() {{{2
4408
+" toggles the display of hidden files
4409
+function! s:toggleShowHidden()
4410
+    let b:NERDTreeShowHidden = !b:NERDTreeShowHidden
4411
+    call s:renderViewSavingPosition()
4412
+    call s:centerView()
4413
+endfunction
4414
+
4415
+" FUNCTION: s:toggleZoom() {{{2
4416
+" zoom (maximize/minimize) the NERDTree window
4417
+function! s:toggleZoom()
4418
+    if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed
4419
+        let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
4420
+        exec "silent vertical resize ". size
4421
+        let b:NERDTreeZoomed = 0
4422
+    else
4423
+        exec "vertical resize"
4424
+        let b:NERDTreeZoomed = 1
4425
+    endif
4426
+endfunction
4427
+
4428
+" FUNCTION: s:upDirCurrentRootOpen() {{{2
4429
+function! s:upDirCurrentRootOpen()
4430
+    call s:upDir(1)
4431
+endfunction
4432
+
4433
+" FUNCTION: s:upDirCurrentRootClosed() {{{2
4434
+function! s:upDirCurrentRootClosed()
4435
+    call s:upDir(0)
4436
+endfunction
4437
+
4438
+" SECTION: Post Source Actions {{{1
4439
+call s:postSourceActions()
4440
+
4441
+"reset &cpo back to users setting
4442
+let &cpo = s:old_cpo
4443
+
4444
+" vim: set sw=4 sts=4 et fdm=marker:
... ...
@@ -0,0 +1,88 @@
1
+let s:tree_up_dir_line = '.. (up a dir)'
2
+"NERDTreeFlags are syntax items that should be invisible, but give clues as to
3
+"how things should be highlighted
4
+syn match NERDTreeFlag #\~#
5
+syn match NERDTreeFlag #\[RO\]#
6
+
7
+"highlighting for the .. (up dir) line at the top of the tree
8
+execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#"
9
+
10
+"highlighting for the ~/+ symbols for the directory nodes
11
+syn match NERDTreeClosable #\~\<#
12
+syn match NERDTreeClosable #\~\.#
13
+syn match NERDTreeOpenable #+\<#
14
+syn match NERDTreeOpenable #+\.#he=e-1
15
+
16
+"highlighting for the tree structural parts
17
+syn match NERDTreePart #|#
18
+syn match NERDTreePart #`#
19
+syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart
20
+
21
+"quickhelp syntax elements
22
+syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1
23
+syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1
24
+syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag
25
+syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey
26
+syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey
27
+syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3
28
+syn match NERDTreeHelp  #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand
29
+
30
+"highlighting for readonly files
31
+syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile
32
+
33
+"highlighting for sym links
34
+syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash
35
+
36
+"highlighing for directory nodes and file nodes
37
+syn match NERDTreeDirSlash #/#
38
+syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable
39
+syn match NERDTreeExecFile  #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark
40
+syn match NERDTreeFile  #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
41
+syn match NERDTreeFile  #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
42
+syn match NERDTreeCWD #^[</].*$#
43
+
44
+"highlighting for bookmarks
45
+syn match NERDTreeBookmark # {.*}#hs=s+1
46
+
47
+"highlighting for the bookmarks table
48
+syn match NERDTreeBookmarksLeader #^>#
49
+syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader
50
+syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader
51
+syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader
52
+
53
+if exists("g:NERDChristmasTree") && g:NERDChristmasTree
54
+    hi def link NERDTreePart Special
55
+    hi def link NERDTreePartFile Type
56
+    hi def link NERDTreeFile Normal
57
+    hi def link NERDTreeExecFile Title
58
+    hi def link NERDTreeDirSlash Identifier
59
+    hi def link NERDTreeClosable Type
60
+else
61
+    hi def link NERDTreePart Normal
62
+    hi def link NERDTreePartFile Normal
63
+    hi def link NERDTreeFile Normal
64
+    hi def link NERDTreeClosable Title
65
+endif
66
+
67
+hi def link NERDTreeBookmarksHeader statement
68
+hi def link NERDTreeBookmarksLeader ignore
69
+hi def link NERDTreeBookmarkName Identifier
70
+hi def link NERDTreeBookmark normal
71
+
72
+hi def link NERDTreeHelp String
73
+hi def link NERDTreeHelpKey Identifier
74
+hi def link NERDTreeHelpCommand Identifier
75
+hi def link NERDTreeHelpTitle Macro
76
+hi def link NERDTreeToggleOn Question
77
+hi def link NERDTreeToggleOff WarningMsg
78
+
79
+hi def link NERDTreeDir Directory
80
+hi def link NERDTreeUp Directory
81
+hi def link NERDTreeCWD Statement
82
+hi def link NERDTreeLink Macro
83
+hi def link NERDTreeOpenable Title
84
+hi def link NERDTreeFlag ignore
85
+hi def link NERDTreeRO WarningMsg
86
+hi def link NERDTreeBookmark Statement
87
+
88
+hi def link NERDTreeCurrentNode Search
... ...
@@ -0,0 +1,1501 @@
1
+*taglist.txt*	Plugin for browsing source code
2
+
3
+Author: Yegappan Lakshmanan  (yegappan AT yahoo DOT com)
4
+For Vim version 6.0 and above
5
+Last change: 2007 May 24
6
+
7
+1. Overview 					|taglist-intro|
8
+2. Taglist on the internet			|taglist-internet|
9
+3. Requirements					|taglist-requirements|
10
+4. Installation 				|taglist-install|
11
+5. Usage 					|taglist-using|
12
+6. Options 					|taglist-options|
13
+7. Commands 					|taglist-commands|
14
+8. Global functions 				|taglist-functions|
15
+9. Extending 					|taglist-extend|
16
+10. FAQ 					|taglist-faq|
17
+11. License 					|taglist-license|
18
+12. Todo					|taglist-todo|
19
+
20
+==============================================================================
21
+						*taglist-intro*
22
+1. Overview~
23
+
24
+The "Tag List" plugin is a source code browser plugin for Vim. This plugin
25
+allows you to efficiently browse through source code files for different
26
+programming languages. The "Tag List" plugin provides the following features:
27
+
28
+    * Displays the tags (functions, classes, structures, variables, etc.) 
29
+      defined in a file in a vertically or horizontally split Vim window.
30
+    * In GUI Vim, optionally displays the tags in the Tags drop-down menu and
31
+      in the popup menu.
32
+    * Automatically updates the taglist window as you switch between
33
+      files/buffers. As you open new files, the tags defined in the new files
34
+      are added to the existing file list and the tags defined in all the
35
+      files are displayed grouped by the filename.
36
+    * When a tag name is selected from the taglist window, positions the
37
+      cursor at the definition of the tag in the source file.
38
+    * Automatically highlights the current tag name.
39
+    * Groups the tags by their type and displays them in a foldable tree.
40
+    * Can display the prototype and scope of a tag.
41
+    * Can optionally display the tag prototype instead of the tag name in the
42
+      taglist window.
43
+    * The tag list can be sorted either by name or by chronological order.
44
+    * Supports the following language files: Assembly, ASP, Awk, Beta, C,
45
+      C++, C#, Cobol, Eiffel, Erlang, Fortran, HTML, Java, Javascript, Lisp,
46
+      Lua, Make, Pascal, Perl, PHP, Python, Rexx, Ruby, Scheme, Shell, Slang,
47
+      SML, Sql, TCL, Verilog, Vim and Yacc.
48
+    * Can be easily extended to support new languages. Support for
49
+      existing languages can be modified easily.
50
+    * Provides functions to display the current tag name in the Vim status
51
+      line or the window title bar.
52
+    * The list of tags and files in the taglist can be saved and
53
+      restored across Vim sessions.
54
+    * Provides commands to get the name and prototype of the current tag.
55
+    * Runs in both console/terminal and GUI versions of Vim.
56
+    * Works with the winmanager plugin. Using the winmanager plugin, you
57
+      can use Vim plugins like the file explorer, buffer explorer and the
58
+      taglist plugin at the same time like an IDE.
59
+    * Can be used in both Unix and MS-Windows systems.
60
+
61
+==============================================================================
62
+						*taglist-internet*
63
+2. Taglist on the internet~
64
+
65
+The home page of the taglist plugin is at:
66
+>
67
+	http://vim-taglist.sourceforge.net/
68
+<
69
+You can subscribe to the taglist mailing list to post your questions or
70
+suggestions for improvement or to send bug reports. Visit the following page
71
+for subscribing to the mailing list:
72
+>
73
+	http://groups.yahoo.com/group/taglist
74
+<
75
+==============================================================================
76
+						*taglist-requirements*
77
+3. Requirements~
78
+
79
+The taglist plugin requires the following:
80
+
81
+    * Vim version 6.0 and above
82
+    * Exuberant ctags 5.0 and above
83
+
84
+The taglist plugin will work on all the platforms where the exuberant ctags
85
+utility and Vim are supported (this includes MS-Windows and Unix based
86
+systems).
87
+
88
+The taglist plugin relies on the exuberant ctags utility to dynamically
89
+generate the tag listing.  The exuberant ctags utility must be installed in
90
+your system to use this plugin.  The exuberant ctags utility is shipped with
91
+most of the Linux distributions.  You can download the exuberant ctags utility
92
+from
93
+>
94
+	http://ctags.sourceforge.net
95
+<
96
+The taglist plugin doesn't use or create a tags file and there is no need to
97
+create a tags file to use this plugin. The taglist plugin will not work with
98
+the GNU ctags or the Unix ctags utility.
99
+
100
+This plugin relies on the Vim "filetype" detection mechanism to determine the
101
+type of the current file. You have to turn on the Vim filetype detection by
102
+adding the following line to your .vimrc file:
103
+>
104
+	filetype on
105
+<
106
+The taglist plugin will not work if you run Vim in the restricted mode (using
107
+the -Z command-line argument).
108
+
109
+The taglist plugin uses the Vim system() function to invoke the exuberant
110
+ctags utility. If Vim is compiled without the system() function then you
111
+cannot use the taglist plugin. Some of the Linux distributions (Suse) compile
112
+Vim without the system() function for security reasons.
113
+
114
+==============================================================================
115
+						*taglist-install*
116
+4. Installation~
117
+
118
+1. Download the taglist.zip file and unzip the files to the $HOME/.vim or the
119
+   $HOME/vimfiles or the $VIM/vimfiles directory. After this step, you should
120
+   have the following two files (the directory structure should be preserved):
121
+
122
+	plugin/taglist.vim - main taglist plugin file
123
+	doc/taglist.txt    - documentation (help) file
124
+
125
+   Refer to the |add-plugin|and |'runtimepath'| Vim help pages for more
126
+   details about installing Vim plugins.
127
+2. Change to the $HOME/.vim/doc or $HOME/vimfiles/doc or $VIM/vimfiles/doc
128
+   directory, start Vim and run the ":helptags ." command to process the
129
+   taglist help file. Without this step, you cannot jump to the taglist help
130
+   topics.
131
+3. If the exuberant ctags utility is not present in one of the directories in
132
+   the PATH environment variable, then set the 'Tlist_Ctags_Cmd' variable to
133
+   point to the location of the exuberant ctags utility (not to the directory)
134
+   in the .vimrc file.
135
+4. If you are running a terminal/console version of Vim and the terminal
136
+   doesn't support changing the window width then set the
137
+   'Tlist_Inc_Winwidth' variable to 0 in the .vimrc file.
138
+5. Restart Vim.
139
+6. You can now use the ":TlistToggle" command to open/close the taglist
140
+   window. You can use the ":help taglist" command to get more information
141
+   about using the taglist plugin.
142
+
143
+To uninstall the taglist plugin, remove the plugin/taglist.vim and
144
+doc/taglist.txt files from the $HOME/.vim or $HOME/vimfiles directory.
145
+
146
+==============================================================================
147
+						*taglist-using*
148
+5. Usage~
149
+
150
+The taglist plugin can be used in several different ways.
151
+
152
+1. You can keep the taglist window open during the entire editing session. On
153
+   opening the taglist window, the tags defined in all the files in the Vim
154
+   buffer list will be displayed in the taglist window. As you edit files, the
155
+   tags defined in them will be added to the taglist window. You can select a
156
+   tag from the taglist window and jump to it. The current tag will be
157
+   highlighted in the taglist window. You can close the taglist window when
158
+   you no longer need the window.
159
+2. You can configure the taglist plugin to process the tags defined in all the
160
+   edited files always. In this configuration, even if the taglist window is
161
+   closed and the taglist menu is not displayed, the taglist plugin will
162
+   processes the tags defined in newly edited files. You can then open the
163
+   taglist window only when you need to select a tag and then automatically
164
+   close the taglist window after selecting the tag.
165
+3. You can configure the taglist plugin to display only the tags defined in
166
+   the current file in the taglist window. By default, the taglist plugin
167
+   displays the tags defined in all the files in the Vim buffer list. As you
168
+   switch between files, the taglist window will be refreshed to display only
169
+   the tags defined in the current file.
170
+4. In GUI Vim, you can use the Tags pull-down and popup menu created by the
171
+   taglist plugin to display the tags defined in the current file and select a
172
+   tag to jump to it. You can use the menu without opening the taglist window.
173
+   By default, the Tags menu is disabled.
174
+5. You can configure the taglist plugin to display the name of the current tag
175
+   in the Vim window status line or in the Vim window title bar. For this to
176
+   work without the taglist window or menu, you need to configure the taglist
177
+   plugin to process the tags defined in a file always.
178
+6. You can save the tags defined in multiple files to a taglist session file
179
+   and load it when needed. You can also configure the taglist plugin to not
180
+   update the taglist window when editing new files. You can then manually add
181
+   files to the taglist window.
182
+
183
+Opening the taglist window~
184
+You can open the taglist window using the ":TlistOpen" or the ":TlistToggle"
185
+commands. The ":TlistOpen" command opens the taglist window and jumps to it.
186
+The ":TlistToggle" command opens or closes (toggle) the taglist window and the
187
+cursor remains in the current window. If the 'Tlist_GainFocus_On_ToggleOpen'
188
+variable is set to 1, then the ":TlistToggle" command opens the taglist window
189
+and moves the cursor to the taglist window.
190
+
191
+You can map a key to invoke these commands. For example, the following command
192
+creates a normal mode mapping for the <F8> key to toggle the taglist window.
193
+>
194
+	nnoremap <silent> <F8> :TlistToggle<CR>
195
+<
196
+Add the above mapping to your ~/.vimrc or $HOME/_vimrc file.
197
+
198
+To automatically open the taglist window on Vim startup, set the
199
+'Tlist_Auto_Open' variable to 1.
200
+
201
+You can also open the taglist window on startup using the following command
202
+line:
203
+>
204
+	$ vim +TlistOpen
205
+<
206
+Closing the taglist window~
207
+You can close the taglist window from the taglist window by pressing 'q' or
208
+using the Vim ":q" command. You can also use any of the Vim window commands to
209
+close the taglist window. Invoking the ":TlistToggle" command when the taglist
210
+window is opened, closes the taglist window. You can also use the
211
+":TlistClose" command to close the taglist window.
212
+
213
+To automatically close the taglist window when a tag or file is selected, you
214
+can set the 'Tlist_Close_On_Select' variable to 1.  To exit Vim when only the
215
+taglist window is present, set the 'Tlist_Exit_OnlyWindow' variable to 1.
216
+
217
+Jumping to a tag or a file~
218
+You can select a tag in the taglist window either by pressing the <Enter> key
219
+or by double clicking the tag name using the mouse. To jump to a tag on a
220
+single mouse click set the 'Tlist_Use_SingleClick' variable to 1.
221
+
222
+If the selected file is already opened in a window, then the cursor is moved
223
+to that window. If the file is not currently opened in a window then the file
224
+is opened in the window used by the taglist plugin to show the previously
225
+selected file. If there are no usable windows, then the file is opened in a
226
+new window.  The file is not opened in special windows like the quickfix
227
+window, preview window and windows containing buffer with the 'buftype' option
228
+set.
229
+
230
+To jump to the tag in a new window, press the 'o' key. To open the file in the
231
+previous window (Ctrl-W_p) use the 'P' key. You can press the 'p' key to jump
232
+to the tag but still keep the cursor in the taglist window (preview).
233
+
234
+To open the selected file in a tab, use the 't' key.  If the file is already
235
+present in a tab then the cursor is moved to that tab otherwise the file is
236
+opened in a new tab. To jump to a tag in a new tab press Ctrl-t.  The taglist
237
+window is automatically opened in the newly created tab.
238
+
239
+Instead of jumping to a tag, you can open a file by pressing the <Enter> key
240
+or by double clicking the file name using the mouse.
241
+
242
+In the taglist window, you can use the [[ or <Backspace> key to jump to the
243
+beginning of the previous file. You can use the ]] or <Tab> key to jump to the
244
+beginning of the next file. When you reach the first or last file, the search
245
+wraps around and the jumps to the next/previous file.
246
+
247
+Highlighting the current tag~
248
+The taglist plugin automatically highlights the name of the current tag in the
249
+taglist window. The Vim |CursorHold| autocmd event is used for this. If the
250
+current tag name is not visible in the taglist window, then the taglist window
251
+contents are scrolled to make that tag name visible. You can also use the
252
+":TlistHighlightTag" command to force the highlighting of the current tag.
253
+
254
+The tag name is highlighted if no activity is performed for |'updatetime'|
255
+milliseconds. The default value for this Vim option is 4 seconds. To avoid
256
+unexpected problems, you should not set the |'updatetime'| option to a very
257
+low value.
258
+
259
+To disable the automatic highlighting of the current tag name in the taglist
260
+window, set the 'Tlist_Auto_Highlight_Tag' variable to zero.
261
+
262
+When entering a Vim buffer/window, the taglist plugin automatically highlights
263
+the current tag in that buffer/window.  If you like to disable the automatic
264
+highlighting of the current tag when entering a buffer, set the
265
+'Tlist_Highlight_Tag_On_BufEnter' variable to zero.
266
+
267
+Adding files to the taglist~
268
+When the taglist window is opened, all the files in the Vim buffer list are
269
+processed and the supported files are added to the taglist.  When you edit a
270
+file in Vim, the taglist plugin automatically processes this file and adds it
271
+to the taglist. If you close the taglist window, the tag information in the
272
+taglist is retained.
273
+
274
+To process files even when the taglist window is not open, set the
275
+'Tlist_Process_File_Always' variable to 1.
276
+
277
+You can manually add multiple files to the taglist without opening them using
278
+the ":TlistAddFiles" and the ":TlistAddFilesRecursive" commands.
279
+
280
+For example, to add all the C files in the /my/project/dir directory to the
281
+taglist, you can use the following command:
282
+>
283
+	:TlistAddFiles /my/project/dir/*.c
284
+<
285
+Note that when adding several files with a large number of tags or a large
286
+number of files, it will take several seconds to several minutes for the
287
+taglist plugin to process all the files. You should not interrupt the taglist
288
+plugin by pressing <CTRL-C>.
289
+
290
+You can recursively add multiple files from a directory tree using the
291
+":TlistAddFilesRecursive" command:
292
+>
293
+	:TlistAddFilesRecursive /my/project/dir *.c
294
+<
295
+This command takes two arguments. The first argument specifies the directory
296
+from which to recursively add the files. The second optional argument
297
+specifies the wildcard matching pattern for selecting the files to add. The
298
+default pattern is * and all the files are added.
299
+
300
+Displaying tags for only one file~
301
+The taglist window displays the tags for all the files in the Vim buffer list
302
+and all the manually added files. To display the tags for only the current
303
+active buffer, set the 'Tlist_Show_One_File' variable to 1.
304
+
305
+Removing files from the taglist~
306
+You can remove a file from the taglist window, by pressing the 'd' key when the
307
+cursor is on one of the tags listed for the file in the taglist window. The
308
+removed file will no longer be displayed in the taglist window in the current
309
+Vim session. To again display the tags for the file, open the file in a Vim
310
+window and then use the ":TlistUpdate" command or use ":TlistAddFiles" command
311
+to add the file to the taglist.
312
+
313
+When a buffer is removed from the Vim buffer list using the ":bdelete" or the
314
+":bwipeout" command, the taglist is updated to remove the stored information
315
+for this buffer.
316
+
317
+Updating the tags displayed for a file~
318
+The taglist plugin keeps track of the modification time of a file. When the
319
+modification time changes (the file is modified), the taglist plugin
320
+automatically updates the tags listed for that file. The modification time of
321
+a file is checked when you enter a window containing that file or when you
322
+load that file.
323
+
324
+You can also update or refresh the tags displayed for a file by pressing the
325
+"u" key in the taglist window. If an existing file is modified, after the file
326
+is saved, the taglist plugin automatically updates the tags displayed for the
327
+file.
328
+
329
+You can also use the ":TlistUpdate" command to update the tags for the current
330
+buffer after you made some changes to it. You should save the modified buffer
331
+before you update the taglist window. Otherwise the listed tags will not
332
+include the new tags created in the buffer. 
333
+
334
+If you have deleted the tags displayed for a file in the taglist window using
335
+the 'd' key, you can again display the tags for that file using the
336
+":TlistUpdate" command.
337
+
338
+Controlling the taglist updates~
339
+To disable the automatic processing of new files or modified files, you can
340
+set the 'Tlist_Auto_Update' variable to zero. When this variable is set to
341
+zero, the taglist is updated only when you use the ":TlistUpdate" command or
342
+the ":TlistAddFiles" or the ":TlistAddFilesRecursive" commands. You can use
343
+this option to control which files are added to the taglist.
344
+
345
+You can use the ":TlistLock" command to lock the taglist contents. After this
346
+command is executed, new files are not automatically added to the taglist.
347
+When the taglist is locked, you can use the ":TlistUpdate" command to add the
348
+current file or the ":TlistAddFiles" or ":TlistAddFilesRecursive" commands to
349
+add new files to the taglist.  To unlock the taglist, use the ":TlistUnlock"
350
+command.
351
+
352
+Displaying the tag prototype~
353
+To display the prototype of the tag under the cursor in the taglist window,
354
+press the space bar. If you place the cursor on a tag name in the taglist
355
+window, then the tag prototype is displayed at the Vim status line after
356
+|'updatetime'| milliseconds. The default value for the |'updatetime'| Vim
357
+option is 4 seconds.
358
+
359
+You can get the name and prototype of a tag without opening the taglist window
360
+and the taglist menu using the ":TlistShowTag" and the ":TlistShowPrototype"
361
+commands. These commands will work only if the current file is already present
362
+in the taglist. To use these commands without opening the taglist window, set
363
+the 'Tlist_Process_File_Always' variable to 1.
364
+
365
+You can use the ":TlistShowTag" command to display the name of the tag at or
366
+before the specified line number in the specified file.  If the file name and
367
+line number are not supplied, then this command will display the name of the
368
+current tag. For example,
369
+>
370
+	:TlistShowTag
371
+	:TlistShowTag myfile.java 100
372
+<
373
+You can use the ":TlistShowPrototype" command to display the prototype of the
374
+tag at or before the specified line number in the specified file.  If the file
375
+name and the line number are not supplied, then this command will display the
376
+prototype of the current tag.  For example,
377
+>
378
+	:TlistShowPrototype
379
+	:TlistShowPrototype myfile.c 50
380
+<
381
+In the taglist window, when the mouse is moved over a tag name, the tag
382
+prototype is displayed in a balloon. This works only in GUI versions where
383
+balloon evaluation is supported.
384
+
385
+Taglist window contents~
386
+The taglist window contains the tags defined in various files in the taglist
387
+grouped by the filename and by the tag type (variable, function, class, etc.).
388
+For tags with scope information (like class members, structures inside
389
+structures, etc.), the scope information is displayed in square brackets "[]"
390
+after the tag name.
391
+
392
+The contents of the taglist buffer/window are managed by the taglist plugin.
393
+The |'filetype'| for the taglist buffer is set to 'taglist'.  The Vim
394
+|'modifiable'| option is turned off for the taglist buffer. You should not
395
+manually edit the taglist buffer, by setting the |'modifiable'| flag. If you
396
+manually edit the taglist buffer contents, then the taglist plugin will be out
397
+of sync with the taglist buffer contents and the plugin will no longer work
398
+correctly. To redisplay the taglist buffer contents again, close the taglist
399
+window and reopen it.
400
+
401
+Opening and closing the tag and file tree~
402
+In the taglist window, the tag names are displayed as a foldable tree using
403
+the Vim folding support. You can collapse the tree using the '-' key or using
404
+the Vim |zc| fold command. You can open the tree using the '+' key or using
405
+the Vim |zo| fold command. You can open all the folds using the '*' key or
406
+using the Vim |zR| fold command. You can also use the mouse to open/close the
407
+folds. You can close all the folds using the '=' key. You should not manually
408
+create or delete the folds in the taglist window.
409
+
410
+To automatically close the fold for the inactive files/buffers and open only
411
+the fold for the current buffer in the taglist window, set the
412
+'Tlist_File_Fold_Auto_Close' variable to 1.
413
+
414
+Sorting the tags for a file~
415
+The tags displayed in the taglist window can be sorted either by their name or
416
+by their chronological order. The default sorting method is by the order in
417
+which the tags appear in a file. You can change the default sort method by
418
+setting the 'Tlist_Sort_Type' variable to either "name" or "order". You can
419
+sort the tags by their name by pressing the "s" key in the taglist window. You
420
+can again sort the tags by their chronological order using the "s" key. Each
421
+file in the taglist window can be sorted using different order.
422
+
423
+Zooming in and out of the taglist window~
424
+You can press the 'x' key in the taglist window to maximize the taglist
425
+window width/height. The window will be maximized to the maximum possible
426
+width/height without closing the other existing windows. You can again press
427
+'x' to restore the taglist window to the default width/height.
428
+
429
+						*taglist-session*
430
+Taglist Session~
431
+A taglist session refers to the group of files and their tags stored in the
432
+taglist in a Vim session.
433
+
434
+You can save and restore a taglist session (and all the displayed tags) using
435
+the ":TlistSessionSave" and ":TlistSessionLoad" commands.
436
+
437
+To save the information about the tags and files in the taglist to a file, use
438
+the ":TlistSessionSave" command and specify the filename:
439
+>
440
+	:TlistSessionSave <file name>
441
+<
442
+To load a saved taglist session, use the ":TlistSessionLoad" command: >
443
+
444
+	:TlistSessionLoad <file name>
445
+<
446
+When you load a taglist session file, the tags stored in the file will be
447
+added to the tags already stored in the taglist.
448
+
449
+The taglist session feature can be used to save the tags for large files or a
450
+group of frequently used files (like a project). By using the taglist session
451
+file, you can minimize the amount to time it takes to load/refresh the taglist
452
+for multiple files.
453
+
454
+You can create more than one taglist session file for multiple groups of
455
+files.
456
+
457
+Displaying the tag name in the Vim status line or the window title bar~
458
+You can use the Tlist_Get_Tagname_By_Line() function provided by the taglist
459
+plugin to display the current tag name in the Vim status line or the window
460
+title bar. Similarly, you can use the Tlist_Get_Tag_Prototype_By_Line()
461
+function to display the current tag prototype in the Vim status line or the
462
+window title bar.
463
+
464
+For example, the following command can be used to display the current tag name
465
+in the status line:
466
+>
467
+	:set statusline=%<%f%=%([%{Tlist_Get_Tagname_By_Line()}]%)
468
+<
469
+The following command can be used to display the current tag name in the
470
+window title bar:
471
+>
472
+	:set title titlestring=%<%f\ %([%{Tlist_Get_Tagname_By_Line()}]%)
473
+<
474
+Note that the current tag name can be displayed only after the file is
475
+processed by the taglist plugin. For this, you have to either set the
476
+'Tlist_Process_File_Always' variable to 1 or open the taglist window or use
477
+the taglist menu. For more information about configuring the Vim status line,
478
+refer to the documentation for the Vim |'statusline'| option.
479
+
480
+Changing the taglist window highlighting~
481
+The following Vim highlight groups are defined and used to highlight the
482
+various entities in the taglist window:
483
+
484
+    TagListTagName  - Used for tag names
485
+    TagListTagScope - Used for tag scope
486
+    TagListTitle    - Used for tag titles
487
+    TagListComment  - Used for comments
488
+    TagListFileName - Used for filenames
489
+
490
+By default, these highlight groups are linked to the standard Vim highlight
491
+groups. If you want to change the colors used for these highlight groups,
492
+prefix the highlight group name with 'My' and define it in your .vimrc or
493
+.gvimrc file: MyTagListTagName, MyTagListTagScope, MyTagListTitle,
494
+MyTagListComment and MyTagListFileName.  For example, to change the colors
495
+used for tag names, you can use the following command:
496
+>
497
+    :highlight MyTagListTagName guifg=blue ctermfg=blue
498
+<
499
+Controlling the taglist window~
500
+To use a horizontally split taglist window, instead of a vertically split
501
+window, set the 'Tlist_Use_Horiz_Window' variable to 1.
502
+
503
+To use a vertically split taglist window on the rightmost side of the Vim
504
+window, set the 'Tlist_Use_Right_Window' variable to 1.
505
+
506
+You can specify the width of the vertically split taglist window, by setting
507
+the 'Tlist_WinWidth' variable.  You can specify the height of the horizontally
508
+split taglist window, by setting the 'Tlist_WinHeight' variable.
509
+
510
+When opening a vertically split taglist window, the Vim window width is
511
+increased to accommodate the new taglist window. When the taglist window is
512
+closed, the Vim window is reduced. To disable this, set the
513
+'Tlist_Inc_Winwidth' variable to zero.
514
+
515
+To reduce the number of empty lines in the taglist window, set the
516
+'Tlist_Compact_Format' variable to 1.
517
+
518
+To not display the Vim fold column in the taglist window, set the
519
+'Tlist_Enable_Fold_Column' variable to zero.
520
+
521
+To display the tag prototypes instead of the tag names in the taglist window,
522
+set the 'Tlist_Display_Prototype' variable to 1.
523
+
524
+To not display the scope of the tags next to the tag names, set the
525
+'Tlist_Display_Tag_Scope' variable to zero.
526
+
527
+						*taglist-keys*
528
+Taglist window key list~
529
+The following table lists the description of the keys that can be used
530
+in the taglist window.
531
+
532
+  Key           Description~
533
+
534
+  <CR>          Jump to the location where the tag under cursor is
535
+                defined.
536
+  o             Jump to the location where the tag under cursor is
537
+                defined in a new window.
538
+  P             Jump to the tag in the previous (Ctrl-W_p) window.
539
+  p             Display the tag definition in the file window and
540
+                keep the cursor in the taglist window itself.
541
+  t             Jump to the tag in a new tab. If the file is already
542
+                opened in a tab, move to that tab.
543
+  Ctrl-t	Jump to the tag in a new tab.
544
+  <Space>       Display the prototype of the tag under the cursor.
545
+  		For file names, display the full path to the file,
546
+		file type and the number of tags. For tag types, display the
547
+		tag type and the number of tags.
548
+  u             Update the tags listed in the taglist window
549
+  s             Change the sort order of the tags (by name or by order)
550
+  d             Remove the tags for the file under the cursor
551
+  x             Zoom-in or Zoom-out the taglist window
552
+  +             Open a fold
553
+  -             Close a fold
554
+  *             Open all folds
555
+  =             Close all folds
556
+  [[		Jump to the beginning of the previous file
557
+  <Backspace>	Jump to the beginning of the previous file
558
+  ]]		Jump to the beginning of the next file
559
+  <Tab>		Jump to the beginning of the next file
560
+  q             Close the taglist window
561
+  <F1>          Display help
562
+
563
+The above keys will work in both the normal mode and the insert mode.
564
+
565
+						*taglist-menu*
566
+Taglist menu~
567
+When using GUI Vim, the taglist plugin can display the tags defined in the
568
+current file in the drop-down menu and the popup menu. By default, this
569
+feature is turned off. To turn on this feature, set the 'Tlist_Show_Menu'
570
+variable to 1.
571
+
572
+You can jump to a tag by selecting the tag name from the menu. You can use the
573
+taglist menu independent of the taglist window i.e. you don't need to open the
574
+taglist window to get the taglist menu.
575
+
576
+When you switch between files/buffers, the taglist menu is automatically
577
+updated to display the tags defined in the current file/buffer.
578
+
579
+The tags are grouped by their type (variables, functions, classes, methods,
580
+etc.) and displayed as a separate sub-menu for each type. If all the tags
581
+defined in a file are of the same type (e.g. functions), then the sub-menu is
582
+not used.
583
+
584
+If the number of items in a tag type submenu exceeds the value specified by
585
+the 'Tlist_Max_Submenu_Items' variable, then the submenu will be split into
586
+multiple submenus. The default setting for 'Tlist_Max_Submenu_Items' is 25.
587
+The first and last tag names in the submenu are used to form the submenu name.
588
+The menu items are prefixed by alpha-numeric characters for easy selection by
589
+keyboard.
590
+
591
+If the popup menu support is enabled (the |'mousemodel'| option contains
592
+"popup"), then the tags menu is added to the popup menu. You can access
593
+the popup menu by right clicking on the GUI window.
594
+
595
+You can regenerate the tags menu by selecting the 'Tags->Refresh menu' entry.
596
+You can sort the tags listed in the menu either by name or by order by
597
+selecting the 'Tags->Sort menu by->Name/Order' menu entry.
598
+
599
+You can tear-off the Tags menu and keep it on the side of the Vim window
600
+for quickly locating the tags.
601
+
602
+Using the taglist plugin with the winmanager plugin~
603
+You can use the taglist plugin with the winmanager plugin. This will allow you
604
+to use the file explorer, buffer explorer and the taglist plugin at the same
605
+time in different windows. To use the taglist plugin with the winmanager
606
+plugin, set 'TagList' in the 'winManagerWindowLayout' variable. For example,
607
+to use the file explorer plugin and the taglist plugin at the same time, use
608
+the following setting: >
609
+
610
+	let winManagerWindowLayout = 'FileExplorer|TagList'
611
+<
612
+Getting help~
613
+If you have installed the taglist help file (this file), then you can use the
614
+Vim ":help taglist-<keyword>" command to get help on the various taglist
615
+topics.
616
+
617
+You can press the <F1> key in the taglist window to display the help
618
+information about using the taglist window. If you again press the <F1> key,
619
+the help information is removed from the taglist window.
620
+
621
+						*taglist-debug*
622
+Debugging the taglist plugin~
623
+You can use the ":TlistDebug" command to enable logging of the debug messages
624
+from the taglist plugin. To display the logged debug messages, you can use the
625
+":TlistMessages" command. To disable the logging of the debug messages, use
626
+the ":TlistUndebug" command.
627
+
628
+You can specify a file name to the ":TlistDebug" command to log the debug
629
+messages to a file. Otherwise, the debug messages are stored in a script-local
630
+variable. In the later case, to minimize memory usage, only the last 3000
631
+characters from the debug messages are stored.
632
+
633
+==============================================================================
634
+						*taglist-options*
635
+6. Options~
636
+
637
+A number of Vim variables control the behavior of the taglist plugin. These
638
+variables are initialized to a default value. By changing these variables you
639
+can change the behavior of the taglist plugin. You need to change these
640
+settings only if you want to change the behavior of the taglist plugin. You
641
+should use the |:let| command in your .vimrc file to change the setting of any
642
+of these variables. 
643
+
644
+The configurable taglist variables are listed below. For a detailed
645
+description of these variables refer to the text below this table.
646
+
647
+|'Tlist_Auto_Highlight_Tag'|	Automatically highlight the current tag in the
648
+				taglist.
649
+|'Tlist_Auto_Open'|		Open the taglist window when Vim starts.
650
+|'Tlist_Auto_Update'|		Automatically update the taglist to include
651
+				newly edited files.
652
+|'Tlist_Close_On_Select'|	Close the taglist window when a file or tag is
653
+				selected.
654
+|'Tlist_Compact_Format'|	Remove extra information and blank lines from
655
+       				the taglist window.
656
+|'Tlist_Ctags_Cmd'|		Specifies the path to the ctags utility.
657
+|'Tlist_Display_Prototype'|	Show prototypes and not tags in the taglist
658
+				window.
659
+|'Tlist_Display_Tag_Scope'|	Show tag scope next to the tag name.
660
+|'Tlist_Enable_Fold_Column'|	Show the fold indicator column in the taglist
661
+				window.
662
+|'Tlist_Exit_OnlyWindow'|	Close Vim if the taglist is the only window.
663
+|'Tlist_File_Fold_Auto_Close'|	Close tag folds for inactive buffers.
664
+|'Tlist_GainFocus_On_ToggleOpen'|
665
+				Jump to taglist window on open.
666
+|'Tlist_Highlight_Tag_On_BufEnter'|
667
+				On entering a buffer, automatically highlight
668
+				the current tag.
669
+|'Tlist_Inc_Winwidth'|		Increase the Vim window width to accommodate
670
+				the taglist window.
671
+|'Tlist_Max_Submenu_Items'|	Maximum number of items in a tags sub-menu.
672
+|'Tlist_Max_Tag_Length'|	Maximum tag length used in a tag menu entry.
673
+|'Tlist_Process_File_Always'|	Process files even when the taglist window is
674
+				closed.
675
+|'Tlist_Show_Menu'|		Display the tags menu.
676
+|'Tlist_Show_One_File'|		Show tags for the current buffer only.
677
+|'Tlist_Sort_Type'|		Sort method used for arranging the tags.
678
+|'Tlist_Use_Horiz_Window'|	Use a horizontally split window for the
679
+				taglist window.
680
+|'Tlist_Use_Right_Window'|	Place the taglist window on the right side.
681
+|'Tlist_Use_SingleClick'|	Single click on a tag jumps to it.
682
+|'Tlist_WinHeight'|		Horizontally split taglist window height.
683
+|'Tlist_WinWidth'|		Vertically split taglist window width.
684
+
685
+						*'Tlist_Auto_Highlight_Tag'*
686
+Tlist_Auto_Highlight_Tag~
687
+The taglist plugin will automatically highlight the current tag in the taglist
688
+window. If you want to disable this, then you can set the
689
+'Tlist_Auto_Highlight_Tag' variable to zero. Note that even though the current
690
+tag highlighting is disabled, the tags for a new file will still be added to
691
+the taglist window.
692
+>
693
+	let Tlist_Auto_Highlight_Tag = 0
694
+<
695
+With the above variable set to 1, you can use the ":TlistHighlightTag" command
696
+to highlight the current tag.
697
+
698
+						*'Tlist_Auto_Open'*
699
+Tlist_Auto_Open~
700
+To automatically open the taglist window, when you start Vim, you can set the
701
+'Tlist_Auto_Open' variable to 1. By default, this variable is set to zero and
702
+the taglist window will not be opened automatically on Vim startup.
703
+>
704
+	let Tlist_Auto_Open = 1
705
+<
706
+The taglist window is opened only when a supported type of file is opened on
707
+Vim startup. For example, if you open text files, then the taglist window will
708
+not be opened.
709
+
710
+						*'Tlist_Auto_Update'*
711
+Tlist_Auto_Update~
712
+When a new file is edited, the tags defined in the file are automatically
713
+processed and added to the taglist. To stop adding new files to the taglist,
714
+set the 'Tlist_Auto_Update' variable to zero. By default, this variable is set
715
+to 1.
716
+>
717
+	let Tlist_Auto_Update = 0
718
+<
719
+With the above variable set to 1, you can use the ":TlistUpdate" command to
720
+add the tags defined in the current file to the taglist.
721
+
722
+						*'Tlist_Close_On_Select'*
723
+Tlist_Close_On_Select~
724
+If you want to close the taglist window when a file or tag is selected, then
725
+set the 'Tlist_Close_On_Select' variable to 1. By default, this variable is
726
+set zero and when you select a tag or file from the taglist window, the window
727
+is not closed.
728
+>
729
+	let Tlist_Close_On_Select = 1
730
+<
731
+						*'Tlist_Compact_Format'*
732
+Tlist_Compact_Format~
733
+By default, empty lines are used to separate different tag types displayed for
734
+a file and the tags displayed for different files in the taglist window. If
735
+you want to display as many tags as possible in the taglist window, you can
736
+set the 'Tlist_Compact_Format' variable to 1 to get a compact display.
737
+>
738
+	let Tlist_Compact_Format = 1
739
+<
740
+						*'Tlist_Ctags_Cmd'*
741
+Tlist_Ctags_Cmd~
742
+The 'Tlist_Ctags_Cmd' variable specifies the location (path) of the exuberant
743
+ctags utility. If exuberant ctags is present in any one of the directories in
744
+the PATH environment variable, then there is no need to set this variable.
745
+
746
+The exuberant ctags tool can be installed under different names.  When the
747
+taglist plugin starts up, if the 'Tlist_Ctags_Cmd' variable is not set, it
748
+checks for the names exuberant-ctags, exctags, ctags, ctags.exe and tags in
749
+the PATH environment variable.  If any one of the named executable is found,
750
+then the Tlist_Ctags_Cmd variable is set to that name.
751
+
752
+If exuberant ctags is not present in one of the directories specified in the
753
+PATH environment variable, then set this variable to point to the location of
754
+the ctags utility in your system. Note that this variable should point to the
755
+fully qualified exuberant ctags location and NOT to the directory in which
756
+exuberant ctags is installed. If the exuberant ctags tool is not found in
757
+either PATH or in the specified location, then the taglist plugin will not be
758
+loaded. Examples:
759
+>
760
+	let Tlist_Ctags_Cmd = 'd:\tools\ctags.exe'
761
+	let Tlist_Ctags_Cmd = '/usr/local/bin/ctags'
762
+<
763
+						*'Tlist_Display_Prototype'*
764
+Tlist_Display_Prototype~
765
+By default, only the tag name will be displayed in the taglist window. If you
766
+like to see tag prototypes instead of names, set the 'Tlist_Display_Prototype'
767
+variable to 1. By default, this variable is set to zero and only tag names
768
+will be displayed.
769
+>
770
+	let Tlist_Display_Prototype = 1
771
+<
772
+						*'Tlist_Display_Tag_Scope'*
773
+Tlist_Display_Tag_Scope~
774
+By default, the scope of a tag (like a C++ class) will be displayed in
775
+square brackets next to the tag name. If you don't want the tag scopes
776
+to be displayed, then set the 'Tlist_Display_Tag_Scope' to zero. By default,
777
+this variable is set to 1 and the tag scopes will be displayed.
778
+>
779
+	let Tlist_Display_Tag_Scope = 0
780
+<
781
+						*'Tlist_Enable_Fold_Column'*
782
+Tlist_Enable_Fold_Column~
783
+By default, the Vim fold column is enabled and displayed in the taglist
784
+window. If you wish to disable this (for example, when you are working with a
785
+narrow Vim window or terminal), you can set the 'Tlist_Enable_Fold_Column'
786
+variable to zero.
787
+>
788
+	let Tlist_Enable_Fold_Column = 1
789
+<
790
+						*'Tlist_Exit_OnlyWindow'*
791
+Tlist_Exit_OnlyWindow~
792
+If you want to exit Vim if only the taglist window is currently opened, then
793
+set the 'Tlist_Exit_OnlyWindow' variable to 1. By default, this variable is
794
+set to zero and the Vim instance will not be closed if only the taglist window
795
+is present.
796
+>
797
+	let Tlist_Exit_OnlyWindow = 1
798
+<
799
+						*'Tlist_File_Fold_Auto_Close'*
800
+Tlist_File_Fold_Auto_Close~
801
+By default, the tags tree displayed in the taglist window for all the files is
802
+opened. You can close/fold the tags tree for the files manually. To
803
+automatically close the tags tree for inactive files, you can set the
804
+'Tlist_File_Fold_Auto_Close' variable to 1. When this variable is set to 1,
805
+the tags tree for the current buffer is automatically opened and for all the
806
+other buffers is closed.
807
+>
808
+	let Tlist_File_Fold_Auto_Close = 1
809
+<
810
+					    *'Tlist_GainFocus_On_ToggleOpen'*
811
+Tlist_GainFocus_On_ToggleOpen~
812
+When the taglist window is opened using the ':TlistToggle' command, this
813
+option controls whether the cursor is moved to the taglist window or remains
814
+in the current window. By default, this option is set to 0 and the cursor
815
+remains in the current window. When this variable is set to 1, the cursor
816
+moves to the taglist window after opening the taglist window.
817
+>
818
+	let Tlist_GainFocus_On_ToggleOpen = 1
819
+<
820
+					    *'Tlist_Highlight_Tag_On_BufEnter'*
821
+Tlist_Highlight_Tag_On_BufEnter~
822
+When you enter a Vim buffer/window, the current tag in that buffer/window is
823
+automatically highlighted in the taglist window. If the current tag name is
824
+not visible in the taglist window, then the taglist window contents are
825
+scrolled to make that tag name visible. If you like to disable the automatic
826
+highlighting of the current tag when entering a buffer, you can set the
827
+'Tlist_Highlight_Tag_On_BufEnter' variable to zero. The default setting for
828
+this variable is 1.
829
+>
830
+	let Tlist_Highlight_Tag_On_BufEnter = 0
831
+<
832
+						*'Tlist_Inc_Winwidth'*
833
+Tlist_Inc_Winwidth~
834
+By default, when the width of the window is less than 100 and a new taglist
835
+window is opened vertically, then the window width is increased by the value
836
+set in the 'Tlist_WinWidth' variable to accommodate the new window. The value
837
+of this variable is used only if you are using a vertically split taglist
838
+window.
839
+
840
+If your terminal doesn't support changing the window width from Vim (older
841
+version of xterm running in a Unix system) or if you see any weird problems in
842
+the screen due to the change in the window width or if you prefer not to
843
+adjust the window width then set the 'Tlist_Inc_Winwidth' variable to zero.
844
+CAUTION: If you are using the MS-Windows version of Vim in a MS-DOS command
845
+window then you must set this variable to zero, otherwise the system may hang
846
+due to a Vim limitation (explained in :help win32-problems)
847
+>
848
+	let Tlist_Inc_Winwidth = 0
849
+<
850
+						*'Tlist_Max_Submenu_Items'*
851
+Tlist_Max_Submenu_Items~
852
+If a file contains too many tags of a particular type (function, variable,
853
+class, etc.), greater than that specified by the 'Tlist_Max_Submenu_Items'
854
+variable, then the menu for that tag type will be split into multiple
855
+sub-menus. The default setting for the 'Tlist_Max_Submenu_Items' variable is
856
+25.  This can be changed by setting the 'Tlist_Max_Submenu_Items' variable:
857
+>
858
+	let Tlist_Max_Submenu_Items = 20
859
+<
860
+The name of the submenu is formed using the names of the first and the last
861
+tag entries in that submenu.
862
+
863
+						*'Tlist_Max_Tag_Length'*
864
+Tlist_Max_Tag_Length~
865
+Only the first 'Tlist_Max_Tag_Length' characters from the tag names will be
866
+used to form the tag type submenu name. The default value for this variable is
867
+10.  Change the 'Tlist_Max_Tag_Length' setting if you want to include more or
868
+less characters:
869
+>
870
+	let Tlist_Max_Tag_Length = 10
871
+<
872
+						*'Tlist_Process_File_Always'*
873
+Tlist_Process_File_Always~
874
+By default, the taglist plugin will generate and process the tags defined in
875
+the newly opened files only when the taglist window is opened or when the
876
+taglist menu is enabled. When the taglist window is closed, the taglist plugin
877
+will stop processing the tags for newly opened files.
878
+
879
+You can set the 'Tlist_Process_File_Always' variable to 1 to generate the list
880
+of tags for new files even when the taglist window is closed and the taglist
881
+menu is disabled.
882
+>
883
+	let Tlist_Process_File_Always = 1
884
+<
885
+To use the ":TlistShowTag" and the ":TlistShowPrototype" commands without the
886
+taglist window and the taglist menu, you should set this variable to 1.
887
+
888
+						*'Tlist_Show_Menu'*
889
+Tlist_Show_Menu~
890
+When using GUI Vim, you can display the tags defined in the current file in a
891
+menu named "Tags". By default, this feature is turned off. To turn on this
892
+feature, set the 'Tlist_Show_Menu' variable to 1:
893
+>
894
+	let Tlist_Show_Menu = 1
895
+<
896
+						*'Tlist_Show_One_File'*
897
+Tlist_Show_One_File~
898
+By default, the taglist plugin will display the tags defined in all the loaded
899
+buffers in the taglist window. If you prefer to display the tags defined only
900
+in the current buffer, then you can set the 'Tlist_Show_One_File' to 1. When
901
+this variable is set to 1, as you switch between buffers, the taglist window
902
+will be refreshed to display the tags for the current buffer and the tags for
903
+the previous buffer will be removed.
904
+>
905
+	let Tlist_Show_One_File = 1
906
+<
907
+						*'Tlist_Sort_Type'*
908
+Tlist_Sort_Type~
909
+The 'Tlist_Sort_Type' variable specifies the sort order for the tags in the
910
+taglist window. The tags can be sorted either alphabetically by their name or
911
+by the order of their appearance in the file (chronological order). By
912
+default, the tag names will be listed by the order in which they are defined
913
+in the file. You can change the sort type (from name to order or from order to
914
+name) by pressing the "s" key in the taglist window. You can also change the
915
+default sort order by setting 'Tlist_Sort_Type' to "name" or "order":
916
+>
917
+	let Tlist_Sort_Type = "name"
918
+<
919
+						*'Tlist_Use_Horiz_Window'*
920
+Tlist_Use_Horiz_Window~
921
+Be default, the tag names are displayed in a vertically split window. If you
922
+prefer a horizontally split window, then set the 'Tlist_Use_Horiz_Window'
923
+variable to 1. If you are running MS-Windows version of Vim in a MS-DOS
924
+command window, then you should use a horizontally split window instead of a
925
+vertically split window. Also, if you are using an older version of xterm in a
926
+Unix system that doesn't support changing the xterm window width, you should
927
+use a horizontally split window.
928
+>
929
+	let Tlist_Use_Horiz_Window = 1
930
+<
931
+						*'Tlist_Use_Right_Window'*
932
+Tlist_Use_Right_Window~
933
+By default, the vertically split taglist window will appear on the left hand
934
+side. If you prefer to open the window on the right hand side, you can set the
935
+'Tlist_Use_Right_Window' variable to 1:
936
+>
937
+	let Tlist_Use_Right_Window = 1
938
+<
939
+						*'Tlist_Use_SingleClick'*
940
+Tlist_Use_SingleClick~
941
+By default, when you double click on the tag name using the left mouse 
942
+button, the cursor will be positioned at the definition of the tag. You 
943
+can set the 'Tlist_Use_SingleClick' variable to 1 to jump to a tag when
944
+you single click on the tag name using the mouse. By default this variable
945
+is set to zero.
946
+>
947
+	let Tlist_Use_SingleClick = 1
948
+<
949
+Due to a bug in Vim, if you set 'Tlist_Use_SingleClick' to 1 and try to resize
950
+the taglist window using the mouse, then Vim will crash. This problem is fixed
951
+in Vim 6.3 and above. In the meantime, instead of resizing the taglist window
952
+using the mouse, you can use normal Vim window resizing commands to resize the
953
+taglist window.
954
+
955
+						*'Tlist_WinHeight'*
956
+Tlist_WinHeight~
957
+The default height of the horizontally split taglist window is 10. This can be
958
+changed by modifying the 'Tlist_WinHeight' variable:
959
+>
960
+	let Tlist_WinHeight = 20
961
+<
962
+The |'winfixheight'| option is set for the taglist window, to maintain the
963
+height of the taglist window, when new Vim windows are opened and existing
964
+windows are closed.
965
+
966
+						*'Tlist_WinWidth'*
967
+Tlist_WinWidth~
968
+The default width of the vertically split taglist window is 30. This can be
969
+changed by modifying the 'Tlist_WinWidth' variable:
970
+>
971
+	let Tlist_WinWidth = 20
972
+<
973
+Note that the value of the |'winwidth'| option setting determines the minimum
974
+width of the current window. If you set the 'Tlist_WinWidth' variable to a
975
+value less than that of the |'winwidth'| option setting, then Vim will use the
976
+value of the |'winwidth'| option.
977
+
978
+When new Vim windows are opened and existing windows are closed, the taglist
979
+plugin will try to maintain the width of the taglist window to the size
980
+specified by the 'Tlist_WinWidth' variable.
981
+
982
+==============================================================================
983
+						*taglist-commands*
984
+7. Commands~
985
+
986
+The taglist plugin provides the following ex-mode commands:
987
+
988
+|:TlistAddFiles|	Add multiple files to the taglist.
989
+|:TlistAddFilesRecursive|
990
+			Add files recursively to the taglist.
991
+|:TlistClose|		Close the taglist window.
992
+|:TlistDebug|		Start logging of taglist debug messages.
993
+|:TlistLock|		Stop adding new files to the taglist.
994
+|:TlistMessages|	Display the logged taglist plugin debug messages.
995
+|:TlistOpen|		Open and jump to the taglist window.
996
+|:TlistSessionSave|	Save the information about files and tags in the
997
+			taglist to a session file.
998
+|:TlistSessionLoad|	Load the information about files and tags stored
999
+			in a session file to taglist.
1000
+|:TlistShowPrototype|	Display the prototype of the tag at or before the
1001
+		    	specified line number.
1002
+|:TlistShowTag|		Display the name of the tag defined at or before the
1003
+			specified line number.
1004
+|:TlistHighlightTag|	Highlight the current tag in the taglist window.
1005
+|:TlistToggle|		Open or close (toggle) the taglist window.
1006
+|:TlistUndebug|		Stop logging of taglist debug messages.
1007
+|:TlistUnlock|		Start adding new files to the taglist.
1008
+|:TlistUpdate|		Update the tags for the current buffer.
1009
+
1010
+						*:TlistAddFiles*
1011
+:TlistAddFiles {file(s)} [file(s) ...]
1012
+		Add one or more specified files to the taglist. You can
1013
+		specify multiple filenames using wildcards. To specify a
1014
+		file name with space character, you should escape the space
1015
+		character with a backslash.
1016
+		Examples:
1017
+>
1018
+		    :TlistAddFiles *.c *.cpp
1019
+		    :TlistAddFiles file1.html file2.html
1020
+<
1021
+		If you specify a large number of files, then it will take some
1022
+		time for the taglist plugin to process all of them. The
1023
+		specified files will not be edited in a Vim window and will
1024
+		not be added to the Vim buffer list.
1025
+
1026
+						*:TlistAddFilesRecursive*
1027
+:TlistAddFilesRecursive {directory} [ {pattern} ]
1028
+		Add files matching {pattern} recursively from the specified
1029
+		{directory} to the taglist. If {pattern} is not specified,
1030
+		then '*' is assumed. To specify the current directory, use "."
1031
+		for {directory}. To specify a directory name with space
1032
+		character, you should escape the space character with a
1033
+		backslash.
1034
+		Examples:
1035
+>
1036
+		    :TlistAddFilesRecursive myproject *.java
1037
+		    :TlistAddFilesRecursive smallproject
1038
+<
1039
+		If large number of files are present in the specified
1040
+		directory tree, then it will take some time for the taglist
1041
+		plugin to process all of them.
1042
+
1043
+						*:TlistClose*
1044
+:TlistClose	Close the taglist window. This command can be used from any
1045
+		one of the Vim windows.
1046
+
1047
+						*:TlistDebug*
1048
+:TlistDebug [filename]
1049
+		Start logging of debug messages from the taglist plugin.
1050
+		If {filename} is specified, then the debug messages are stored
1051
+		in the specified file. Otherwise, the debug messages are
1052
+		stored in a script local variable. If the file {filename} is
1053
+		already present, then it is overwritten.
1054
+
1055
+						*:TlistLock*
1056
+:TlistLock
1057
+		Lock the taglist and don't process new files. After this
1058
+		command is executed, newly edited files will not be added to
1059
+		the taglist.
1060
+
1061
+						*:TlistMessages*
1062
+:TlistMessages
1063
+		Display the logged debug messages from the taglist plugin
1064
+		in a window.  This command works only when logging to a
1065
+		script-local variable.
1066
+
1067
+						*:TlistOpen*
1068
+:TlistOpen	Open and jump to the taglist window. Creates the taglist
1069
+		window, if the window is not opened currently. After executing
1070
+		this command, the cursor is moved to the taglist window.  When
1071
+		the taglist window is opened for the first time, all the files
1072
+		in the buffer list are processed and the tags defined in them
1073
+		are displayed in the taglist window.
1074
+
1075
+						*:TlistSessionSave*
1076
+:TlistSessionSave {filename}
1077
+		Saves the information about files and tags in the taglist to
1078
+		the specified file. This command can be used to save and
1079
+		restore the taglist contents across Vim sessions.
1080
+
1081
+						*:TlistSessionLoad*
1082
+:TlistSessionLoad {filename}
1083
+		Load the information about files and tags stored in the
1084
+		specified session file to the taglist.
1085
+
1086
+						*:TlistShowPrototype*
1087
+:TlistShowPrototype [filename] [linenumber]
1088
+		Display the prototype of the tag at or before the specified
1089
+		line number. If the file name and the line number are not
1090
+		specified, then the current file name and line number are
1091
+		used. A tag spans multiple lines starting from the line where
1092
+		it is defined to the line before the next tag. This command
1093
+		displays the prototype for the tag for any line number in this
1094
+		range. 
1095
+
1096
+						*:TlistShowTag*
1097
+:TlistShowTag [filename] [linenumber]
1098
+		Display the name of the tag defined at or before the specified
1099
+		line number. If the file name and the line number are not
1100
+		specified, then the current file name and line number are
1101
+		used. A tag spans multiple lines starting from the line where
1102
+		it is defined to the line before the next tag. This command
1103
+		displays the tag name for any line number in this range. 
1104
+
1105
+						*:TlistHighlightTag*
1106
+:TlistHighlightTag
1107
+		Highlight the current tag in the taglist window. By default,
1108
+		the taglist plugin periodically updates the taglist window to
1109
+		highlight the current tag. This command can be used to force
1110
+		the taglist plugin to highlight the current tag.
1111
+
1112
+						*:TlistToggle*
1113
+:TlistToggle	Open or close (toggle) the taglist window. Opens the taglist
1114
+		window, if the window is not opened currently. Closes the
1115
+		taglist window, if the taglist window is already opened. When
1116
+		the taglist window is opened for the first time, all the files
1117
+		in the buffer list are processed and the tags are displayed in
1118
+		the taglist window. After executing this command, the cursor
1119
+		is not moved from the current window to the taglist window.
1120
+
1121
+						*:TlistUndebug*
1122
+:TlistUndebug
1123
+		Stop logging of debug messages from the taglist plugin.
1124
+
1125
+						*:TlistUnlock*
1126
+:TlistUnlock
1127
+		Unlock the taglist and start processing newly edited files.
1128
+
1129
+						*:TlistUpdate*
1130
+:TlistUpdate	Update the tags information for the current buffer. This
1131
+		command can be used to re-process the current file/buffer and
1132
+		get the tags information. As the taglist plugin uses the file
1133
+		saved in the disk (instead of the file displayed in a Vim
1134
+		buffer), you should save a modified buffer before you update
1135
+		the taglist. Otherwise the listed tags will not include the
1136
+		new tags created in the buffer. You can use this command even
1137
+		when the taglist window is not opened.
1138
+
1139
+==============================================================================
1140
+						*taglist-functions*
1141
+8. Global functions~
1142
+
1143
+The taglist plugin provides several global functions that can be used from
1144
+other Vim plugins to interact with the taglist plugin. These functions are
1145
+described below.
1146
+
1147
+|Tlist_Update_File_Tags()|		Update the tags for the specified file
1148
+|Tlist_Get_Tag_Prototype_By_Line()|	Return the prototype of the tag at or
1149
+				    	before the specified line number in the
1150
+				    	specified file.
1151
+|Tlist_Get_Tagname_By_Line()|		Return the name of the tag at or
1152
+					before the specified line number in
1153
+					the specified file.
1154
+|Tlist_Set_App()|			Set the name of the application
1155
+					controlling the taglist window.
1156
+
1157
+					    *Tlist_Update_File_Tags()*
1158
+Tlist_Update_File_Tags({filename}, {filetype})
1159
+		Update the tags for the file {filename}. The second argument
1160
+		specifies the Vim filetype for the file. If the taglist plugin
1161
+		has not processed the file previously, then the exuberant
1162
+		ctags tool is invoked to generate the tags for the file.
1163
+
1164
+					    *Tlist_Get_Tag_Prototype_By_Line()*
1165
+Tlist_Get_Tag_Prototype_By_Line([{filename}, {linenumber}])
1166
+		Return the prototype of the tag at or before the specified
1167
+		line number in the specified file. If the filename and line
1168
+		number are not specified, then the current buffer name and the
1169
+		current line number are used.
1170
+
1171
+					    *Tlist_Get_Tagname_By_Line()*
1172
+Tlist_Get_Tagname_By_Line([{filename}, {linenumber}])
1173
+		Return the name of the tag at or before the specified line
1174
+		number in the specified file. If the filename and line number
1175
+		are not specified, then the current buffer name and the
1176
+		current line number are used.
1177
+
1178
+					    *Tlist_Set_App()*
1179
+Tlist_Set_App({appname})
1180
+		Set the name of the plugin that controls the taglist plugin
1181
+		window and buffer. This can be used to integrate the taglist
1182
+		plugin with other Vim plugins.
1183
+		
1184
+		For example, the winmanager plugin and the Cream package use
1185
+		this function and specify the appname as "winmanager" and
1186
+		"cream" respectively.
1187
+		
1188
+		By default, the taglist plugin is a stand-alone plugin and
1189
+		controls the taglist window and buffer. If the taglist window
1190
+		is controlled by an external plugin, then the appname should
1191
+		be set appropriately.
1192
+
1193
+==============================================================================
1194
+						*taglist-extend*
1195
+9. Extending~
1196
+
1197
+The taglist plugin supports all the languages supported by the exuberant ctags
1198
+tool, which includes the following languages: Assembly, ASP, Awk, Beta, C,
1199
+C++, C#, Cobol, Eiffel, Erlang, Fortran, HTML, Java, Javascript, Lisp, Lua,
1200
+Make, Pascal, Perl, PHP, Python, Rexx, Ruby, Scheme, Shell, Slang, SML, Sql,
1201
+TCL, Verilog, Vim and Yacc.
1202
+
1203
+You can extend the taglist plugin to add support for new languages and also
1204
+modify the support for the above listed languages.
1205
+
1206
+You should NOT make modifications to the taglist plugin script file to add
1207
+support for new languages. You will lose these changes when you upgrade to the
1208
+next version of the taglist plugin. Instead you should follow the below
1209
+described instructions to extend the taglist plugin.
1210
+
1211
+You can extend the taglist plugin by setting variables in the .vimrc or _vimrc
1212
+file. The name of these variables depends on the language name and is
1213
+described below.
1214
+
1215
+Modifying support for an existing language~
1216
+To modify the support for an already supported language, you have to set the
1217
+tlist_xxx_settings variable in the ~/.vimrc or $HOME/_vimrc file. Replace xxx
1218
+with the Vim filetype name for the language file.  For example, to modify the
1219
+support for the perl language files, you have to set the tlist_perl_settings
1220
+variable. To modify the support for java files, you have to set the
1221
+tlist_java_settings variable.
1222
+
1223
+To determine the filetype name used by Vim for a file, use the following
1224
+command in the buffer containing the file:
1225
+
1226
+	:set filetype
1227
+
1228
+The above command will display the Vim filetype for the current buffer.
1229
+
1230
+The format of the value set in the tlist_xxx_settings variable is
1231
+
1232
+    <language_name>;flag1:name1;flag2:name2;flag3:name3
1233
+
1234
+The different fields in the value are separated by the ';' character.
1235
+
1236
+The first field 'language_name' is the name used by exuberant ctags to refer
1237
+to this language file. This name can be different from the file type name used
1238
+by Vim. For example, for C++, the language name used by ctags is 'c++' but the
1239
+filetype name used by Vim is 'cpp'. To get the list of language names
1240
+supported by exuberant ctags, use the following command:
1241
+
1242
+	$ ctags --list-maps=all
1243
+
1244
+The remaining fields follow the format "flag:name". The sub-field 'flag' is
1245
+the language specific flag used by exuberant ctags to generate the
1246
+corresponding tags. For example, for the C language, to list only the
1247
+functions, the 'f' flag is used. To get the list of flags supported by
1248
+exuberant ctags for the various languages use the following command:
1249
+
1250
+	$ ctags --list-kinds=all
1251
+
1252
+The sub-field 'name' specifies the title text to use for displaying the tags
1253
+of a particular type. For example, 'name' can be set to 'functions'. This
1254
+field can be set to any text string name.
1255
+
1256
+For example, to list only the classes and functions defined in a C++ language
1257
+file, add the following line to your .vimrc file:
1258
+
1259
+	let tlist_cpp_settings = 'c++;c:class;f:function'
1260
+
1261
+In the above setting, 'cpp' is the Vim filetype name and 'c++' is the name
1262
+used by the exuberant ctags tool. 'c' and 'f' are the flags passed to
1263
+exuberant ctags to list C++ classes and functions and 'class' is the title
1264
+used for the class tags and 'function' is the title used for the function tags
1265
+in the taglist window.
1266
+
1267
+For example, to display only functions defined in a C file and to use "My
1268
+Functions" as the title for the function tags, use
1269
+
1270
+	let tlist_c_settings = 'c;f:My Functions'
1271
+
1272
+When you set the tlist_xxx_settings variable, you will override the default
1273
+setting used by the taglist plugin for the 'xxx' language. You cannot add to
1274
+the default options used by the taglist plugin for a particular file type. To
1275
+add to the options used by the taglist plugin for a language, copy the option
1276
+values from the taglist plugin file to your .vimrc file and modify it.
1277
+
1278
+Adding support for a new language~
1279
+If you want to add support for a new language to the taglist plugin, you need
1280
+to first extend the exuberant ctags tool. For more information about extending
1281
+exuberant ctags, visit the following page:
1282
+
1283
+    http://ctags.sourceforge.net/EXTENDING.html
1284
+
1285
+To add support for a new language, set the tlist_xxx_settings variable in the
1286
+~/.vimrc file appropriately as described above. Replace 'xxx' in the variable
1287
+name with the Vim filetype name for the new language.
1288
+
1289
+For example, to extend the taglist plugin to support the latex language, you
1290
+can use the following line (assuming, you have already extended exuberant
1291
+ctags to support the latex language):
1292
+
1293
+	let tlist_tex_settings='latex;b:bibitem;c:command;l:label'
1294
+
1295
+With the above line, when you edit files of filetype "tex" in Vim, the taglist
1296
+plugin will invoke the exuberant ctags tool passing the "latex" filetype and
1297
+the flags b, c and l to generate the tags. The text heading 'bibitem',
1298
+'command' and 'label' will be used in the taglist window for the tags which
1299
+are generated for the flags b, c and l respectively.
1300
+
1301
+==============================================================================
1302
+						*taglist-faq*
1303
+10. Frequently Asked Questions~
1304
+
1305
+Q. The taglist plugin doesn't work. The taglist window is empty and the tags
1306
+   defined in a file are not displayed. 
1307
+A. Are you using Vim version 6.0 and above? The taglist plugin relies on the
1308
+   features supported by Vim version 6.0 and above. You can use the following
1309
+   command to get the Vim version:
1310
+>
1311
+	$ vim --version
1312
+<
1313
+   Are you using exuberant ctags version 5.0 and above? The taglist plugin
1314
+   relies on the features supported by exuberant ctags and will not work with
1315
+   GNU ctags or the Unix ctags utility. You can use the following command to
1316
+   determine whether the ctags installed in your system is exuberant ctags:
1317
+>
1318
+	$ ctags --version
1319
+<
1320
+   Is exuberant ctags present in one of the directories in your PATH? If not,
1321
+   you need to set the Tlist_Ctags_Cmd variable to point to the location of
1322
+   exuberant ctags. Use the following Vim command to verify that this is setup
1323
+   correctly:
1324
+>
1325
+	:echo system(Tlist_Ctags_Cmd . ' --version')
1326
+<
1327
+   The above command should display the version information for exuberant
1328
+   ctags.
1329
+
1330
+   Did you turn on the Vim filetype detection? The taglist plugin relies on
1331
+   the filetype detected by Vim and passes the filetype to the exuberant ctags
1332
+   utility to parse the tags. Check the output of the following Vim command:
1333
+>
1334
+	:filetype
1335
+<
1336
+   The output of the above command should contain "filetype detection:ON".
1337
+   To turn on the filetype detection, add the following line to the .vimrc or
1338
+   _vimrc file:
1339
+>
1340
+	filetype on
1341
+<
1342
+   Is your version of Vim compiled with the support for the system() function?
1343
+   The following Vim command should display 1:
1344
+>
1345
+	:echo exists('*system')
1346
+<
1347
+   In some Linux distributions (particularly Suse Linux), the default Vim
1348
+   installation is built without the support for the system() function. The
1349
+   taglist plugin uses the system() function to invoke the exuberant ctags
1350
+   utility. You need to rebuild Vim after enabling the support for the
1351
+   system() function. If you use the default build options, the system()
1352
+   function will be supported. 
1353
+
1354
+   Do you have the |'shellslash'| option set? You can try disabling the
1355
+   |'shellslash'| option. When the taglist plugin invokes the exuberant ctags
1356
+   utility with the path to the file, if the incorrect slashes are used, then
1357
+   you will see errors.
1358
+   
1359
+   Check the shell related Vim options values using the following command:
1360
+>
1361
+	:set shell? shellcmdflag? shellpipe?
1362
+	:set shellquote? shellredir? shellxquote?
1363
+<
1364
+   If these options are set in your .vimrc or _vimrc file, try removing those
1365
+   lines.
1366
+
1367
+   Are you using a Unix shell in a MS-Windows environment? For example,
1368
+   the Unix shell from the MKS-toolkit. Do you have the SHELL environment
1369
+   set to point to this shell? You can try resetting the SHELL environment
1370
+   variable.
1371
+
1372
+   If you are using a Unix shell on MS-Windows, you should try to use
1373
+   exuberant ctags that is compiled for Unix-like environments so that
1374
+   exuberant ctags will understand path names with forward slash characters.
1375
+
1376
+   Is your filetype supported by the exuberant ctags utility? The file types
1377
+   supported by the exuberant ctags utility are listed in the ctags help. If a
1378
+   file type is not supported, you have to extend exuberant ctags. You can use
1379
+   the following command to list the filetypes supported by exuberant ctags:
1380
+>
1381
+	ctags --list-languages
1382
+<
1383
+   Run the following command from the shell prompt and check whether the tags
1384
+   defined in your file are listed in the output from exuberant ctags:
1385
+>
1386
+	ctags -f - --format=2 --excmd=pattern --fields=nks <filename>
1387
+<
1388
+   If you see your tags in the output from the above command, then the
1389
+   exuberant ctags utility is properly parsing your file.
1390
+
1391
+   Do you have the .ctags or _ctags or the ctags.cnf file in your home
1392
+   directory for specifying default options or for extending exuberant ctags?
1393
+   If you do have this file, check the options in this file and make sure
1394
+   these options are not interfering with the operation of the taglist plugin.
1395
+
1396
+   If you are using MS-Windows, check the value of the TEMP and TMP
1397
+   environment variables. If these environment variables are set to a path
1398
+   with space characters in the name, then try using the DOS 8.3 short name
1399
+   for the path or set them to a path without the space characters in the
1400
+   name. For example, if the temporary directory name is "C:\Documents and
1401
+   Settings\xyz\Local Settings\Temp", then try setting the TEMP variable to
1402
+   the following:
1403
+>
1404
+	set TEMP=C:\DOCUMEN~1\xyz\LOCALS~1\Temp
1405
+<
1406
+   If exuberant ctags is installed in a directory with space characters in the
1407
+   name, then try adding the directory to the PATH environment variable or try
1408
+   setting the 'Tlist_Ctags_Cmd' variable to the shortest path name to ctags
1409
+   or try copying the exuberant ctags to a path without space characters in
1410
+   the name. For example, if exuberant ctags is installed in the directory
1411
+   "C:\Program Files\Ctags", then try setting the 'Tlist_Ctags_Cmd' variable
1412
+   as below:
1413
+>
1414
+	let Tlist_Ctags_Cmd='C:\Progra~1\Ctags\ctags.exe'
1415
+<
1416
+   If you are using a cygwin compiled version of exuberant ctags on MS-Windows,
1417
+   make sure that either you have the cygwin compiled sort utility installed
1418
+   and available in your PATH or compile exuberant ctags with internal sort
1419
+   support. Otherwise, when exuberant ctags sorts the tags output by invoking
1420
+   the sort utility, it may end up invoking the MS-Windows version of
1421
+   sort.exe, thereby resulting in failure.
1422
+
1423
+Q. When I try to open the taglist window, I am seeing the following error
1424
+   message. How do I fix this problem?
1425
+
1426
+   Taglist: Failed to generate tags for /my/path/to/file
1427
+   ctags: illegal option -- -^@usage: ctags [-BFadtuwvx] [-f tagsfile] file ...
1428
+
1429
+A. The taglist plugin will work only with the exuberant ctags tool. You
1430
+   cannot use the GNU ctags or the Unix ctags program with the taglist plugin.
1431
+   You will see an error message similar to the one shown above, if you try
1432
+   use a non-exuberant ctags program with Vim. To fix this problem, either add
1433
+   the exuberant ctags tool location to the PATH environment variable or set
1434
+   the 'Tlist_Ctags_Cmd' variable.
1435
+
1436
+Q. A file has more than one tag with the same name. When I select a tag name
1437
+   from the taglist window, the cursor is positioned at the incorrect tag
1438
+   location. 
1439
+A. The taglist plugin uses the search pattern generated by the exuberant ctags
1440
+   utility to position the cursor at the location of a tag definition. If a
1441
+   file has more than one tag with the same name and same prototype, then the
1442
+   search pattern will be the same. In this case, when searching for the tag
1443
+   pattern, the cursor may be positioned at the incorrect location. 
1444
+
1445
+Q. I have made some modifications to my file and introduced new
1446
+   functions/classes/variables. I have not yet saved my file. The taglist
1447
+   plugin is not displaying the new tags when I update the taglist window.
1448
+A. The exuberant ctags utility will process only files that are present in the
1449
+   disk. To list the tags defined in a file, you have to save the file and
1450
+   then update the taglist window. 
1451
+
1452
+Q. I have created a ctags file using the exuberant ctags utility for my source
1453
+   tree. How do I configure the taglist plugin to use this tags file? 
1454
+A. The taglist plugin doesn't use a tags file stored in disk. For every opened
1455
+   file, the taglist plugin invokes the exuberant ctags utility to get the
1456
+   list of tags dynamically. The Vim system() function is used to invoke
1457
+   exuberant ctags and get the ctags output. This function internally uses a
1458
+   temporary file to store the output. This file is deleted after the output
1459
+   from the command is read. So you will never see the file that contains the
1460
+   output of exuberant ctags.
1461
+
1462
+Q. When I set the |'updatetime'| option to a low value (less than 1000) and if
1463
+   I keep pressing a key with the taglist window open, the current buffer
1464
+   contents are changed. Why is this?
1465
+A. The taglist plugin uses the |CursorHold| autocmd to highlight the current
1466
+   tag. The CursorHold autocmd triggers for every |'updatetime'| milliseconds.
1467
+   If the |'updatetime'| option is set to a low value, then the CursorHold
1468
+   autocmd will be triggered frequently. As the taglist plugin changes
1469
+   the focus to the taglist window to highlight the current tag, this could
1470
+   interfere with the key movement resulting in changing the contents of
1471
+   the current buffer. The workaround for this problem is to not set the
1472
+   |'updatetime'| option to a low value.
1473
+
1474
+==============================================================================
1475
+						*taglist-license*
1476
+11. License~
1477
+Permission is hereby granted to use and distribute the taglist plugin, with or
1478
+without modifications, provided that this copyright notice is copied with it.
1479
+Like anything else that's free, taglist.vim is provided *as is* and comes with
1480
+no warranty of any kind, either expressed or implied. In no event will the
1481
+copyright holder be liable for any damamges resulting from the use of this
1482
+software.
1483
+
1484
+==============================================================================
1485
+						*taglist-todo*
1486
+12. Todo~
1487
+
1488
+1. Group tags according to the scope and display them. For example,
1489
+   group all the tags belonging to a C++/Java class 
1490
+2. Support for displaying tags in a modified (not-yet-saved) file. 
1491
+3. Automatically open the taglist window only for selected filetypes.
1492
+   For other filetypes, close the taglist window. 
1493
+4. When using the shell from the MKS toolkit, the taglist plugin 
1494
+   doesn't work.
1495
+5. The taglist plugin doesn't work with files edited remotely using the
1496
+   netrw plugin. The exuberant ctags utility cannot process files over
1497
+   scp/rcp/ftp, etc.
1498
+
1499
+==============================================================================
1500
+
1501
+vim:tw=78:ts=8:noet:ft=help:
... ...
@@ -0,0 +1,62 @@
1
+'Tlist_Auto_Highlight_Tag'	taglist.txt	/*'Tlist_Auto_Highlight_Tag'*
2
+'Tlist_Auto_Open'	taglist.txt	/*'Tlist_Auto_Open'*
3
+'Tlist_Auto_Update'	taglist.txt	/*'Tlist_Auto_Update'*
4
+'Tlist_Close_On_Select'	taglist.txt	/*'Tlist_Close_On_Select'*
5
+'Tlist_Compact_Format'	taglist.txt	/*'Tlist_Compact_Format'*
6
+'Tlist_Ctags_Cmd'	taglist.txt	/*'Tlist_Ctags_Cmd'*
7
+'Tlist_Display_Prototype'	taglist.txt	/*'Tlist_Display_Prototype'*
8
+'Tlist_Display_Tag_Scope'	taglist.txt	/*'Tlist_Display_Tag_Scope'*
9
+'Tlist_Enable_Fold_Column'	taglist.txt	/*'Tlist_Enable_Fold_Column'*
10
+'Tlist_Exit_OnlyWindow'	taglist.txt	/*'Tlist_Exit_OnlyWindow'*
11
+'Tlist_File_Fold_Auto_Close'	taglist.txt	/*'Tlist_File_Fold_Auto_Close'*
12
+'Tlist_GainFocus_On_ToggleOpen'	taglist.txt	/*'Tlist_GainFocus_On_ToggleOpen'*
13
+'Tlist_Highlight_Tag_On_BufEnter'	taglist.txt	/*'Tlist_Highlight_Tag_On_BufEnter'*
14
+'Tlist_Inc_Winwidth'	taglist.txt	/*'Tlist_Inc_Winwidth'*
15
+'Tlist_Max_Submenu_Items'	taglist.txt	/*'Tlist_Max_Submenu_Items'*
16
+'Tlist_Max_Tag_Length'	taglist.txt	/*'Tlist_Max_Tag_Length'*
17
+'Tlist_Process_File_Always'	taglist.txt	/*'Tlist_Process_File_Always'*
18
+'Tlist_Show_Menu'	taglist.txt	/*'Tlist_Show_Menu'*
19
+'Tlist_Show_One_File'	taglist.txt	/*'Tlist_Show_One_File'*
20
+'Tlist_Sort_Type'	taglist.txt	/*'Tlist_Sort_Type'*
21
+'Tlist_Use_Horiz_Window'	taglist.txt	/*'Tlist_Use_Horiz_Window'*
22
+'Tlist_Use_Right_Window'	taglist.txt	/*'Tlist_Use_Right_Window'*
23
+'Tlist_Use_SingleClick'	taglist.txt	/*'Tlist_Use_SingleClick'*
24
+'Tlist_WinHeight'	taglist.txt	/*'Tlist_WinHeight'*
25
+'Tlist_WinWidth'	taglist.txt	/*'Tlist_WinWidth'*
26
+:TlistAddFiles	taglist.txt	/*:TlistAddFiles*
27
+:TlistAddFilesRecursive	taglist.txt	/*:TlistAddFilesRecursive*
28
+:TlistClose	taglist.txt	/*:TlistClose*
29
+:TlistDebug	taglist.txt	/*:TlistDebug*
30
+:TlistHighlightTag	taglist.txt	/*:TlistHighlightTag*
31
+:TlistLock	taglist.txt	/*:TlistLock*
32
+:TlistMessages	taglist.txt	/*:TlistMessages*
33
+:TlistOpen	taglist.txt	/*:TlistOpen*
34
+:TlistSessionLoad	taglist.txt	/*:TlistSessionLoad*
35
+:TlistSessionSave	taglist.txt	/*:TlistSessionSave*
36
+:TlistShowPrototype	taglist.txt	/*:TlistShowPrototype*
37
+:TlistShowTag	taglist.txt	/*:TlistShowTag*
38
+:TlistToggle	taglist.txt	/*:TlistToggle*
39
+:TlistUndebug	taglist.txt	/*:TlistUndebug*
40
+:TlistUnlock	taglist.txt	/*:TlistUnlock*
41
+:TlistUpdate	taglist.txt	/*:TlistUpdate*
42
+Tlist_Get_Tag_Prototype_By_Line()	taglist.txt	/*Tlist_Get_Tag_Prototype_By_Line()*
43
+Tlist_Get_Tagname_By_Line()	taglist.txt	/*Tlist_Get_Tagname_By_Line()*
44
+Tlist_Set_App()	taglist.txt	/*Tlist_Set_App()*
45
+Tlist_Update_File_Tags()	taglist.txt	/*Tlist_Update_File_Tags()*
46
+taglist-commands	taglist.txt	/*taglist-commands*
47
+taglist-debug	taglist.txt	/*taglist-debug*
48
+taglist-extend	taglist.txt	/*taglist-extend*
49
+taglist-faq	taglist.txt	/*taglist-faq*
50
+taglist-functions	taglist.txt	/*taglist-functions*
51
+taglist-install	taglist.txt	/*taglist-install*
52
+taglist-internet	taglist.txt	/*taglist-internet*
53
+taglist-intro	taglist.txt	/*taglist-intro*
54
+taglist-keys	taglist.txt	/*taglist-keys*
55
+taglist-license	taglist.txt	/*taglist-license*
56
+taglist-menu	taglist.txt	/*taglist-menu*
57
+taglist-options	taglist.txt	/*taglist-options*
58
+taglist-requirements	taglist.txt	/*taglist-requirements*
59
+taglist-session	taglist.txt	/*taglist-session*
60
+taglist-todo	taglist.txt	/*taglist-todo*
61
+taglist-using	taglist.txt	/*taglist-using*
62
+taglist.txt	taglist.txt	/*taglist.txt*
... ...
@@ -0,0 +1,4546 @@
1
+" File: taglist.vim
2
+" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
3
+" Version: 4.5
4
+" Last Modified: September 21, 2007
5
+" Copyright: Copyright (C) 2002-2007 Yegappan Lakshmanan
6
+"            Permission is hereby granted to use and distribute this code,
7
+"            with or without modifications, provided that this copyright
8
+"            notice is copied with it. Like anything else that's free,
9
+"            taglist.vim is provided *as is* and comes with no warranty of any
10
+"            kind, either expressed or implied. In no event will the copyright
11
+"            holder be liable for any damamges resulting from the use of this
12
+"            software.
13
+"
14
+" The "Tag List" plugin is a source code browser plugin for Vim and provides
15
+" an overview of the structure of the programming language files and allows
16
+" you to efficiently browse through source code files for different
17
+" programming languages.  You can visit the taglist plugin home page for more
18
+" information:
19
+"
20
+"       http://vim-taglist.sourceforge.net
21
+"
22
+" You can subscribe to the taglist mailing list to post your questions
23
+" or suggestions for improvement or to report bugs. Visit the following
24
+" page for subscribing to the mailing list:
25
+"
26
+"       http://groups.yahoo.com/group/taglist/
27
+"
28
+" For more information about using this plugin, after installing the
29
+" taglist plugin, use the ":help taglist" command.
30
+"
31
+" Installation
32
+" ------------
33
+" 1. Download the taglist.zip file and unzip the files to the $HOME/.vim
34
+"    or the $HOME/vimfiles or the $VIM/vimfiles directory. This should
35
+"    unzip the following two files (the directory structure should be
36
+"    preserved):
37
+"
38
+"       plugin/taglist.vim - main taglist plugin file
39
+"       doc/taglist.txt    - documentation (help) file
40
+"
41
+"    Refer to the 'add-plugin', 'add-global-plugin' and 'runtimepath'
42
+"    Vim help pages for more details about installing Vim plugins.
43
+" 2. Change to the $HOME/.vim/doc or $HOME/vimfiles/doc or
44
+"    $VIM/vimfiles/doc directory, start Vim and run the ":helptags ."
45
+"    command to process the taglist help file.
46
+" 3. If the exuberant ctags utility is not present in your PATH, then set the
47
+"    Tlist_Ctags_Cmd variable to point to the location of the exuberant ctags
48
+"    utility (not to the directory) in the .vimrc file.
49
+" 4. If you are running a terminal/console version of Vim and the
50
+"    terminal doesn't support changing the window width then set the
51
+"    'Tlist_Inc_Winwidth' variable to 0 in the .vimrc file.
52
+" 5. Restart Vim.
53
+" 6. You can now use the ":TlistToggle" command to open/close the taglist
54
+"    window. You can use the ":help taglist" command to get more
55
+"    information about using the taglist plugin.
56
+"
57
+" ****************** Do not modify after this line ************************
58
+
59
+" Line continuation used here
60
+let s:cpo_save = &cpo
61
+set cpo&vim
62
+
63
+if !exists('loaded_taglist')
64
+    " First time loading the taglist plugin
65
+    "
66
+    " To speed up the loading of Vim, the taglist plugin uses autoload
67
+    " mechanism to load the taglist functions.
68
+    " Only define the configuration variables, user commands and some
69
+    " auto-commands and finish sourcing the file
70
+
71
+    " The taglist plugin requires the built-in Vim system() function. If this
72
+    " function is not available, then don't load the plugin.
73
+    if !exists('*system')
74
+        echomsg 'Taglist: Vim system() built-in function is not available. ' .
75
+                    \ 'Plugin is not loaded.'
76
+        let loaded_taglist = 'no'
77
+        let &cpo = s:cpo_save
78
+        finish
79
+    endif
80
+
81
+    " Location of the exuberant ctags tool
82
+    if !exists('Tlist_Ctags_Cmd')
83
+        if executable('exuberant-ctags')
84
+            " On Debian Linux, exuberant ctags is installed
85
+            " as exuberant-ctags
86
+            let Tlist_Ctags_Cmd = 'exuberant-ctags'
87
+        elseif executable('exctags')
88
+            " On Free-BSD, exuberant ctags is installed as exctags
89
+            let Tlist_Ctags_Cmd = 'exctags'
90
+        elseif executable('ctags')
91
+            let Tlist_Ctags_Cmd = 'ctags'
92
+        elseif executable('ctags.exe')
93
+            let Tlist_Ctags_Cmd = 'ctags.exe'
94
+        elseif executable('tags')
95
+            let Tlist_Ctags_Cmd = 'tags'
96
+        else
97
+            echomsg 'Taglist: Exuberant ctags (http://ctags.sf.net) ' .
98
+                        \ 'not found in PATH. Plugin is not loaded.'
99
+            " Skip loading the plugin
100
+            let loaded_taglist = 'no'
101
+            let &cpo = s:cpo_save
102
+            finish
103
+        endif
104
+    endif
105
+
106
+
107
+    " Automatically open the taglist window on Vim startup
108
+    if !exists('Tlist_Auto_Open')
109
+        let Tlist_Auto_Open = 0
110
+    endif
111
+
112
+    " When the taglist window is toggle opened, move the cursor to the
113
+    " taglist window
114
+    if !exists('Tlist_GainFocus_On_ToggleOpen')
115
+        let Tlist_GainFocus_On_ToggleOpen = 0
116
+    endif
117
+
118
+    " Process files even when the taglist window is not open
119
+    if !exists('Tlist_Process_File_Always')
120
+        let Tlist_Process_File_Always = 0
121
+    endif
122
+
123
+    if !exists('Tlist_Show_Menu')
124
+        let Tlist_Show_Menu = 0
125
+    endif
126
+
127
+    " Tag listing sort type - 'name' or 'order'
128
+    if !exists('Tlist_Sort_Type')
129
+        let Tlist_Sort_Type = 'order'
130
+    endif
131
+
132
+    " Tag listing window split (horizontal/vertical) control
133
+    if !exists('Tlist_Use_Horiz_Window')
134
+        let Tlist_Use_Horiz_Window = 0
135
+    endif
136
+
137
+    " Open the vertically split taglist window on the left or on the right
138
+    " side.  This setting is relevant only if Tlist_Use_Horiz_Window is set to
139
+    " zero (i.e.  only for vertically split windows)
140
+    if !exists('Tlist_Use_Right_Window')
141
+        let Tlist_Use_Right_Window = 0
142
+    endif
143
+
144
+    " Increase Vim window width to display vertically split taglist window.
145
+    " For MS-Windows version of Vim running in a MS-DOS window, this must be
146
+    " set to 0 otherwise the system may hang due to a Vim limitation.
147
+    if !exists('Tlist_Inc_Winwidth')
148
+        if (has('win16') || has('win95')) && !has('gui_running')
149
+            let Tlist_Inc_Winwidth = 0
150
+        else
151
+            let Tlist_Inc_Winwidth = 1
152
+        endif
153
+    endif
154
+
155
+    " Vertically split taglist window width setting
156
+    if !exists('Tlist_WinWidth')
157
+        let Tlist_WinWidth = 30
158
+    endif
159
+
160
+    " Horizontally split taglist window height setting
161
+    if !exists('Tlist_WinHeight')
162
+        let Tlist_WinHeight = 10
163
+    endif
164
+
165
+    " Display tag prototypes or tag names in the taglist window
166
+    if !exists('Tlist_Display_Prototype')
167
+        let Tlist_Display_Prototype = 0
168
+    endif
169
+
170
+    " Display tag scopes in the taglist window
171
+    if !exists('Tlist_Display_Tag_Scope')
172
+        let Tlist_Display_Tag_Scope = 1
173
+    endif
174
+
175
+    " Use single left mouse click to jump to a tag. By default this is disabled.
176
+    " Only double click using the mouse will be processed.
177
+    if !exists('Tlist_Use_SingleClick')
178
+        let Tlist_Use_SingleClick = 0
179
+    endif
180
+
181
+    " Control whether additional help is displayed as part of the taglist or
182
+    " not.  Also, controls whether empty lines are used to separate the tag
183
+    " tree.
184
+    if !exists('Tlist_Compact_Format')
185
+        let Tlist_Compact_Format = 0
186
+    endif
187
+
188
+    " Exit Vim if only the taglist window is currently open. By default, this is
189
+    " set to zero.
190
+    if !exists('Tlist_Exit_OnlyWindow')
191
+        let Tlist_Exit_OnlyWindow = 0
192
+    endif
193
+
194
+    " Automatically close the folds for the non-active files in the taglist
195
+    " window
196
+    if !exists('Tlist_File_Fold_Auto_Close')
197
+        let Tlist_File_Fold_Auto_Close = 0
198
+    endif
199
+
200
+    " Close the taglist window when a tag is selected
201
+    if !exists('Tlist_Close_On_Select')
202
+        let Tlist_Close_On_Select = 0
203
+    endif
204
+
205
+    " Automatically update the taglist window to display tags for newly
206
+    " edited files
207
+    if !exists('Tlist_Auto_Update')
208
+        let Tlist_Auto_Update = 1
209
+    endif
210
+
211
+    " Automatically highlight the current tag
212
+    if !exists('Tlist_Auto_Highlight_Tag')
213
+        let Tlist_Auto_Highlight_Tag = 1
214
+    endif
215
+    
216
+    " Automatically highlight the current tag on entering a buffer
217
+    if !exists('Tlist_Highlight_Tag_On_BufEnter')
218
+        let Tlist_Highlight_Tag_On_BufEnter = 1
219
+    endif
220
+
221
+    " Enable fold column to display the folding for the tag tree
222
+    if !exists('Tlist_Enable_Fold_Column')
223
+        let Tlist_Enable_Fold_Column = 1
224
+    endif
225
+
226
+    " Display the tags for only one file in the taglist window
227
+    if !exists('Tlist_Show_One_File')
228
+        let Tlist_Show_One_File = 0
229
+    endif
230
+
231
+    if !exists('Tlist_Max_Submenu_Items')
232
+        let Tlist_Max_Submenu_Items = 20
233
+    endif
234
+
235
+    if !exists('Tlist_Max_Tag_Length')
236
+        let Tlist_Max_Tag_Length = 10
237
+    endif
238
+
239
+    " Do not change the name of the taglist title variable. The winmanager
240
+    " plugin relies on this name to determine the title for the taglist
241
+    " plugin.
242
+    let TagList_title = "__Tag_List__"
243
+
244
+    " Taglist debug messages
245
+    let s:tlist_msg = ''
246
+
247
+    " Define the taglist autocommand to automatically open the taglist window
248
+    " on Vim startup
249
+    if g:Tlist_Auto_Open
250
+        autocmd VimEnter * nested call s:Tlist_Window_Check_Auto_Open()
251
+    endif
252
+
253
+    " Refresh the taglist
254
+    if g:Tlist_Process_File_Always
255
+        autocmd BufEnter * call s:Tlist_Refresh()
256
+    endif
257
+
258
+    if g:Tlist_Show_Menu
259
+        autocmd GUIEnter * call s:Tlist_Menu_Init()
260
+    endif
261
+
262
+    " When the taglist buffer is created when loading a Vim session file,
263
+    " the taglist buffer needs to be initialized. The BufFilePost event
264
+    " is used to handle this case.
265
+    autocmd BufFilePost __Tag_List__ call s:Tlist_Vim_Session_Load()
266
+
267
+    " Define the user commands to manage the taglist window
268
+    command! -nargs=0 -bar TlistToggle call s:Tlist_Window_Toggle()
269
+    command! -nargs=0 -bar TlistOpen call s:Tlist_Window_Open()
270
+    " For backwards compatiblity define the Tlist command
271
+    command! -nargs=0 -bar Tlist TlistToggle
272
+    command! -nargs=+ -complete=file TlistAddFiles
273
+                \  call s:Tlist_Add_Files(<f-args>)
274
+    command! -nargs=+ -complete=dir TlistAddFilesRecursive
275
+                \ call s:Tlist_Add_Files_Recursive(<f-args>)
276
+    command! -nargs=0 -bar TlistClose call s:Tlist_Window_Close()
277
+    command! -nargs=0 -bar TlistUpdate call s:Tlist_Update_Current_File()
278
+    command! -nargs=0 -bar TlistHighlightTag call s:Tlist_Window_Highlight_Tag(
279
+                        \ fnamemodify(bufname('%'), ':p'), line('.'), 2, 1)
280
+    " For backwards compatiblity define the TlistSync command
281
+    command! -nargs=0 -bar TlistSync TlistHighlightTag
282
+    command! -nargs=* -complete=buffer TlistShowPrototype
283
+                \ echo Tlist_Get_Tag_Prototype_By_Line(<f-args>)
284
+    command! -nargs=* -complete=buffer TlistShowTag
285
+                \ echo Tlist_Get_Tagname_By_Line(<f-args>)
286
+    command! -nargs=* -complete=file TlistSessionLoad
287
+                \ call s:Tlist_Session_Load(<q-args>)
288
+    command! -nargs=* -complete=file TlistSessionSave
289
+                \ call s:Tlist_Session_Save(<q-args>)
290
+    command! -bar TlistLock let Tlist_Auto_Update=0
291
+    command! -bar TlistUnlock let Tlist_Auto_Update=1
292
+
293
+    " Commands for enabling/disabling debug and to display debug messages
294
+    command! -nargs=? -complete=file -bar TlistDebug
295
+                \ call s:Tlist_Debug_Enable(<q-args>)
296
+    command! -nargs=0 -bar TlistUndebug  call s:Tlist_Debug_Disable()
297
+    command! -nargs=0 -bar TlistMessages call s:Tlist_Debug_Show()
298
+
299
+    " Define autocommands to autoload the taglist plugin when needed.
300
+
301
+    " Trick to get the current script ID
302
+    map <SID>xx <SID>xx
303
+    let s:tlist_sid = substitute(maparg('<SID>xx'), '<SNR>\(\d\+_\)xx$',
304
+                                \ '\1', '')
305
+    unmap <SID>xx
306
+
307
+    exe 'autocmd FuncUndefined *' . s:tlist_sid . 'Tlist_* source ' .
308
+                \ escape(expand('<sfile>'), ' ')
309
+    exe 'autocmd FuncUndefined *' . s:tlist_sid . 'Tlist_Window_* source ' .
310
+                \ escape(expand('<sfile>'), ' ')
311
+    exe 'autocmd FuncUndefined *' . s:tlist_sid . 'Tlist_Menu_* source ' .
312
+                \ escape(expand('<sfile>'), ' ')
313
+    exe 'autocmd FuncUndefined Tlist_* source ' .
314
+                \ escape(expand('<sfile>'), ' ')
315
+    exe 'autocmd FuncUndefined TagList_* source ' .
316
+                \ escape(expand('<sfile>'), ' ')
317
+
318
+    let loaded_taglist = 'fast_load_done'
319
+
320
+    if g:Tlist_Show_Menu && has('gui_running')
321
+        call s:Tlist_Menu_Init()
322
+    endif
323
+
324
+    " restore 'cpo'
325
+    let &cpo = s:cpo_save
326
+    finish
327
+endif
328
+
329
+if !exists('s:tlist_sid')
330
+    " Two or more versions of taglist plugin are installed. Don't
331
+    " load this version of the plugin.
332
+    finish
333
+endif
334
+
335
+unlet! s:tlist_sid
336
+
337
+if loaded_taglist != 'fast_load_done'
338
+    " restore 'cpo'
339
+    let &cpo = s:cpo_save
340
+    finish
341
+endif
342
+
343
+" Taglist plugin functionality is available
344
+let loaded_taglist = 'available'
345
+
346
+"------------------- end of user configurable options --------------------
347
+
348
+" Default language specific settings for supported file types and tag types
349
+"
350
+" Variable name format:
351
+"
352
+"       s:tlist_def_{vim_ftype}_settings
353
+" 
354
+" vim_ftype - Filetype detected by Vim
355
+"
356
+" Value format:
357
+"
358
+"       <ctags_ftype>;<flag>:<name>;<flag>:<name>;...
359
+"
360
+" ctags_ftype - File type supported by exuberant ctags
361
+" flag        - Flag supported by exuberant ctags to generate a tag type
362
+" name        - Name of the tag type used in the taglist window to display the
363
+"               tags of this type
364
+"
365
+
366
+" assembly language
367
+let s:tlist_def_asm_settings = 'asm;d:define;l:label;m:macro;t:type'
368
+
369
+" aspperl language
370
+let s:tlist_def_aspperl_settings = 'asp;f:function;s:sub;v:variable'
371
+
372
+" aspvbs language
373
+let s:tlist_def_aspvbs_settings = 'asp;f:function;s:sub;v:variable'
374
+
375
+" awk language
376
+let s:tlist_def_awk_settings = 'awk;f:function'
377
+
378
+" beta language
379
+let s:tlist_def_beta_settings = 'beta;f:fragment;s:slot;v:pattern'
380
+
381
+" c language
382
+let s:tlist_def_c_settings = 'c;d:macro;g:enum;s:struct;u:union;t:typedef;' .
383
+                           \ 'v:variable;f:function'
384
+
385
+" c++ language
386
+let s:tlist_def_cpp_settings = 'c++;n:namespace;v:variable;d:macro;t:typedef;' .
387
+                             \ 'c:class;g:enum;s:struct;u:union;f:function'
388
+
389
+" c# language
390
+let s:tlist_def_cs_settings = 'c#;d:macro;t:typedef;n:namespace;c:class;' .
391
+                             \ 'E:event;g:enum;s:struct;i:interface;' .
392
+                             \ 'p:properties;m:method'
393
+
394
+" cobol language
395
+let s:tlist_def_cobol_settings = 'cobol;d:data;f:file;g:group;p:paragraph;' .
396
+                               \ 'P:program;s:section'
397
+
398
+" eiffel language
399
+let s:tlist_def_eiffel_settings = 'eiffel;c:class;f:feature'
400
+
401
+" erlang language
402
+let s:tlist_def_erlang_settings = 'erlang;d:macro;r:record;m:module;f:function'
403
+
404
+" expect (same as tcl) language
405
+let s:tlist_def_expect_settings = 'tcl;c:class;f:method;p:procedure'
406
+
407
+" fortran language
408
+let s:tlist_def_fortran_settings = 'fortran;p:program;b:block data;' .
409
+                    \ 'c:common;e:entry;i:interface;k:type;l:label;m:module;' .
410
+                    \ 'n:namelist;t:derived;v:variable;f:function;s:subroutine'
411
+
412
+" HTML language
413
+let s:tlist_def_html_settings = 'html;a:anchor;f:javascript function'
414
+
415
+" java language
416
+let s:tlist_def_java_settings = 'java;p:package;c:class;i:interface;' .
417
+                              \ 'f:field;m:method'
418
+
419
+" javascript language
420
+let s:tlist_def_javascript_settings = 'javascript;f:function'
421
+
422
+" lisp language
423
+let s:tlist_def_lisp_settings = 'lisp;f:function'
424
+
425
+" lua language
426
+let s:tlist_def_lua_settings = 'lua;f:function'
427
+
428
+" makefiles
429
+let s:tlist_def_make_settings = 'make;m:macro'
430
+
431
+" pascal language
432
+let s:tlist_def_pascal_settings = 'pascal;f:function;p:procedure'
433
+
434
+" perl language
435
+let s:tlist_def_perl_settings = 'perl;c:constant;l:label;p:package;s:subroutine'
436
+
437
+" php language
438
+let s:tlist_def_php_settings = 'php;c:class;d:constant;v:variable;f:function'
439
+
440
+" python language
441
+let s:tlist_def_python_settings = 'python;c:class;m:member;f:function'
442
+
443
+" rexx language
444
+let s:tlist_def_rexx_settings = 'rexx;s:subroutine'
445
+
446
+" ruby language
447
+let s:tlist_def_ruby_settings = 'ruby;c:class;f:method;F:function;' .
448
+                              \ 'm:singleton method'
449
+
450
+" scheme language
451
+let s:tlist_def_scheme_settings = 'scheme;s:set;f:function'
452
+
453
+" shell language
454
+let s:tlist_def_sh_settings = 'sh;f:function'
455
+
456
+" C shell language
457
+let s:tlist_def_csh_settings = 'sh;f:function'
458
+
459
+" Z shell language
460
+let s:tlist_def_zsh_settings = 'sh;f:function'
461
+
462
+" slang language
463
+let s:tlist_def_slang_settings = 'slang;n:namespace;f:function'
464
+
465
+" sml language
466
+let s:tlist_def_sml_settings = 'sml;e:exception;c:functor;s:signature;' .
467
+                             \ 'r:structure;t:type;v:value;f:function'
468
+
469
+" sql language
470
+let s:tlist_def_sql_settings = 'sql;c:cursor;F:field;P:package;r:record;' .
471
+            \ 's:subtype;t:table;T:trigger;v:variable;f:function;p:procedure'
472
+
473
+" tcl language
474
+let s:tlist_def_tcl_settings = 'tcl;c:class;f:method;m:method;p:procedure'
475
+
476
+" vera language
477
+let s:tlist_def_vera_settings = 'vera;c:class;d:macro;e:enumerator;' .
478
+                                \ 'f:function;g:enum;m:member;p:program;' .
479
+                                \ 'P:prototype;t:task;T:typedef;v:variable;' .
480
+                                \ 'x:externvar'
481
+
482
+"verilog language
483
+let s:tlist_def_verilog_settings = 'verilog;m:module;c:constant;P:parameter;' .
484
+            \ 'e:event;r:register;t:task;w:write;p:port;v:variable;f:function'
485
+
486
+" vim language
487
+let s:tlist_def_vim_settings = 'vim;a:autocmds;v:variable;f:function'
488
+
489
+" yacc language
490
+let s:tlist_def_yacc_settings = 'yacc;l:label'
491
+
492
+"------------------- end of language specific options --------------------
493
+
494
+" Vim window size is changed by the taglist plugin or not
495
+let s:tlist_winsize_chgd = -1
496
+" Taglist window is maximized or not
497
+let s:tlist_win_maximized = 0
498
+" Name of files in the taglist
499
+let s:tlist_file_names=''
500
+" Number of files in the taglist
501
+let s:tlist_file_count = 0
502
+" Number of filetypes supported by taglist
503
+let s:tlist_ftype_count = 0
504
+" Is taglist part of other plugins like winmanager or cream?
505
+let s:tlist_app_name = "none"
506
+" Are we displaying brief help text
507
+let s:tlist_brief_help = 1
508
+" List of files removed on user request
509
+let s:tlist_removed_flist = ""
510
+" Index of current file displayed in the taglist window
511
+let s:tlist_cur_file_idx = -1
512
+" Taglist menu is empty or not
513
+let s:tlist_menu_empty = 1
514
+
515
+" An autocommand is used to refresh the taglist window when entering any
516
+" buffer. We don't want to refresh the taglist window if we are entering the
517
+" file window from one of the taglist functions. The 'Tlist_Skip_Refresh'
518
+" variable is used to skip the refresh of the taglist window and is set
519
+" and cleared appropriately.
520
+let s:Tlist_Skip_Refresh = 0
521
+
522
+" Tlist_Window_Display_Help()
523
+function! s:Tlist_Window_Display_Help()
524
+    if s:tlist_app_name == "winmanager"
525
+        " To handle a bug in the winmanager plugin, add a space at the
526
+        " last line
527
+        call setline('$', ' ')
528
+    endif
529
+
530
+    if s:tlist_brief_help
531
+        " Add the brief help
532
+        call append(0, '" Press <F1> to display help text')
533
+    else
534
+        " Add the extensive help
535
+        call append(0, '" <enter> : Jump to tag definition')
536
+        call append(1, '" o : Jump to tag definition in new window')
537
+        call append(2, '" p : Preview the tag definition')
538
+        call append(3, '" <space> : Display tag prototype')
539
+        call append(4, '" u : Update tag list')
540
+        call append(5, '" s : Select sort field')
541
+        call append(6, '" d : Remove file from taglist')
542
+        call append(7, '" x : Zoom-out/Zoom-in taglist window')
543
+        call append(8, '" + : Open a fold')
544
+        call append(9, '" - : Close a fold')
545
+        call append(10, '" * : Open all folds')
546
+        call append(11, '" = : Close all folds')
547
+        call append(12, '" [[ : Move to the start of previous file')
548
+        call append(13, '" ]] : Move to the start of next file')
549
+        call append(14, '" q : Close the taglist window')
550
+        call append(15, '" <F1> : Remove help text')
551
+    endif
552
+endfunction
553
+
554
+" Tlist_Window_Toggle_Help_Text()
555
+" Toggle taglist plugin help text between the full version and the brief
556
+" version
557
+function! s:Tlist_Window_Toggle_Help_Text()
558
+    if g:Tlist_Compact_Format
559
+        " In compact display mode, do not display help
560
+        return
561
+    endif
562
+
563
+    " Include the empty line displayed after the help text
564
+    let brief_help_size = 1
565
+    let full_help_size = 16
566
+
567
+    setlocal modifiable
568
+
569
+    " Set report option to a huge value to prevent informational messages
570
+    " while deleting the lines
571
+    let old_report = &report
572
+    set report=99999
573
+
574
+    " Remove the currently highlighted tag. Otherwise, the help text
575
+    " might be highlighted by mistake
576
+    match none
577
+
578
+    " Toggle between brief and full help text
579
+    if s:tlist_brief_help
580
+        let s:tlist_brief_help = 0
581
+
582
+        " Remove the previous help
583
+        exe '1,' . brief_help_size . ' delete _'
584
+
585
+        " Adjust the start/end line numbers for the files
586
+        call s:Tlist_Window_Update_Line_Offsets(0, 1, full_help_size - brief_help_size)
587
+    else
588
+        let s:tlist_brief_help = 1
589
+
590
+        " Remove the previous help
591
+        exe '1,' . full_help_size . ' delete _'
592
+
593
+        " Adjust the start/end line numbers for the files
594
+        call s:Tlist_Window_Update_Line_Offsets(0, 0, full_help_size - brief_help_size)
595
+    endif
596
+
597
+    call s:Tlist_Window_Display_Help()
598
+
599
+    " Restore the report option
600
+    let &report = old_report
601
+
602
+    setlocal nomodifiable
603
+endfunction
604
+
605
+" Taglist debug support
606
+let s:tlist_debug = 0
607
+
608
+" File for storing the debug messages
609
+let s:tlist_debug_file = ''
610
+
611
+" Tlist_Debug_Enable
612
+" Enable logging of taglist debug messages.
613
+function! s:Tlist_Debug_Enable(...)
614
+    let s:tlist_debug = 1
615
+
616
+    " Check whether a valid file name is supplied.
617
+    if a:1 != ''
618
+        let s:tlist_debug_file = fnamemodify(a:1, ':p')
619
+
620
+        " Empty the log file
621
+        exe 'redir! > ' . s:tlist_debug_file
622
+        redir END
623
+
624
+        " Check whether the log file is present/created
625
+        if !filewritable(s:tlist_debug_file)
626
+            call s:Tlist_Warning_Msg('Taglist: Unable to create log file '
627
+                        \ . s:tlist_debug_file)
628
+            let s:tlist_debug_file = ''
629
+        endif
630
+    endif
631
+endfunction
632
+
633
+" Tlist_Debug_Disable
634
+" Disable logging of taglist debug messages.
635
+function! s:Tlist_Debug_Disable(...)
636
+    let s:tlist_debug = 0
637
+    let s:tlist_debug_file = ''
638
+endfunction
639
+
640
+" Tlist_Debug_Show
641
+" Display the taglist debug messages in a new window
642
+function! s:Tlist_Debug_Show()
643
+    if s:tlist_msg == ''
644
+        call s:Tlist_Warning_Msg('Taglist: No debug messages')
645
+        return
646
+    endif
647
+
648
+    " Open a new window to display the taglist debug messages
649
+    new taglist_debug.txt
650
+    " Delete all the lines (if the buffer already exists)
651
+    silent! %delete _
652
+    " Add the messages
653
+    silent! put =s:tlist_msg
654
+    " Move the cursor to the first line
655
+    normal! gg
656
+endfunction
657
+
658
+" Tlist_Log_Msg
659
+" Log the supplied debug message along with the time
660
+function! s:Tlist_Log_Msg(msg)
661
+    if s:tlist_debug
662
+        if s:tlist_debug_file != ''
663
+            exe 'redir >> ' . s:tlist_debug_file
664
+            silent echon strftime('%H:%M:%S') . ': ' . a:msg . "\n"
665
+            redir END
666
+        else
667
+            " Log the message into a variable
668
+            " Retain only the last 3000 characters
669
+            let len = strlen(s:tlist_msg)
670
+            if len > 3000
671
+                let s:tlist_msg = strpart(s:tlist_msg, len - 3000)
672
+            endif
673
+            let s:tlist_msg = s:tlist_msg . strftime('%H:%M:%S') . ': ' . 
674
+                        \ a:msg . "\n"
675
+        endif
676
+    endif
677
+endfunction
678
+
679
+" Tlist_Warning_Msg()
680
+" Display a message using WarningMsg highlight group
681
+function! s:Tlist_Warning_Msg(msg)
682
+    echohl WarningMsg
683
+    echomsg a:msg
684
+    echohl None
685
+endfunction
686
+
687
+" Last returned file index for file name lookup.
688
+" Used to speed up file lookup
689
+let s:tlist_file_name_idx_cache = -1
690
+
691
+" Tlist_Get_File_Index()
692
+" Return the index of the specified filename
693
+function! s:Tlist_Get_File_Index(fname)
694
+    if s:tlist_file_count == 0 || a:fname == ''
695
+        return -1
696
+    endif
697
+
698
+    " If the new filename is same as the last accessed filename, then
699
+    " return that index
700
+    if s:tlist_file_name_idx_cache != -1 &&
701
+                \ s:tlist_file_name_idx_cache < s:tlist_file_count
702
+        if s:tlist_{s:tlist_file_name_idx_cache}_filename == a:fname
703
+            " Same as the last accessed file
704
+            return s:tlist_file_name_idx_cache
705
+        endif
706
+    endif
707
+
708
+    " First, check whether the filename is present
709
+    let s_fname = a:fname . "\n"
710
+    let i = stridx(s:tlist_file_names, s_fname)
711
+    if i == -1
712
+        let s:tlist_file_name_idx_cache = -1
713
+        return -1
714
+    endif
715
+
716
+    " Second, compute the file name index
717
+    let nl_txt = substitute(strpart(s:tlist_file_names, 0, i), "[^\n]", '', 'g')
718
+    let s:tlist_file_name_idx_cache = strlen(nl_txt)
719
+    return s:tlist_file_name_idx_cache
720
+endfunction
721
+
722
+" Last returned file index for line number lookup.
723
+" Used to speed up file lookup
724
+let s:tlist_file_lnum_idx_cache = -1
725
+
726
+" Tlist_Window_Get_File_Index_By_Linenum()
727
+" Return the index of the filename present in the specified line number
728
+" Line number refers to the line number in the taglist window
729
+function! s:Tlist_Window_Get_File_Index_By_Linenum(lnum)
730
+    call s:Tlist_Log_Msg('Tlist_Window_Get_File_Index_By_Linenum (' . a:lnum . ')')
731
+
732
+    " First try to see whether the new line number is within the range
733
+    " of the last returned file
734
+    if s:tlist_file_lnum_idx_cache != -1 &&
735
+                \ s:tlist_file_lnum_idx_cache < s:tlist_file_count
736
+        if a:lnum >= s:tlist_{s:tlist_file_lnum_idx_cache}_start &&
737
+                    \ a:lnum <= s:tlist_{s:tlist_file_lnum_idx_cache}_end
738
+            return s:tlist_file_lnum_idx_cache
739
+        endif
740
+    endif
741
+
742
+    let fidx = -1
743
+
744
+    if g:Tlist_Show_One_File
745
+        " Displaying only one file in the taglist window. Check whether
746
+        " the line is within the tags displayed for that file
747
+        if s:tlist_cur_file_idx != -1
748
+            if a:lnum >= s:tlist_{s:tlist_cur_file_idx}_start
749
+                        \ && a:lnum <= s:tlist_{s:tlist_cur_file_idx}_end
750
+                let fidx = s:tlist_cur_file_idx
751
+            endif
752
+
753
+        endif
754
+    else
755
+        " Do a binary search in the taglist
756
+        let left = 0
757
+        let right = s:tlist_file_count - 1
758
+
759
+        while left < right
760
+            let mid = (left + right) / 2
761
+
762
+            if a:lnum >= s:tlist_{mid}_start && a:lnum <= s:tlist_{mid}_end
763
+                let s:tlist_file_lnum_idx_cache = mid
764
+                return mid
765
+            endif
766
+
767
+            if a:lnum < s:tlist_{mid}_start
768
+                let right = mid - 1
769
+            else
770
+                let left = mid + 1
771
+            endif
772
+        endwhile
773
+
774
+        if left >= 0 && left < s:tlist_file_count
775
+                    \ && a:lnum >= s:tlist_{left}_start
776
+                    \ && a:lnum <= s:tlist_{left}_end
777
+            let fidx = left
778
+        endif
779
+    endif
780
+
781
+    let s:tlist_file_lnum_idx_cache = fidx
782
+
783
+    return fidx
784
+endfunction
785
+
786
+" Tlist_Exe_Cmd_No_Acmds
787
+" Execute the specified Ex command after disabling autocommands
788
+function! s:Tlist_Exe_Cmd_No_Acmds(cmd)
789
+    let old_eventignore = &eventignore
790
+    set eventignore=all
791
+    exe a:cmd
792
+    let &eventignore = old_eventignore
793
+endfunction
794
+
795
+" Tlist_Skip_File()
796
+" Check whether tag listing is supported for the specified file
797
+function! s:Tlist_Skip_File(filename, ftype)
798
+    " Skip buffers with no names and buffers with filetype not set
799
+    if a:filename == '' || a:ftype == ''
800
+        return 1
801
+    endif
802
+
803
+    " Skip files which are not supported by exuberant ctags
804
+    " First check whether default settings for this filetype are available.
805
+    " If it is not available, then check whether user specified settings are
806
+    " available. If both are not available, then don't list the tags for this
807
+    " filetype
808
+    let var = 's:tlist_def_' . a:ftype . '_settings'
809
+    if !exists(var)
810
+        let var = 'g:tlist_' . a:ftype . '_settings'
811
+        if !exists(var)
812
+            return 1
813
+        endif
814
+    endif
815
+
816
+    " Skip files which are not readable or files which are not yet stored
817
+    " to the disk
818
+    if !filereadable(a:filename)
819
+        return 1
820
+    endif
821
+
822
+    return 0
823
+endfunction
824
+
825
+" Tlist_User_Removed_File
826
+" Returns 1 if a file is removed by a user from the taglist
827
+function! s:Tlist_User_Removed_File(filename)
828
+    return stridx(s:tlist_removed_flist, a:filename . "\n") != -1
829
+endfunction
830
+
831
+" Tlist_Update_Remove_List
832
+" Update the list of user removed files from the taglist
833
+" add == 1, add the file to the removed list
834
+" add == 0, delete the file from the removed list
835
+function! s:Tlist_Update_Remove_List(filename, add)
836
+    if a:add
837
+        let s:tlist_removed_flist = s:tlist_removed_flist . a:filename . "\n"
838
+    else
839
+        let idx = stridx(s:tlist_removed_flist, a:filename . "\n")
840
+        let text_before = strpart(s:tlist_removed_flist, 0, idx)
841
+        let rem_text = strpart(s:tlist_removed_flist, idx)
842
+        let next_idx = stridx(rem_text, "\n")
843
+        let text_after = strpart(rem_text, next_idx + 1)
844
+
845
+        let s:tlist_removed_flist = text_before . text_after
846
+    endif
847
+endfunction
848
+
849
+" Tlist_FileType_Init
850
+" Initialize the ctags arguments and tag variable for the specified
851
+" file type
852
+function! s:Tlist_FileType_Init(ftype)
853
+    call s:Tlist_Log_Msg('Tlist_FileType_Init (' . a:ftype . ')')
854
+    " If the user didn't specify any settings, then use the default
855
+    " ctags args. Otherwise, use the settings specified by the user
856
+    let var = 'g:tlist_' . a:ftype . '_settings'
857
+    if exists(var)
858
+        " User specified ctags arguments
859
+        let settings = {var} . ';'
860
+    else
861
+        " Default ctags arguments
862
+        let var = 's:tlist_def_' . a:ftype . '_settings'
863
+        if !exists(var)
864
+            " No default settings for this file type. This filetype is
865
+            " not supported
866
+            return 0
867
+        endif
868
+        let settings = s:tlist_def_{a:ftype}_settings . ';'
869
+    endif
870
+
871
+    let msg = 'Taglist: Invalid ctags option setting - ' . settings