[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 9093834d0b5: Eglot: unbreak activation/management of derived mode
From: |
João Távora |
Subject: |
master 9093834d0b5: Eglot: unbreak activation/management of derived modes (bug#62907) |
Date: |
Tue, 18 Apr 2023 20:02:04 -0400 (EDT) |
branch: master
commit 9093834d0b590bc15ed994bd62f18f7b47a48f55
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Eglot: unbreak activation/management of derived modes (bug#62907)
After recent changes to how LSP "languageId" is computed from major
modes and stored in the eglot-lsp-server object, the activation of the
'eglot--managed-mode' minor mode in modes _derived_ from some
major-mode mentioned in 'eglot-server-programs' was broken.
This commit restores that by introducing a new helper which uses the
same logic to provide the current-buffer's "languageId" to the server
and to discover if the server should manage the mode at all. This
ensures the two things stay in sync.
Also, this helper uses the function 'provided-mode-derived-p' to fix
this bug#62907.
* lisp/progmodes/eglot.el (eglot--languageId): New helper.
(eglot-current-server, eglot--TextDocumentItem): Use it.
---
lisp/progmodes/eglot.el | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 7ad33fa3786..fe0c986d746 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1935,10 +1935,9 @@ Use `eglot-managed-p' to determine if current buffer is
managed.")
"Return logical Eglot server for current buffer, nil if none."
(setq eglot--cached-server
(or eglot--cached-server
- (cl-find major-mode
- (gethash (eglot--current-project)
eglot--servers-by-project)
- :key #'eglot--major-modes
- :test #'memq)
+ (cl-find-if #'eglot--languageId
+ (gethash (eglot--current-project)
+ eglot--servers-by-project))
(and eglot-extend-to-xref
buffer-file-name
(gethash (expand-file-name buffer-file-name)
@@ -2360,12 +2359,20 @@ THINGS are either registrations or unregisterations
(sic)."
(append (eglot--TextDocumentIdentifier)
`(:version ,eglot--versioned-identifier)))
+(cl-defun eglot--languageId (&optional (server
(eglot--current-server-or-lose)))
+ "Compute LSP \\='languageId\\=' string for current buffer.
+Doubles as an predicate telling if SERVER can manage current
+buffer."
+ (cl-loop for (mode . languageid) in
+ (eglot--languages server)
+ when (provided-mode-derived-p major-mode mode)
+ return languageid))
+
(defun eglot--TextDocumentItem ()
"Compute TextDocumentItem object for current buffer."
(append
(eglot--VersionedTextDocumentIdentifier)
- (list :languageId
- (alist-get major-mode (eglot--languages
(eglot--current-server-or-lose)))
+ (list :languageId (eglot--languageId)
:text
(eglot--widening
(buffer-substring-no-properties (point-min) (point-max))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 9093834d0b5: Eglot: unbreak activation/management of derived modes (bug#62907),
João Távora <=