-
Notifications
You must be signed in to change notification settings - Fork 171
Language Server Protocol Support #142
Comments
Somewhat related, looks like someone made a vim plugin https://github.com/jjo/vim-cue |
Some other links as well:
I was chatting with @mpvl about this a bit at KubeCon this week, and I think this could be highly valuable for CUE. |
To get a better idea of what this should look like: what kind of functionality and analysis would people want to see supported by a LSP implementation? |
basically, I'd like the same editing experience for Kubernetes objects in CUE as you can get for YAML in VS Code |
|
Long term goal, I'd like to build something like Barlin. This gets into some very meta concepts underpinning cue but theoretically a cue evaluator could be written in cue similar to the way Barlin utilizes a scheme interpreter implemented in MiniKanren which implemented scheme 🤔 |
I created packages that lsp for Go. (for my project, Neovim LSP plugin written in Go :D) If we develop lsp for CUE written in Go, it might be helpful that package. |
We can likely reuse some of the work in Probably worth starting with simple diagnostics. That will allow us to flesh out a basic skeleton for what the LSP server should look like (including how to handle modules, a la Go modules). AFAIK, syntax definitions fall outside the spec of LSP. I plan to implement a Vim plugin in Go using |
I've talked to @mpvl at FOSDEM and it might be worth checking out the Prometheus Language Server @slrtbtfs created as part of his internship in our team. It reuses parts of gopls but in a more general purpose way. @slrtbtfs should have more details about why things needed to be changed, in case you have questions. That should already get this going a bit quicker :) |
Hi, I've had a quick look at cue, and it should probably be possible to reuse parts of the PromQL language server for the cue language server. What is definitely reusable and turned out be very useful is the golang.org/x/tools/internal/lsp/proctocol package, which contains (almost) all the types defined in the LSP specification. What could be useful for you, too, is forking the Then the only thing left to do is implementing the Feel free to reach out if you have any questions. |
Another more recent development related to language servers is The Language Server Index Format (LSIF). Basically the idea is to spit out the analysis to a JSON file. Sourcegraph (a code search tool) lets you upload the LSIF file and gives you language-server-like code navigation (but without the language server even running!). Perhaps cue could spit out the LSIF JSON data? I've just grep'ed for my notes on the topic and thought I'd share them here in case they are helpful. See below. Loving cue at the moment and the vscode-cue plugin. Can't wait for a language server! .............................................................. https://github.com/microsoft/lsif-node/blob/master/README.md vscode extension (to serve LSP from the file) https://about.sourcegraph.com/blog/sourcegraph-3.9 https://docs.sourcegraph.com/user/code_intelligence/lsif go get -u github.com/sourcegraph/lsif-go/cmd/lsif-go https://github.com/sourcegraph/lsif-go https://github.com/microsoft/lsif-node/tree/master/tsc lsif-protocol: Protocol defined as TypeScript interfaces |
Hi, I semi-hacked together a working implementation (using
(There might be one or two crashes though 😅 ) Should I fork this project and add what I have up until know, then open a PR? Some thoughts I had during my implementation, most of these are probably my fault for not being familiar with the codebase though 😛 :
Lastly, I wanted to say, that I really love this project! I think it's really cool and we plan on using it in our new infrastructure for all config management (hence why I decided to spend some time implementing this :)). |
@galli-leo this is awesome! Have you signed the Google CLA? If not, we can get you a link to the instructions Cue accepts PRs from here or Gerrit, with some preference for Gerrit as it is the actual source of truth for the code. Gerrit uses a slightly different commit methodology which is pretty cool to experience if you are up for it. Depending on which method you prefer, we'll follow up with more details. Are you aware the syntax is changing slightly? In particular, I see your example (really cool by the way) has the old style definitions with There are some other changes that may impact the lang-server implementation, and hopefully they will only make it easier. As a general FYI, Cue is going through some bigger changes right now on its way to stability later this year. Have you joined the slack group? (link to join is here: https://cuelang.org/community) |
Yep signed it already.
I prefer Github, since I don't have experience with gerrit. But I am also fine with using gerrit, if that makes it easier for you :)
I am now ;) To be honest, I delved into this without having familiarized myself 100% (probably not even 80% :P) with the language spec (in hindsight maybe not the best idea).
I saw the issues regarding that. Is there a central document detailing those changes?
Yep! Will ask further questions there. |
@galli-leo looks great! Any plans to open-source the LSP? |
LSP is close to the top of the list to be worked on in the near future... so this will get some attention soon. |
This would be absolutely invaluable |
I haven't seen any mention of Sublime Text 4 yet, so I'll share some quick thoughts. Sublime Text 4 has a generic LSP implementation which works pretty well. I've been using it in conjunction with gopls for about a year now and both have improved significantly in that time. It's an exciting prospect to have a similar LSP for CUE. |
@myitcv I'm interested in helping with the LSP |
I am now starting work on a first cut of This first cut of Once we have the right "structure" in place ( I will now tag all LSP-related issues with That said, any contribution will of course be greatly appreciated! Because when we have an initial implementation of |
Also interested with helping with this as this is the main thing blocking our adoption of CUE, and I really want to adopt it 😄 |
This is also the main thing blocking CUE adoption at my org. |
Note that while there's no LSP yet, there are a number of language/syntax plugins for various editors: ...and probably more. That might be good enough to unblock adoption while waiting for full autocompletion :) The IntellIj one in particular is commercially supported by us and has a full parser/lexer and will highlight syntax errors. |
Thanks for everyone's patience here. This is in progress; we very much understand the importance of good editor support for the success of CUE. |
Let me know if there's any way I could help!
Yeah I've been using those for some things I've been trying out, but in order to kick off replacing all of our Jsonnet we're going to need things like go to definition, type information, and autocomplete for both VSCode and IntelliJ |
This issue has been migrated to cue-lang/cue#142. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
Here is an example of a YAML file LSP https://github.com/redhat-developer/yaml-language-server
I've never created one so I can't say for certian how much work it would be but it would be great for integrations in to vim, emacs, VSCode, etc.
https://langserver.org/
The text was updated successfully, but these errors were encountered: