[Q] Why not use textobjects for everything? #672
|
Hello! I just got started using Conjure, and I have a question: Why does Conjure have its own set of "textobjects" when neovim already has textobjects? Conjure has so many variations on the "evaluate <this> and put it <here>" command, when most of them could be reasonably accomplished if there were just a single command that accepts a textobject - rather than having so many separate ones. Maybe it's here because it was just an early design decision? Ignoring the
Written more directly, the current interface could be almost entirely written with these commands:
... and these textobjects:
Wouldn't it be more flexible to define three commands and a few textobjects to replace the existing commands as a simpler and more flexible way to accomplish all this? The commands could even be made to accept a register (eg. I realize it's possible to remap these keys, so a composable |
Replies: 2 comments 7 replies
|
This decision of how the keys work was inspired by fireplace and CIDER and was designed at a time that treesitter didn't exist. This meant that I was limited to walking the code and using regexes to find the right pairs of parens. That plus the desire for logic like "evaluate a This decision ended up being hugely beneficial because it meant I could migrate all clients and users gracefully onto tree sitter with added features with backwards compatible support for those that do not wish to use tree sitter at all (you can still get by without it in lisp-y languages). I don't think I would do it differently, I like the control I have over the code selection, it's tightly integrated and coupled, but that has given me some nice control. What you're suggesting is decomplecting the selection of the code from the action, which I think is a noble effort, it's just a different approach with different tradeoffs. All operations require more key presses for instance, something some people are fine with, others would hate (the sheer number of options we support shows how we try to accommodate a large number of tastes and opinions at once 😄 ). I could see this being good as an option though, maybe. If you are decoupling code selection from evaluation though, I think Conjure shouldn't even define the text objects, at that point that's a plugin per language, like clojure-treesitter-text-objects, python-treesitter-text-objects etc all powered by something like https://github.com/nvim-treesitter/nvim-treesitter-textobjects (I have never dabbled with this, I have no idea how powerful it is). Then on the Conjure side an option could turn off the built in mappings and swap to a "I require text objects" mode, but it won't care what those are, it's up to the user to compose. Maybe Conjure can provide some behind an option, but I think it'd be overstepping boundaries if it provided them by default, that would be very surprising for most users. So in summary: I just took different design decisions back in the day, shaped by what Neovim features existed at the time and the original Conjure implementations (one was written in Clojure as a remote plugin). We could do this now, but it'd be an alternate control scheme you opt into with different tradeoffs. An interesting idea though! |
|
Could you share what programming language you are working with when using Conjure? It could help to understand your workflow; what your pain points are; and how things might be composed to help you get things done with minimal friction. The Fennel tutorial and reference should help you on your fennel-lang journey. You should also be aware of the built-in functions that Neovim has and the functions that nfnl provides (see the api docs). You can ignore the Aniseed stuff because nfnl can replace most things that it provides. Most of the Aniseed functions have been upgraded to nfnl but you may see a few that haven't been. To create mappings, you would use the Neovim functions. The help docs detail the Lua functions and their parameters but you'll need to convert that to Fennel syntax. There is a Lua <-> Fennel converter available to help this mental transition. Why Fennel? should also help with the differences between Fennel and Lua. An example of the current imperative tree sitter walking code selection can be seen in the Python client. It defines the form-node? function so that it grabs pieces of code that are appropriate for Python. |
This decision of how the keys work was inspired by fireplace and CIDER and was designed at a time that treesitter didn't exist. This meant that I was limited to walking the code and using regexes to find the right pairs of parens. That plus the desire for logic like "evaluate a
(comment)block but ignore the comment and evaluate the first level of form below that your cursor is within" makes it easy (in my opinion) to justify implementing the code selection in the code itself.This decision ended up being hugely beneficial because it meant I could migrate all clients and users gracefully onto tree sitter with added features with backwards compatible support for those that do not wish to u…