Remove NERDTree and use netrw instead.
David Blume

David Blume commited on 2020-07-08 11:39:03
Showing 8 changed files, with 4 additions and 6309 deletions.

... ...
@@ -1,3 +0,0 @@
1
-*~
2
-*.swp
3
-tags
... ...
@@ -1,104 +0,0 @@
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
-
... ...
@@ -1,1362 +0,0 @@
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.
... ...
@@ -1,41 +0,0 @@
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
... ...
@@ -1,262 +0,0 @@
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:
... ...
@@ -1,4444 +0,0 @@
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:
... ...
@@ -1,88 +0,0 @@
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
... ...
@@ -46,11 +46,10 @@ See [config.dlma.com](http://config.dlma.com) for more.
46 46
         1. [pathogen](https://github.com/tpope/vim-pathogen), the Vim plugin manager.
47 47
         2. [vim-airline](https://github.com/vim-airline/vim-airline), for a better Vim statusline.
48 48
         3. [bbye for :Bdelete](https://github.com/moll/vim-bbye), to delete buffers without affecting windows.
49
-        4. [nerdtree](https://github.com/scrooloose/nerdtree), a better filesystem tree-view explorer.
50
-        5. [taglist](http://www.vim.org/scripts/script.php?script_id=273), a ctags tree-view explorer.
51
-        6. [file-line](http://www.vim.org/scripts/script.php?script_id=2184), to open file:line as from a compiler error.
52
-        7. [visual-star-search](http://got-ravings.blogspot.com/2008/07/vim-pr0n-visual-search-mappings.html), so * and # work in visual mode too.
53
-        8. Assorted favorite colors like [desert](https://github.com/dblume/desert.vim).
49
+        4. [taglist](http://www.vim.org/scripts/script.php?script_id=273), a ctags tree-view explorer.
50
+        5. [file-line](http://www.vim.org/scripts/script.php?script_id=2184), to open file:line as from a compiler error.
51
+        6. [visual-star-search](http://got-ravings.blogspot.com/2008/07/vim-pr0n-visual-search-mappings.html), so * and # work in visual mode too.
52
+        7. Assorted favorite colors like [desert](https://github.com/dblume/desert.vim).
54 53
 3. .gitconfig and .gitignore
55 54
 4. .tmux.conf
56 55
 5. .inputrc, for a [partially matched command history traversal](http://askubuntu.com/questions/59846/bash-history-search-partial-up-arrow/59855#59855).
57 56