Fork me on GitHub
#parinfer
<
2018-03-20
>
eraserhd07:03:31

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?

dominicm07:03:29

Maybe I'm misunderstanding, the idea of smart mode is that you don't have paren/indent mode, you just make changes.

eraserhd08:03:25

Huh, yeah. That's what I want 🙂

eraserhd08:03:42

Yeah, it wants "changes". Hrmm.... How to synthesize in Vim.

dominicm08:03:29

What is changes?

eraserhd09:03:53

A list of column, line number, old text and new text that can be sent to parinfer.

dominicm09:03:08

So the whole of the old buffer, whole of the new?

dominicm09:03:46

And I guess column and line number are where the cursor is?

dominicm09:03:35

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.

dominicm09:03:07

@eraserhd crazy idea, reach into undo

eraserhd10:03:46

Woot! got it working!

eraserhd10:03:56

Undo doesn't update for each character typed in insert mode.

eraserhd10:03:49

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.

eraserhd10:03:14

I added code the FFI wrapper to compute the minimal change (assuming there's only one changed block).

dominicm11:03:05

this is amazing

dominicm11:03:12

I need to switch immediately.

eraserhd11:03:17

It might still die every so often, but I think at least it will tell us why now. Also, there are definitely rough edges.

eraserhd11:03:46

Like, I think smart mode wants to know whenever the cursor moves. I'll have to figure out how to do that.

dominicm11:03:53

No. Rust is stable and web-scale. It will never crash.

eraserhd11:03:51

Ha! I mean, I think it is, but you know, computers.

dominicm13:03:53

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 😞

dominicm13:03:20

I'll see about master

eraserhd13:03:39

Ohhh. That was just added to Vim.

eraserhd13:03:49

I'll add a guard around it.

dominicm13:03:51

do you happen to know what patch it was?

eraserhd13:03:09

Not really. I just vaguely remember the discussion.

dominicm13:03:18

make sure to guard on has('TextChangedP'), not on anything else

dominicm13:03:32

I'm gonna try the appimage dev build

eraserhd13:03:45

pushed. (`exists('##TextChangedP')` actually)

dominicm13:03:20

Sorry, that's me being cautious against this not working in the future for neovim 😛

dominicm13:03:30

neovim doesn't have the patch on master so...

dominicm13:03:06

8.0.1494 is the patch

snoe14:03:30

Is it bad practice to include the dylib/so files in the repo?

dominicm14:03:05

I wouldn't be against doing what fzf does: fetch them from the github releases using curl in response to a command

dominicm14:03:13

@eraserhd this is amazing, very fast.

dominicm14:03:52

Hmm, >> doesn't indent the whole structure like I would expect

eraserhd14:03:22

as in multiple lines?

eraserhd14:03:08

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.

dominicm14:03:13

(let [x]
  {:foo 1
   :bar 2})
>> on the :foo line becomes
(let [x]
    {:foo 1}
   :bar 2)

dominicm14:03:06

It's a shame that auto-indent doesn't work with parinfer either. I know we've covered this in the past.

eraserhd14:03:06

You expect it to indent the :bar line also, or you expect it to be indented inside the [?

dominicm14:03:36

@eraserhd the :bar being indent also is what I meant. But tabstops would be good too.

dominicm14:03:50

I think nvim-parinfer had a custom >> for that reason.

eraserhd14:03:57

IIRC, it's custom >> just used the parinfer tab stops (and also ignored count, unfortunately).

eraserhd14:03:50

I think >a) is better for indenting a form, personally.

dominicm14:03:55

Parinfer exposes all the tabstops I'd guess, based on the visuals on the codemirror editor.

eraserhd14:03:20

Yeah, I just haven't figured out how to make Vim use them.

dominicm14:03:45

I did a quick google and didn't see that it existed. I suspect it will be a case of overriding > and >>

eraserhd14:03:02

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.

eraserhd14:03:19

I use plenty of them: 3>>, >i], 2<a), etc.

eraserhd14:03:32

I'm actually wondering if, now that I have smart mode, I'll not need to use >> in the same way. Hmm.

eraserhd14:03:42

Well, my plan today is to dogfood the heck out of this, so we'll see. 🙂

eraserhd14:03:30

Pushed a fix for one glaring error. Need a test suite 😞

dominicm15:03:19

The motion happens in operator pending, sure. But you can add an operator?

eraserhd16:03:18

Yes, with omap. I don't know the details, though.

eraserhd16:03:57

er, I mean, I guess that's the motion, not the operator, even though it's called "operator pending"?

eraserhd16:03:47

So, I tracked down the random mac os abort! I think I can fix.

dominicm16:03:06

There's 'opfunc' which is run by [email protected]. This is how cp works in fireplace.

snoe16:03:47

the custom >> in nvim-parinfer.js is pretty hacky

snoe16:03:04

I couldn’t figure out how to make vim use them either - especially since << and >> might use different stops in parinfer

dominicm17:03:40

To my knowledge, there's no functionality for that :(