unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Troy Brown <brownts@troybrown.dev>
To: 73280@debbugs.gnu.org
Cc: "João Távora" <joaotavora@gmail.com>
Subject: bug#73280: 30.0.90; Eglot: eglot-workspace-configuration might not be found in .dir-locals.el
Date: Sun, 15 Sep 2024 15:54:00 -0400	[thread overview]
Message-ID: <CABvCZ40Sva9Mdhf1mw+uuOerQ0L1ERW-7W6itrBK5k1sivNafQ@mail.gmail.com> (raw)

I discovered that the workspace configuration specified in a
`.dir-locals.el` file was not being used if the mode is not listed
first in `eglot-server-programs`.  Consider a scenario where the
current buffer's major mode is `ada-ts-mode` and Eglot is enabled in
that buffer.  Also, consider the following `.dir-locals.el` in a
parent directory containing the file of the buffer.

```elisp
((ada-ts-mode . ((eglot-workspace-configuration . (:ada (:projectFile
"src/gtkada.gpr"))))))
```

If I then execute `M-x eglot-show-workspace-configuration RET` in that
`ada-ts-mode` buffer, the "*EGLOT workspace configuration*" buffer
opens and displays a value of "null".

```json
null
```

However, if I change the mode in `.dir-locals.el` from `ada-ts-mode`
to `ada-mode` and repeat the "show configuration" command, I see the
configuration as expected, even though the major mode is
`ada-ts-mode`.

```json
{
  "ada": {
    "projectFile": "src/gtkada.gpr"
  }
}
```

I believe this is due to the following statement in
`eglot--workspace-configuration-plist`, which sets the major mode in
the temporary buffer before calling
`hack-dir-local-variables-non-file-buffer`:

```elisp
;; Set the major mode to be the first of the managed
;; modes.  This is the one the user started eglot in.
(setq major-mode (car (eglot--major-modes server)))
```

The comment indicates that the major mode that Eglot was started in
will be listed first, but that is not the case.  If I execute `M-:
(eglot--major-modes (eglot-current-server))` from the `ada-ts-mode`
buffer, the value is `(ada-mode ada-ts-mode)`, which is the same order
they are listed in `eglot-server-programs`, and is not ordered based
on the major mode of the buffer where Eglot was started.
Additionally, `eglot--connect` which populates `eglot--languages`
doesn't change the order from how they are listed in
`eglot-server-programs`.





             reply	other threads:[~2024-09-15 19:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-15 19:54 Troy Brown [this message]
2024-09-16 11:38 ` bug#73280: 30.0.90; Eglot: eglot-workspace-configuration might not be found in .dir-locals.el Eli Zaretskii
2024-09-16 13:48   ` João Távora
2024-09-16 17:07     ` Troy Brown
2024-09-16 18:15       ` Eli Zaretskii
2024-09-16 18:39         ` João Távora
2024-09-16 18:43           ` Eli Zaretskii
2024-09-16 18:53         ` Troy Brown
2024-09-16 19:07           ` João Távora
2024-09-16 21:34             ` Troy Brown
2024-09-16 19:17           ` Eli Zaretskii
2024-09-16 21:34   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABvCZ40Sva9Mdhf1mw+uuOerQ0L1ERW-7W6itrBK5k1sivNafQ@mail.gmail.com \
    --to=brownts@troybrown.dev \
    --cc=73280@debbugs.gnu.org \
    --cc=joaotavora@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).