serkonda7/vscode-vba

Making this repo the grammar used by GitHub for syntax highlighting

DecimalTurn opened this issue · 10 comments

Currently, the grammar referenced by GitHub (via Linguist) for syntax highlighting of VBA code is the following repo :
https://github.com/peters-ben-0007/VBDotNetSyntax

Since it's a VB.NET repo, it works OK most of the times, but it would be better to replace it with a grammar that is specifically made for VBA's syntax like this repo.

I'm willing to make the PR to Linguist in order to make that change, but there might be changes needed to make this work, so I wanted to know if you approve of this idea.

Nice suggestion. I will look into it.

Awesome! Let's wait to see what comes up in the discussion.

Well, the discussion is not really helpful and support for yaml is just awful:
github-linguist/linguist#6438

I think it might be the best solution to create another repo, containing the JSON files.

@DecimalTurn I have created a repo with the JSON grammar: https://github.com/tiabeast/vscode-vba-json
But I closed my PR to the linguist repo. Please feel free to superseed it and just ping me if there are problems

Sure, I can make the PR, but I got the following error while running the add-grammar script:

3 errors found in new grammar 'repository `vendor/grammars/vscode-vba-json` (from https://github.com/tiabeast/vscode-vba-json.git)':
- Grammar conversion failed. File `syntaxes/language-configuration.json` failed to parse: Undeclared scope in grammar: `syntaxes/language-configuration.json` has no scope name
- Invalid regex in grammar: `source.vba` (in `syntaxes/vba.tmGrammar.json`) contains a malformed regex (regex "`(?i)(?<=\s+As\s+)([a-zA-Z]+)`": lookbehind assertion is not fixed length (at offset 16))
- Invalid regex in grammar: `source.vba` (in `syntaxes/vba.tmGrammar.json`) contains a malformed regex (regex "`(?i:\b(?<=(Call|Function|Sub)\s)`...": lookbehind assertion is not fixed length (at offset 31))

Regarding the first one, I think we can ignore it, but Linguist won't include informations from language-configuration.json I'm not sure what to do.

For the other 2 issues, looks like the regex engine that Linguist uses is more picky when it comes to lookbehinds. However, it seems likes we could simply use non-capturing groups and it would keep the original outcome without the use of lookbehinds. I'll submit a PR for this.

Actually, for language-configuration.json, is it necessary in the repo? Could we just exclude it? I'm not even sure that Linguist makes use of it.

I can always ask what causes the error when I make the PR. Maybe it has to do with the fact that the repo contains a grammar for both VBA and WWD.

The language-configuration.json is not needed, I will remove it.

Thank you for bringing this up and your contributions!

My pleasure!