branch: elpa/clojure-ts-mode commit c2aedeb48830e74b344c04a2fd2e2a1e4b8e49e9 Author: Roman Rudakov <rruda...@fastmail.com> Commit: Bozhidar Batsov <bozhi...@batsov.dev>
[#60] Fix issue with fontification when markdown-inline is enabled Many thanks to Juri Linkov <j...@linkov.net> for his assistance. --- CHANGELOG.md | 1 + clojure-ts-mode.el | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 627b567dc4..ec08ddaca0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - [#74](https://github.com/clojure-emacs/clojure-ts-mode/issues/74): Add imenu support for keywords definitions. - [#77](https://github.com/clojure-emacs/clojure-ts-mode/issues/77): Update grammars to the latest versions. - [#79](https://github.com/clojure-emacs/clojure-ts-mode/pull/79): Improve markdown highlighting in the docstrings. +- [#60](https://github.com/clojure-emacs/clojure-ts-mode/issues/60): Fix issue with incorrect fontification, when `markdown-inline` is enabled. ## 0.2.3 (2025-03-04) diff --git a/clojure-ts-mode.el b/clojure-ts-mode.el index 8f89f47036..29fe1b2091 100644 --- a/clojure-ts-mode.el +++ b/clojure-ts-mode.el @@ -345,6 +345,7 @@ if a third argument (the value) is provided. (treesit-range-rules :embed 'markdown-inline :host 'clojure + :local t (clojure-ts--docstring-query '@capture))) (defun clojure-ts--font-lock-settings (markdown-available) @@ -1230,7 +1231,7 @@ It is simply `clojure-ts-docstring-fill-prefix-width' number of spaces." (defun clojure-ts--fill-paragraph (&optional justify) "Like `fill-paragraph', but can handler Clojure docstrings. If JUSTIFY is non-nil, justify as well as fill the paragraph." - (let ((current-node (treesit-node-at (point)))) + (let ((current-node (treesit-node-at (point) 'clojure))) (if (clojure-ts--match-docstring nil current-node nil) (let ((fill-column (or clojure-ts-docstring-fill-column fill-column)) (fill-prefix (clojure-ts--docstring-fill-prefix)) @@ -1260,11 +1261,20 @@ If JUSTIFY is non-nil, justify as well as fill the paragraph." "map_lit" "ns_map_lit" "vec_lit" "set_lit") "A regular expression that matches nodes that can be treated as lists.") +(defconst clojure-ts--markdown-inline-sexp-nodes + '("inline_link" "full_reference_link" "collapsed_reference_link" + "uri_autolink" "email_autolink" "shortcut_link" "image" + "code_span") + "Nodes representing s-expressions in the `markdown-inline' parser.") + (defconst clojure-ts--thing-settings `((clojure (sexp ,(regexp-opt clojure-ts--sexp-nodes)) (list ,(regexp-opt clojure-ts--list-nodes)) - (text ,(regexp-opt '("comment")))))) + (text ,(regexp-opt '("comment")))) + (when clojure-ts-use-markdown-inline + (markdown-inline + (sexp ,(regexp-opt clojure-ts--markdown-inline-sexp-nodes)))))) (defvar clojure-ts-mode-map (let ((map (make-sparse-keymap))) @@ -1380,7 +1390,6 @@ See `clojure-ts--font-lock-settings' for usage of MARKDOWN-AVAILABLE." (let ((use-markdown-inline (and clojure-ts-use-markdown-inline (treesit-ready-p 'markdown-inline t)))) (when use-markdown-inline - (treesit-parser-create 'markdown-inline) (setq-local treesit-range-settings clojure-ts--treesit-range-settings)) (when (treesit-ready-p 'clojure)