parinfer

eraserhd 2016-10-27T00:07:59.000085Z

AFAICT, parinfer-jvm has not been uploaded to clojars yet. Is it nascent? Should I use cross-parinfer?

cfleming 2016-10-27T00:09:02.000086Z

@eraserhd I think it’s pretty stable. Cursive’s solution is based on it (although doesn’t use the exact code) and I believe @sekao uses it in nightcode.

cfleming 2016-10-27T00:09:44.000087Z

I haven’t deployed it to clojars partly out of laziness and also because you’ll probably double the number of users if you use it 🙂

eraserhd 2016-10-27T00:11:11.000088Z

It looks like org.clojars.oaks/parinfer is the most recent version.

eraserhd 2016-10-27T01:21:09.000089Z

Welp, got a super-basic thing working, though not in the right way.

eraserhd 2016-10-27T01:21:57.000090Z

Next week or so: add modes and a hook for modifying all changes to a file.

eraserhd 2016-10-27T01:22:14.000091Z

Then, get the real thing working.

tianshu 2016-10-27T03:27:09.000093Z

Hi, @snoe . Will this be considered about? https://github.com/clojure-vim/nvim-parinfer.js/issues/22 each >> will change the struct of sexp, but we may want the correct indentation instead of the minimal indentation after >> operation. If we have:

(str "hello")
"world"
after >> on line 2, we probably want:
(str "hello"
     "world")
instead of
(str "hello"
 "world")

snoe 2016-10-27T03:41:13.000095Z

@doglooksgood I've been thinking about this, I feel the answer is to use a formatting plugin like clojure-static or clj-fmt after indenting and add do a =- (for instance) after indenting . However, I tried doing this, and it's difficult to do because of the way nvim-parinfer.js is mapping >> (you can't map a map).

tianshu 2016-10-27T03:44:03.000096Z

when doing (`>>` or > with multiple lines), saving the begin line number and end line number. after >>, use = to format this lines. is it possible?

tianshu 2016-10-27T03:45:25.000097Z

i'm not familiar with vim script. or you means the difficult stuff is how to map keys?

snoe 2016-10-27T03:45:44.000098Z

I don't think so, I believe with parinfer you pretty much always want to indent at the top level. (again, I haven't touched it for awhile)

snoe 2016-10-27T03:46:20.000099Z

yeah the plugin makes it difficult to map because vimrc stuff is run before plugins

snoe 2016-10-27T03:46:30.000100Z

and would overwrite your mapping.

snoe 2016-10-27T03:46:56.000101Z

luckily vim-sexp has =-

tianshu 2016-10-27T03:49:50.000105Z

I didn't know that vim-sexp has =-, with this shortcut i can quick indent top level manaully. it's still convenient.

eraserhd 2016-10-27T22:28:31.000106Z

Hrmm

eraserhd 2016-10-27T22:29:23.000107Z

wrt nvim-parinfer.js, I'd like to figure out how to make it stop touching files that I open.

snoe 2016-10-27T22:40:41.000108Z

I guess the place to start is looking at https://github.com/clojure-vim/nvim-parinfer.js/blob/master/plugin/parinfer.vim#L22 and figure out if lines differ from :echo getline(1,'$')

eraserhd 2016-10-27T22:48:56.000110Z

looking.

eraserhd 2016-10-27T22:49:29.000111Z

Just got familiar with the plugin code. Let me see if I can make a small test case first, though.

eraserhd 2016-10-27T22:53:38.000112Z

Hrmm, it kept happening when pairing today, but the only file it's happened on right now was literrally wrongly indented.

snoe 2016-10-27T22:56:05.000113Z

https://github.com/clojure-vim/nvim-parinfer.js/blob/master/src/nvim_parinfer/main.cljs#L42 I wonder if it's line endings, since vim doesn't give me those

eraserhd 2016-10-27T22:56:55.000115Z

Oh, that'd be interesting.

eraserhd 2016-10-27T22:57:33.000116Z

I don't have any CRs in any source files.

eraserhd 2016-10-27T23:01:43.000117Z

find src test dev -name '*.clj*' -type f -exec nvim -c :wq {} \; 🙂

eraserhd 2016-10-27T23:05:09.000118Z

yup that did it. Lots of stuff like this:

diff --git a/src/twou/centralpark/devcards.cljs b/src/twou/centralpark/devcards.cljs
index 0d81853..de0ec23 100644
--- a/src/twou/centralpark/devcards.cljs
+++ b/src/twou/centralpark/devcards.cljs
@@ -1,8 +1,8 @@
 (ns twou.centralpark.devcards
-  (:require
-   [twou.centralpark.devcards.domain]
-   [twou.centralpark.devcards.workflow]
-   [devcards.core :as dc :include-macros true]))
+ (:require
+  [twou.centralpark.devcards.domain]
+  [twou.centralpark.devcards.workflow]
+  [devcards.core :as dc :include-macros true]))

eraserhd 2016-10-27T23:09:34.000119Z

There's a lot of changes, but it looks like the changes are all either a) legitimate fixes, or b) dedenting the second line of the file (inside the ns directive) by one.

eraserhd 2016-10-27T23:10:09.000120Z

Some nses have docstrings, some don't.

snoe 2016-10-27T23:16:00.000121Z

I wonder if you pass the text through https://github.com/shaunlebron/parinfer/blob/master/lib/parinfer.js#L883 you still get the dedent

eraserhd 2016-10-27T23:17:47.000123Z

I'm going to bet so. Not sure I have time tonight, but I'll try it.

snoe 2016-10-27T23:20:09.000124Z

well, I'll bet my code's wrong, not shaun's 😛

eraserhd 2016-10-27T23:24:22.000125Z

ha, it does it with nvim-parinfer.js's project.clj.

eraserhd 2016-10-27T23:30:05.000126Z

The debug log. https://gist.github.com/eraserhd/df006649e34178cbac45901e1392523e

eraserhd 2016-10-27T23:35:05.000127Z

Here's the simplest example: https://gist.github.com/eraserhd/4d35251bb1f64d8a05fd983363fe765d

snoe 2016-10-27T23:47:59.000128Z

looks like i'm passing a negative cusrorDx

> parinfer.parenMode('(ab\n  :q)', {cursorX: 0, cursorDx: 0, cursorLine: 0})
{ text: '(ab\n  :q)',
  cursorX: 0,
  success: true,
  changedLines: [],
  tabStops: [] }
> parinfer.parenMode('(ab\n  :q)', {cursorX: 0, cursorDx: -6, cursorLine: 0})
{ text: '(ab\n :q)',
  cursorX: 0,
  success: true,
  changedLines: [ { lineNo: 1, line: ' :q)' } ],
  tabStops: [] }