I debated whether to do this, since technically speaking it's
not needed for single-language modes. But ultimately it's
better to be explicit and set a good example with builtin modes.
* lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode):
* lisp/progmodes/csharp-mode.el (csharp-ts-mode):
* lisp/progmodes/dockerfile-ts-mode.el (dockerfile-ts-mode):
* lisp/progmodes/go-ts-mode.el (go-ts-mode):
(go-mod-ts-mode):
* lisp/progmodes/heex-ts-mode.el (heex-ts-mode):
* lisp/progmodes/json-ts-mode.el (json-ts-mode):
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode):
* lisp/progmodes/python.el (python-ts-mode):
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode):
* lisp/progmodes/sh-script.el:
* lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode):
(tsx-ts-mode):
* lisp/textmodes/css-mode.el (css-ts-mode):
* lisp/textmodes/html-ts-mode.el (html-ts-mode):
* lisp/textmodes/toml-ts-mode.el (toml-ts-mode):
* lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode): Set
treesit-primary-parser.
(cherry picked from commit
c436d4eff97b3919c9f8cdec504272d6f7ed393f)
:syntax-table cmake-ts-mode--syntax-table
(when (treesit-ready-p 'cmake)
- (treesit-parser-create 'cmake)
+ (setq treesit-primary-parser (treesit-parser-create 'cmake))
;; Comments.
(setq-local comment-start "# ")
(error "Tree-sitter for C# isn't available"))
;; Tree-sitter.
- (treesit-parser-create 'c-sharp)
+ (setq treesit-primary-parser (treesit-parser-create 'c-sharp))
;; Comments.
(c-ts-common-comment-setup)
:syntax-table dockerfile-ts-mode--syntax-table
(when (treesit-ready-p 'dockerfile)
- (treesit-parser-create 'dockerfile)
+ (setq treesit-primary-parser (treesit-parser-create 'dockerfile))
;; Comments.
(setq-local comment-start "# ")
:syntax-table go-ts-mode--syntax-table
(when (treesit-ready-p 'go)
- (treesit-parser-create 'go)
+ (setq treesit-primary-parser (treesit-parser-create 'go))
;; Comments.
(setq-local comment-start "// ")
:syntax-table go-mod-ts-mode--syntax-table
(when (treesit-ready-p 'gomod)
- (treesit-parser-create 'gomod)
+ (setq treesit-primary-parser (treesit-parser-create 'gomod))
;; Comments.
(setq-local comment-start "// ")
:group 'heex-ts
(when (treesit-ready-p 'heex)
- (treesit-parser-create 'heex)
+ (setq treesit-primary-parser (treesit-parser-create 'heex))
;; Comments
(setq-local treesit-thing-settings
(unless (treesit-ready-p 'json)
(error "Tree-sitter for JSON isn't available"))
- (treesit-parser-create 'json)
+ (setq treesit-primary-parser (treesit-parser-create 'json))
;; Comments.
(setq-local comment-start "// ")
(use-local-map lua-ts-mode-map)
(when (treesit-ready-p 'lua)
- (treesit-parser-create 'lua)
+ (setq treesit-primary-parser (treesit-parser-create 'lua))
;; Comments.
(setq-local comment-start "--")
\\{python-ts-mode-map}"
:syntax-table python-mode-syntax-table
(when (treesit-ready-p 'python)
- (treesit-parser-create 'python)
+ (setq treesit-primary-parser (treesit-parser-create 'python))
(setq-local treesit-font-lock-feature-list
'(( comment definition)
( keyword string type)
(unless (treesit-ready-p 'ruby)
(error "Tree-sitter for Ruby isn't available"))
- (treesit-parser-create 'ruby)
+ (setq treesit-primary-parser (treesit-parser-create 'ruby))
(setq-local add-log-current-defun-function #'ruby-ts-add-log-current-function)
:syntax-table rust-ts-mode--syntax-table
(when (treesit-ready-p 'rust)
- (treesit-parser-create 'rust)
+ (setq treesit-primary-parser (treesit-parser-create 'rust))
;; Syntax.
(setq-local syntax-propertize-function
(add-hook 'flymake-diagnostic-functions #'sh-shellcheck-flymake nil t)
(add-hook 'hack-local-variables-hook
#'sh-after-hack-local-variables nil t)
- (treesit-parser-create 'bash)
+ (setq treesit-primary-parser (treesit-parser-create 'bash))
(setq-local treesit-font-lock-feature-list
'(( comment function)
( command declaration-command keyword string)
:syntax-table typescript-ts-mode--syntax-table
(when (treesit-ready-p 'typescript)
- (treesit-parser-create 'typescript)
+ (setq treesit-primary-parser (treesit-parser-create 'typescript))
;; Indent.
(setq-local treesit-simple-indent-rules
:syntax-table typescript-ts-mode--syntax-table
(when (treesit-ready-p 'tsx)
- (treesit-parser-create 'tsx)
+ (setq treesit-primary-parser (treesit-parser-create 'tsx))
;; Comments.
(setq-local comment-start "// ")
(setq-local font-lock-fontify-region-function #'css--fontify-region)
;; Tree-sitter specific setup.
- (treesit-parser-create 'css)
+ (setq treesit-primary-parser (treesit-parser-create 'css))
(setq-local treesit-simple-indent-rules css--treesit-indent-rules)
(setq-local treesit-defun-type-regexp "rule_set")
(setq-local treesit-defun-name-function #'css--treesit-defun-name)
(unless (treesit-ready-p 'html)
(error "Tree-sitter for HTML isn't available"))
- (treesit-parser-create 'html)
+ (setq treesit-primary-parser (treesit-parser-create 'html))
;; Indent.
(setq-local treesit-simple-indent-rules html-ts-mode--indent-rules)
:syntax-table toml-ts-mode--syntax-table
(when (treesit-ready-p 'toml)
- (treesit-parser-create 'toml)
+ (setq treesit-primary-parser (treesit-parser-create 'toml))
;; Comments
(setq-local comment-start "# ")
:syntax-table yaml-ts-mode--syntax-table
(when (treesit-ready-p 'yaml)
- (treesit-parser-create 'yaml)
+ (setq treesit-primary-parser (treesit-parser-create 'yaml))
;; Comments.
(setq-local comment-start "# ")