Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"#dontformat" directive #265

Open
cab404 opened this issue Oct 22, 2021 · 4 comments
Open

"#dontformat" directive #265

cab404 opened this issue Oct 22, 2021 · 4 comments
Labels
enhancement New feature or request needs triage

Comments

@cab404
Copy link

cab404 commented Oct 22, 2021

Is your feature request related to a problem? Please describe.
Some blocks of code are just better formatted by humans:

colors = [
   "3A3C43" "BE3E48" "869A3A" "C4A535" "4E76A1" "855B8D" "568EA3" "B8BCB9"
   "888987" "FB001E" "0E712E" "C37033" "176CE3" "FB0067" "2D6F6C" "FCFFB8"
];

turns into

colors = [
   "3A3C43"
   "BE3E48"
   ...
   "2D6F6C"
   "FCFFB8"
];

Describe the solution you'd like
#dontformat directives, turning off formatting for a given code block:

colors = [
    #dontformat
    "3A3C43" "BE3E48" "869A3A" "C4A535" "4E76A1" "855B8D" "568EA3" "B8BCB9"
    "888987" "FB001E" "0E712E" "C37033" "176CE3" "FB0067" "2D6F6C" "FCFFB8"
    #/dontformat
];

Describe alternatives you've considered

  1. Per-block formatting, which would ignore formatting in tree and it's descendants
    {
        something = [
           #dontfornat
           "3A3C43" "BE3E48" "869A3A" "C4A535" "4E76A1" "855B8D"
        ];
        thiswillbeformatted = { a = 12; b = 5; };
    }
    
  2. Just giving up hope and accepting blackness of this formatter.
@cab404 cab404 added enhancement New feature or request needs triage labels Oct 22, 2021
@piegamesde
Copy link

I'd prefer what you call "per-block formatting", because I think writing end sequences for the directive is more tedious than it helps.

@zimbatm
Copy link
Member

zimbatm commented Oct 25, 2021

Potentially it could also target a specific rule if we give them proper names.

{
  # nixpkgs-fmt skip=list-formatting
  something = [
     "3A3C43" "BE3E48" "869A3A" "C4A535"
     "4E76A1" "855B8D"
  ];
}

tapayne88 added a commit to tapayne88/dotfiles that referenced this issue Dec 9, 2021
Would have liked to keep most of this but it currently doesn't support
ignore comments - see nix-community/nixpkgs-fmt#265
tapayne88 added a commit to tapayne88/dotfiles that referenced this issue Dec 12, 2021
Would have liked to keep most of this but it currently doesn't support
ignore comments - see nix-community/nixpkgs-fmt#265
@PAI5REECHO
Copy link

This is the only thing I've found missing from this tool. It's nice to be able to control whitespace indentation sometimes

@SuperSandro2000
Copy link
Member

Potentially it could also target a specific rule if we give them proper names.

This feels like the right way to do and aligns with other linter tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs triage
Projects
None yet
Development

No branches or pull requests

5 participants