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

Use nix-indent-line as the default indentation function #198

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

slotThe
Copy link
Member

@slotThe slotThe commented Mar 16, 2024

Somewhat closes #57

Basically, this change unifies nix-indent-line with SMIE, in that it uses the latter most of the time, only falling back to hand-baked indentation functions when SMIE would return something surprising. I've been using this for a few months, and haven't noticed any problems so far.

The changes so far are somewhat backwards incompatible, and should be seen as an extreme version of what they could be. I'm happy to e.g. completely revert 0f480d2 in case people think keeping these functions around is worthwhile.

Commit summary

nix-smie-rules: Fix indentation of ","

This seems deceptively simple, but there are actually quite a few situations that can occur; e.g.,

f = { a,    f = {    f = { a      f =       f =
      b       a,         , b        { a       {
    }         b          }          , b         a
            }                       }           , b
                                              }

Thankfully, smie already sanely handles all of these for us, so rely on that instead.

nix-indent-line: Use smie-indent-line in most cases

SMIE does not know how to handle multiline strings, but other than that it's quite a solid foundation—use it.

Make old indentation functions obsolete

SMIE is necessary now, and nix-indent-line is the one and only indent function to use.

[EXPERIMENTAL] Remove old nix-indent-line code

slotThe added 4 commits March 16, 2024 14:27
This seems deceptively simple, but there are actually quite a few
situations that can occur; e.g.,

    f = { a,    f = {    f = { a      f =       f =
          b       a,         , b        { a       {
        }         b          }          , b         a
                }                       }           , b
                                                  }

Thankfully, smie already sanely handles all of these for us, so rely on
that instead.
SMIE does not know how to handle multiline strings, but other than that
it's quite a solid foundation—use it.
SMIE is necessary now, and nix-indent-line is the one and only indent
function to use.
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.

nix-indent-line as default nix-indent-function
1 participant