LSP :: could not find `Cargo.toml`
うまく行かなかったメモ。
目的
emacs で rust-analyzer を LSP ってやつを使って使えるようにするぜ。
init.el の変更
以下とか、いろいろ参照しつつ、init.el を編集する。
Rustプログラミングのための環境構築 | Emacs JP
関連部分はこちら。
(leaf lsp-mode :ensure t :init (yas-global-mode) :custom ((lsp-rust-server . 'rust-analyzer)) :hook ((web-mode-hook rust-mode-hook) . lsp) :config (leaf lsp-ui :ensure t) (leaf lsp-ivy :ensure t)) (leaf rust-mode :ensure t ;; :custom ((rust-format-on-save . t)) :config (leaf cargo :ensure t :hook (rust-mode . cargo-minor-mode)) )
なんか失敗したときのエラーは以下。
.rs ファイルを開くときに、Cargo.toml よりも遡ったところを監視するぜって言っているような気がする。
LSP :: Connected to [rls:14780/starting]. LSP :: rls:14780 initialized successfully in folders: (/home/ochir/atcoder) Watching all the files in <home directory>/competitive_programming/atcoder/ would require adding watches to 1773 directories, so watching the repo may slow Emacs down. Do you want to watch all files in <home directory>/competitive_programming/atcoder/? (y or n) y LSP :: You can configure this warning with the `lsp-enable-file-watchers' and `lsp-file-watch-threshold' variables LSP :: could not find `Cargo.toml` in `<home directory>/atcoder` or any parent directory
ディレクトリ構造はこちら。
abc195以下は、`cargo atcoder new abc195`で生成されています。
GitHub - tanakh/cargo-atcoder: Cargo subcommand for AtCoder
competitive_programming/ └── atcoder └── rust └── abc195 ├── Cargo.lock ├── Cargo.toml ├── src │ └── bin │ ├── a.rs │ ├── b.rs │ ├── c.rs │ ├── d.rs │ ├── e.rs │ └── f.rs └── target ├── CACHEDIR.TAG ├── debug │ ├── build │ │ ├── getrandom-38ff49cfcf8d31ca
本当は、abc195 を監視してほしいけど、atcoder のとこを監視している。
新しく別のところに abc195 以下を作成するとうまくいくので、LSP の設定から変更できないか調べてみたけど分からず・・・。
分からなかったというメモだけ残しておく。
なんかヒントになりそうな issue だけおいとく。
github.com
workspace
workspace がいかれていることが分かってきた。
というか、これが workspace っていうことがわかった。
M-x lsp-workspace-folders-remove
でよくわからんやつを消して、emacs を再起動したら、直った。OK。
多分、connection を再確立すればええんやろうけど。