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 · 15 comments

Comments

Projects
None yet
9 participants
@AnthonyBobsin
Copy link

AnthonyBobsin commented Apr 11, 2015

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

This comment has been minimized.

Copy link

ryanoasis commented Apr 14, 2015

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

This comment has been minimized.

Copy link

AnthonyBobsin commented Apr 14, 2015

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

@ryanoasis

This comment has been minimized.

Copy link

ryanoasis commented Apr 14, 2015

Mine is just in my vimrc

@AnthonyBobsin

This comment has been minimized.

Copy link

AnthonyBobsin commented Apr 14, 2015

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.

@nbicalcarata

This comment has been minimized.

Copy link

nbicalcarata commented Apr 16, 2015

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

This comment has been minimized.

Copy link

AnthonyBobsin commented Apr 16, 2015

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

@nbicalcarata

This comment has been minimized.

Copy link

nbicalcarata commented Apr 16, 2015

Yes, i did

@nbicalcarata

This comment has been minimized.

Copy link

nbicalcarata commented May 11, 2015

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

@tomprats

This comment has been minimized.

Copy link

tomprats commented Mar 23, 2016

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

@tnguyen14

This comment has been minimized.

Copy link

tnguyen14 commented May 25, 2016

@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

This comment has been minimized.

Copy link

tiagofumo commented Jun 14, 2016

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

@marzzz21

This comment has been minimized.

Copy link

marzzz21 commented Nov 8, 2016

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

@tiagofumo

This comment has been minimized.

Copy link

tiagofumo commented Nov 8, 2016

@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

This comment has been minimized.

Copy link

SeaflyGithub commented Nov 15, 2017

Thank U! It's useful for me!

@Sonic0

This comment has been minimized.

Copy link

Sonic0 commented Jun 7, 2018

Thanks! Works with Vim 8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment