Fork me on GitHub
#parinfer
<
2016-08-20
>
tianshu16:08:14

which editor has a good support for parinfer?

shaunlebron16:08:04

none are perfect

shaunlebron16:08:09

i’d recommend atom and cursive

shaunlebron16:08:43

I think vim’s implementation is also good, though I haven’t checked in a long time

tianshu16:08:22

parinfer in atom seems can not calculate indent correctly when I start a newline.

tianshu16:08:08

and I think something like aggressive-indent-mode in emacs is necessary? otherwise some case I have adjust indent manually.

shaunlebron16:08:30

atom’s support for indentation is pretty bad

shaunlebron16:08:57

it relies on regex grammar for some reason, which makes it pretty hard to get indentation right on newline

tianshu16:08:25

it's really hard to find a good editor for clojure with all features work perfectly

shaunlebron16:08:22

i bet nightcode works really well

shaunlebron16:08:37

i can’t speak for other clojure features, but parinfer’s implementation has been limited a lot by editor APIs

shaunlebron16:08:54

they’re just not prepared for the fine control it needs

shaunlebron16:08:42

there are other problems that are not the editor’s fault too, some design problems I overlooked in the initial design

tianshu16:08:21

why not write a editor with built-in ast support? I mean save code as ast instead of plain text? I saw someone made demo, but they didn't continue their work.

shaunlebron16:08:11

Cirru I think is a leading example of that idea

shaunlebron16:08:06

he’s building an AST editor http://cirru.org/

shaunlebron16:08:30

it just won’t be popular in the clojure community because he’s getting rid of parens to do so

shaunlebron16:08:00

and the problem with outputting AST is that people still want text files for collaboration

tianshu16:08:37

convert plain text to AST after reading file, and convert AST to plain text before saving file

shaunlebron16:08:55

oh, i guess it’s possible if you save spacing information

tianshu16:08:01

does parinfer use AST?

tianshu16:08:15

what's the struct it use?

shaunlebron16:08:33

it uses a minimal one that tries to be compatible with different lisp dialects

shaunlebron16:08:19

like, it has a paren stack, knows about comments and strings and escaped characters, I think that’s it

shaunlebron16:08:59

it does a fast read over the whole file everytime it’s processed

shaunlebron16:08:07

is that your question?

tianshu16:08:21

that's it.

shaunlebron16:08:35

yeah, it would be impossible otherwise

tianshu16:08:47

does it save spacing information or align information?

tianshu16:08:16

{:a   10
 :long 20}

shaunlebron16:08:40

parinfer would preserve that, but not because it’s tracking it

shaunlebron16:08:06

it only modifies close-parens, with exception to some trailing spaces behind them

shaunlebron16:08:28

let me correct what i said about AST

shaunlebron16:08:10

it doesn’t remember the AST at the end of the run, it’s like a reader state that is mutated after every line

tianshu16:08:05

so It doesn't have to parse code to AST, instead it just mutate the state when typing?

shaunlebron16:08:47

for example, if the reader is currently at line 180 of the file, it had to parse lines 0-179

shaunlebron16:08:07

but the paren stack could be empty at 180

shaunlebron16:08:21

it doesn’t remember the states of the paren stack before then

shaunlebron16:08:36

it doesn’t track an AST, but it still reads and remember what it needs from the file

shaunlebron16:08:58

the former paren stack is irrelevant to it, so it doesn’t produce an AST

tianshu16:08:09

will this have a performance issue when there's so many lines?

shaunlebron16:08:24

we’ve run perf tests in both js and jvm

shaunlebron16:08:34

it seems really fast

shaunlebron16:08:56

i forget the numbers, but the repos have the perf commands documented if you want to try

tianshu16:08:24

really appreciate for your answers

tianshu16:08:47

I'm thinking about a editor written in React, with built-in AST support, for each command, simply modify the AST, let React redraw the code in UI. as it rendering code according to clojure indent guide style, so we will never have to indent code manually.

shaunlebron16:08:30

you mean it would aggressively apply cljfmt? https://github.com/weavejester/cljfmt

tianshu16:08:14

yes, need a library like this.

tianshu16:08:54

It seems there are many indent style in clojure. I saw a git repo https://github.com/bbatsov/clojure-style-guide the indentation is really complex, and editors such as nightcode, lighttable are not indent this way.

shaunlebron16:08:45

> It seems there are many indent style in clojure. I agree, people tend to favor different styles

shaunlebron16:08:38

(something foo
  bar)

(something foo
           bar)

shaunlebron16:08:30

the clojure style guide is not necessarily a complete description, but it does specify a lot

shaunlebron16:08:00

batsov’s is very opinionated, some of the rules are pretty restricting

tianshu16:08:24

which editor you prefer currently?

tianshu16:08:30

for daily coding

shaunlebron16:08:54

I’m currently fighting atom

shaunlebron16:08:03

I came from macvim

shaunlebron16:08:22

i’ve never given emacs an honest chance

shaunlebron16:08:40

I write js at my job, and cljs on side

shaunlebron16:08:30

I don’t use fancy editor debugging or nrepl integration in my editors though

tianshu16:08:13

i write python in the past, use vim without any debugging, completing. perhaps I should keep it simple, write clojure just with a REPL.

shaunlebron17:08:27

cursive’s features are pretty compelling though!

tianshu17:08:45

don't like cursive. too heavy

tianshu17:08:19

It's midnight now, I'm going to sleep