kaarmu / typst.vim

Vim plugin for Typst
MIT License
279 stars 24 forks source link

Show-set rules lose highlighting with `where` specifications #100

Open thornoar opened 2 months ago

thornoar commented 2 months ago

Consider the following show-set rule:

#show heading.where(level: 2): set text(stroke: red)

Here, the text becomes white after the second colon. In fact, it seems that the problem is the symbols between the first colon and the set keyword. If these symbols exist, the highlighting is lost. However, such show-set rules start being correctly highlighted if the unnamed function notation (=>) is used, like that:

#show heading.where(level: 2): it => {
  // something
}

Unfortunately, this does not seem to be a reliable workaround. In some cases, a show-set rule (like the first one) is necessary, for example when you need to modify the behavior of the very function you select for.

kaarmu commented 1 month ago

Sorry for the slow response! It looks like the show statement ends early at the first colon. I am fairly certain about why that happens, though I need to think a bit how to resolve that in a good way. Thank you for reporting this!