Skip to content

Commit a888862

Browse files
committed
Add option to limit or disable default file extensions hilight
1 parent 856204f commit a888862

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

README.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,31 @@ let g:NERDTreeExactMatchHighlightColor = {} " this line is needed to avoid error
7070
let g:NERDTreeExactMatchHighlightColor['.gitignore'] = s:git_orange " sets the color for .gitignore files
7171
7272
let g:NERDTreePatternMatchHighlightColor = {} " this line is needed to avoid error
73-
let g:NERDTreePatternMatchHighlightColor['.*_spec\.rb$'] = s:rspec_red " sets the color files ending with _spec.rb
73+
let g:NERDTreePatternMatchHighlightColor['.*_spec\.rb$'] = s:rspec_red " sets the color for files ending with _spec.rb
7474
7575
```
7676

7777
* Disable Highlight for specific file extension
7878
```vim
79+
" If you have vim-devicons you can customize your icons for each file type.
7980
let g:NERDTreeExtensionHighlightColor = {} "this line is needed to avoid error
8081
let g:NERDTreeExtensionHighlightColor['css'] = '' "assigning it to an empty string will skip highlight
8182
```
8283

83-
Obs: If you have [vim-devicons](https://github.com/ryanoasis/vim-devicons) and you want to customize icons you can customize your icons for each file type.
84+
85+
86+
* Disable uncommon file extensions highlighting (this is a good idea if you are experiencing lag when scrolling)
87+
```vim
88+
let g:NERDTreeLimitedSyntax = 1
89+
```
90+
* Disable all default file extensions highlighting (you can use this to easily customize which extensions you want to highlight)
91+
```vim
92+
let g:NERDTreeSyntaxDisableDefaultExtensions = 1
93+
```
94+
* Customize which file extensions are enabled (you only need this if you set `g:NERDTreeLimitedSyntax` or `g:NERDTreeSyntaxDisableDefaultExtensions`)
95+
```vim
96+
" set g:NERDTreeExtensionHighlightColor if you want a custom color instead of the default one
97+
let g:NERDTreeSyntaxEnabledExtensions = ['hbs', 'lhs'] " enable highlight to .hbs and .lhs files with default colors
98+
```
8499
### generate_files.sh script
85100
There is a script folder called generate_files.sh that will generate all the files supported by this plugin by default for a quick review. These files will be generated on a 'files' subfolder.

after/syntax/nerdtree.vim

+14-8
Original file line numberDiff line numberDiff line change
@@ -341,28 +341,30 @@ let s:file_node_pattern_matches = {
341341
\}
342342

343343
let s:enabled_extensions = [
344-
\ 'bat',
345344
\ 'bmp',
346345
\ 'c',
347-
\ 'c',
348346
\ 'coffee',
349347
\ 'cpp',
350348
\ 'css',
351349
\ 'erb',
352350
\ 'go',
351+
\ 'hs',
353352
\ 'html',
354353
\ 'java',
355354
\ 'jpg',
356355
\ 'js',
357356
\ 'json',
358357
\ 'jsx',
358+
\ 'less',
359359
\ 'lua',
360360
\ 'markdown',
361361
\ 'md',
362362
\ 'php',
363363
\ 'png',
364+
\ 'pl',
364365
\ 'py',
365366
\ 'rb',
367+
\ 'rs',
366368
\ 'scala',
367369
\ 'scss',
368370
\ 'sh',
@@ -374,9 +376,11 @@ if !exists('g:NERDTreeSyntaxEnabledExtensions')
374376
let g:NERDTreeSyntaxEnabledExtensions = []
375377
endif
376378

377-
for extension in s:enabled_extensions
378-
call add(g:NERDTreeSyntaxEnabledExtensions, extension)
379-
endfor
379+
if exists('g:NERDTreeLimitedSyntax') && !exists('g:NERDTreeSyntaxDisableDefaultExtensions')
380+
for extension in s:enabled_extensions
381+
call add(g:NERDTreeSyntaxEnabledExtensions, extension)
382+
endfor
383+
endif
380384

381385
let s:characters = '[a-zA-Z0-9_\#\-\+\*\%\!\~\(\)\{\}\&\.\$\@]'
382386

@@ -387,13 +391,15 @@ if !exists('g:NERDTreeExtensionHighlightColor')
387391
endif
388392

389393
for [key, val] in items(s:file_extension_colors)
390-
if !has_key(g:NERDTreeExtensionHighlightColor , key) &&
391-
\ (!exists('g:NERDTreeLimitedSyntax') ||
392-
\ index(g:NERDTreeSyntaxEnabledExtensions, key) >= 0)
394+
if ((exists('g:NERDTreeLimitedSyntax') ||
395+
\ exists('g:NERDTreeSyntaxDisableDefaultExtensions')) ?
396+
\ index(g:NERDTreeSyntaxEnabledExtensions, key) >= 0 :
397+
\ !has_key(g:NERDTreeExtensionHighlightColor, key))
393398
let g:NERDTreeExtensionHighlightColor[key] = val
394399
endif
395400
endfor
396401

402+
397403
for [key, val] in items(g:NERDTreeExtensionHighlightColor)
398404
let label_identifier = 'nerdtreeFileExtensionLabel_'.key
399405
let icon_identifier = 'nerdtreeFileExtensionIcon_'.key

0 commit comments

Comments
 (0)