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.
@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?look at my last post. I show there 2 possibilities to indent maps. I believe there are only 2.
Personally i prefer https://user-images.githubusercontent.com/3903726/39629544-db71cc00-4fac-11e8-9785-80ad7490881a.png
But another people like the second one, so probably the best idea is to make it configurable.
Like in Cursive
So summarising this up you can pay attention only to my last answer. Previous answers show the issue. Last one solution.
@pez ^
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?
Might be the word indentation that trips me up.
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
yes, probably i should use align instead of indentation
It is starting to be clearer now. Explain number 2 a bit more. How does it differ from number 1?
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.
this is what Crusive do with it
we can see above it looks very clear vs VSC
Can you paste the edn here (the bad version) and I can experiment some and see if it gets clearer.
I have similar code in my projects, but would be nice to have your exact example.
I agree that Cursive seems to do it right.
https://github.com/PEZ/paredit-for-vscode/issues/3 added here
Great!
❤️
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”]}}
Still not quite like what you ask for, but tidier than in your example.
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?
Also if you could tell me which issue is the most horrible. 😃
oh i found misspell there, but still there is an issue
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.
trying to make simpler example, but it sometimes work hmm
That is interesting!
it looks like it depend on data, hang a sec
check example now: https://github.com/PEZ/paredit-for-vscode/issues/3 @pez
looks like a hard work to do 😉
I still thin it is two separate issues. But I can handle it. 😃
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]}
Then it looks like it is only the issue with alignment between tokens, right?
well I don’t even understand if Calva doing this or paredit extension 😉
yes, it looks like that
No, I also lose track of that at times. I disabled Parinfer the other day because things got a bit too crazy,
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.
Both do the same thing with your latest example, actually. They are generally in agreement.
it sound like only one tool should format code
But with the bigger example both do the same thing too, and it is not as tidy.
Yes, ideally only one tool should do that, but it is two separate extensions, and I hesitate to make Calva dependent on Paredit.
why in 2 extensions?
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.
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.
Can you give an example why not in Paredit?
I don’t think Joker deals with indentation/formatting.
Why not Paredit what? 😃
> 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
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.
Because it would get really weird for them to both use Calva and one of those other extensions.
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.
I'm confused by the above. Paredit doesn't handle indentation, parinfer does
Or is there something off?
Perhaps some conflation
@whoneedszzz check example here https://github.com/PEZ/paredit-for-vscode/issues/3 to fast understand the issue
Personally I don’t know which extension should handle it, but it should be only 1 for sure.
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.
Paredit is structural editing only
If I understand at that moment indentation / alignment do: Calva, Paredit and I guess Parinfer too.
*extensions for VSC
For some reason Cursive has option to choose Paredit / Parinfer while it does the same alignment / indentation whatever you choose.
But yeah for Paredit it does it only if i press shortcut
so the conclusion is:
Paredit - shouldn't do any formatting
Calva - shouldn't do any formatting. Maybe some Clojure corner cases?
Parinfer - should format code
Am I right?But I don’t see in Parinfer extension shortucts to do barf forward etc. So it is also work to do.
Or it should be like that:
Parinfer - to format code
Paredit - to use shortcuts to edit code
Calva - to make it work with Clojure
@whoneedszzz What do you think?
The answer is in the above text
Calva and Parinfer clash
Only one indentation feature should be enabled at any given time
I am talking about goal to achieve
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
I think it makes sense to offer support for indentation without having to install parinfer
Why?
Besides of parinfer extension probably at that moment needs to be improved
Not relying on another maintainer
There's trade-offs for both
If you follow the "Do one thing and do it well" philosophy then you wouldn't want to
I love parinfer, but not everybody does, so it becomes ”expensive” to get formatting for some people if they must use parinfer for it.
May be a good idea to make another Parinfer extension like Paredit
Expensive how?
I have considered it. But first we should have a talk with the current maintainer.
”expensive” as in having to endure parinfer.
@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?
Paredit is only for editing (barf forward etc.) without format code
So at least we should use Calva, Paredit, Parinfer
I am confuse 🙂
But it makes sense
Now everybody can choose: extension to format code (Parinfer), extension to edit code (Paredit) and extension for Clojure (Calva)
@whoneedszzz Am I right about extensions purpose?
I'm not a maintainer of any of those, but that's my understanding
I don't have any issues with how Parinfer functions
@pez conclusion
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.
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.
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.
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.
See my ramblings in the main thread. It is not as clear cut.
But at least we can agree formating code is not task for Paredit.
So we can do it in Calva or in Parinfer new version
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?
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
But yeah at least if it will work stable nobody will complain if it happen in Parinfer or Calva
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.