2

I want to highlight special regions in a special extension .html.specialext, the regions are Lua code in some delimiter, here it's {{ and }}.

Detecting custom filetypes is trivial but here is my code in .vim/syntax/specialext.vim:

if exists("b:current_syntax")
    finish
endif

syn clear
set syntax=html
unlet b:current_syntax
syntax include @Lua syntax/lua.vim
syntax region srclua start="{{" end="}}" contains=@Lua

Here is what it does:
region highlighting with my code

The HTML works, but the snippets are broken.

Here is the stock Vim Lua highlighting:
stock vim lua highlighting

This is not due to spell checking as :set spell and set nospell have no effect

5
  • If I had to guess, I'd say the red backgrounds behind then and end are caused by spellchecking still being active. See :help :syn-spell. Doesn't account for the if, though. Commented Jul 29 at 20:36
  • 1
    After playing with :set nospell and :set spell I determined that this is not due to spellchecking (thanks btw @Friedrich) Commented Jul 29 at 20:47
  • I guessed wrong... it happens :-) You should probably edit that information into your question. Commented Jul 29 at 20:56
  • I don't see those red highlights. Could you test with $ vim --clean? Commented Jul 30 at 5:37
  • I tried on an alpine vm and it highlights correctly, my vim installation is supposed to be fresh and when I run vim --clean it does not highlight the format, then I :so .vim/syntax/specialext.vim it comes also wrong (even when I copy paste the content) @romainl Commented Jul 30 at 10:37

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.