]> git.eshelyaron.com Git - emacs.git/commitdiff
Offer better control over "languageid" value sent to lsp
authorrvs314 <71688932+rvs314@users.noreply.github.com>
Fri, 26 Mar 2021 10:08:03 +0000 (06:08 -0400)
committerGitHub <noreply@github.com>
Fri, 26 Mar 2021 10:08:03 +0000 (10:08 +0000)
Handles the issue of languages whose major mode has a
different name than the name that the LSP server expects for
the language.  One can now:

(put 'favourite-major-mode 'eglot-language-id "foobarbaz")

And "foobarbaz" will be used as the LSP "languageId" value.

* eglot.el (eglot--TextDocumentItem): Consult 'eglot-language-id.

Copyright-paperwork-exempt: yes
GitHub-reference: fix https://github.com/joaotavora/eglot/issues/525

lisp/progmodes/eglot.el

index 5914f2ddd4721a100eef9ca2b9f6734be5cd3e8d..03e8baa8b76417dfad81860664de94ad8a7b4272 100644 (file)
@@ -1741,9 +1741,11 @@ THINGS are either registrations or unregisterations (sic)."
   (append
    (eglot--VersionedTextDocumentIdentifier)
    (list :languageId
-         (if (string-match "\\(.*\\)-mode" (symbol-name major-mode))
-             (match-string 1 (symbol-name major-mode))
-           "unknown")
+        (cond
+           ((get major-mode 'eglot-language-id))
+           ((string-match "\\(.*\\)-mode" (symbol-name major-mode))
+            (match-string 1 (symbol-name major-mode)))
+           (t "unknown"))
          :text
          (eglot--widening
           (buffer-substring-no-properties (point-min) (point-max))))))