Fork me on GitHub
#parinfer
<
2016-10-27
>
eraserhd00:10:59

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

cfleming00:10:02

@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.

cfleming00:10:44

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 🙂

eraserhd00:10:11

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

eraserhd01:10:09

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

eraserhd01:10:57

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

eraserhd01:10:14

Then, get the real thing working.

tianshu03:10:09

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")

snoe03:10:13

@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).

tianshu03:10:03

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

tianshu03:10:25

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

snoe03:10:44

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)

snoe03:10:20

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

snoe03:10:30

and would overwrite your mapping.

snoe03:10:56

luckily vim-sexp has =-

tianshu03:10:50

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

eraserhd22:10:23

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

snoe22:10:41

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,'$')

eraserhd22:10:29

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

eraserhd22:10:38

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

eraserhd22:10:55

Oh, that'd be interesting.

eraserhd22:10:33

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

eraserhd23:10:43

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

eraserhd23:10:09

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]))

eraserhd23:10:34

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.

eraserhd23:10:09

Some nses have docstrings, some don't.

snoe23:10:00

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

eraserhd23:10:47

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

snoe23:10:09

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

eraserhd23:10:22

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

snoe23:10:59

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: [] }