bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#73280: 30.0.90; Eglot: eglot-workspace-configuration might not be fo


From: Troy Brown
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

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 via email to

[Prev in Thread] Current Thread [Next in Thread]