Skip to content

Commit

Permalink
initialize treesitter as part of one-time symex initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
countvajhula committed Feb 21, 2025
1 parent 5f32acc commit 48b1a6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
18 changes: 8 additions & 10 deletions symex-ts.el
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@
`internal' means that Emacs has been compiled with native tree
sitter support. `external' means that the `elisp-tree-sitter'
package is being used instead."
(if (treesit-available-p)
(if (and (fboundp 'treesit-available-p)
(treesit-available-p))
'internal
'external))

(defun symex-ts--init ()
"Initialise tree sitter support for Symex.el."
(when symex-mode
(message "Initialising Symex-TS...")
(when (eq (symex-ts--current-ts-library) 'internal)
(symex-ts--init-treesit-builtin))))
"Initialise tree sitter support for Symex.el.
If treesitter isn't available, this doesn't do anything."
(message "Initialising Symex-TS...")
(when (eq (symex-ts--current-ts-library) 'internal)
(symex-ts--init-treesit-builtin)))

(defun symex-ts--init-treesit-builtin ()
"Initialise Symex tree sitter support via built-in tree-sitter library."
Expand Down Expand Up @@ -92,10 +94,6 @@ return nil."
(defalias 'symex-ts--root-node #'treesit-buffer-root-node)
t)

(require 'symex-transformations-ts)

(add-hook 'symex-mode-hook #'symex-ts--init)

(defun symex-ts-available-p ()
"Predicate to show if tree sitter support is available to Symex."
(and (fboundp 'treesit-available-p)
Expand Down
3 changes: 2 additions & 1 deletion symex.el
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ advises functions to enable or disable features based on user configuration."
;; initialize modal interface frontend
(symex-modal-provider-initialize)
;; initialize repeat command and other evil interop
(symex-initialize-evil))
(symex-initialize-evil)
(symex-ts--init))

(defun symex-disable ()
"Disable symex.
Expand Down

0 comments on commit 48b1a6a

Please sign in to comment.