microsoft / vscode-anycode

MIT License
326 stars 38 forks source link

Question: Simplicity of adding a language #16

Closed borgdylan closed 2 years ago

borgdylan commented 2 years ago

What are the necessary steps to add a new language (given that a grammer already exists for code) to anycode. I do not require to add it to the repo, but just have it work on my machine.

jrieken commented 2 years ago

There is no real contribution story for grammars and today languages are hardcoded into the extension. A couple of pieces are involved

Ideally, this can happen from the outside. The anycode extension could define a contribution point to which other extensions contribute static data (wasm, metainfo, queries) which is then processed. That would make the contribution story the simplest and easier to maintain

borgdylan commented 2 years ago

I did not know that an extra custom parser had to be written (thought tree-sitter was a generic parser fed with textmate grammars). I do not have the requirement to run in the browser and already have a parser written in the language itself (compiles to standard .NET libraries). Would it be more practical for me to attempt writing a Language Server instead? If so, are there any "shell" language servers for .NET where I could implement a set of interfaces only?

jrieken commented 2 years ago

Yes - if you already have a custom parser and language service you should write a language server instead. You can find various SDKs that help with LSP here https://microsoft.github.io/language-server-protocol/implementors/sdks/

borgdylan commented 2 years ago

Thank you. I found https://github.com/OmniSharp/csharp-language-server-protocol . I have a parser but not a language service. The compiler is split into libraries with the lexer and parser having public facades for direct consumption. Is Omnisharp written using https://github.com/OmniSharp/csharp-language-server-protocol ? If yes, it would be the best ever example.

jrieken commented 2 years ago

Is Omnisharp written using https://github.com/OmniSharp/csharp-language-server-protocol ? If yes, it would be the best ever example.

My involvement in OmniSharp is too long ago to know this. Tho, given it is in their org I'd say it's likely used

jrieken commented 2 years ago

Closing this issue which was more of a question. However, we do plan to make contributing tree-sitter based goodness simpler: https://github.com/microsoft/vscode-anycode/issues/24