Update I've managed to get the top part of the file fixed with syn region pugJavascriptLine start=/^\s*-/ end=/$/ contains=@htmlJavascript from this programmer: https://github.com/digitaltoad/vim-pug/issues/98#issuecomment-296461439

But the template strings still don't recognize their contents as JavaScript:

enter image description here

Perhaps there's another line I could add to the pug syntax file that would let it know how template strings work. The file is here: https://github.com/digitaltoad/vim-pug/blob/master/syntax/pug.vim

Anyone with better Regex skills than me out there?

Update end

I'm using neovim for lots of web dev, and I'm having trouble with pug syntax highlighting.

I can't seem to get it to display JavaScript in the pug files (which it was doing just fine before I switched to a new Thinkpad).

enter image description here

The JS is just in plain white text. Here's my vimrc: https://gist.github.com/wamoyo/34405c4672c89dbfded62ea34134003b

And I haven't edited the pug.vim file or anything like that. But I have messed around a bit with the xoria256.vim colorscheme file, adding this to the bottom:

" hi jsBooleanTrue ctermfg=41
" hi jsBooleanFalse ctermfg=174
" hi jsString ctermfg=229
" hi jsComment ctermfg=244
hi jsGlobalObjects ctermfg=256
hi jsGlobalNodeObjects ctermfg=256
" hi jsExceptions ctermfg=256
" hi jsThis ctermfg=256
" hi jsPrototype ctermfg=256
" hi jsHtmlEvents ctermfg=256
" hi jsDecorator ctermfg=146
" hi jsSpecial ctermfg=180
" hi jsFloat ctermfg=180
" hi jsNan ctermfg=180
" hi jsTemplateVar ctermfg=251
" hi jsTemplateBraces ctermfg=146
" hi jsDecoratorFunction ctermfg=182
" hi jsRegexpString ctermfg=180
" hi jsRegexpBoundary ctermfg=180
" hi jsRegexpQuantifier ctermfg=180
" hi jsRegexpOr ctermfg=180
" hi jsRegexpMod ctermfg=180
" hi jsRegexpBackRef ctermfg=180
" hi jsRegexpGroup ctermfg=180
" hi jsRegexpCharClass ctermfg=180

On the old laptop, I didn't have any of those commented out, but the new laptop seems to support more colors in the gnome terminal.

This line from pug.vim seems relevant:

syn region pugJavascript matchgroup=pugJavascriptChar start="-" skip=",\s*$" end="$" contained contains=@htmlJavascript keepend

Lines 6-16 above are using the syntax group pugTagInlineText.

Actually, I know it's not those edits in the xoria256.vim file, because I have the same issue with other colorschemes.

I'm also happy to switch colorschemes if there's one that handles html5, css, and ES6 really nicely.

  • Can you check the syntax highlighting groups in the lines you think are being incorrectly highlighted? (There are various tips for doing this across the web; my plugin synstax can also do it.)
    – D. Ben Knoble
    Nov 10, 2018 at 6:34
  • Hm.. trying. They are lines 6 to 16 above. Nov 10, 2018 at 8:22
  • I tried making changes to pug.vim, but no changes take effect, even after restarting vim. If I can't make changes, maybe something set up wrong? Nov 10, 2018 at 8:38
  • 1
    That does seem odd, but what will be most telling is still the highlight groups being applied to text in those lines.
    – D. Ben Knoble
    Nov 10, 2018 at 17:05
  • It's ['PugBegin'], problem is that's the same for every line I've checked. Nov 10, 2018 at 19:11

1 Answer 1


Issue is solved. It took a couple lines in the pug syntax file.

Adding the third line here for template strings:

syn region  pugJavascriptString start=+"+  skip=+\\\("\|$\)+  end=+"\|$+ contained
syn region  pugJavascriptString start=+'+  skip=+\\\('\|$\)+  end=+'\|$+ contained
" TODO my patch for template strings
syn region  pugJavascriptString start=+`+  skip=+\\\(`\|$\)+  end=+`\|$+ contained

And the single line for single lines of JS: syn region pugJavascriptLine start=/^\s*-/ end=/$/ contains=@htmlJavascript

Github issues here: https://github.com/digitaltoad/vim-pug/issues/109 and here: https://github.com/digitaltoad/vim-pug/issues/108

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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