mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 12:31:25 +00:00
Eglot: unbreak for treesit-less builds
* lisp/progmodes/eglot.el (eglot--builtin-mdown-p): New helper. (eglot--accepted-formats) (eglot--format-markup): Use it.
This commit is contained in:
parent
10e91e096d
commit
389874c533
1 changed files with 9 additions and 7 deletions
|
|
@ -726,11 +726,15 @@ This can be useful when using docker to run a language server.")
|
||||||
(executable-find command)))
|
(executable-find command)))
|
||||||
|
|
||||||
(declare-function treesit-grammar-location "treesit.c")
|
(declare-function treesit-grammar-location "treesit.c")
|
||||||
|
|
||||||
|
(defun eglot--builtin-mdown-p ()
|
||||||
|
(and (fboundp 'markdown-ts-view-mode)
|
||||||
|
(fboundp 'treesit-grammar-location)
|
||||||
|
(treesit-grammar-location 'markdown)))
|
||||||
|
|
||||||
(defun eglot--accepted-formats ()
|
(defun eglot--accepted-formats ()
|
||||||
(if (and (not eglot-prefer-plaintext)
|
(if (and (not eglot-prefer-plaintext)
|
||||||
(or (fboundp 'gfm-view-mode)
|
(or (fboundp 'gfm-view-mode) (eglot--builtin-mdown-p)))
|
||||||
(and (fboundp 'markdown-ts-view-mode)
|
|
||||||
(treesit-grammar-location 'markdown))))
|
|
||||||
["markdown" "plaintext"]
|
["markdown" "plaintext"]
|
||||||
["plaintext"]))
|
["plaintext"]))
|
||||||
|
|
||||||
|
|
@ -2237,9 +2241,7 @@ Doubles as an indicator of snippet support."
|
||||||
|
|
||||||
(cl-defun eglot--format-markup
|
(cl-defun eglot--format-markup
|
||||||
(markup &optional mode
|
(markup &optional mode
|
||||||
&aux string lang render extract
|
&aux string lang render extract)
|
||||||
(built-in (and (fboundp 'markdown-ts-view-mode)
|
|
||||||
(treesit-grammar-location 'markdown))))
|
|
||||||
"Format MARKUP according to LSP's spec.
|
"Format MARKUP according to LSP's spec.
|
||||||
MARKUP is either an LSP MarkedString or MarkupContent object.
|
MARKUP is either an LSP MarkedString or MarkupContent object.
|
||||||
If MODE, force MODE to be used for fontifying MARKUP."
|
If MODE, force MODE to be used for fontifying MARKUP."
|
||||||
|
|
@ -2261,7 +2263,7 @@ If MODE, force MODE to be used for fontifying MARKUP."
|
||||||
(calc2 (forced-mode)
|
(calc2 (forced-mode)
|
||||||
(cond
|
(cond
|
||||||
(forced-mode `(,forced-mode))
|
(forced-mode `(,forced-mode))
|
||||||
(built-in `(,#'markdown-ts-view-mode))
|
((eglot--builtin-mdown-p) `(,#'markdown-ts-view-mode))
|
||||||
((fboundp 'gfm-view-mode) `(,#'gfm-view-mode ,#'gfm-extract))
|
((fboundp 'gfm-view-mode) `(,#'gfm-view-mode ,#'gfm-extract))
|
||||||
(t `(#'text-mode))))
|
(t `(#'text-mode))))
|
||||||
(calc (s &optional (forced-mode mode) &aux (x (calc2 forced-mode)))
|
(calc (s &optional (forced-mode mode) &aux (x (calc2 forced-mode)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue