parinfer

dominicm 2018-03-20T06:24:10.000258Z

@eraserhd smart mode!

eraserhd 2018-03-20T07:53:31.000233Z

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?

dominicm 2018-03-20T07:55:29.000122Z

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

dominicm 2018-03-20T07:55:43.000104Z

https://shaunlebron.github.io/parinfer/demo if you haven't tried it.

eraserhd 2018-03-20T08:07:25.000261Z

Huh, yeah. That's what I want 🙂

eraserhd 2018-03-20T08:16:42.000184Z

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

dominicm 2018-03-20T08:22:29.000218Z

What is changes?

eraserhd 2018-03-20T09:01:53.000348Z

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

dominicm 2018-03-20T09:08:08.000220Z

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

dominicm 2018-03-20T09:10:46.000367Z

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

dominicm 2018-03-20T09:13:35.000542Z

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.

dominicm 2018-03-20T09:55:07.000401Z

@eraserhd crazy idea, reach into undo

eraserhd 2018-03-20T10:01:46.000303Z

Woot! got it working!

eraserhd 2018-03-20T10:01:56.000432Z

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

eraserhd 2018-03-20T10:02:49.000127Z

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.

eraserhd 2018-03-20T10:03:14.000376Z

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

eraserhd 2018-03-20T10:05:22.000439Z

Smart mode rocks! @shaunlebron

dominicm 2018-03-20T11:14:05.000372Z

this is amazing

dominicm 2018-03-20T11:14:12.000097Z

I need to switch immediately.

eraserhd 2018-03-20T11:40:17.000238Z

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

eraserhd 2018-03-20T11:43:46.000116Z

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

dominicm 2018-03-20T11:43:53.000444Z

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

eraserhd 2018-03-20T11:44:51.000336Z

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

dominicm 2018-03-20T13:45:53.000433Z

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 😞

dominicm 2018-03-20T13:46:20.000432Z

I'll see about master

eraserhd 2018-03-20T13:47:39.000536Z

Ohhh. That was just added to Vim.

dominicm 2018-03-20T13:47:43.000033Z

yep

eraserhd 2018-03-20T13:47:49.000480Z

I'll add a guard around it.

dominicm 2018-03-20T13:47:51.000567Z

do you happen to know what patch it was?

eraserhd 2018-03-20T13:48:09.000268Z

Not really. I just vaguely remember the discussion.

dominicm 2018-03-20T13:48:18.000327Z

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

dominicm 2018-03-20T13:48:32.000537Z

I'm gonna try the appimage dev build

eraserhd 2018-03-20T13:50:45.000413Z

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

dominicm 2018-03-20T13:52:04.000593Z

weird 😮

dominicm 2018-03-20T13:52:20.000495Z

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

dominicm 2018-03-20T13:52:30.000413Z

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

dominicm 2018-03-20T13:53:06.000670Z

8.0.1494 is the patch

dominicm 2018-03-20T13:53:32.000576Z

https://github.com/neovim/neovim/pull/7996 it's on the way

snoe 2018-03-20T14:20:30.000743Z

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

dominicm 2018-03-20T14:22:05.000088Z

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

dominicm 2018-03-20T14:24:13.000394Z

@eraserhd this is amazing, very fast.

dominicm 2018-03-20T14:24:52.000557Z

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

eraserhd 2018-03-20T14:25:22.000599Z

as in multiple lines?

eraserhd 2018-03-20T14:26:08.000210Z

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.

dominicm 2018-03-20T14:26:13.000562Z

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

dominicm 2018-03-20T14:27:06.000038Z

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

eraserhd 2018-03-20T14:27:06.000688Z

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

dominicm 2018-03-20T14:27:36.000140Z

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

dominicm 2018-03-20T14:27:50.000409Z

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

eraserhd 2018-03-20T14:28:57.000267Z

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

eraserhd 2018-03-20T14:29:50.000392Z

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

dominicm 2018-03-20T14:29:55.000118Z

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

eraserhd 2018-03-20T14:30:20.000852Z

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

dominicm 2018-03-20T14:30:45.000798Z

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

eraserhd 2018-03-20T14:32:02.000330Z

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.

eraserhd 2018-03-20T14:33:19.000192Z

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

eraserhd 2018-03-20T14:34:32.000106Z

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

eraserhd 2018-03-20T14:36:42.000227Z

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

eraserhd 2018-03-20T14:51:30.000296Z

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

dominicm 2018-03-20T15:07:19.000707Z

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

eraserhd 2018-03-20T16:15:18.000251Z

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

eraserhd 2018-03-20T16:15:57.000120Z

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

eraserhd 2018-03-20T16:16:47.000090Z

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

dominicm 2018-03-20T16:41:06.000261Z

There's 'opfunc' which is run by g@. This is how cp works in fireplace.

snoe 2018-03-20T16:41:47.000739Z

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

snoe 2018-03-20T16:49:04.000901Z

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

dominicm 2018-03-20T17:19:40.000829Z

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