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

Indentation of multiline maps/keyword lists/structs #87

Open
ghost opened this issue Mar 23, 2017 · 1 comment
Open

Indentation of multiline maps/keyword lists/structs #87

ghost opened this issue Mar 23, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Mar 23, 2017

If i try to indent a multiline map the plugin will indent the map incorrectly. For example, the auto-indented map will look like this.

%{foo: "bar",
baz: "buzz"}

Where it should be

%{foo: "bar",
  baz: "buzz"}

of note, if you try to make a map with newlines (i.e. javascript style), it auto-indents fine.

%{
  foo: "bar",
  baz: "buzz
}

however, this is not usually how elixir code is formatted. The same is true for keyword lists as well as structs.

@keathley
Copy link
Contributor

keathley commented Jun 6, 2017

Thanks @colbydehart!

I can try to take a look at this. The indenting regex is notoriously tricky. A friend of mine tried to have a go at fixing this and eventually gave up in frustration 😉.

I don't necessarily agree that the later example isn't normally how elixir code is formatted. I use that formatting for maps and keyword lists quite often. That said, it would be nice to make the "lisp" style formatting work out of the box. What I think we would need to do is add indentation rule that does something like finds a %{ or [ and a , on the same line then it should indent. IIRC there are more edgecases then that. If you would like to take a look at it that would be great. Otherwise I can but it'll be a bit before I can get to it.

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

No branches or pull requests

1 participant