From: Yuan Fu Date: Sat, 14 Sep 2024 07:46:05 +0000 (-0700) Subject: Set treesit-primary-parser for c and elixir ts mode X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b673e65517e8d51c309c0bd1a3e5b70aefe43465;p=emacs.git Set treesit-primary-parser for c and elixir ts mode 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. (cherry picked from commit 3cad7cc8dc823b8b1dd66d7777a01778e1a4defe) --- diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 7f23b30a88a..26b352874c2 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -1325,7 +1325,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))) (let ((primary-parser (treesit-parser-create 'c))) ;; Comments. diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el index 815827ed13c..a3e11658468 100644 --- a/lisp/progmodes/elixir-ts-mode.el +++ b/lisp/progmodes/elixir-ts-mode.el @@ -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)