Nvim LSP dartls 无法启动

发布于 2025-01-17 05:35:11 字数 1436 浏览 3 评论 0原文

我想为flutter配置一个开发环境,我刚刚配置了flutter和android studio,并且我已经启动了一个正在运行的应用程序。现在我只需要配置 dartls ,我一直在使用 cmd 属性,因为它看起来默认配置无法找到可执行文件。由于flutter将dart-sdk一起打包,因此我相应地更改了路径。

require'lspconfig'.dartls.setup{
    cmd = {"dart", "~/source/flutter/bin/cache/dart-sdk/bin/snapshots/analysis_server.dart.snapshot", "--protocol=lsp"},
    on_attach = on_attach
}

您确定这是正确的道路吗?

ls ~/source/flutter/bin/cache/dart-sdk/bin/snapshots/ | grep analysis_server
# analysis_server.dart.snapshot

为什么要更改 --lsp 标志?

dart ~/source/flutter/bin/cache/dart-sdk/bin/snapshots/analysis_server.dart.snapshot --help | grep protocol
    --protocol=<protocol>                 Specify the protocol to use to communicate with the analysis server.
          [analyzer] (default)            Dart's analysis server protocol (https://dart.dev/go/analysis-server-protocol)
          [lsp]                           The Language Server Protocol (https://microsoft.github.io/language-server-protocol)

打开 dart 文件时是否收到任何错误?

Spawning language server with cmd: `dart` failed. The language server is either not installed, missing from PATH, or not executable.   

I would like to configure a development environment for flutter, I just configured flutter and android studio and I already got a started app running. Now I just need to configure the dartls, I've been playing around with the cmd property since it looks like the default configuration is not able to find the executable. Since flutter packages the dart-sdk along with it, I changed the path accordingly.

require'lspconfig'.dartls.setup{
    cmd = {"dart", "~/source/flutter/bin/cache/dart-sdk/bin/snapshots/analysis_server.dart.snapshot", "--protocol=lsp"},
    on_attach = on_attach
}

Are you sure this is the right path?

ls ~/source/flutter/bin/cache/dart-sdk/bin/snapshots/ | grep analysis_server
# analysis_server.dart.snapshot

Why did you change the --lsp flag?

dart ~/source/flutter/bin/cache/dart-sdk/bin/snapshots/analysis_server.dart.snapshot --help | grep protocol
    --protocol=<protocol>                 Specify the protocol to use to communicate with the analysis server.
          [analyzer] (default)            Dart's analysis server protocol (https://dart.dev/go/analysis-server-protocol)
          [lsp]                           The Language Server Protocol (https://microsoft.github.io/language-server-protocol)

Are you receiving any errors when opening a dart file?

Spawning language server with cmd: `dart` failed. The language server is either not installed, missing from PATH, or not executable.   

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文