@eraserhd smart mode!
I still don't understand smart mode. It doesn't appear to do that. I might be sending in the previous cursor position wrong. Does it need changes to work?
Maybe I'm misunderstanding, the idea of smart mode is that you don't have paren/indent mode, you just make changes.
https://shaunlebron.github.io/parinfer/demo if you haven't tried it.
Huh, yeah. That's what I want 🙂
Yeah, it wants "changes". Hrmm.... How to synthesize in Vim.
What is changes?
A list of column, line number, old text and new text that can be sent to parinfer.
So the whole of the old buffer, whole of the new?
And I guess column and line number are where the cursor is?
Only thing I can think of is to keep a copy of the buffer somewhere, and send on TextChanged send both to parinfer, and then replace the copy with the new text.
@eraserhd crazy idea, reach into undo
Woot! got it working!
Undo doesn't update for each character typed in insert mode.
There's an event called InsertCharPre that works for a lot of typing, though it doesn't work for things like backspace. For those, I store the old position and text after updating them in TextChangedI.
I added code the FFI wrapper to compute the minimal change (assuming there's only one changed block).
Smart mode rocks! @shaunlebron
this is amazing
I need to switch immediately.
It might still die every so often, but I think at least it will tell us why now. Also, there are definitely rough edges.
Like, I think smart mode wants to know whenever the cursor moves. I'll have to figure out how to do that.
No. Rust is stable and web-scale. It will never crash.
Ha! I mean, I think it is, but you know, computers.
E216: No such event: TextChangedP <buffer> :call <SID>process(g:parinfer_mode,1)
E216: No such event: TextChangedP <buffer> :call <SID>process(g:parinfer_mode,1)
Looks like it's not nvim supporting anymore 😞I'll see about master
Ohhh. That was just added to Vim.
yep
I'll add a guard around it.
do you happen to know what patch it was?
Not really. I just vaguely remember the discussion.
make sure to guard on has('TextChangedP'), not on anything else
I'm gonna try the appimage dev build
pushed. (`exists('##TextChangedP')` actually)
weird 😮
Sorry, that's me being cautious against this not working in the future for neovim 😛
neovim doesn't have the patch on master so...
8.0.1494 is the patch
https://github.com/neovim/neovim/pull/7996 it's on the way
Is it bad practice to include the dylib/so files in the repo?
I wouldn't be against doing what fzf does: fetch them from the github releases using curl in response to a command
@eraserhd this is amazing, very fast.
Hmm, >>
doesn't indent the whole structure like I would expect
as in multiple lines?
I noticed it will leave a trailing paren if the cursor is to the left of the indent when using >>
. That's something I'm going to try to fix eventually.
(let [x]
{:foo 1
:bar 2})
>>
on the :foo
line becomes
(let [x]
{:foo 1}
:bar 2)
It's a shame that auto-indent doesn't work with parinfer either. I know we've covered this in the past.
You expect it to indent the :bar
line also, or you expect it to be indented inside the [
?
@eraserhd the :bar
being indent also is what I meant. But tabstops would be good too.
I think nvim-parinfer had a custom >>
for that reason.
IIRC, it's custom >>
just used the parinfer tab stops (and also ignored count, unfortunately).
I think >a)
is better for indenting a form, personally.
Parinfer exposes all the tabstops I'd guess, based on the visuals on the codemirror editor.
Yeah, I just haven't figured out how to make Vim use them.
I did a quick google and didn't see that it existed. I suspect it will be a case of overriding >
and >>
I looked into that, and... I'm not really sure how to override >
. All the motions following happen in "operator pending" mode, so scripts can add new ones, but in my cursory search, it seems like I'd have to override each sequence individually.
I use plenty of them: 3>>
, >i]
, 2<a)
, etc.
I'm actually wondering if, now that I have smart mode, I'll not need to use >>
in the same way. Hmm.
Well, my plan today is to dogfood the heck out of this, so we'll see. 🙂
Pushed a fix for one glaring error. Need a test suite 😞
The motion happens in operator pending, sure. But you can add an operator?
Yes, with omap. I don't know the details, though.
er, I mean, I guess that's the motion, not the operator, even though it's called "operator pending"?
So, I tracked down the random mac os abort! I think I can fix.
There's 'opfunc'
which is run by g@
. This is how cp
works in fireplace.
the custom >>
in nvim-parinfer.js is pretty hacky
I couldn’t figure out how to make vim use them either - especially since <<
and >>
might use different stops in parinfer
To my knowledge, there's no functionality for that :(