summary refs log tree commit diff
path: root/emacs
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-06-26 14:13:15 -0700
committerFranck Cuny <franck@fcuny.net>2022-06-26 14:15:24 -0700
commitc88637df9f4b0a92ed048bf8dff507cb73118819 (patch)
tree0667195112a84452a878c16c22af185158fc3d27 /emacs
parentfix(prog): simplify flymake's configuration to work with eglot (diff)
downloademacs.d-c88637df9f4b0a92ed048bf8dff507cb73118819.tar.gz
feat(prog): enable tree-sitter
tree-sitter is an incremental parsing system, and this change installs
the binding for Emacs. It improves significantly the code highlighting
system (as it does not rely on regex when the language is supported by
tree-sitter) and improves performance in general.

Change-Id: Ibc3d6c7133b323d6cc63ffb248cd83f71ac5c94a
Diffstat (limited to 'emacs')
-rw-r--r--emacs/custom/my-prog.el9
-rw-r--r--emacs/init.el2
2 files changed, 11 insertions, 0 deletions
diff --git a/emacs/custom/my-prog.el b/emacs/custom/my-prog.el
index 65faad2..b1a0403 100644
--- a/emacs/custom/my-prog.el
+++ b/emacs/custom/my-prog.el
@@ -4,6 +4,15 @@
 
 ;;; Code:
 
+(require 'tree-sitter)
+(require 'tree-sitter-langs)
+;; enable tree-sitter mode for all supported major modes
+(global-tree-sitter-mode)
+;; the minor mode tree-sitter-hl-mode provides the framework for syntax
+;; highlighting. It overrides the regex-based highlighting provided by
+;; font-lock-mode, using the syntax tree provided by tree-sitter-mode
+(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode)
+
 (customize-set-variable 'Man-notify-method 'aggressive)
 (customize-set-variable 'Man-fontify-manpage-flag t)
 
diff --git a/emacs/init.el b/emacs/init.el
index 0582745..cb2fbfa 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -48,6 +48,8 @@
                           systemd
                           terraform-doc
                           terraform-mode
+                          tree-sitter
+                          tree-sitter-langs
                           vertico
                           which-key
                           yaml-mode