Skip to content

Commit

Permalink
treesit-langs: add autoload and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ymarco committed Jun 17, 2022
1 parent acd5f2f commit e745a91
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions treesit-langs.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,24 @@
(require 'tree-sitter-langs)


(defun treesit-langs--reformat-shared-objects (&rest _args)
"tree-sitter-langs saves grammars as LANG.so, but treesit needs libtree-sitter-LANG.so"
(defun treesit-langs--reformat-shared-objects ()
"Make symlinks so *.so files are aliased to libtree-sitter-*.so in `tree-sitter-langs--bin-dir' .
Rationale: tree-sitter-langs saves grammars as LANG.so, but
treesit needs libtree-sitter-LANG.so."
(dolist (file (directory-files (tree-sitter-langs--bin-dir) 'full
(concat "\\" (car tree-sitter-load-suffixes) "$")))
;; make symlink libtree-sitter-c.so -> c.so
(concat (regexp-opt (list module-file-suffix)) "$")))
;; make a symlink so that libtree-sitter-c.so points to c.so
(make-symbolic-link file
(concat (file-name-as-directory (file-name-directory file))
"libtree-sitter-"
(file-name-nondirectory file)))))

(unless (file-exists-p (concat (tree-sitter-langs--bin-dir)
"libtree-sitter-c"
(car tree-sitter-load-suffixes)))
;; don't make symlinks *again*, we don't want stuff like
;; libtree-sitterlibtree-sitter-c.so
(unless (directory-files (concat (tree-sitter-langs--bin-dir)
"libtree-sitter-c"
(regexp-opt (list module-file-suffix))))
(treesit-langs--reformat-shared-objects))

(cl-pushnew (tree-sitter-langs--bin-dir) treesit-extra-load-path
Expand Down Expand Up @@ -88,8 +93,9 @@ elisp-tree-sitter) to a query string compatible with treesit."
(defvar-local treesit-langs-current-patterns nil
"Loaded query patterns for current buffer.")

;;;###autoload
(define-minor-mode treesit-langs-hl-mode
"TODO"
"Minor mode to enable syntax highlighting via `treesit'."
:init-value nil
:group 'treesit
(if treesit-langs-hl-mode
Expand Down

0 comments on commit e745a91

Please sign in to comment.