Skip to content

Commit

Permalink
Check for treesitter in prog-mode and text-mode buffers
Browse files Browse the repository at this point in the history
Instead of enumerating treesitter modes, we just ask every buffer
whether it's a treesitter buffer in its hook.
  • Loading branch information
adimit committed Mar 20, 2023
1 parent a617ded commit 8c54012
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions treesit-er-expansions.el
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,12 @@

(defun er/add-treesit-er-expansion ()
"Add the expansion for treesit mode."
(set (make-local-variable 'er/try-expand-list)
(append er/try-expand-list '(er/treesit-er-parent-node))))
(when (treesit-language-at (point))
(set (make-local-variable 'er/try-expand-list)
(append er/try-expand-list '(er/treesit-er-parent-node)))))

(er/enable-mode-expansions 'c-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'js-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'go-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'css-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'c++-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'html-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'yaml-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'bash-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'ruby-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'java-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'toml-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'json-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'rust-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'cmake-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'csharp-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'python-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'go-mod-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'tsx-ts-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'prog-mode 'er/add-treesit-er-expansion)
(er/enable-mode-expansions 'text-mode 'er/add-treesit-er-expansion)

(provide 'treesit-er-expansions)

Expand Down

0 comments on commit 8c54012

Please sign in to comment.