vscode-arduino-tools icon indicating copy to clipboard operation
vscode-arduino-tools copied to clipboard

Remove the contributed `ino` language and grammar, reuse it from the default VS Code C++ contibution

Open kittaakos opened this issue 1 year ago • 2 comments

Due to the lack of workforce on this project, all grammar and language customizations should be avoided. Let's stick to the default C++ behavior from VS Code that is used by a large number of developers.

IDE2 users complain about the syntax highlighting (https://github.com/arduino/arduino-ide/issues/2305), which seems to be a reasonable complaint; however, this is how syntax coloring works in VS Code, Eclipse Theia, GitHub, etc., and this project also provides the same behavior. There is no real reason for copying outdated grammar and syntax into this project.

Acceptance criteria:

  • Remove copied grammar and language files from the project,
  • Use grammar injection to support customized coloring for loop, setup, etc.,
  • If the grammar injection is impossible, programmatically generate the customized grammar and syntax, but do not copy it. See how the Code devs generate it on the fly: https://github.com/microsoft/vscode/blob/36480163695273734a80cc8fa2080952708eeb57/extensions/cpp/build/update-grammars.js. Evaluate whether vscode-grammar-updater can be used.

kittaakos avatar Dec 12 '23 08:12 kittaakos

My feeling is that, at least for the initial implementation, the ability to customize the grammar is not required.

I don't see much value in the customization of setup and loop. The stock C++ grammar will highlight these as functions and I think that is perfectly fine. The current grammar seems to try to give these two keywords special treatment:

https://github.com/arduino/vscode-arduino-tools/blob/6b9ee4b8feac6116f50876eb7c2d566835f87f9d/syntaxes/ino.tmGrammar.json#L134-L137

However, in practice it seems they are highlighted as any other function:

image

So if they were no longer included explicitly in the grammar after the migration to the new system, that would not actually be a regression. Nobody has complained about setup and loop being highlighted the same as any other function. So I would not single these specific keywords out.

We have received reports about the lack of highlighting for other things: https://github.com/arduino/arduino-ide/issues/380. I do think it would be nice if we could eventually customize the grammar to cover the fundamental Arduino core API keywords such as the ones mentioned in https://github.com/arduino/arduino-ide/issues/380. So it would be worth investigating whether the new system has the capability to accommodate such customization. However, the current system does not cover them, so it would not be a regression if a new system didn't cover them either.

per1234 avatar Dec 13 '23 09:12 per1234

  • If the grammar injection is impossible,

Same issue: https://stackoverflow.com/questions/70397002/vs-code-injection-grammar-scope-for-custom-keyword-is-overriden-in-c

kittaakos avatar Dec 14 '23 14:12 kittaakos