GNU bug report logs -
#74334
29.4; Eglot ignores locally set configuration
Previous Next
Reported by: Acid Bong <acidbong <at> tilde.club>
Date: Wed, 13 Nov 2024 02:02:01 UTC
Severity: normal
Found in version 29.4
Done: João Távora <joaotavora <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 74334 in the body.
You can then email your comments to 74334 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#74334
; Package
emacs
.
(Wed, 13 Nov 2024 02:02:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Acid Bong <acidbong <at> tilde.club>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 13 Nov 2024 02:02:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Can be observed on both builtin (1.12.29) and the newest Eglot (1.17). I'm starting Eglot manually, i have no hooks for Rust.
My repo structure:
/
...
|_pkgs/rsblocks/
|_.dir-locals.el
|_Cargo.toml
...
Since my Rust project isn't in the root of the repo, I need to specify its location for rust-analyzer. Using .dir-locals.el with this content:
```lisp
((nil
. ((eglot-workspace-configuration
. (:rust-analyzer (:linkedProjects ["pkgs/rsblocks/Cargo.toml"]))))))
;; thank god it supports relative paths
```
does nothing: I see the variable value is set properly with `C-h v`, but Eglot doesn't seem to recognize it (`eglot-show-workspace-configuration` shows "null").
However, only when I set it globally, Eglot can apply the config to the language server.
Expected behaviour: like described in the manual, Eglot should recognize local values.
Possibly related report: https://github.com/joaotavora/eglot/issues/355 (unresolved)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#74334
; Package
emacs
.
(Wed, 13 Nov 2024 08:04:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 74334 <at> debbugs.gnu.org (full text, mbox):
Ight, Joao, you accidentally created a new report, but i'll answer your questions under the original one.
> What is the '...'preceding your excerpt of a structure?
This is short for "other files that don't matter". Here's my repo
(https://codeberg.org/acidbong/nixos/src/commit/2d0eec312d83db0c685aa6de184d0477b0bf2041),
where I pushed my current state. The Cargo project is under /pkgs/rsblocks,
including .dir-locals.el.
> Where are you executing C-h v? What file are you M-x eglot'int in?
> Where are you running M-x eglot-show-worspace-configuration?
I'll describe all my actions:
1. open Emacs, it's in *scratch* and in ~:
- `eglot-workspace-configuration` is empty
2. `C-x p f ~/.config/nixos/pkgs/rsblocks/src/main.rs`:
- `e-w-c` (i'm abbreviating now, if you don't mind) now follows the content
in .dir-locals.el
3. `M-x eglot` in that exact main.rs:
- rust-analyzer complains that it can't find the workspace:
```
[eglot] Server reports (type=1): Failed to discover workspace.
Consider adding the `Cargo.toml` of the workspace to the [`linkedProjects`](https://rust-analyzer.github.io/manual.html#rust-analyzer.linkedProjects) setting.
Failed to load workspaces.
```
- `eglot-show-w-c` shows "null"
4. Go back to the *scratch*, type in (setq-default eglot-workspace-configuration '(that value))
and evaluate it with `C-x C-e`. Now the config is set globally.
5. Back to main.rs and `M-x eglot` once more:
- it launches and loads successfully
- `eglot-show-w-c` shows the config in JSON, and the config looks correct:
```
{
"rust-analyzer": {
"linkedProjects": [
"pkgs/rsblocks/Cargo.toml"
]
}
}
```
> What does M-: (project-current) RET show?
(vc Git "~/.config/nixos") ;; this is where I store my NixOS config
> All these commands are highly dependent on context, so I think it's best if you
> show a full recipe from Emacs -Q to clear these doubts.
I could replicate it with `emacs -Q`.
Speaking of `project-current`: I tried to follow the advices from
https://github.com/joaotavora/eglot/discussions/687 and add "Cargo.toml"
and "Cargo.lock" to `project-vc-extra-root-markers`, but `M-: (project-current)`
still shows "~/.config/nixos". Looks like project.el can't recognize nested
projects (both 0.9.8 and 0.11.0), but that's a whole different issue I don't care about.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#74334
; Package
emacs
.
(Wed, 13 Nov 2024 08:42:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 74334 <at> debbugs.gnu.org (full text, mbox):
On Wed, Nov 13, 2024 at 8:03 AM Acid Bong <acidbong <at> tilde.club> wrote:
>
> Ight, Joao, you accidentally created a new report, but i'll answer your questions under the original one.
Bug in tracker, likely you weren't vetted yet. Reply all usually
works and fetches the bug report. Who's Ight?
> Speaking of `project-current`: I tried to follow the advices from
> https://github.com/joaotavora/eglot/discussions/687 and add "Cargo.toml"
> and "Cargo.lock" to `project-vc-extra-root-markers`, but `M-: (project-current)`
> still shows "~/.config/nixos". Looks like project.el can't recognize nested
> projects (both 0.9.8 and 0.11.0), but that's a whole different issue I don't care about.
You probably should care because .dir-locals needs to exist in the
project root directory. Read the manual
https://joaotavora.github.io/eglot/#Project_002dspecific-configuration
"The most common way to set eglot-workspace-configuration is using a
.dir-locals.el file in the root of your project."
M-x eglot doesn't much care where inside a given project you start it. For
all it knows you could started it visiting ight.rs in your nixis dir and it'd
be the same.
João
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#74334
; Package
emacs
.
(Wed, 13 Nov 2024 09:46:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 74334 <at> debbugs.gnu.org (full text, mbox):
> On Wed, Nov 13, 2024 at 8:03 AM Acid Bong <acidbong <at> tilde.club> wrote:
>
> >
> > Ight, Joao, you accidentally created a new report, but i'll answer your questions under the original one.
> >
>
> Bug in tracker, likely you weren't vetted yet. Reply all usually
> works and fetches the bug report. Who's Ight?
>
It's short for "alright", sorry for confusing you.
>
> >
> > Speaking of `project-current`: I tried to follow the advices from
> > https://github.com/joaotavora/eglot/discussions/687 and add "Cargo.toml"
> > and "Cargo.lock" to `project-vc-extra-root-markers`, but `M-: (project-current)`
> > still shows "~/.config/nixos". Looks like project.el can't recognize nested
> > projects (both 0.9.8 and 0.11.0), but that's a whole different issue I don't care about.
>
> You probably should care because .dir-locals needs to exist in the
> project root directory. Read the manual
> https://joaotavora.github.io/eglot/#Project_002dspecific-configuration
> "The most common way to set eglot-workspace-configuration is using a
> .dir-locals.el file in the root of your project."
>
> M-x eglot doesn't much care where inside a given project you start it. For
> all it knows you could started it visiting ight.rs in your nixis dir and it'd
> be the same.
>
Woah, it actually works. Kinda weird that it requires .dir-locals.el to be in the
Git root, not in the Cargo root.
Thanks a lot
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#74334
; Package
emacs
.
(Wed, 13 Nov 2024 10:12:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 74334 <at> debbugs.gnu.org (full text, mbox):
On Wed, Nov 13, 2024 at 9:45 AM Acid Bong <acidbong <at> tilde.club> wrote:
> Woah, it actually works. Kinda weird that it requires .dir-locals.el to be in the
> Git root, not in the Cargo root.
It's weird, but only because having this particular project very deep inside
the only dir that Emacs knows how to automatically recognize as a
project is weird. Look into teaching project.el about "Cargo.toml" files,
it shouldn't be very hard.
You may or may not need "nested" projects, that's an orthogonal
issue. If you're sure you do need nested or complicated project
setups, look at [1])
João
[1]: https://github.com/joaotavora/eglot/discussions/1337#discussioncomment-8853117
Reply sent
to
João Távora <joaotavora <at> gmail.com>
:
You have taken responsibility.
(Wed, 13 Nov 2024 10:12:03 GMT)
Full text and
rfc822 format available.
Notification sent
to
Acid Bong <acidbong <at> tilde.club>
:
bug acknowledged by developer.
(Wed, 13 Nov 2024 10:12:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 11 Dec 2024 12:24:09 GMT)
Full text and
rfc822 format available.
This bug report was last modified 268 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.