-;;; markdown-ts-mode.el --- tree sitter support for Markdown -*- lexical-binding: t; -*-
+;;; markdown-ts-mode.el --- major mode for Markdown -*- lexical-binding: t; -*-
;; Copyright (C) 2024-2025 Free Software Foundation, Inc.
:feature 'delimiter
'([ "[" "]" "(" ")" ] @shadow)
-
:language 'markdown
:feature 'paragraph
'([((setext_heading) @font-lock-keyword-face)
(defun markdown-ts-imenu-node-p (node)
"Check if NODE is a valid entry to imenu."
- (equal (treesit-node-type (treesit-node-parent node))
- "atx_heading"))
+ (equal (treesit-node-type (treesit-node-parent node)) "atx_heading"))
(defun markdown-ts-imenu-name-function (node)
"Return an imenu entry if NODE is a valid header."
(let ((name (treesit-node-text node)))
(if (markdown-ts-imenu-node-p node)
- (thread-first (treesit-node-parent node)(treesit-node-text))
+ (treesit-node-text (treesit-node-parent node))
name)))
(defun markdown-ts-setup ()
- "Setup treesit for `markdown-ts-mode'."
+ "Setup tree-sitter for `markdown-ts-mode'."
(setq-local treesit-font-lock-settings markdown-ts--treesit-settings)
(treesit-major-mode-setup))
(define-derived-mode markdown-ts-mode text-mode "Markdown"
"Major mode for editing Markdown using tree-sitter grammar."
(setq-local font-lock-defaults nil
- treesit-font-lock-feature-list '((delimiter)
- (paragraph)
- (paragraph-inline)))
+ treesit-font-lock-feature-list '((delimiter)
+ (paragraph)
+ (paragraph-inline)))
(setq-local treesit-simple-imenu-settings
- `(("Headings" markdown-ts-imenu-node-p nil markdown-ts-imenu-name-function)))
+ `(("Headings"
+ markdown-ts-imenu-node-p nil markdown-ts-imenu-name-function)))
(when (treesit-ready-p 'markdown)
(treesit-parser-create 'markdown-inline)
(derived-mode-add-parents 'markdown-ts-mode '(markdown-mode))
-(if (treesit-ready-p 'markdown)
- (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-ts-mode)))
-
(provide 'markdown-ts-mode)
;;; markdown-ts-mode.el ends here