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

better nix-indent-line #42

Merged
merged 5 commits into from Jun 12, 2018
Merged

better nix-indent-line #42

merged 5 commits into from Jun 12, 2018

Conversation

yorickvP
Copy link
Contributor

@yorickvP yorickvP commented Jun 6, 2018

Two rules for indentation:

  1. lines starting with }, ], ) or in get indented to the same level as their matching token.
  2. any other lines get indented to the next level for their matching =, or 2, unless they start with let, with, [, { or (

These seem to work okay on simple nix files, and only take a few seconds (per line) on 2MB of attrsets. Let me know if you find any failure cases.

@matthewbauer
Copy link
Member

Awesome! Can you leave nix-indent-function as it was for now? That way we can avoid pushing this to people unless they've opted in.

@yorickvP yorickvP changed the title [wip] better nix-indent-line better nix-indent-line Jun 12, 2018
@yorickvP
Copy link
Contributor Author

@matthewbauer rebased it out

@matthewbauer matthewbauer merged commit 5a8b334 into NixOS:master Jun 12, 2018
@matthewbauer
Copy link
Member

Thanks!

@infinisil
Copy link
Member

How do I opt in?

@matthewbauer
Copy link
Member

M-x customize-variable<RET>nix-indent-function

@infinisil
Copy link
Member

Very nice, works wonderfully! (Although I'm not sure what this PR changed exactly, since I've used the default indenting method til now)

@matthewbauer
Copy link
Member

Yeah I think it will take a while to hit MELPA if you're using that. Previously it worked well for simple attribute sets but was really annoying for things like let & in (and any other weird hanging indentation stuff).

@infinisil
Copy link
Member

Ah then it's probably from this PR, the let in indentation works really well now. I'm using an override to get the latest version: infinisil/system@69850ad#diff-ead122d1171f94751babb654c3083b18R37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants