Closed grierson closed 1 year ago
Agreed this will be useful to have, and should be straight forward to add. Will get around to it when I have a moment :)
Just a note that I don't think there's a way to select root elements / forms still. So there's no vaF
to select a whole defn
from anywhere inside the form for example. If I'm right in that assumption maybe I can add it soon.
You'll have to ignore the Fennel and custom macros for exporting values from the Lua module, but here's what I use in Conjure to select the root form in tree sitter across multiple languages.
So this may be a good template to rip off to get started with.
Ah you are right I forgot about the root form selections. Shouldn't be too difficult to add, if you want to take a stab at it go ahead :)
Otherwise I can look into it when I get a moment.
I'm working on this at the moment but a heads up that the tests seem to fail for the slurp/barfing in the Neovim nightly build. I swapped to stable and they run just fine. tests/nvim-paredit/barf_spec.lua
was the only failing file for me on Arch Linux, I see errors like:
Fail || barfing barfing backwards should barf different form types quoted list
./tests/nvim-paredit/utils.lua:34: Expected objects to be the same.
Passed in:
(table: 0x7f4118fe6c08) {
[1] = 1
*[2] = 0 }
Expected:
(table: 0x7f41193c6810) {
[1] = 1
*[2] = 2 }
stack traceback:
./tests/nvim-paredit/utils.lua:34: in function 'expect'
./tests/nvim-paredit/utils.lua:51: in function <./tests/nvim-paredit/utils.lua:40>
Yea I noticed this recently too, something changed upstream in nightly that's broken this plugin.
See #32 as well - split tests to allow running against either nightly or stable. Will try get nightly working again in that PR.
Ok I actually just disabled nightly for now and merged that PR. Running just test
will now use stable.
Nice, rebased my changes on this and opening a PR with my first pass now. I have selections and deletions working, will probably add more tests, may need to add more methods for visual selections too, mostly focussed on deletions so far.
Also you may find this useful: https://github.com/Olical/nfnl/blob/main/.github/workflows/test.yaml
It's my GitHub action tests I use to run Plenary Busted (like you do) in GitHub Actions across multiple Neovim versions. The downside is that it doesn't work locally the same way, I run the tests in whatever Neovim version I have installed locally.
Just thought I'd share in case you liked the way you can just add version numbers to the list.
The af and if objects selects forms The aF and iF objects select top-level forms.
Why
Replicate vim-sexp Text Object Selections
Clojure uses multiples types for surrounds
( { [
being able to refer to each with justf/F
makes text manipulation within Clojure much easier.Expected behaviour
Current form
(+ 1 1)
(Cursor anywhere within expression)()
deletes everything within formTop level form
(+ 1 (+ 2 3))
(Cursor within sub form)()
deletes everything within top level form