【问题标题】:Emacs: rust-analyzer + rustic - couldn't discover workspaceEmacs:rust-analyzer + rustic - 无法发现工作区
【发布时间】:2023-02-13 22:44:35
【问题描述】:

我是一个比 Arch Linux 新手更进一步的用户...我一直在使用这个设置(emacs + rustic + rust-analyzer + lsp-ui 等等,设置如下 https://robert.kra.hn/posts/rust-emacs-setup/)现在一个月。昨天我试着安装anki来自 AUR 的包,但在构建之后它无法实现,所以我使用删除了整个东西sudo pacman -Rs anki,因为它安装了很多东西(出于某种原因包括 rust 平台),而且似乎在所有这些操作之后 rust 平台停止与 emacs 一起工作...... 今天我尝试使用类似的东西rustup 组件添加 rustcrustup 组件删除/添加 rust-analyzer等等......它实际上重新安装了一些东西,但帮助不大。所以欢迎任何建议:(

这是我启动任何默认项目时的一些日志(通过货物新--bin):

[yas] Prepared just-in-time loading of snippets successfully.
Loading /home/geo/.emacs.d/custom.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
C-<mouse-1> is undefined
Making completion list... [2 times]
LSP :: Connected to [rust-analyzer:9205/starting]. [2 times]
LSP :: rust-analyzer:9205 initialized successfully in folders: (/home/geo)
LSP :: rust-analyzer failed to discover workspace

我害怕说生锈分析器是在/home/geo文件夹,但也许那只是我......

这是我的完整配置:https://github.com/geothecode/save/blob/laptop/.emacs.d/init.el

之前:一切正常,没有错误,没有具体警告 - 很好;我得到了所需的 lsp 的各种支持,lsp-ui 正在工作(但现在停止显示)。

【问题讨论】:

  • rust-analyzer 应该在您的项目文件夹中初始化 - (1) 使用 lsp-workspace-folders-remove 删除错误的工作空间(例如 /home/geo),(2) 确保 lsp-auto-guess-rootnil,(3) 并打开一个 rust项目中的文件以交互方式设置正确的工作区根目录
  • @Rorschach 非常感激,先生,它现在正在工作! :)
  • @Rorschach 你能提交你的评论作为答案吗,这将帮助其他有类似问题的人,因为没有太多人看 cmets...(我知道你知道,但是...)

标签: rust emacs language-server-protocol rust-analyzer


【解决方案1】:

Rorschachcomment 中发布的解决方案对我有用:

rust-analyzer 应该在您的项目文件夹中初始化 - (1) 使用 lsp-workspace-folders-remove 删除错误的工作空间(例如 /home/geo),(2) 确保 lsp-auto-guess-root 为 nil,( 3) 并在您的项目中打开一个 rust 文件以交互方式设置正确的工作区根目录*

不久:

  1. lsp-工作区-文件夹-删除
  2. 设置lsp-自动猜测根
  3. 打开项目的 rust 文件

【讨论】:

    猜你喜欢
    • 2022-06-11
    • 2022-11-10
    • 2022-10-25
    • 2010-10-01
    • 1970-01-01
    • 2018-10-08
    • 2016-03-12
    • 2023-01-29
    • 1970-01-01
    相关资源
    最近更新 更多