feat(tree-sitter): conditionally enable ts-hl-mode

Based on the new variable `+tree-sitter-hl-enabled-modes`

This allows for people to use tree sitters tools without having
to use it for highlighting.
Useful because some modes (such as web-mode and its derivatives) do a
better job than the tree sitter alternative in this respect.
This commit is contained in:
Jeetaditya Chatterjee 2022-07-25 00:31:57 +01:00 committed by Henrik Lissner
parent 4f23a02877
commit 8e68cd5ffd
2 changed files with 26 additions and 3 deletions

View file

@ -1,7 +1,17 @@
;;; tools/tree-sitter/config.el -*- lexical-binding: t; -*-
(defvar +tree-sitter-hl-enabled-modes '(not web-mode typescript-tsx-mode)
"A list of major modes which should be highlighted by tree-sitter.
If this list begins with `not', then it negates the list.
If it is t, it is enabled in all modes.
If nil, it is disabled in all modes")
;;
;;; Packages
(use-package! tree-sitter
:hook (tree-sitter-after-on . tree-sitter-hl-mode)
:defer t
:config
(require 'tree-sitter-langs)
;; This makes every node a link to a section of code