module: add :tools tree-sitter
This module installs 'tree-sitter' and 'tree-sitter-langs' as well as the 'evil-textobj-treesitter' and configures them. This module is based on the prototype module that @hlissner has started and I am just fleshing out that work. It also comes with a README file Fix: #4151
This commit is contained in:
parent
8a27eb99be
commit
862e7980d8
4 changed files with 152 additions and 0 deletions
32
modules/tools/tree-sitter/config.el
Normal file
32
modules/tools/tree-sitter/config.el
Normal file
|
@ -0,0 +1,32 @@
|
|||
;;; tools/tree-sitter/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(use-package! tree-sitter
|
||||
:when (bound-and-true-p module-file-suffix)
|
||||
:hook (prog-mode . tree-sitter-mode)
|
||||
:hook (tree-sitter-after-on . tree-sitter-hl-mode)
|
||||
:config
|
||||
(require 'tree-sitter-langs)
|
||||
(setq tree-sitter-debug-jump-buttons t
|
||||
tree-sitter-debug-highlight-jump-region t)
|
||||
|
||||
(defadvice! doom-tree-sitter-fail-gracefully-a (orig-fn &rest args)
|
||||
"Don't break with errors when current major mode lacks tree-sitter support."
|
||||
:around #'tree-sitter-mode
|
||||
(condition-case e
|
||||
(apply orig-fn args)
|
||||
(error
|
||||
(unless (string-match-p (concat "^Cannot find shared library\\|"
|
||||
"^No language registered\\|"
|
||||
"cannot open shared object file")
|
||||
(error-message-string e))
|
||||
(signal (car e) (cadr e)))))))
|
||||
|
||||
(use-package! evil-textobj-tree-sitter
|
||||
:after tree-sitter
|
||||
:config
|
||||
(map!
|
||||
:textobj "f" (evil-textobj-tree-sitter-get-textobj "function.inner") (evil-textobj-tree-sitter-get-textobj "function.outer") ;; redef
|
||||
:textobj "C" (evil-textobj-tree-sitter-get-textobj "class.inner") (evil-textobj-tree-sitter-get-textobj "class.outer")
|
||||
:textobj "c" nil (evil-textobj-tree-sitter-get-textobj "comment.outer")
|
||||
:textobj "i" (evil-textobj-tree-sitter-get-textobj "conditional.inner") (evil-textobj-tree-sitter-get-textobj "conditional.outer")
|
||||
:textobj "l" (evil-textobj-tree-sitter-get-textobj "loop.inner") (evil-textobj-tree-sitter-get-textobj "loop.outer")))
|
Loading…
Add table
Add a link
Reference in a new issue