Skip to content
New issue

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

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

Already on GitHub? # to your account

Indentation for fn body misaligned when ( is on next line #152

Open
nikomatsakis opened this issue Apr 20, 2016 · 2 comments
Open

Indentation for fn body misaligned when ( is on next line #152

nikomatsakis opened this issue Apr 20, 2016 · 2 comments

Comments

@nikomatsakis
Copy link
Contributor

The fn body here indents as shown:

pub fn build_lane_table_states<'grammar>
    (grammar: &'grammar Grammar,
     start: NonterminalString)
     -> Result<Vec<LR1State<'grammar>>, LR1TableConstructionError<'grammar>> {
        let (lr0_states, lr0_conflicts) = match build::build_lr0_states(grammar, start) {
            Ok(s) => (s, vec![]),
            Err(e) => (e.states, e.conflicts),
        };

        unimplemented!()
    }

But I would expect:

pub fn build_lane_table_states<'grammar>
    (grammar: &'grammar Grammar,
     start: NonterminalString)
     -> Result<Vec<LR1State<'grammar>>, LR1TableConstructionError<'grammar>> {
    let (lr0_states, lr0_conflicts) = match build::build_lr0_states(grammar, start) {
        Ok(s) => (s, vec![]),
        Err(e) => (e.states, e.conflicts),
    };

    unimplemented!()
}

The trigger is definitely having the open paren on the next line. Admittedly, I wouldn't ordinarily write a fn this way, but it is produced by rustfmt in some cases.

@FelipeLema
Copy link

Hey, there

I implemented a fix to this issue in tree-sitter-indent.el.

I added the sample code as an unit test and it's currently passing.

One thing to note is that I de-dented the "->" return type line since it's currently a matter of discussion

@Hi-Angel
Copy link
Contributor

I'm wondering btw if there are plans on migrating to tree-sitter. For example, csharp mode seems has migrated.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants