Comments (7)
We should adopt whatever style is predominant in nixpkgs.
Does that mean you prefer adopting predominant style over good/useful style?
Some of the stuff which is predominant right now is not good and negatively impacts editing workflow / git diffs etc., see for example: #248
If the ultimate goal is to establish a standard that is going to be enforced at some point in the future, shouldn't the first priority be to make that standard good and useful instead of adopting what is predominant right now?
For the current issue, I suggest that we just allow both styles (containers with and without space), because it really doesn't matter if there is a space or not. Maybe limiting the number of spaces to 1 could make sense.
from nixpkgs-fmt.
Some people see a formatter as a way to make code more beautiful, but beauty is subjective
So my perspective of a formatter is that it's a tool that avoid discussions of style A vs style B and standardizes code,
so people can focus on the soul of the software instead of its skin
To me, having a rule, even if ugly to some people (again, ugliness is subjective)
is more valuable than not having a rule
from nixpkgs-fmt.
When we wrote the rule my impression was that the space was predominant. We should adopt whatever style is predominant in nixpkgs.
from nixpkgs-fmt.
I think no space also has the advantage that it takes less horizontal space. And probably (but this is highly unscientific) your brain has it easier to parse it as its kind of "one token"
from nixpkgs-fmt.
Even putting personal preference aside, from a purely descriptivist standpoint no-space appears to be the predominant style in Nixpkgs:
$ cd nixpkgs
$ rg '\[ \]' | wc -l
2797
$ rg '\[\]' | wc -l
11617
$ rg '\{ \}' | wc -l
16714
$ rg '\{\}' | wc -l
23533
from nixpkgs-fmt.
Proposed implementation: #280
from nixpkgs-fmt.
Does that mean you prefer adopting predominant style over good/useful style?
It depends on how clear the improvement is. For example, here it could make things less consistent:
{
listA = [];
listB = [ 1 2 3 ];
}
vs
{
listA = [ ];
listB = [ 1 2 3 ];
}
In the second case, the whitespace is always present. To me, that seems like a simpler rule. I think most people are used to no spaces at all, in both listA and listB, coming from other languages and so would more readily adopt the first list.
It feels a bit nit-picky either way and I'm ready to change my mind. My only concern is that we aren't really representative of the community as a whole. That's when I think we should default to whatever is the most common. @r-burns showed that the no space is more common for empty lists so I guess we can go down that route.
from nixpkgs-fmt.
Related Issues (20)
- `error: input 'nixpkgs-fmt/fenix/naersk' follows a non-existent input 'naersk'` HOT 8
- Peculiar indentation choice HOT 1
- Wrong indentation on multi line if/then/else expression HOT 4
- Full line comment wrongfully converted to same line comment
- "#dontformat" directive HOT 4
- sample: list of floats formatted surpised me HOT 3
- improve CLI ergonomics when parsing errors occur when using parse flag HOT 1
- [Security] Make formatted expression free from CVE-2021-42574 (Trojan Source) HOT 5
- Misaligned lists of attribute sets HOT 1
- sample: List after in has no indentation
- Second comment line is indented after let … in
- Multi-line strings in let/in-expressions are wrongly indented
- Add a binary to Releases
- Re-release for security updates HOT 2
- Wrong indention for attr set as parameter
- Space removed before comments in multi-line inherit expressions HOT 1
- Add option to choose indention style HOT 2
- Confusing attset merging
- Shell completions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nixpkgs-fmt.