diff options
author | Sam Chudnick <sam@chudnick.com> | 2023-06-11 07:54:59 -0400 |
---|---|---|
committer | Sam Chudnick <sam@chudnick.com> | 2023-06-11 07:54:59 -0400 |
commit | 3adcf542289a0883924ae9b9be8b898c36702c95 (patch) | |
tree | f02166ef4c95161ffa994eb1a3e5729c93c2c66b /.vim/pack/vendor/start/nerdtree/nerdtree_plugin | |
parent | dfcc303e7cc284a45f55bae81ed888dc256432b8 (diff) |
Add some Vim plugins
Diffstat (limited to '.vim/pack/vendor/start/nerdtree/nerdtree_plugin')
3 files changed, 571 insertions, 0 deletions
diff --git a/.vim/pack/vendor/start/nerdtree/nerdtree_plugin/exec_menuitem.vim b/.vim/pack/vendor/start/nerdtree/nerdtree_plugin/exec_menuitem.vim new file mode 100644 index 0000000..fb6c486 --- /dev/null +++ b/.vim/pack/vendor/start/nerdtree/nerdtree_plugin/exec_menuitem.vim | |||
@@ -0,0 +1,40 @@ | |||
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 | " License: This program is free software. It comes without any warranty, | ||
6 | " to the extent permitted by applicable law. You can redistribute | ||
7 | " it and/or modify it under the terms of the Do What The Fuck You | ||
8 | " Want To Public License, Version 2, as published by Sam Hocevar. | ||
9 | " See http://sam.zoy.org/wtfpl/COPYING for more details. | ||
10 | " | ||
11 | " ============================================================================ | ||
12 | if exists('g:loaded_nerdtree_exec_menuitem') | ||
13 | finish | ||
14 | endif | ||
15 | let g:loaded_nerdtree_exec_menuitem = 1 | ||
16 | |||
17 | call NERDTreeAddMenuItem({ | ||
18 | \ 'text': '(!)Execute file', | ||
19 | \ 'shortcut': '!', | ||
20 | \ 'callback': 'NERDTreeExecFile', | ||
21 | \ 'isActiveCallback': 'NERDTreeExecFileActive' }) | ||
22 | |||
23 | function! NERDTreeExecFileActive() | ||
24 | let node = g:NERDTreeFileNode.GetSelected() | ||
25 | return !node.path.isDirectory && node.path.isExecutable | ||
26 | endfunction | ||
27 | |||
28 | function! NERDTreeExecFile() | ||
29 | let treenode = g:NERDTreeFileNode.GetSelected() | ||
30 | echo "==========================================================\n" | ||
31 | echo "Complete the command to execute (add arguments etc):\n" | ||
32 | let cmd = treenode.path.str({'escape': 1}) | ||
33 | let cmd = input(':!', cmd . ' ') | ||
34 | |||
35 | if cmd !=# '' | ||
36 | exec ':!' . cmd | ||
37 | else | ||
38 | echo 'Aborted' | ||
39 | endif | ||
40 | endfunction | ||
diff --git a/.vim/pack/vendor/start/nerdtree/nerdtree_plugin/fs_menu.vim b/.vim/pack/vendor/start/nerdtree/nerdtree_plugin/fs_menu.vim new file mode 100644 index 0000000..05bee60 --- /dev/null +++ b/.vim/pack/vendor/start/nerdtree/nerdtree_plugin/fs_menu.vim | |||
@@ -0,0 +1,484 @@ | |||
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 | " License: This program is free software. It comes without any warranty, | ||
6 | " to the extent permitted by applicable law. You can redistribute | ||
7 | " it and/or modify it under the terms of the Do What The Fuck You | ||
8 | " Want To Public License, Version 2, as published by Sam Hocevar. | ||
9 | " See http://sam.zoy.org/wtfpl/COPYING for more details. | ||
10 | " | ||
11 | " ============================================================================ | ||
12 | if exists('g:loaded_nerdtree_fs_menu') | ||
13 | finish | ||
14 | endif | ||
15 | let g:loaded_nerdtree_fs_menu = 1 | ||
16 | |||
17 | "Automatically delete the buffer after deleting or renaming a file | ||
18 | if !exists('g:NERDTreeAutoDeleteBuffer') | ||
19 | let g:NERDTreeAutoDeleteBuffer = 0 | ||
20 | endif | ||
21 | |||
22 | call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'}) | ||
23 | call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) | ||
24 | call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) | ||
25 | |||
26 | if has('gui_mac') || has('gui_macvim') || has('mac') | ||
27 | call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) | ||
28 | call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'}) | ||
29 | call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'}) | ||
30 | endif | ||
31 | |||
32 | if executable('xdg-open') | ||
33 | call NERDTreeAddMenuItem({'text': '(r)eveal the current node in file manager', 'shortcut': 'r', 'callback': 'NERDTreeRevealFileLinux'}) | ||
34 | call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileLinux'}) | ||
35 | endif | ||
36 | |||
37 | if nerdtree#runningWindows() | ||
38 | call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileWindows'}) | ||
39 | endif | ||
40 | |||
41 | if g:NERDTreePath.CopyingSupported() | ||
42 | call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) | ||
43 | endif | ||
44 | call NERDTreeAddMenuItem({'text': (has('clipboard')?'copy (p)ath to clipboard':'print (p)ath to screen'), 'shortcut': 'p', 'callback': 'NERDTreeCopyPath'}) | ||
45 | |||
46 | if has('unix') || has('osx') | ||
47 | call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'}) | ||
48 | else | ||
49 | call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'}) | ||
50 | endif | ||
51 | |||
52 | if exists('*system') | ||
53 | call NERDTreeAddMenuItem({'text': 'Run (s)ystem command in this directory', 'shortcut':'s', 'callback': 'NERDTreeSystemCommand'}) | ||
54 | endif | ||
55 | |||
56 | "FUNCTION: s:inputPrompt(action){{{1 | ||
57 | "returns the string that should be prompted to the user for the given action | ||
58 | " | ||
59 | "Args: | ||
60 | "action: the action that is being performed, e.g. 'delete' | ||
61 | function! s:inputPrompt(action) | ||
62 | if a:action ==# 'add' | ||
63 | let title = 'Add a childnode' | ||
64 | let info = "Enter the dir/file name to be created. Dirs end with a '/'" | ||
65 | let minimal = 'Add node:' | ||
66 | |||
67 | elseif a:action ==# 'copy' | ||
68 | let title = 'Copy the current node' | ||
69 | let info = 'Enter the new path to copy the node to:' | ||
70 | let minimal = 'Copy to:' | ||
71 | |||
72 | elseif a:action ==# 'delete' | ||
73 | let title = 'Delete the current node' | ||
74 | let info = 'Are you sure you wish to delete the node:' | ||
75 | let minimal = 'Delete?' | ||
76 | |||
77 | elseif a:action ==# 'deleteNonEmpty' | ||
78 | let title = 'Delete the current node' | ||
79 | let info = "STOP! Directory is not empty! To delete, type 'yes'" | ||
80 | let minimal = 'Delete directory?' | ||
81 | |||
82 | elseif a:action ==# 'move' | ||
83 | let title = 'Rename the current node' | ||
84 | let info = 'Enter the new path for the node:' | ||
85 | let minimal = 'Move to:' | ||
86 | endif | ||
87 | |||
88 | if g:NERDTreeMenuController.isMinimal() | ||
89 | redraw! " Clear the menu | ||
90 | return minimal . ' ' | ||
91 | else | ||
92 | let divider = '==========================================================' | ||
93 | return title . "\n" . divider . "\n" . info . "\n" | ||
94 | end | ||
95 | endfunction | ||
96 | |||
97 | "FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1 | ||
98 | "prints out the given msg and, if the user responds by pushing 'y' then the | ||
99 | "buffer with the given bufnum is deleted | ||
100 | " | ||
101 | "Args: | ||
102 | "bufnum: the buffer that may be deleted | ||
103 | "msg: a message that will be echoed to the user asking them if they wish to | ||
104 | " del the buffer | ||
105 | function! s:promptToDelBuffer(bufnum, msg) | ||
106 | echo a:msg | ||
107 | if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' | ||
108 | " 1. ensure that all windows which display the just deleted filename | ||
109 | " now display an empty buffer (so a layout is preserved). | ||
110 | " Is not it better to close single tabs with this file only ? | ||
111 | let s:originalTabNumber = tabpagenr() | ||
112 | let s:originalWindowNumber = winnr() | ||
113 | " Go to the next buffer in buffer list if at least one extra buffer is listed | ||
114 | " Otherwise open a new empty buffer | ||
115 | if v:version >= 800 | ||
116 | let l:listedBufferCount = len(getbufinfo({'buflisted':1})) | ||
117 | elseif v:version >= 702 | ||
118 | let l:listedBufferCount = len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) | ||
119 | else | ||
120 | " Ignore buffer count in this case to make sure we keep the old | ||
121 | " behavior | ||
122 | let l:listedBufferCount = 0 | ||
123 | endif | ||
124 | if l:listedBufferCount > 1 | ||
125 | call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufnum . " | exec ':bnext! ' | endif", 1) | ||
126 | else | ||
127 | call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufnum . " | exec ':enew! ' | endif", 1) | ||
128 | endif | ||
129 | call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) | ||
130 | call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) | ||
131 | " 3. We don't need a previous buffer anymore | ||
132 | call nerdtree#exec('bwipeout! ' . a:bufnum, 0) | ||
133 | endif | ||
134 | endfunction | ||
135 | |||
136 | "FUNCTION: s:renameBuffer(bufNum, newNodeName, isDirectory){{{1 | ||
137 | "The buffer with the given bufNum is replaced with a new one | ||
138 | " | ||
139 | "Args: | ||
140 | "bufNum: the buffer that may be deleted | ||
141 | "newNodeName: the name given to the renamed node | ||
142 | "isDirectory: determines how to do the create the new filenames | ||
143 | function! s:renameBuffer(bufNum, newNodeName, isDirectory) | ||
144 | if a:isDirectory | ||
145 | let quotedFileName = fnameescape(a:newNodeName . '/' . fnamemodify(bufname(a:bufNum),':t')) | ||
146 | let editStr = g:NERDTreePath.New(a:newNodeName . '/' . fnamemodify(bufname(a:bufNum),':t')).str({'format': 'Edit'}) | ||
147 | else | ||
148 | let quotedFileName = fnameescape(a:newNodeName) | ||
149 | let editStr = g:NERDTreePath.New(a:newNodeName).str({'format': 'Edit'}) | ||
150 | endif | ||
151 | " 1. ensure that a new buffer is loaded | ||
152 | call nerdtree#exec('badd ' . quotedFileName, 0) | ||
153 | " 2. ensure that all windows which display the just deleted filename | ||
154 | " display a buffer for a new filename. | ||
155 | let s:originalTabNumber = tabpagenr() | ||
156 | let s:originalWindowNumber = winnr() | ||
157 | call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufNum . " | exec ':e! " . editStr . "' | endif", 0) | ||
158 | call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) | ||
159 | call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) | ||
160 | " 3. We don't need a previous buffer anymore | ||
161 | try | ||
162 | call nerdtree#exec('confirm bwipeout ' . a:bufNum, 0) | ||
163 | catch | ||
164 | " This happens when answering Cancel if confirmation is needed. Do nothing. | ||
165 | endtry | ||
166 | endfunction | ||
167 | |||
168 | "FUNCTION: NERDTreeAddNode(){{{1 | ||
169 | function! NERDTreeAddNode() | ||
170 | let curDirNode = g:NERDTreeDirNode.GetSelected() | ||
171 | let prompt = s:inputPrompt('add') | ||
172 | let newNodeName = substitute(input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file'), '\(^\s*\|\s*$\)', '', 'g') | ||
173 | |||
174 | if newNodeName ==# '' | ||
175 | call nerdtree#echo('Node Creation Aborted.') | ||
176 | return | ||
177 | endif | ||
178 | |||
179 | try | ||
180 | let newPath = g:NERDTreePath.Create(newNodeName) | ||
181 | let parentNode = b:NERDTree.root.findNode(newPath.getParent()) | ||
182 | |||
183 | let newTreeNode = g:NERDTreeFileNode.New(newPath, b:NERDTree) | ||
184 | " Emptying g:NERDTreeOldSortOrder forces the sort to | ||
185 | " recalculate the cached sortKey so nodes sort correctly. | ||
186 | let g:NERDTreeOldSortOrder = [] | ||
187 | if empty(parentNode) | ||
188 | call b:NERDTree.root.refresh() | ||
189 | call b:NERDTree.render() | ||
190 | elseif parentNode.isOpen || !empty(parentNode.children) | ||
191 | call parentNode.addChild(newTreeNode, 1) | ||
192 | call NERDTreeRender() | ||
193 | call newTreeNode.putCursorHere(1, 0) | ||
194 | endif | ||
195 | |||
196 | redraw! | ||
197 | catch /^NERDTree/ | ||
198 | call nerdtree#echoWarning('Node Not Created.') | ||
199 | endtry | ||
200 | endfunction | ||
201 | |||
202 | "FUNCTION: NERDTreeMoveNode(){{{1 | ||
203 | function! NERDTreeMoveNode() | ||
204 | let curNode = g:NERDTreeFileNode.GetSelected() | ||
205 | let prompt = s:inputPrompt('move') | ||
206 | let newNodePath = input(prompt, curNode.path.str(), 'file') | ||
207 | while filereadable(newNodePath) | ||
208 | call nerdtree#echoWarning('This destination already exists. Try again.') | ||
209 | let newNodePath = substitute(input(prompt, curNode.path.str(), 'file'), '\(^\s*\|\s*$\)', '', 'g') | ||
210 | endwhile | ||
211 | |||
212 | |||
213 | if newNodePath ==# '' | ||
214 | call nerdtree#echo('Node Renaming Aborted.') | ||
215 | return | ||
216 | endif | ||
217 | |||
218 | try | ||
219 | if curNode.path.isDirectory | ||
220 | let l:curPath = escape(curNode.path.str(),'\') . (nerdtree#runningWindows()?'\\':'/') . '.*' | ||
221 | let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# "'.escape(l:curPath,'\').'"') | ||
222 | else | ||
223 | let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") ==# curNode.path.str()') | ||
224 | endif | ||
225 | |||
226 | call curNode.rename(newNodePath) | ||
227 | " Emptying g:NERDTreeOldSortOrder forces the sort to | ||
228 | " recalculate the cached sortKey so nodes sort correctly. | ||
229 | let g:NERDTreeOldSortOrder = [] | ||
230 | call b:NERDTree.root.refresh() | ||
231 | call NERDTreeRender() | ||
232 | |||
233 | " If the file node is open, or files under the directory node are | ||
234 | " open, ask the user if they want to replace the file(s) with the | ||
235 | " renamed files. | ||
236 | if !empty(l:openBuffers) | ||
237 | if curNode.path.isDirectory | ||
238 | echo "\nDirectory renamed.\n\nFiles with the old directory name are open in buffers " . join(l:openBuffers, ', ') . '. Replace these buffers with the new files? (yN)' | ||
239 | else | ||
240 | echo "\nFile renamed.\n\nThe old file is open in buffer " . l:openBuffers[0] . '. Replace this buffer with the new file? (yN)' | ||
241 | endif | ||
242 | if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' | ||
243 | for bufNum in l:openBuffers | ||
244 | call s:renameBuffer(bufNum, newNodePath, curNode.path.isDirectory) | ||
245 | endfor | ||
246 | endif | ||
247 | endif | ||
248 | |||
249 | call curNode.putCursorHere(1, 0) | ||
250 | |||
251 | redraw! | ||
252 | catch /^NERDTree/ | ||
253 | call nerdtree#echoWarning('Node Not Renamed.') | ||
254 | endtry | ||
255 | endfunction | ||
256 | |||
257 | " FUNCTION: NERDTreeDeleteNode() {{{1 | ||
258 | function! NERDTreeDeleteNode() | ||
259 | let currentNode = g:NERDTreeFileNode.GetSelected() | ||
260 | let confirmed = 0 | ||
261 | |||
262 | if currentNode.path.isDirectory && ((currentNode.isOpen && currentNode.getChildCount() > 0) || | ||
263 | \ (len(currentNode._glob('*', 1)) > 0)) | ||
264 | let prompt = s:inputPrompt('deleteNonEmpty') . currentNode.path.str() . ': ' | ||
265 | let choice = input(prompt) | ||
266 | let confirmed = choice ==# 'yes' | ||
267 | else | ||
268 | let prompt = s:inputPrompt('delete') . currentNode.path.str() . ' (yN): ' | ||
269 | echo prompt | ||
270 | let choice = nr2char(getchar()) | ||
271 | let confirmed = choice ==# 'y' | ||
272 | endif | ||
273 | |||
274 | if confirmed | ||
275 | try | ||
276 | call currentNode.delete() | ||
277 | call NERDTreeRender() | ||
278 | |||
279 | "if the node is open in a buffer, ask the user if they want to | ||
280 | "close that buffer | ||
281 | let bufnum = bufnr('^'.currentNode.path.str().'$') | ||
282 | if buflisted(bufnum) | ||
283 | let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? ' (hidden)' : '') .'. Delete this buffer? (yN)' | ||
284 | call s:promptToDelBuffer(bufnum, prompt) | ||
285 | endif | ||
286 | |||
287 | redraw! | ||
288 | catch /^NERDTree/ | ||
289 | call nerdtree#echoWarning('Could not remove node') | ||
290 | endtry | ||
291 | else | ||
292 | call nerdtree#echo('delete aborted') | ||
293 | endif | ||
294 | endfunction | ||
295 | |||
296 | " FUNCTION: NERDTreeListNode() {{{1 | ||
297 | function! NERDTreeListNode() | ||
298 | let treenode = g:NERDTreeFileNode.GetSelected() | ||
299 | if !empty(treenode) | ||
300 | let s:uname = system('uname') | ||
301 | let stat_cmd = 'stat -c "%s" ' | ||
302 | |||
303 | if s:uname =~? 'Darwin' | ||
304 | let stat_cmd = 'stat -f "%z" ' | ||
305 | endif | ||
306 | |||
307 | let cmd = 'size=$(' . stat_cmd . shellescape(treenode.path.str()) . ') && ' . | ||
308 | \ 'size_with_commas=$(echo $size | sed -e :a -e "s/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta") && ' . | ||
309 | \ 'ls -ld ' . shellescape(treenode.path.str()) . ' | sed -e "s/ $size / $size_with_commas /"' | ||
310 | |||
311 | let metadata = split(system(cmd),'\n') | ||
312 | call nerdtree#echo(metadata[0]) | ||
313 | else | ||
314 | call nerdtree#echo('No information available') | ||
315 | endif | ||
316 | endfunction | ||
317 | |||
318 | " FUNCTION: NERDTreeListNodeWin32() {{{1 | ||
319 | function! NERDTreeListNodeWin32() | ||
320 | let l:node = g:NERDTreeFileNode.GetSelected() | ||
321 | |||
322 | if !empty(l:node) | ||
323 | let l:path = l:node.path.str() | ||
324 | call nerdtree#echo(printf('%s:%s MOD:%s BYTES:%d PERMISSIONS:%s', | ||
325 | \ toupper(getftype(l:path)), | ||
326 | \ fnamemodify(l:path, ':t'), | ||
327 | \ strftime('%c', getftime(l:path)), | ||
328 | \ getfsize(l:path), | ||
329 | \ getfperm(l:path))) | ||
330 | return | ||
331 | endif | ||
332 | |||
333 | call nerdtree#echo('node not recognized') | ||
334 | endfunction | ||
335 | |||
336 | " FUNCTION: NERDTreeCopyNode() {{{1 | ||
337 | function! NERDTreeCopyNode() | ||
338 | let currentNode = g:NERDTreeFileNode.GetSelected() | ||
339 | let prompt = s:inputPrompt('copy') | ||
340 | let newNodePath = substitute(input(prompt, currentNode.path.str(), 'file'), '\(^\s*\|\s*$\)', '', 'g') | ||
341 | |||
342 | if newNodePath !=# '' | ||
343 | "strip trailing slash | ||
344 | let newNodePath = substitute(newNodePath, '\/$', '', '') | ||
345 | |||
346 | let confirmed = 1 | ||
347 | if currentNode.path.copyingWillOverwrite(newNodePath) | ||
348 | call nerdtree#echo('Warning: copying may overwrite files! Continue? (yN)') | ||
349 | let choice = nr2char(getchar()) | ||
350 | let confirmed = choice ==# 'y' | ||
351 | endif | ||
352 | |||
353 | if confirmed | ||
354 | try | ||
355 | let newNode = currentNode.copy(newNodePath) | ||
356 | " Emptying g:NERDTreeOldSortOrder forces the sort to | ||
357 | " recalculate the cached sortKey so nodes sort correctly. | ||
358 | let g:NERDTreeOldSortOrder = [] | ||
359 | if empty(newNode) | ||
360 | call b:NERDTree.root.refresh() | ||
361 | call b:NERDTree.render() | ||
362 | else | ||
363 | call NERDTreeRender() | ||
364 | call newNode.putCursorHere(0, 0) | ||
365 | endif | ||
366 | catch /^NERDTree/ | ||
367 | call nerdtree#echoWarning('Could not copy node') | ||
368 | endtry | ||
369 | endif | ||
370 | else | ||
371 | call nerdtree#echo('Copy aborted.') | ||
372 | endif | ||
373 | redraw! | ||
374 | endfunction | ||
375 | |||
376 | " FUNCTION: NERDTreeCopyPath() {{{1 | ||
377 | function! NERDTreeCopyPath() | ||
378 | let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str() | ||
379 | if has('clipboard') | ||
380 | if &clipboard ==# 'unnamedplus' | ||
381 | let @+ = l:nodePath | ||
382 | else | ||
383 | let @* = l:nodePath | ||
384 | endif | ||
385 | call nerdtree#echo('The path [' . l:nodePath . '] was copied to your clipboard.') | ||
386 | else | ||
387 | call nerdtree#echo('The full path is: ' . l:nodePath) | ||
388 | endif | ||
389 | endfunction | ||
390 | |||
391 | " FUNCTION: NERDTreeQuickLook() {{{1 | ||
392 | function! NERDTreeQuickLook() | ||
393 | let l:node = g:NERDTreeFileNode.GetSelected() | ||
394 | |||
395 | if empty(l:node) | ||
396 | return | ||
397 | endif | ||
398 | |||
399 | call system('qlmanage -p 2>/dev/null ' . shellescape(l:node.path.str())) | ||
400 | endfunction | ||
401 | |||
402 | " FUNCTION: NERDTreeRevealInFinder() {{{1 | ||
403 | function! NERDTreeRevealInFinder() | ||
404 | let l:node = g:NERDTreeFileNode.GetSelected() | ||
405 | |||
406 | if empty(l:node) | ||
407 | return | ||
408 | endif | ||
409 | |||
410 | call system('open -R ' . shellescape(l:node.path.str())) | ||
411 | endfunction | ||
412 | |||
413 | " FUNCTION: NERDTreeExecuteFile() {{{1 | ||
414 | function! NERDTreeExecuteFile() | ||
415 | let l:node = g:NERDTreeFileNode.GetSelected() | ||
416 | |||
417 | if empty(l:node) | ||
418 | return | ||
419 | endif | ||
420 | |||
421 | call system('open ' . shellescape(l:node.path.str())) | ||
422 | endfunction | ||
423 | |||
424 | " FUNCTION: NERDTreeRevealFileLinux() {{{1 | ||
425 | function! NERDTreeRevealFileLinux() | ||
426 | let l:node = g:NERDTreeFileNode.GetSelected() | ||
427 | |||
428 | if empty(l:node) | ||
429 | return | ||
430 | endif | ||
431 | |||
432 | " Handle the edge case of "/", which has no parent. | ||
433 | if l:node.path.str() ==# '/' | ||
434 | call system('xdg-open /') | ||
435 | return | ||
436 | endif | ||
437 | |||
438 | if empty(l:node.parent) | ||
439 | return | ||
440 | endif | ||
441 | |||
442 | call system('xdg-open ' . shellescape(l:node.parent.path.str())) | ||
443 | endfunction | ||
444 | |||
445 | " FUNCTION: NERDTreeExecuteFileLinux() {{{1 | ||
446 | function! NERDTreeExecuteFileLinux() | ||
447 | let l:node = g:NERDTreeFileNode.GetSelected() | ||
448 | |||
449 | if empty(l:node) | ||
450 | return | ||
451 | endif | ||
452 | |||
453 | call system('xdg-open ' . shellescape(l:node.path.str())) | ||
454 | endfunction | ||
455 | |||
456 | " FUNCTION: NERDTreeExecuteFileWindows() {{{1 | ||
457 | function! NERDTreeExecuteFileWindows() | ||
458 | let l:node = g:NERDTreeFileNode.GetSelected() | ||
459 | |||
460 | if empty(l:node) | ||
461 | return | ||
462 | endif | ||
463 | |||
464 | call system('cmd.exe /c start "" ' . shellescape(l:node.path.str())) | ||
465 | endfunction | ||
466 | |||
467 | " FUNCTION: NERDTreeSystemCommand() {{{1 | ||
468 | function! NERDTreeSystemCommand() | ||
469 | let l:node = g:NERDTreeFileNode.GetSelected() | ||
470 | |||
471 | if empty(l:node) | ||
472 | return | ||
473 | endif | ||
474 | |||
475 | let l:cwd = getcwd() | ||
476 | let l:directory = l:node.path.isDirectory ? l:node.path.str() : l:node.parent.path.str() | ||
477 | execute 'cd '.l:directory | ||
478 | |||
479 | let l:nl = nr2char(10) | ||
480 | echo l:nl . system(input(l:directory . (nerdtree#runningWindows() ? '> ' : ' $ '))) | ||
481 | execute 'cd '.l:cwd | ||
482 | endfunction | ||
483 | |||
484 | " vim: set sw=4 sts=4 et fdm=marker: | ||
diff --git a/.vim/pack/vendor/start/nerdtree/nerdtree_plugin/vcs.vim b/.vim/pack/vendor/start/nerdtree/nerdtree_plugin/vcs.vim new file mode 100644 index 0000000..d20e35e --- /dev/null +++ b/.vim/pack/vendor/start/nerdtree/nerdtree_plugin/vcs.vim | |||
@@ -0,0 +1,47 @@ | |||
1 | " ============================================================================ | ||
2 | " File: vcs.vim | ||
3 | " Description: NERDTree plugin that provides a command to open on the root of | ||
4 | " a version control system repository. | ||
5 | " Maintainer: Phil Runninger | ||
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 | command! -n=? -complete=dir -bar NERDTreeVCS :call <SID>CreateTabTreeVCS('<args>') | ||
14 | command! -n=? -complete=dir -bar NERDTreeToggleVCS :call <SID>ToggleTabTreeVCS('<args>') | ||
15 | |||
16 | " FUNCTION: s:CreateTabTreeVCS(a:name) {{{1 | ||
17 | function! s:CreateTabTreeVCS(name) | ||
18 | let l:path = g:NERDTreeCreator._pathForString(a:name) | ||
19 | let l:path = s:FindParentVCSRoot(l:path) | ||
20 | call g:NERDTreeCreator.createTabTree(empty(l:path) ? '' : l:path._str()) | ||
21 | endfunction | ||
22 | |||
23 | " FUNCTION: s:ToggleTabTreeVCS(a:name) {{{1 | ||
24 | " Behaves the same as ToggleTabTree except roots directory at VCS root | ||
25 | function! s:ToggleTabTreeVCS(name) | ||
26 | let l:path = g:NERDTreeCreator._pathForString(a:name) | ||
27 | let l:path = s:FindParentVCSRoot(l:path) | ||
28 | call g:NERDTreeCreator.toggleTabTree(empty(l:path) ? '' : l:path._str()) | ||
29 | endfunction | ||
30 | |||
31 | " FUNCTION: s:FindParentVCSRoot(a:path) {{{1 | ||
32 | " Finds the root version control system folder of the given path. If a:path is | ||
33 | " not part of a repository, return the original path. | ||
34 | function! s:FindParentVCSRoot(path) | ||
35 | let l:path = a:path | ||
36 | while !empty(l:path) && | ||
37 | \ l:path._str() !~# '^\(\a:[\\\/]\|\/\)$' && | ||
38 | \ !isdirectory(l:path._str() . '/.git') && | ||
39 | \ !isdirectory(l:path._str() . '/.svn') && | ||
40 | \ !isdirectory(l:path._str() . '/.hg') && | ||
41 | \ !isdirectory(l:path._str() . '/.bzr') && | ||
42 | \ !isdirectory(l:path._str() . '/_darcs') | ||
43 | let l:path = l:path.getParent() | ||
44 | endwhile | ||
45 | return (empty(l:path) || l:path._str() =~# '^\(\a:[\\\/]\|\/\)$') ? a:path : l:path | ||
46 | endfunction | ||
47 | |||