Emacs 29 provides native tree-sitter support. But currently the functionality is
not integrated in the existing major modes, instead there exist new
<major-mode>-ts-mode
modes, which must explicitly be used to enjoy the new
tree-sitter based syntax highlighting. The problem with this approach is, that
if you use e.g. c-ts-mode
, the yasnippet-snippets for c-mode
are not
loaded.
The goal is to create an easy to setup and at the same time easy to remove
workaround, as long as it is required, which needs minimal
configuration. Therefore the .yas-parents feature is used, to create a folder,
for each -ts-mode
and link it to the snippets for the original mode.
After cloning the repository, make sure to include this snippet repository via
(add-to-list 'yas-snippet-dirs "/path/to/yasnippet-treesitter-shim/snippets/")
If you are using the straight.el
package manager with use-package
,
you can use the following to achieve the same:
(use-package yasnippet-treesitter-shim
:straight (:host github :repo "fbrosda/yasnippet-treesitter-shim"
:files ("snippets/*"))
:no-require t
:config
(add-to-list 'yas-snippet-dirs
(straight--build-dir "yasnippet-treesitter-shim")))