vscode

Quiet in here? Check #calva-dev out :smiley:
kwladyka 2018-05-04T13:13:07.000023Z

hi guys, did you find solution for this issue https://github.com/PEZ/paredit-for-vscode/issues/3 ? This one makes for me too big mess in maps and I have to back to my old editor. I would like to solve it in some way.

pez 2018-05-04T13:24:56.000012Z

@kwladyka Thanks for reporting the issues. Is it just one issue? (I’m a bit tired so having a bit of troubles to unpack things.) How would you want the example:

{:a 1
 :b           2
 :c 3}
to be handled?

kwladyka 2018-05-04T13:30:18.000449Z

look at my last post. I show there 2 possibilities to indent maps. I believe there are only 2.

kwladyka 2018-05-04T13:30:54.000580Z

But another people like the second one, so probably the best idea is to make it configurable.

kwladyka 2018-05-04T13:31:00.000201Z

Like in Cursive

kwladyka 2018-05-04T13:31:48.000188Z

So summarising this up you can pay attention only to my last answer. Previous answers show the issue. Last one solution.

kwladyka 2018-05-04T13:32:01.000798Z

@pez ^

pez 2018-05-04T13:36:24.000789Z

I still don’t quite understand what the problem is, so the solution is a bit hard to understand too. 😃 Anyway, is it that the extension does not adjust the space between things, that is the problem?

pez 2018-05-04T13:37:03.000168Z

Might be the word indentation that trips me up.

kwladyka 2018-05-04T13:38:03.000522Z

the issue is maps looks like a mess. 1) on first screen we can see too many spaces between key and value 2) on second screen we can see keys and values are not aligned 3) on last 2 screens we can see right indentation and aligned

kwladyka 2018-05-04T13:38:38.000030Z

yes, probably i should use align instead of indentation

pez 2018-05-04T13:39:37.000126Z

It is starting to be clearer now. Explain number 2 a bit more. How does it differ from number 1?

kwladyka 2018-05-04T13:41:00.000728Z

