vim

2023-08-25T17:20:05.694009Z

I've been reimplementing vim-sexp using neovim's treesitter, in case anyone's interested https://github.com/PaterJason/nvim-treesitter-sexp

🙌 15
🙌🏻 1
🎉 10
emilaasa 2023-09-12T12:58:17.136319Z

Happy user so far!

😊 1
dominicm 2023-08-30T10:53:42.601239Z

@jason808 this is really cool, what was your motivation?

2023-08-30T17:39:06.465449Z

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.

🙌 1
dominicm 2023-08-30T17:39:44.352109Z

Oh, so you're grouping things that vim-sexp isn't? Nice!

dominicm 2023-08-30T17:39:58.299809Z

Some of the #() is what catches me out most often.

2023-08-30T17:45:47.971109Z

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

2023-08-29T08:43:09.464739Z

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

rafaeldelboni 2023-08-25T19:06:20.058349Z

I was searching yesterday for a modern implementation of the sexp plugin.

andre.stylianos 2023-08-28T09:00:01.946619Z

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.

andre.stylianos 2023-08-31T09:46:49.317309Z

> Some of the #() is what catches me out most often. Ouch. Yeah, same here!

1
fuad 2023-09-01T08:03:47.861659Z

> Could handle things like namespaced maps that don't work in vim-sexp for basically free. this is so nice!

fuad 2023-09-01T16:00:03.208779Z

@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.

2023-09-01T16:12:34.581459Z

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.

fuad 2023-09-01T16:14:56.778439Z

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.

2023-09-01T16:18:59.354769Z

For example #foo/bar [1 2 3] is an element, with foo/bar and [1 2 3] as child elements

2023-09-01T16:23:05.441299Z

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.

fuad 2023-09-01T16:27:45.612559Z

> 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.

2023-09-01T16:35:08.918279Z

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

fuad 2023-09-01T17:03:53.458869Z

> 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.