Code Monkey home page Code Monkey logo

Comments (9)

fhs avatar fhs commented on June 29, 2024 1

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.

from acme-lsp.

farhaven avatar farhaven commented on June 29, 2024 1

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.

from acme-lsp.

fhs avatar fhs commented on June 29, 2024

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.

from acme-lsp.

mpl avatar mpl commented on June 29, 2024

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...

from acme-lsp.

fhs avatar fhs commented on June 29, 2024

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.

from acme-lsp.

mpl avatar mpl commented on June 29, 2024

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.

from acme-lsp.

farhaven avatar farhaven commented on June 29, 2024

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"

from acme-lsp.

mpl avatar mpl commented on June 29, 2024

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!

from acme-lsp.

mpl avatar mpl commented on June 29, 2024

@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?

from acme-lsp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.