kylechui / nvim-surround

Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua.
MIT License
3.18k stars 62 forks source link

Allow changing/deleting treesitter text-objects #52

Closed kylechui closed 2 years ago

kylechui commented 2 years ago

Theoretically speaking it should be possible to modify custom text-objects, so long as i[char] and a[char] are well-defined. For example, HTML tags can have a dynamic length, but it is still possible to discern where the tags are by "subtracting" g@at from g@it. Since there are other plugins like nvim-treesitter-textobjects that define objects for functions, it may be possible to define dsf and csf[char] by taking the "difference" of g@af and g@if. Furthermore, this would work across file types, due to Tree-sitter syntax parsing.

kylechui commented 2 years ago

There might be an issue with nvim-treesitter-textobjects upstream, so unsure if more progress will be made on this at the moment. The latest commit on the branch is broken, so please do not try to "daily drive" it (unless you are cloning it to contribute on it).

kylechui commented 2 years ago

Merging this issue into #60.