A major mode for Emacs providing really BASIC syntax highlight for markdown files using Treesitter.
Please note this provides very basic functionality. If you’re looking for a fully featured mature mode, please consider markdown-mode.
This package is available on MELPA. If you already have it set, add to your init.el
file:
(use-package markdown-ts-mode
:mode ("\\.md\\'" . markdown-ts-mode)
:defer 't
:config
(add-to-list 'treesit-language-source-alist '(markdown "https://github.com/tree-sitter-grammars/tree-sitter-markdown" "split_parser" "tree-sitter-markdown/src"))
(add-to-list 'treesit-language-source-alist '(markdown-inline "https://github.com/tree-sitter-grammars/tree-sitter-markdown" "split_parser" "tree-sitter-markdown-inline/src")))
Alternatively, download the markdown-ts-mode.el
file to a directory
of your liking. And add to your init.el
file the path:
(add-to-list 'load-path "~/you_liked_dir/")
(use-package markdown-ts-mode
:mode ("\\.md\\'" . markdown-ts-mode)
:defer 't
:config
(add-to-list 'treesit-language-source-alist '(markdown "https://github.com/tree-sitter-grammars/tree-sitter-markdown" "split_parser" "tree-sitter-markdown/src"))
(add-to-list 'treesit-language-source-alist '(markdown-inline "https://github.com/tree-sitter-grammars/tree-sitter-markdown" "split_parser" "tree-sitter-markdown-inline/src")))
Before using it, be sure you have BOTH markdown
and markdown-inline
grammars installed.
M-x treesit-install-language-grammar RET markdown RET
M-x treesit-install-language-grammar RET markdown-inline RET
Visit the tree-sitter-grammars repository, you’ll get redirected to
the split_parser
branch, since this is the default branch nowadays.
If you visit the main
branch, there’s a note communicating it is not
used anymore on the README.md
file.
Not my fault. The developers of tree-sitter-markdown decided so some years ago there would be 2 parsers, one to the “body” part of documents and one for “inline” statements.
So if you’re only seeing part of your markdown files highlighted, one of the grammars might be missing.
Visit a markdown file. Turn on the mode with markdown-ts-mode
.
Navigate trough headings with imenu
.
This shows the text provided by TEST.md file, with syntax highlighting using Treesitter.
To contribute, submit a pull request or report a bug. This package is aspiring to be part of GNU ELPA. Major contributions must be from someone with FSF papers.