Open mpl opened 1 year ago
I think first step would be to try it out with debugging/tracing turned on. Then try to get file management and basic commands working. Maybe it already works but from what I've seen, there are always some incompatibilities between how client and server implement the LSP protocol and what version of LSP protocol they assume.
I've not had a lot time to work on acme-lsp. The more I look at it, the more I dislike the JSON-rpc based LSP protocol, and Go is not the best language to implement a LSP client because it lack an union type. The acme-lsp code is heavily based on gopls and I've not kept up with updates to gopls. We desperately need to update the LSP protocol definitions to the latest LSP version, and auto-generate it from the LSP spec instead of manually updating them. I've attempted to update it few months ago, but the gopls code base have changed in a very incompatible way that it wasn't an easy change.
To summarize, you may need to manually update protocol definitions to support dart, but this might get very tedious. The proper fix for protocol incompatibles is to auto-generate protocol definitions from the latest LSP spec.
oh, so you're saying it might already partially work? it hadn't even occurred to me that it could, so I didn't even try it out, heh. Will do that first then, thanks.
In the meantime I'm using vim to "Ldef" and I just keep on coding in acme anyway. it kinda works...
I gave it a shot but doesn't work:
acme-lsp -server '\.dart$:dart language-server'
2023/06/18 18:21:41 LSP 4: Loading packages...
2023/06/18 18:21:41 failed to create file manager: failed to connect to language server ["dart" "language-server"]: initialize failed: json: cannot unmarshal bool into Go struct field WorkspaceFolders5Gn.capabilities.workspace.workspaceFolders.changeNotifications of type string
This is with the auto-generated LSP structs from gopls I recently merged. changeNotifications
can be with a bool or string according to the LSP spec, but auto-generated struct declares this field as a string.
Fixed that issue but now dart language server just hangs after successful initialization and uses 100% CPU. I'm guessing we might be triggering a bug in dart LS.
Thank you for the time you spent on this. I wanted to investigate a bit myself, but I think I got demotivated because I didn't get how to run a dart language server.
I just got basic Dart LSP support to work here. The key was setting the onlyAnalyzeProjectsWithOpenFiles
LSP option to true
. Otherwise, I had the hang that @fhs mentions (at 100% CPU).
Diagnostics and Jump To Definition work, hover help does not:
2024/02/16 13:39:30 jsonrpc2: code -32603 message: json: cannot unmarshal string into Go struct field Hover.contents of type protocol.MarkupContent
Lhov: exit 1
and neither does formatting:
2024/02/16 13:39:46 jsonrpc2: code -32603 message: jsonrpc2: code -32602 message: Invalid params for textDocument/codeAction:
params.context.diagnostics must not be null
Lfmt: exit 1
I believe I have seen the hover help output with e.g. the Typescript language server as well, and I believe an issue for it already exists, but it boils down to "The LSP specs that the Go code acme-lsp uses is generated from is a bit too advanced for Go's type system to translate 1:1".
All in all, it's not at 100%, but this covers at least half of my use cases for Android Studio, so I'm happy.
This is the relevant part of my config:
[Servers]
[Servers.dartls]
Command = ["dart", "language-server", "--client-id=acme-lsp", "--client-version=1.0"]
StderrFile = "dartls.stderr.log"
LogFile = "dartls.log"
[Servers.dartls.Options]
onlyAnalyzeProjectsWithOpenFiles = true
[[FilenameHandlers]]
Pattern = "\\.dart$"
LanguageID = "dart"
ServerKey = "dartls"
oooh, you got jump to definition working? color me interested then, because that's pretty much all I need. I'll need to give it another try, thanks!
@farhaven Given that I'm not using Android Studio (only acme, and acme-lsp), what are all the pieces that I need to be able t o get to the point you are at? Are you using Android Studio as an LSP server for Dart?
No, Android Studio is not required (to be running) per se. I have a flutter toolchain in ~/flutter
installed as per their instructions, as well as Android Studio installed for the Android SDKs (mostly because I'm using Dart on a mac, and it's easier to install the SDK through Android Studio than to manage it on my own).
The config I pasted above is all that I had to do to get it working (listing references works as well).
Just a heads up, the LSP has the habit of spamming the /LSP/Diagnostics
window with a lot of uninteresting stuff as soon as you open one of the flutter files (such as by jumping to a definition in there), but that seems to kick in only after the file has been open for a few seconds.
Hello,
Do you have any idea how hard it would be to add (at least partial) support for dart (https://dart.dev/) ? FYI, vim does it through https://github.com/natebosch/vim-lsc , and https://github.com/natebosch/vim-lsc-dart for example.
As a long time user of acme-lsp, but having never touched the code, I'm wondering if I should attempt it. TBH, I would only need Ldef to work. Would you have any recommendation on where to start?
Cheers