joaotavora / yasnippet

A template system for Emacs
http://joaotavora.github.io/yasnippet/
2.81k stars 311 forks source link

[Feature] Support tree-sitter #1157

Closed seagle0128 closed 10 months ago

seagle0128 commented 1 year ago

I am always enjoying this great package. Thanks a lot!

Recently Emacs 29 introduces native tree-sitter, and I read this interesting post: https://xenodium.com/emacs-generate-a-swift-initializer/ .

IMO, Context-aware yasnippets is amazing feature. I am not sure if it could be implemented in yasnippet, but please think about this idea. Thanks!

IcedQuinn commented 1 year ago

I seem to remember there is a way to hook snippets to be contextual. I did it once--years ago--where a snippet would do something in a comment and something else outside of it. But there was no way to really get the context outside of checking the font lock style. That was the only real context that existed in an emacs buffer at the time.

dgutov commented 1 year ago

I suppose yasnippet should now consider major-mode-remap-alist when deciding the snippets directory for the current mode.

Cons-Cat commented 10 months ago

Another interesting example of Tree Sitter snippet possibilities in Emacs can be seen here: https://blog.meain.io/2021/intelligent-snippets-treesitter/

monnier commented 10 months ago

Fancier snippets that make use of the richer syntax information provided by tree-sitter sound great. But these belong with the yasnippet-snippets rather than here, unless they require special support from YASnippet itself. So I'm closing this for now. Feel free to open a new issue if/when you find that such snippets indeed require special extra support from YASnippet.