2) :profiles {:dev {:dependencies [[figwheel-sidecar "0.5.15"] start correctly but next lines have bad indentation / alignment. This time it is not only about map key / value, but about values in more than 1 line. In this example vector.

kwladyka 2018-05-04T13:41:51.000240Z

this is what Crusive do with it

kwladyka 2018-05-04T13:42:17.000557Z

we can see above it looks very clear vs VSC

pez 2018-05-04T13:43:21.000251Z

Can you paste the edn here (the bad version) and I can experiment some and see if it gets clearer.

pez 2018-05-04T13:44:12.000114Z

I have similar code in my projects, but would be nice to have your exact example.

pez 2018-05-04T13:45:06.000194Z

I agree that Cursive seems to do it right.

kwladyka 2018-05-04T13:45:16.000665Z

https://github.com/PEZ/paredit-for-vscode/issues/3 added here

pez 2018-05-04T13:45:44.000243Z

Great!

kwladyka 2018-05-04T13:46:41.000302Z

❤️

pez 2018-05-04T13:48:29.000500Z

When I try it both Paredit and cljfmt indent things like so for the :profiles key:

:profiles {:dev {:dependencies [[figwheel-sidecar “0.5.15”]]
                   [binaryage/devtools “0.9.9"]
                   [com.cemerick/piggieback “0.2.2”]}}

pez 2018-05-04T13:49:03.000346Z

Still not quite like what you ask for, but tidier than in your example.

pez 2018-05-04T13:50:48.000291Z

Can you make it two different issues? Easier to track for me then. One is clearly about indentation and the other is about alignment of tokens 2 and up on a line, right?

pez 2018-05-04T13:51:07.000630Z

Also if you could tell me which issue is the most horrible. 😃

kwladyka 2018-05-04T13:54:32.000445Z

oh i found misspell there, but still there is an issue

pez 2018-05-04T13:54:41.000197Z

A problem for me here is that Calva and Paredit both format the code. (Calva even uses two different systems for it…) But it might be a workaround to see if cljfmt can be configured to indent and align things the way you like them to be. Then, even if paredit doesn’t do the right thing you could use Calva to tidy it up. No promises though. I do hope to find the time to look at it.

kwladyka 2018-05-04T13:54:57.000097Z

trying to make simpler example, but it sometimes work hmm

pez 2018-05-04T13:57:14.000176Z

That is interesting!

kwladyka 2018-05-04T13:57:59.000131Z

it looks like it depend on data, hang a sec

kwladyka 2018-05-04T14:00:53.000718Z

check example now: https://github.com/PEZ/paredit-for-vscode/issues/3 @pez

kwladyka 2018-05-04T14:04:07.000371Z

looks like a hard work to do 😉

pez 2018-05-04T14:12:26.000752Z

I still thin it is two separate issues. But I can handle it. 😃

pez 2018-05-04T14:16:05.000033Z

This is what Calva does with it, using cljfmt:

{:1 1
 :2                2
 :3 3
 :4 {:a [1 2
         3 4]}
 :5 {:a {:b [[1 2]
             [3 4]
             [5 6]
             [7 8]]}}
 :profiles {:dev {:dependencies [[figwheel-sidecar "0.5.15"]
                                 [binaryage/devtools "0.9.9"]
                                 [com.cemerick/piggieback "0.2.2"]]}}
 :6 [1                            2]}

pez 2018-05-04T14:17:01.000340Z

Then it looks like it is only the issue with alignment between tokens, right?

kwladyka 2018-05-04T14:17:28.000357Z

well I don’t even understand if Calva doing this or paredit extension 😉

kwladyka 2018-05-04T14:18:24.000003Z

yes, it looks like that

pez 2018-05-04T14:18:36.000407Z

No, I also lose track of that at times. I disabled Parinfer the other day because things got a bit too crazy,

pez 2018-05-04T14:19:54.000669Z

Anyway, when you barf and slurp and such, it is Paredit at work. And if you have Calva’s format on save active, it will format the file when you save it.

pez 2018-05-04T14:20:12.000564Z

Both do the same thing with your latest example, actually. They are generally in agreement.

kwladyka 2018-05-04T14:21:18.000349Z

it sound like only one tool should format code

pez 2018-05-04T14:21:26.000111Z

But with the bigger example both do the same thing too, and it is not as tidy.

pez 2018-05-04T14:22:40.000519Z

Yes, ideally only one tool should do that, but it is two separate extensions, and I hesitate to make Calva dependent on Paredit.

kwladyka 2018-05-04T14:23:23.000763Z

why in 2 extensions?

pez 2018-05-04T14:24:47.000867Z

You think Calva should include Paredit functionality? But for people who only want the Paredit stuff and uses some other extension for repl and whatever that would not be ideal.

kwladyka 2018-05-04T14:26:05.000126Z

I am not sure which tool should solve it, but I am sure for long term condition it has to be 1. It could be even Joker maybe.

kwladyka 2018-05-04T14:26:34.000681Z

Can you give an example why not in Paredit?

pez 2018-05-04T14:26:40.000603Z

I don’t think Joker deals with indentation/formatting.

pez 2018-05-04T14:26:53.000664Z

Why not Paredit what? 😃

kwladyka 2018-05-04T14:27:56.000046Z

> But for people who only want the Paredit stuff and uses some other extension for repl and whatever that would not be ideal. If you can extend this

pez 2018-05-04T14:30:56.000662Z

I mean. Calva is nice and all and my own first choice. But there are at least two other Clojure REPL extensions that are worth using. If I would have bundled Paredit with Calva, instead of keeping it an extension of itself, then those people choosing the other Clojure extensions would have hade to do with the old, unmaintained Paredit.

pez 2018-05-04T14:31:38.000525Z

Because it would get really weird for them to both use Calva and one of those other extensions.

pez 2018-05-04T14:33:24.000061Z

But what I could do is make Calva dependent of, and include, Paredit. And add an API to Paredit so that there wouldn’t be clashing formatting going on. It is just a lot of work and I only do this on my free time, which is not plenty.

WhoNeedszZz 2018-05-04T14:47:05.000693Z

I'm confused by the above. Paredit doesn't handle indentation, parinfer does

WhoNeedszZz 2018-05-04T14:47:44.000136Z

Or is there something off?

WhoNeedszZz 2018-05-04T14:47:50.000553Z

Perhaps some conflation

kwladyka 2018-05-04T14:48:17.000235Z

@whoneedszzz check example here https://github.com/PEZ/paredit-for-vscode/issues/3 to fast understand the issue

kwladyka 2018-05-04T14:49:11.000342Z

Personally I don’t know which extension should handle it, but it should be only 1 for sure.

WhoNeedszZz 2018-05-04T14:49:15.000210Z

See

Paredit & Parinfer

Calva works nicely together with Paredit. Make sure you use the maintained version. We call it Paredit Revived.

However Parinfer clashes with the auto adjustment of indents feature. Therefore Calva provides a command for toggling the auto adjustment off and on (ctrl+alt+v tab), just like Parinfer has commands for enabling and disabling its assistance.

Consider these settings for keeping auto adjust of indents on:

    "parinfer.defaultMode": "disabled",
    "calva.autoAdjustIndent": true,
Switch them around if you prefer to default to Parinfer on. We'll be looking for a solution to this problem.

WhoNeedszZz 2018-05-04T14:49:45.000102Z

Paredit is structural editing only

kwladyka 2018-05-04T14:53:03.000060Z

If I understand at that moment indentation / alignment do: Calva, Paredit and I guess Parinfer too.

kwladyka 2018-05-04T14:54:02.000529Z

*extensions for VSC

kwladyka 2018-05-04T14:55:00.000242Z

For some reason Cursive has option to choose Paredit / Parinfer while it does the same alignment / indentation whatever you choose.

kwladyka 2018-05-04T14:58:58.000878Z

But yeah for Paredit it does it only if i press shortcut

kwladyka 2018-05-04T14:59:03.000582Z

so the conclusion is:

kwladyka 2018-05-04T15:00:01.000537Z

Paredit - shouldn't do any formatting
Calva - shouldn't do any formatting. Maybe some Clojure corner cases?
Parinfer - should format code
Am I right?

kwladyka 2018-05-04T15:03:27.000476Z

But I don’t see in Parinfer extension shortucts to do barf forward etc. So it is also work to do.

kwladyka 2018-05-04T15:04:20.000217Z

Or it should be like that:

Parinfer - to format code
Paredit - to use shortcuts to edit code
Calva - to make it work with Clojure

kwladyka 2018-05-04T15:04:39.000197Z

@whoneedszzz What do you think?

WhoNeedszZz 2018-05-04T15:04:48.000514Z

The answer is in the above text

WhoNeedszZz 2018-05-04T15:05:02.000872Z

Calva and Parinfer clash

WhoNeedszZz 2018-05-04T15:05:22.000777Z

Only one indentation feature should be enabled at any given time

kwladyka 2018-05-04T15:05:24.000201Z

I am talking about goal to achieve

kwladyka 2018-05-04T15:05:54.000828Z

Paredit - shouldn't do any formatting
Calva - shouldn't do any formatting. Maybe some Clojure corner cases?
Parinfer - should format code
vs
Parinfer - to format code
Paredit - to use shortcuts to edit code
Calva - to make it work with Clojure

WhoNeedszZz 2018-05-04T15:05:59.000882Z

I think it makes sense to offer support for indentation without having to install parinfer

kwladyka 2018-05-04T15:06:55.000232Z

Why?

kwladyka 2018-05-04T15:07:23.000559Z

Besides of parinfer extension probably at that moment needs to be improved

WhoNeedszZz 2018-05-04T15:08:00.000663Z

Not relying on another maintainer

WhoNeedszZz 2018-05-04T15:08:13.000284Z

There's trade-offs for both

WhoNeedszZz 2018-05-04T15:09:00.000431Z

If you follow the "Do one thing and do it well" philosophy then you wouldn't want to

pez 2018-05-04T15:09:18.000459Z

I love parinfer, but not everybody does, so it becomes ”expensive” to get formatting for some people if they must use parinfer for it.

WhoNeedszZz 2018-05-04T15:09:31.000194Z

May be a good idea to make another Parinfer extension like Paredit

WhoNeedszZz 2018-05-04T15:09:46.000685Z

Expensive how?

pez 2018-05-04T15:10:17.000464Z

I have considered it. But first we should have a talk with the current maintainer.

pez 2018-05-04T15:10:55.000385Z

”expensive” as in having to endure parinfer.

kwladyka 2018-05-04T15:12:12.000015Z

@pez but as I understand Parinfer is to format code. So if somebody don’t want to use it means he doesn’t want to format code for him. Am I right?

kwladyka 2018-05-04T15:12:38.000422Z

Paredit is only for editing (barf forward etc.) without format code

kwladyka 2018-05-04T15:12:55.000267Z

So at least we should use Calva, Paredit, Parinfer

kwladyka 2018-05-04T15:13:04.000192Z

I am confuse 🙂

kwladyka 2018-05-04T15:13:08.000568Z

But it makes sense

kwladyka 2018-05-04T15:15:12.000676Z

Now everybody can choose: extension to format code (Parinfer), extension to edit code (Paredit) and extension for Clojure (Calva)

kwladyka 2018-05-04T15:16:08.000697Z

@whoneedszzz Am I right about extensions purpose?

WhoNeedszZz 2018-05-04T15:16:24.000136Z

I'm not a maintainer of any of those, but that's my understanding

WhoNeedszZz 2018-05-04T15:16:45.000424Z

I don't have any issues with how Parinfer functions

kwladyka 2018-05-04T15:20:09.000549Z

@pez conclusion

pez 2018-05-04T16:02:16.000447Z

My main issue with Parinfer is that it keeps nagging about reformatting files I open, even when I have toggled it off, and even when it is code that is not in the workspace.

pez 2018-05-04T16:03:37.000535Z

As the maintainer of Calva, and Paredit, I wish that Parinfer would have some API for coexistance, similar to the one I hope to be able to add to Paredit.

pez 2018-05-04T16:10:05.000198Z

And things are not as clear cut when it comes to which extension edits code and which formats it. I mostly use Parinfer in the mode where it edits my code, based on how I format it. I love when I can use both Paredit and Parinfer together. And I also like when code is indented correctly as I enter new lines, which is why I added auto indent to Calva. I considered using cljfmt for that, but decided against it, since it relies on the repl connection being active and responsive. So there are like four formatters in play when using Calva, Paredit and Parinfer. I can control at least three of those as the maintainer.

pez 2018-05-04T16:13:20.000130Z

Actually there might be a fifth formatter in play. I think Clojure code indents half OK even without any plugins. So vscode seems to have something built in. I am not sure of this, and should investigate it. Because that might be how this mess should be solved. If the built in formatter could be made to do the job really good, then the extensions could rely on that and concentrate on their respeciv main tasks.

pez 2018-05-04T16:17:56.000387Z

See my ramblings in the main thread. It is not as clear cut.

kwladyka 2018-05-04T16:46:38.000174Z

But at least we can agree formating code is not task for Paredit.

kwladyka 2018-05-04T16:47:31.000319Z

So we can do it in Calva or in Parinfer new version

pez 2018-05-04T16:55:39.000144Z

Still we have those who do not want to use Calva, nor Parinfer. We do agree that regardless who does the formatting, when editing code using Parinfer the code should get formatted, right?

kwladyka 2018-05-04T17:16:30.000352Z

I am not an expert about that but it make sense to split it in the way: paredit - structural editing, moving expressions parinfer - formating code calva - clojure integration so formating code should happen only in Parinfer extension and user choose which one want to use

kwladyka 2018-05-04T17:25:46.000116Z

But yeah at least if it will work stable nobody will complain if it happen in Parinfer or Calva

pez 2018-05-04T20:04:48.000460Z

Anyway, back to the issue. To me it seems like the indentation works, all three formatters involved in my setup, Calvas intent on return, Calva using cljfmt and Paredit all indent the maps provided correctly. What none of them helps with is the spacing between/alignment of tokens on the same line.