Legacy Theme Highlighting

Hello, I’m currently working on implementing a theme into CodeMirror 6. For context, I’m using @codemirror/lang-markdown and then I’m using @codemirror/language-data to autoload languages when detected in markdown.

I noticed that many languages look great. However, legacy languages (such as lua in my example) interpret just about every Tag as name (except for keywords). Thus, almost everything is red (or purple). You can see similar behavior with other legacy languages such as Go.

Small clarification. “Legacy Languages”, when I look at the source for language-data some languages are being imported via @codemirror/legacy-modes/mode/ – These seem to be the languages (AFAIK) that are interpreting most Tags as name.

Just curious if there’s anything I can do here on my end or if I’m overlooking something? Thanks!

Those red things are variable names, so it seems expected that they’ll be highlighted as such?

Yes and no, I get that function names, arg names, prop names, are all still technically variable names. Comparing to the jsx or typescript pasted above I figured the regex could differentiate. However, this was a bad assumption on my part.

Once I compared CodeMirror lua syntax highlighting to other regex (non-AST) highlighters it’s pretty close to what others do. (Also, I believe Legacy code mirror modes are streams, not regex, just grouping these together for simplicity)

Comparing to PrismJS, the only thing different is local function names, operators (and/or), (/±*). Which is pretty minor.

Also, to clarify, I changed red to white here so the examples line up better.

Lastly, to compare to the neovim syntax highlighter (with AST/Treesitter off), again it’s pretty close. That highlighter differentiates function/end and in/and/or whereas CodeMirror groups all keywords together.

2022-10-07_07-42

TLDR This is okay, thanks for taking the time to reply.