Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Simplicity of adding a language #16

Closed
borgdylan opened this issue Nov 24, 2021 · 6 comments
Closed

Question: Simplicity of adding a language #16

borgdylan opened this issue Nov 24, 2021 · 6 comments
Assignees
Labels
feature-request Request for new features or functionality

Comments

@borgdylan
Copy link

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
Copy link
Member

jrieken commented Nov 24, 2021

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

  • add the grammar via npm, like here
  • enroll the grammar and some metadata like here
  • write queries that extract the wanted information from a syntax tree, e.g outline for rust etc. This isn't documented but the most laborious part. Also query capture names have some semantics which aren't documented/finalized yet
  • add tests

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

@jrieken jrieken self-assigned this Nov 24, 2021
@jrieken jrieken added the feature-request Request for new features or functionality label Nov 24, 2021
@borgdylan
Copy link
Author

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
Copy link
Member

jrieken commented Nov 24, 2021

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
Copy link
Author

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
Copy link
Member

jrieken commented Nov 24, 2021

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
Copy link
Member

jrieken commented Mar 10, 2022

Closing this issue which was more of a question. However, we do plan to make contributing tree-sitter based goodness simpler: #24

@jrieken jrieken closed this as completed Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

2 participants