GithubHelp home page GithubHelp logo

Indentation is way off about swift.vim HOT 3 CLOSED

supermarin avatar supermarin commented on May 18, 2024
Indentation is way off

from swift.vim.

Comments (3)

sharplet avatar sharplet commented on May 18, 2024

I have an example of some multi-line expressions that took a bit of work to format. Here's about what I would like:

let simple = Add(
               left: Number(1),
               right: Number(2)
             )

let complex = Multiply(
                left: Add(
                  left: Number(1),
                  right: Number(2)
                ),
                right: Number(3)
              )

But this is what you currently get:

let expression = Add(
                     // this level of indent is kind of ok
                     left: Number(1),
                     right: Number(2)
                     )
                 // <= but it would be nice for this to be back here

// <= indent should be reset back to the previous statement
//                   but is instead here, and we keep getting deeper!
                     let complex = Multiply(
                                            left: Add(
                                                      left: Number(1),
                                                      right: Number(2)
                                                      ),
                                                      right: Number(3)
                                                      )

Actually, here's the same thing in Ruby:

simple = Add.new(
  Number.new(1),
  Number.new(2)
)

complex = Multiply.new(
  Number.new(1),
  Add.new(
    Number.new(2),
    Number.new(3)
  )
)

Which is probably a much more sane approach:

let simple = Add(
  Number(1),
  Number(2)
)

let complex = Multiply(
  left: Number(1),
  right: Add(
    left: Number(2),
    right: Number(3)
  )
)

from swift.vim.

keith avatar keith commented on May 18, 2024

@sharplet this indentation around parens was actually intentional. Rather than aligning on colons like Objective-C this is setup to align on the opening paren similar to python. The second example is definitely an issue though. I'm definitely open to suggestions about this. Xcode currently indents this like this:

let bar = Add(
  left: 5,
  right: 6
)

from swift.vim.

keith avatar keith commented on May 18, 2024

@supermarin @sharplet if both of you could try the branch from this PR #30 that would be great. It entirely changes indentation. It is not currently handling the parens example any differently, but it should fix the other examples.

from swift.vim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.