I've been reimplementing vim-sexp using neovim's treesitter, in case anyone's interested https://github.com/PaterJason/nvim-treesitter-sexp
Happy user so far!
@jason808 this is really cool, what was your motivation?
Was hacking around with lua and treesitter, found it relatively simple to implement some of the basics like swapping. Could handle things like namespaced maps that don't work in vim-sexp for basically free.
Oh, so you're grouping things that vim-sexp isn't? Nice!
Some of the #() is what catches me out most often.
The parsing part is already done for me, so I can just think in terms of nodes on the ast. If you run :InspectTree you can see it
Oh, I missed that one. I'll check it out. Quickly skipping over the code I've taken a bit of a different approach using treesitter queries rather than walking the tree and doing the language support in lua
I was searching yesterday for a modern implementation of the sexp plugin.
Nice one! Just so you know, recently https://github.com/julienvincent/nvim-paredit was posted here which seems to cover the same functionality? If that's the case it might make sense to combine efforts. I moved over to that one over the weekend and it has been working out great for me.
> Some of the #() is what catches me out most often. Ouch. Yeah, same here!
> Could handle things like namespaced maps that don't work in vim-sexp for basically free. this is so nice!
@jason808 should it be able to handle tagged literals? I tried treating the tag as an element (as it is in vim-sexp) but it seems the # character is not included in the tag element.
Tagged literals are treated as elements yes. As it stands, you'll need to put your cursor on the # as the tag symbol and the tagged element are themselves elements.
Got it.
So with the cursor on the # it treats both the tag and what comes after it as a single element.
If the cursor is in another part of the tag it treats the tag minus the # as an element.
For example #foo/bar [1 2 3] is an element, with foo/bar and [1 2 3] as child elements
Language support is powered by treesitter query files. So if we want to treat the thing as a form, it should be possible to modify the query file to do that.
> For example #foo/bar [1 2 3] is an element, with foo/bar and [1 2 3] as child elements
Got it. The use case that lead me to this is deleting tags used for debugging purposes; in this case grouping the # with foo/bar would be handy.
Hmm. There is promotion of elements with the <localleader>o /`<localleader>O` maps. If the tagged element were treated like a form the [1 2 3] could be promoted into it. I'll have a think
> Hmm. There is promotion of elements with the <localleader>o /`<localleader>O` maps. If the tagged element were treated like a form the [1 2 3] could be promoted into it. I'll have a think
Interesting! I think it's a valid approach.