summaryrefslogtreecommitdiff
path: root/.vim/pack/vendor/start/vim-devicons/nerdtree_plugin
diff options
context:
space:
mode:
Diffstat (limited to '.vim/pack/vendor/start/vim-devicons/nerdtree_plugin')
-rw-r--r--.vim/pack/vendor/start/vim-devicons/nerdtree_plugin/webdevicons.vim389
1 files changed, 389 insertions, 0 deletions
diff --git a/.vim/pack/vendor/start/vim-devicons/nerdtree_plugin/webdevicons.vim b/.vim/pack/vendor/start/vim-devicons/nerdtree_plugin/webdevicons.vim
new file mode 100644
index 0000000..7c1f9f7
--- /dev/null
+++ b/.vim/pack/vendor/start/vim-devicons/nerdtree_plugin/webdevicons.vim
@@ -0,0 +1,389 @@
1" Version: 0.11.0
2" Webpage: https://github.com/ryanoasis/vim-devicons
3" Maintainer: Ryan McIntyre <ryanoasis@gmail.com>
4" License: see LICENSE
5
6" @todo fix duplicate global variable initialize here:
7if !exists('g:webdevicons_enable')
8 let g:webdevicons_enable = 1
9endif
10
11if !exists('g:webdevicons_enable_nerdtree')
12 let g:webdevicons_enable_nerdtree = 1
13endif
14
15if !exists('g:DevIconsEnableFoldersOpenClose')
16 let g:DevIconsEnableFoldersOpenClose = 0
17endif
18
19if !exists('g:DevIconsEnableFolderPatternMatching')
20 let g:DevIconsEnableFolderPatternMatching = 1
21endif
22
23if !exists('g:DevIconsEnableFolderExtensionPatternMatching')
24 let g:DevIconsEnableFolderExtensionPatternMatching = 0
25endif
26
27" end @todo duplicate global variables
28
29" Temporary (hopefully) fix for glyph issues in gvim (proper fix is with the
30" actual font patcher)
31if !exists('g:webdevicons_gui_glyph_fix')
32 if has('gui_running')
33 let g:webdevicons_gui_glyph_fix = 1
34 else
35 let g:webdevicons_gui_glyph_fix = 0
36 endif
37endif
38
39if !exists('g:DevIconsEnableNERDTreeRedraw')
40 if has('gui_running')
41 let g:DevIconsEnableNERDTreeRedraw = 1
42 else
43 let g:DevIconsEnableNERDTreeRedraw = 0
44 endif
45endif
46
47if g:webdevicons_enable_nerdtree == 1
48 if !exists('g:loaded_nerd_tree')
49 echohl WarningMsg |
50 \ echomsg 'vim-webdevicons requires NERDTree to be loaded before vim-webdevicons.'
51 endif
52
53 if exists('g:loaded_nerd_tree') && g:loaded_nerd_tree == 1 && !exists('g:NERDTreePathNotifier')
54 let g:webdevicons_enable_nerdtree = 0
55 echohl WarningMsg |
56 \ echomsg 'vim-webdevicons requires a newer version of NERDTree to show glyphs in NERDTree - consider updating NERDTree.'
57 endif
58
59 " @todo I don't even want this to execute UNLESS the user has the
60 " 'nerdtree-git-plugin' INSTALLED (not LOADED)
61 " As it currently functions this warning will display even if the user does
62 " not have nerdtree-git-plugin not just if it isn't loaded yet
63 " (not what we want)
64 "if !exists('g:loaded_nerdtree_git_status')
65 " echohl WarningMsg |
66 " \ echomsg 'vim-webdevicons works better when 'nerdtree-git-plugin' is loaded before vim-webdevicons (small refresh issues otherwise).'
67 "endif
68endif
69
70if !exists('g:webdevicons_enable_airline_tabline')
71 let g:webdevicons_enable_airline_tabline = 1
72endif
73
74if !exists('g:webdevicons_enable_airline_statusline')
75 let g:webdevicons_enable_airline_statusline = 1
76endif
77
78function! s:SetupListeners()
79 call g:NERDTreePathNotifier.AddListener('init', 'NERDTreeWebDevIconsRefreshListener')
80 call g:NERDTreePathNotifier.AddListener('refresh', 'NERDTreeWebDevIconsRefreshListener')
81 call g:NERDTreePathNotifier.AddListener('refreshFlags', 'NERDTreeWebDevIconsRefreshListener')
82endfunction
83
84" util like helpers
85" scope: local
86function! s:Refresh()
87 call b:NERDTree.root.refreshFlags()
88 call NERDTreeRender()
89endfunction
90
91" Temporary (hopefully) fix for glyph issues in gvim (proper fix is with the
92" actual font patcher)
93
94" NERDTree-C
95" scope: global
96function! WebDevIconsNERDTreeChangeRootHandler(node)
97 call b:NERDTree.changeRoot(a:node)
98 call NERDTreeRender()
99 call a:node.putCursorHere(0, 0)
100 if g:DevIconsEnableNERDTreeRedraw ==# 1
101 redraw!
102 endif
103endfunction
104
105" NERDTree-u
106" scope: global
107function! WebDevIconsNERDTreeUpDirCurrentRootClosedHandler()
108 call nerdtree#ui_glue#upDir(0)
109 if g:DevIconsEnableNERDTreeRedraw ==# 1
110 redraw!
111 endif
112endfunction
113
114function! WebDevIconsNERDTreeDirUpdateFlags(node, glyph)
115 let path = a:node.path
116 let isOpen = a:node.isOpen
117 let postPadding = g:WebDevIconsNerdTreeAfterGlyphPadding
118 let prePadding = g:WebDevIconsNerdTreeBeforeGlyphPadding
119 let hasGitFlags = (len(path.flagSet._flagsForScope('git')) > 0)
120 let hasGitNerdTreePlugin = (exists('g:loaded_nerdtree_git_status') == 1)
121 let collapsesToSameLine = (exists('g:NERDTreeCascadeSingleChildDir') == 1)
122 let dirHasOnlyOneChildDir = 0
123
124 if collapsesToSameLine
125 " need to call to determin children:
126 call a:node._initChildren(1)
127 let dirHasOnlyOneChildDir = (a:node.getChildCount() ==# 1 && a:node.children[0].path.isDirectory)
128 endif
129
130 " properly set collapsed/combined directory display to opened glyph
131 if collapsesToSameLine && dirHasOnlyOneChildDir
132 call WebDevIconsNERDTreeDirOpen(a:node.children[0])
133 endif
134
135 " align vertically at the same level: non git-flag nodes with git-flag nodes
136 if g:WebDevIconsNerdTreeGitPluginForceVAlign && !hasGitFlags && hasGitNerdTreePlugin
137 let prePadding .= ' '
138 endif
139
140 let flag = prePadding . a:glyph . postPadding
141
142 call a:node.path.flagSet.clearFlags('webdevicons')
143
144 if flag !=? ''
145 call a:node.path.flagSet.addFlag('webdevicons', flag)
146 "echom "added flag of " . flag
147 call a:node.path.refreshFlags(b:NERDTree)
148 "echom "flagset is now " . string(a:node.path.flagSet)
149 endif
150endfunction
151
152function! WebDevIconsNERDTreeDirClose(node)
153 let a:node.path.isOpen = 0
154 let glyph = g:WebDevIconsUnicodeDecorateFolderNodesDefaultSymbol
155 call WebDevIconsNERDTreeDirUpdateFlags(a:node, glyph)
156endfunction
157
158function! WebDevIconsNERDTreeDirOpen(node)
159 let a:node.path.isOpen = 1
160 let glyph = g:DevIconsDefaultFolderOpenSymbol
161 call WebDevIconsNERDTreeDirUpdateFlags(a:node, glyph)
162endfunction
163
164function! WebDevIconsNERDTreeDirOpenRecursively(node)
165 call WebDevIconsNERDTreeDirOpen(a:node)
166 for i in a:node.children
167 if i.path.isDirectory ==# 1
168 call WebDevIconsNERDTreeDirOpenRecursively(i)
169 endif
170 endfor
171endfunction
172
173function! WebDevIconsNERDTreeDirCloseRecursively(node)
174 call WebDevIconsNERDTreeDirClose(a:node)
175 for i in a:node.children
176 if i.path.isDirectory ==# 1
177 call WebDevIconsNERDTreeDirCloseRecursively(i)
178 endif
179 endfor
180endfunction
181
182function! WebDevIconsNERDTreeDirCloseChildren(node)
183 for i in a:node.children
184 if i.path.isDirectory ==# 1
185 call WebDevIconsNERDTreeDirClose(i)
186 endif
187 endfor
188endfunction
189
190" NERDTreeMapActivateNode and <2-LeftMouse>
191" handle the user activating a tree node
192" scope: global
193function! WebDevIconsNERDTreeMapActivateNode(node)
194 let isOpen = a:node.isOpen
195 if isOpen
196 let glyph = g:WebDevIconsUnicodeDecorateFolderNodesDefaultSymbol
197 else
198 let glyph = g:DevIconsDefaultFolderOpenSymbol
199 endif
200 let a:node.path.isOpen = !isOpen
201 call WebDevIconsNERDTreeDirUpdateFlags(a:node, glyph)
202 " continue with normal activate logic
203 call a:node.activate()
204 " glyph change possible artifact clean-up
205 if g:DevIconsEnableNERDTreeRedraw ==# 1
206 redraw!
207 endif
208endfunction
209
210" NERDTreeMapActivateNodeSingleMode
211" handle the user activating a tree node if NERDTreeMouseMode is setted to 3
212" scope: global
213function! WebDevIconsNERDTreeMapActivateNodeSingleMode(node)
214 if g:NERDTreeMouseMode == 3
215 let isOpen = a:node.isOpen
216 if isOpen
217 let glyph = g:WebDevIconsUnicodeDecorateFolderNodesDefaultSymbol
218 else
219 let glyph = g:DevIconsDefaultFolderOpenSymbol
220 endif
221 let a:node.path.isOpen = !isOpen
222 call WebDevIconsNERDTreeDirUpdateFlags(a:node, glyph)
223 " continue with normal activate logic
224 call a:node.activate()
225 " glyph change possible artifact clean-up
226 if g:DevIconsEnableNERDTreeRedraw ==# 1
227 redraw!
228 endif
229 endif
230endfunction
231
232function! WebDevIconsNERDTreeMapOpenRecursively(node)
233 " normal original logic:
234 call nerdtree#echo('Recursively opening node. Please wait...')
235 call WebDevIconsNERDTreeDirOpenRecursively(a:node)
236 call a:node.openRecursively()
237 " continue with normal original logic:
238 call b:NERDTree.render()
239 " glyph change possible artifact clean-up
240 if g:DevIconsEnableNERDTreeRedraw ==# 1
241 redraw!
242 endif
243 call nerdtree#echo('Recursively opening node. Please wait... DONE')
244endfunction
245
246function! WebDevIconsNERDTreeMapCloseChildren(node)
247 " close children but not current node:
248 call WebDevIconsNERDTreeDirCloseChildren(a:node)
249 " continue with normal original logic:
250 call a:node.closeChildren()
251 call b:NERDTree.render()
252 call a:node.putCursorHere(0, 0)
253 " glyph change possible artifact clean-up
254 if g:DevIconsEnableNERDTreeRedraw ==# 1
255 redraw!
256 endif
257endfunction
258
259function! WebDevIconsNERDTreeMapCloseDir(node)
260 " continue with normal original logic:
261 let parent = a:node.parent
262 while g:NERDTreeCascadeOpenSingleChildDir && !parent.isRoot()
263 let childNodes = parent.getVisibleChildren()
264 if len(childNodes) == 1 && childNodes[0].path.isDirectory
265 let parent = parent.parent
266 else
267 break
268 endif
269 endwhile
270 if parent ==# {} || parent.isRoot()
271 call nerdtree#echo('cannot close tree root')
272 else
273 call parent.close()
274 " update the glyph
275 call WebDevIconsNERDTreeDirClose(parent)
276 call b:NERDTree.render()
277 call parent.putCursorHere(0, 0)
278 " glyph change possible artifact clean-up
279 if g:DevIconsEnableNERDTreeRedraw ==# 1
280 redraw!
281 endif
282 endif
283endfunction
284
285function! WebDevIconsNERDTreeMapUpdirKeepOpen()
286 call WebDevIconsNERDTreeDirOpen(b:NERDTree.root)
287 " continue with normal logic:
288 call nerdtree#ui_glue#upDir(1)
289 call s:Refresh()
290 " glyph change possible artifact clean-up
291 if g:DevIconsEnableNERDTreeRedraw ==# 1
292 redraw!
293 endif
294endfunction
295
296if g:webdevicons_enable == 1 && g:webdevicons_enable_nerdtree == 1
297 call s:SetupListeners()
298
299 if g:DevIconsEnableFoldersOpenClose
300
301 " These overrides are needed because we cannot
302 " simply use AddListener for reliably updating
303 " the folder open/close glyphs because the event
304 " path has no access to the 'isOpen' property
305 " some of these are a little more brittle/fragile
306 " than others
307 " TODO FIXME better way to reliably update
308 " open/close glyphs in NERDTreeWebDevIconsRefreshListener
309
310 " NERDTreeMapActivateNode
311 call NERDTreeAddKeyMap({
312 \ 'key': g:NERDTreeMapActivateNode,
313 \ 'callback': 'WebDevIconsNERDTreeMapActivateNode',
314 \ 'override': 1,
315 \ 'scope': 'DirNode' })
316
317 " NERDTreeMapCustomOpen
318 call NERDTreeAddKeyMap({
319 \ 'key': g:NERDTreeMapCustomOpen,
320 \ 'callback': 'WebDevIconsNERDTreeMapActivateNode',
321 \ 'override': 1,
322 \ 'scope': 'DirNode' })
323
324 " NERDTreeMapOpenRecursively
325 call NERDTreeAddKeyMap({
326 \ 'key': g:NERDTreeMapOpenRecursively,
327 \ 'callback': 'WebDevIconsNERDTreeMapOpenRecursively',
328 \ 'override': 1,
329 \ 'scope': 'DirNode' })
330
331 " NERDTreeMapCloseChildren
332 call NERDTreeAddKeyMap({
333 \ 'key': g:NERDTreeMapCloseChildren,
334 \ 'callback': 'WebDevIconsNERDTreeMapCloseChildren',
335 \ 'override': 1,
336 \ 'scope': 'DirNode' })
337
338 " NERDTreeMapCloseChildren
339 call NERDTreeAddKeyMap({
340 \ 'key': g:NERDTreeMapCloseDir,
341 \ 'callback': 'WebDevIconsNERDTreeMapCloseDir',
342 \ 'override': 1,
343 \ 'scope': 'Node' })
344
345 " <2-LeftMouse>
346 call NERDTreeAddKeyMap({
347 \ 'key': '<2-LeftMouse>',
348 \ 'callback': 'WebDevIconsNERDTreeMapActivateNode',
349 \ 'override': 1,
350 \ 'scope': 'DirNode' })
351
352 " <LeftRelease>
353 call NERDTreeAddKeyMap({
354 \ 'key': '<LeftRelease>',
355 \ 'callback': 'WebDevIconsNERDTreeMapActivateNodeSingleMode',
356 \ 'override': 1,
357 \ 'scope': 'DirNode' })
358
359 " NERDTreeMapUpdirKeepOpen
360 call NERDTreeAddKeyMap({
361 \ 'key': g:NERDTreeMapUpdirKeepOpen,
362 \ 'callback': 'WebDevIconsNERDTreeMapUpdirKeepOpen',
363 \ 'override': 1,
364 \ 'scope': 'all' })
365
366 endif
367
368 " Temporary (hopefully) fix for glyph issues in gvim (proper fix is with the
369 " actual font patcher)
370 if g:webdevicons_gui_glyph_fix ==# 1
371 call NERDTreeAddKeyMap({
372 \ 'key': g:NERDTreeMapChangeRoot,
373 \ 'callback': 'WebDevIconsNERDTreeChangeRootHandler',
374 \ 'override': 1,
375 \ 'quickhelpText': "change tree root to the\n\" selected dir\n\" plus devicons redraw\n\" hack fix",
376 \ 'scope': 'Node' })
377
378 call NERDTreeAddKeyMap({
379 \ 'key': g:NERDTreeMapUpdir,
380 \ 'callback': 'WebDevIconsNERDTreeUpDirCurrentRootClosedHandler',
381 \ 'override': 1,
382 \ 'quickhelpText': "move tree root up a dir\n\" plus devicons redraw\n\" hack fix",
383 \ 'scope': 'all' })
384 endif
385
386endif
387
388" modeline syntax:
389" vim: fdm=marker tabstop=2 softtabstop=2 shiftwidth=2 expandtab: