0

Right now I am working on a latex project. When I open a netrw/vinegar window, I get following coloring:

enter image description here

Apparently, certain filetypes are grayed out and other are not. I like the idea to emphasize files which are user input files and those which are generated/binary types.

Netrw has following boolean variable g:netrw_special_syntax. It enables highlighting for certain group of filetypes. Details can be found in $VIMRUNTIME/syntax/netrw.vim.

However, following file extensions are not specified in $VIMRUNTIME/syntax/netrw.vim, but are still grayed out in my screenshot: .fdb_latexmk, .log, .aux, .fls, .out, .toc.

What has to be done to gray out, e.g. the special files of the minitoc package?

1

I think the g:netrw_special_syntax specify wether you want the special highlight or not, you should not be able to change the files types.

You can add you own syntax to your .vimrc if you want:

syn match netrwMiniTOC \(\S\+ \)*\S\+\.minitoc\>" contains=netrwTreeBar,@NoSpell
  • Thanks for your answer. But I was actual searching for an answer showing the same way as done for .fdb_latexmk, .log, .aux, .fls, .out, .toc. I can't find them in the syntax file $VIMRUNTIME/syntax/netrw.vim. – Hotschke Jun 23 '16 at 13:48
  • 1
    I see, you seems to have plugins, can this support be provided by the plugins you use? – nobe4 Jun 23 '16 at 13:50
  • I use vimtex and other unrelated plugins. A grep netrw in the plugin folder does not bring up a single match which defines syntax highlighting for netrw files. Can't you reproduce the problem? A simple touch doc.tex doc.aux doc.maf should set you up. – Hotschke Jun 23 '16 at 13:54
  • Nop, all files are highlighted the same way – nobe4 Jun 23 '16 at 13:57
  • 1
    Sorry, I was to quickly scannig the grep netrw results. I found the plugin: it is tpope/vim-vinegar. Thank you very much for your help. – Hotschke Jun 23 '16 at 14:03
0

With the help of nobe4 I figured it out. The plugin vinegar by tpope adds netrwSuffixes to SpecialKey.

  exe 'syn match netrwSuffixes =\%(\S\+ \)*\S\+\%('.join(map(split(&suffixes, ','), s:escape), '\|') . '\)[*@]\=\S\@!='
  hi def link netrwSuffixes SpecialKey

So I have to extend the definition of 'suffixes' for the latex package minitoc generated files to gray them out as it happens for other generated files by latex.

To change the coloring shown in the screenshot, add following to ~/.vim/after/ftplugin/tex.vim

setlocal suffixes+=.maf
setlocal suffixes+=.mtc
setlocal suffixes+=.mtc0
setlocal suffixes+=.mtc1
setlocal suffixes+=.mtc2
setlocal suffixes+=.ptc
setlocal suffixes+=.stc1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.