Skip to content

Check for extra def forms in the built-in font lock patterns - #171

Merged
bbatsov merged 2 commits into
mainfrom
fold-extra-def-forms
Nov 1, 2026
Merged

bbatsov merged 2 commits into
mainfrom
fold-extra-def-forms

Conversation

@bbatsov

@bbatsov bbatsov commented Nov 1, 2026

Copy link
Copy Markdown
Member

The forms in clojure-ts-extra-def-forms now go through the same defn and docstring patterns as defn, so the Markdown in their docstrings gets highlighted, and the rules added per buffer for them are gone. The function call rule had to move after the definition rules for that, which also fixes method and letfn names colored as calls at font-lock level 4.

@bbatsov
bbatsov force-pushed the fold-extra-def-forms branch from 1bec01d to 927b76f Compare November 1, 2026 09:11
At treesit-font-lock-level 4, the rule that highlights the head of
every list as a function call came before the definition rules, and
the first rule to set a face wins.  So the names of methods in
defrecord, reify and the like, and of letfn functions, were colored as
calls instead of definitions.  Move it after them.
The forms in clojure-ts-extra-def-forms got font lock rules of their
own, added to a buffer only when it had some, with code to keep the
user's disabled features disabled when adding them.  Their docstring
rule wasn't part of the range settings, so the Markdown in those
docstrings wasn't highlighted.

Check for them with a predicate in the defn and docstring patterns
instead.  That costs nothing measurable over the regexps it replaces,
and the Markdown range settings come with it.
@bbatsov
bbatsov force-pushed the fold-extra-def-forms branch from 927b76f to d33358e Compare November 1, 2026 10:38
@bbatsov
bbatsov merged commit 0ac4fc6 into main Nov 1, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant