Fork me on GitHub
#vim
<
2022-06-09
>
Dumch14:06:06

Does anyone folow this guide principle for one space indent for function arguments? And if yes, how to achieve this in vim? https://guide.clojure.style/#one-space-indent

dave14:06:33

I use 2-space indent, mostly because that's what Vim has always done 🤷

👍 1
sheluchin14:06:37

Seems like a tricky one to get working right while taking https://guide.clojure.style/#body-indentation into consideration.

dave14:06:11

Wow, excellent point! "Just use 2-space indent" is a nice pragmatic solution.

dave14:06:24

Unfortunately, Emacs, VS Code, etc. use 1-space indent out of the box.

dave14:06:40

So, my coworkers and I often end up inadvertently re-indenting each others' code whenever we touch it.

Dumch14:06:00

Idea/Cursive also has 2

dave14:06:21

Ooh, nice. So it's not just us Vimmers being weird

Dumch14:06:39

I will bring this topic to the general clojure channel, may be all the comunity should come to conclusion about this

dominicm15:06:21

There's an open issue about this

dominicm15:06:26

For many years

dominicm15:06:41

On the style guide issue tracker.

Dumch15:06:47

Thank you! I was just considering what should I do, having pr with 1-space-indents in my repo

dominicm15:06:03

Open source?

dominicm15:06:51

I might be inclined to just edit their commits prior to merge 😅

dominicm15:06:13

I do that on pack rather than ask people to write commits to my taste

💯 1
sheluchin15:06:30

That's quite the issue there in the tracker. I'm inclined to believe this nuanced rule does more harm than good. It makes it very difficult for everyone to use the same formatting and I'm not really sure what the benefit is.

☝️ 1
1
dominicm15:06:23

My suggestion is to try not to think about it. It's a long unhappy path of people trying to suggest one thing or another. This road is littered with well intentioned formatters and guides.

sheluchin15:06:53

lol good idea. I'm still trying to consolidate the overall ruleset with my preference to put "standard" first args like app, node, config, etc.. on the same line as the function while putting the remaining args indented one level, like:

(foo app
  bar
  :baz 1)

sheluchin15:06:39

And here I go not thinking about it by subscribing to the issue 😏

dominicm15:06:13

May you only have tumbleweed in your GitHub inbox tumbleweed

1
snoe17:06:48

so clojure-lsp does have reformatting with cljfmt if you need to match coworkers, with that you can do it within editor, or as a git hook calling cljfmt (through bb) to match coworkers. overall though, i push for formatting standards that are easiest for editors to agree on, cursive has even less control than clojure-static.

juhoteperi19:06:23

https://github.com/clojure-vim/clojure.vim#gclojure_align_subforms might work for 1-space indent style, though you probably need to control which forms then get the 2-space idennt. Cursive has an option for this also.

Dumch20:06:09

The problem is not about setting 1 or 2 spaces everywhere, but to have 1 space for method params and 2 — for body indentation. As I see Cursive can only set 1 space in every case