[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: |
Eli Zaretskii |
Subject: |
bug#73280: 30.0.90; Eglot: eglot-workspace-configuration might not be found in .dir-locals.el |
Date: |
Mon, 16 Sep 2024 14:38:22 +0300 |
> Cc: João Távora <joaotavora@gmail.com>
> From: Troy Brown <brownts@troybrown.dev>
> 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`.
João and Stefan, any comments?
FWIW, I'd rather think this is a feature, since users don't need
separate Eglot settings for ada-mode and ada-ts-mode. But maybe I'm
missing something.
bug#73280: 30.0.90; Eglot: eglot-workspace-configuration might not be found in .dir-locals.el, Stefan Monnier, 2024/09/16