Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration for multiple highlighting based on file type. #433

Closed
AnthonyBobsin opened this issue Apr 11, 2015 · 17 comments
Closed

Comments

@AnthonyBobsin
Copy link

Similar to the red highlighting on read-only files, it would be nice if you could configure a different colour highlighting based of the file type & extension. If anyone has found a way to do this manually I'd love to hear how.

@ryanoasis
Copy link

I have been using this for a while now:

" NERDTress File highlighting
function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg)
 exec 'autocmd filetype nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg
 exec 'autocmd filetype nerdtree syn match ' . a:extension .' #^\s\ .*'. a:extension .'$#'
endfunction

call NERDTreeHighlightFile('jade', 'green', 'none', 'green', '#151515')
call NERDTreeHighlightFile('ini', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('md', 'blue', 'none', '#3366FF', '#151515')
call NERDTreeHighlightFile('yml', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('config', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('conf', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('json', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('html', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('styl', 'cyan', 'none', 'cyan', '#151515')
call NERDTreeHighlightFile('css', 'cyan', 'none', 'cyan', '#151515')
call NERDTreeHighlightFile('coffee', 'Red', 'none', 'red', '#151515')
call NERDTreeHighlightFile('js', 'Red', 'none', '#ffa500', '#151515')
call NERDTreeHighlightFile('php', 'Magenta', 'none', '#ff00ff', '#151515')

added on orignally from: #201 (comment)

@AnthonyBobsin
Copy link
Author

Thanks, this looks like exactly what I needed. I should be putting this anywhere in ~/.vim/syntax/nerdtree.vim right?

@ryanoasis
Copy link

Mine is just in my vimrc

@AnthonyBobsin
Copy link
Author

Thanks again, this seems to be working. Are you using console vim or gvim? For some reason the colours aren't corresponding with what I am setting.

@adrian-martinez-dev
Copy link

Help, i'm getting this

Se ha detectado un error al procesar function NERDTreeHighlightFile:
línea    1
E216: No existe tal evento: nerdtree highlight jade ctermbg=none ctermfg=green guibg=#151515 guifg=green
línea    2
E216: No existe tal evento: nerdtree syn match jade #^\s\ .*jade$#
línea    1
E216: No existe tal evento: nerdtree highlight ini ctermbg=none ctermfg=yellow guibg=#151515 guifg=yellow
línea    2
E216: No existe tal evento: nerdtree syn match ini #^\s\ .*ini$#
línea    1
E216: No existe tal evento: nerdtree highlight md ctermbg=none ctermfg=blue guibg=#151515 guifg=blue
línea    2
E216: No existe tal evento: nerdtree syn match md #^\s\ .*md$#
línea    1
E216: No existe tal evento: nerdtree highlight yml ctermbg=none ctermfg=yellow guibg=#151515 guifg=yellow
línea    2
E216: No existe tal evento: nerdtree syn match yml #^\s\ .*yml$#
línea    1
E216: No existe tal evento: nerdtree highlight config ctermbg=none ctermfg=yellow guibg=#151515 guifg=yellow
línea    2
E216: No existe tal evento: nerdtree syn match config #^\s\ .*config$#
línea    1
E216: No existe tal evento: nerdtree highlight conf ctermbg=none ctermfg=yellow guibg=#151515 guifg=yellow
línea    2
E216: No existe tal evento: nerdtree syn match conf #^\s\ .*conf$#
línea    1
E216: No existe tal evento: nerdtree highlight json ctermbg=none ctermfg=yellow guibg=#151515 guifg=yellow
línea    2
E216: No existe tal evento: nerdtree syn match json #^\s\ .*json$#
línea    1
E216: No existe tal evento: nerdtree highlight html ctermbg=none ctermfg=yellow guibg=#151515 guifg=yellow
línea    2
E216: No existe tal evento: nerdtree syn match html #^\s\ .*html$#
línea    1
E216: No existe tal evento: nerdtree highlight styl ctermbg=none ctermfg=cyan guibg=#151515 guifg=cyan
línea    2
E216: No existe tal evento: nerdtree syn match styl #^\s\ .*styl$#
línea    1
E216: No existe tal evento: nerdtree highlight css ctermbg=none ctermfg=cyan guibg=#151515 guifg=cyan
línea    2
E216: No existe tal evento: nerdtree syn match css #^\s\ .*css$#
línea    1
E216: No existe tal evento: nerdtree highlight coffee ctermbg=none ctermfg=Red guibg=#151515 guifg=red
línea    2
E216: No existe tal evento: nerdtree syn match coffee #^\s\ .*coffee$#
línea    1
E216: No existe tal evento: nerdtree highlight js ctermbg=none ctermfg=Red guibg=#151515 guifg=#ffa500
línea    2
E216: No existe tal evento: nerdtree syn match js #^\s\ .*js$#
línea    1
E216: No existe tal evento: nerdtree highlight php ctermbg=none ctermfg=Magenta guibg=#151515 guifg=#ff00ff
línea    2
E216: No existe tal evento: nerdtree syn match php #^\s\ .*php$#
línea    1
E216: No existe tal evento: nerdtree highlight py ctermbg=none ctermfg=green guibg=#151515 guifg=green
línea    2
E216: No existe tal evento: nerdtree syn match py #^\s\ .*py$#

It means: event doesn't exist

@AnthonyBobsin
Copy link
Author

Did you make sure to include the function NERDTreeHighlightFile(extension, fg, bg, guifg, guibg) that ryanoasis posted as well?

@adrian-martinez-dev
Copy link

Yes, i did

@adrian-martinez-dev
Copy link

Ok, i fixed it replacing filetype with FileType, and it's working now :)

@tomprats
Copy link

This is pretty great, but is it possible to change the color for folders?

@tnguyen14
Copy link

@ryanoasis your script works great to change the color of files, but for the case of executable files, the script does not change the color of those. Is there any way to get around that?

@tiagofumo
Copy link

I made this if anyone cares: https://github.com/tiagofumo/vim-nerdtree-syntax-highlight

@marzzz21
Copy link

marzzz21 commented Nov 8, 2016

@tiagofumo is there anyway I can install that with Vundle?

@tiagofumo
Copy link

@marzzz21 I suppose, yeah. I never used vundle but what I made is like a common extension, so it should work. You will need vim-devicons and nerdfonts for the icons. Checkout the description on repo page.

@seaflygithub
Copy link

Thank U! It's useful for me!

@Sonic0
Copy link

Sonic0 commented Jun 7, 2018

Thanks! Works with Vim 8.1

@tzmf
Copy link

tzmf commented Jun 1, 2019

Thx a lot! It is really helpful.

@PhilRunninger PhilRunninger pinned this issue Sep 11, 2019
@PhilRunninger PhilRunninger unpinned this issue Sep 11, 2019
@rpdelaney
Copy link

Parsing LS_COLORS would be the dream but my vimscript is nowhere near that level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests