jvalue / jayvee

Jayvee is a domain-specific language and runtime for automated processing of data pipelines
https://jvalue.github.io/jayvee/
103 stars 10 forks source link

[FEATURE] Improve neovim support #550

Open TungstnBallon opened 2 months ago

TungstnBallon commented 2 months ago

User Story

  1. As a neovim user
  2. I want to integrate jayve into the neovim ecosystem
  3. So that comfortably edit jayvee files in neovim

User Acceptance Criteria

Notes

All languages with good neovim support share these features:

  1. File recognition All this requires is getting the .jv extension added to this file (example pr).

  2. Language server This is also easily accomplished by adding the jayvee language server to mason-registry (auto-install) and nvim-lspconfig (auto-configure). Until now, I've extracted the language server executable from the vscode extension. This is tedious though and it also makes automatic installation hard. I propse that we publish the lsp executable as a separate package.

  3. Syntax highlighting? Most big languages have a treesitter grammar which, among other things, provides syntax highlighting. However, I did not find a way to convert a langium grammar to a treesitter grammar and writing one from scratch seems very difficult. This will probably have to wait.

While the PRs necessary for 1. and 2. are waiting to be merged, they can be replicated with a plugin.

Definitions of Done

rhazn commented 2 months ago

This sounds like a really nice extension, even though most of it is in projects we have no control over (e.g. vim)? From what I see, for us this would mean:

TungstnBallon commented 2 months ago

most of it is in projects we have no control over (e.g. vim)?

Yes, but in case of vim and nvim-lspconfig a plugin can accomplish the same without a noticeable difference. So we are not dependent on our changes getting merged there.

Langium generates TextMate and Monarch grammars, would any of these work?

I found this plugin. It looks into the VSCode extension directory and uses the textmate grammars there to highlight the file in neovim. This means that both VSCode and our extension for it need to be installed in order for syntax highlighting in neovim to work. It's a little janky but it does work.

rhazn commented 2 months ago

I think we'd have an okay time setting up a buildstep that exports textmate grammars and the lsp executable on their own. That would free these files up from the VSCode extension. I think that would be a step that would make integration into neovim more elegant, right?

TungstnBallon commented 2 months ago

The problem is that nvim-textmate doesn't support loading the grammar from a specific file. It only supports VSCode extensions. It may be possible to create a hacky solution where vscode doesn't have to be installed, but I can't say how much effort that would be.