Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add customization option to disable markdown syntax highlighting #59

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
- Fix semantic indentation of quoted functions
- Add custom `fill-paragraph-function` which respects docstrings similar to
`clojure-mode`.
- Add customization option to disable markdown syntax highlighting in the
docstrings.

## 0.2.2 (2024-02-16)

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ To highlight entire rich `comment` expression with the comment font face, set
By default this is `nil`, so that anything within a `comment` expression is
highlighted like regular clojure code.

### Highlight markdown syntax in docstrings

By default markdown syntax is highlighted in the docstrings using
`markdown_inline` grammar. To disable this feature set

``` emacs-lisp
(setopt clojure-ts-use-markdown-inline nil)
```

### Navigation and Evaluation

To make forms inside of `(comment ...)` forms appear as top-level forms for evaluation and navigation, set
Expand Down
13 changes: 10 additions & 3 deletions clojure-ts-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ double quotes on the third column."
:safe #'integerp
:package-version '(clojure-ts-mode . "0.2.3"))

(defcustom clojure-ts-use-markdown-inline t
"When non-nil, use Markdown inline grammar for docstrings."
:type 'boolean
:safe #'booleanp
:package-version '(clojure-ts-mode . "0.2.3"))

(defvar clojure-ts--debug nil
"Enables debugging messages, shows current node in mode-line.
Only intended for use at development time.")
Expand Down Expand Up @@ -1010,13 +1016,14 @@ See `clojure-ts--font-lock-settings' for usage of MARKDOWN-AVAILABLE."
\\{clojure-ts-mode-map}"
:syntax-table clojure-ts-mode-syntax-table
(clojure-ts--ensure-grammars)
(let ((markdown-available (treesit-ready-p 'markdown_inline t)))
(when 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)
(treesit-parser-create 'clojure)
(clojure-ts-mode-variables markdown-available)
(clojure-ts-mode-variables use-markdown-inline)
(when clojure-ts--debug
(setq-local treesit--indent-verbose t)
(when (eq clojure-ts--debug 'font-lock)
Expand Down