Set treesit-primary-parser for c and elixir ts mode
authorYuan Fu <casouri@gmail.com>
Sat, 14 Sep 2024 07:46:05 +0000 (00:46 -0700)
committerYuan Fu <casouri@gmail.com>
Sat, 14 Sep 2024 07:46:05 +0000 (00:46 -0700)
For buffers with multiple parsers, it's important to set this variable
so font-lock invalidation works smoothly.

* lisp/progmodes/c-ts-mode.el (c-ts-mode): Set treesit-primary-parser.
* lisp/progmodes/elixir-ts-mode.el (elixir-ts-mode): Set
treesit-primary-parser.

lisp/progmodes/c-ts-mode.el
lisp/progmodes/elixir-ts-mode.el

index 6c406a8acd953af404231498b25f2e0ff327b334..f5cd36c68c74100be3255e2647b0c55ae5d1c15d 100644 (file)
@@ -1318,7 +1318,8 @@ in your init files."
     ;; Create an "for-each" parser, see `c-ts-mode--emacs-set-ranges'
     ;; for more.
     (when c-ts-mode-emacs-sources-support
-      (treesit-parser-create 'c nil nil 'for-each))
+      (setq-local treesit-primary-parser
+                  (treesit-parser-create 'c nil nil 'for-each)))
 
     (treesit-parser-create 'c)
     ;; Comments.
index 815827ed13cb9580edd967b0b79c58ca7a7840f2..a3e11658468a683bb823ae3a3a2e89cc89bf3503 100644 (file)
@@ -701,7 +701,8 @@ Return nil if NODE is not a defun node or doesn't have a name."
       (require 'heex-ts-mode)
       (treesit-parser-create 'heex))
 
-    (treesit-parser-create 'elixir)
+    (setq-local treesit-primary-parser
+                (treesit-parser-create 'elixir))
 
     (setq-local treesit-language-at-point-function
                 'elixir-ts--treesit-language-at-point)