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

Wrong indent with interfaces #133

Open
jpevarnek opened this issue Feb 2, 2018 · 12 comments
Open

Wrong indent with interfaces #133

jpevarnek opened this issue Feb 2, 2018 · 12 comments

Comments

@jpevarnek
Copy link

Plugin corrects

interface foo {
  a: number;
  b: number;
}

to

interface foo {
  a: number;
     b: number;
}
@mboughaba
Copy link

mboughaba commented Mar 13, 2018

This is also occurring with enums:

enum Foo {
  Bar = 'one',
  Bazinga = 'two'
}

Indenting with vim turns enum into:

enum Foo {
  Bar = 'one',
    Bazinga = 'two'
}

I am not sure where to start, looking at the indent file 😨
there is nothing specific for interfaces and enums.

@chemzqm
Copy link

chemzqm commented Jun 17, 2018

Same issue, it's disturbing.

@chemzqm
Copy link

chemzqm commented Jun 17, 2018

I found the indent file from https://github.com/HerringtonDarkholme/yats.vim works well.

@thejohnfreeman
Copy link

Is this project just unmaintained? Maybe time to start a fork.

@leafgarland
Copy link
Owner

Not unmaintained but low on my priorities right now - I'm happy to take in PRs but I don't have time to fix this indent issue.

Note, the indent file is almost entirely a copy of the indent file in https://github.com/pangloss/vim-javascript. This issue might be fixed by updating to their latest version.

@thejohnfreeman
Copy link

There are three ways to terminate member declarations in Typescript interfaces and object type aliases: semicolons, commas, and newlines.

interface foo {
  a: number;
  b: number;
}

interface foo {
  a: number,
  b: number,
}

interface foo {
  a: number
  b: number
}

The latest version of this plugin correctly indents all but comma-terminated member declarations within interface declarations (not within object type aliases). Such style might be uncommon, but it is legal. I was using it, but I'm not sure where I picked up the habit; perhaps from switching a type alias to an interface declaration. I'm going to change my personal style, but if this plugin wants to be 100% complete, it will need to handle that case.

@moofish32
Copy link

since I don't see this getting fixed I have disabled indent from this plugin and used https://github.com/jason0x43/vim-js-indent which seems to actually work.

@thejohnfreeman
Copy link

Although I still have this plugin installed (I guess for syntax highlighting), I've switched to using Prettier to format my TypeScript. It's a huge relief.

@leafgarland
Copy link
Owner

@thejohnfreeman The indent support for ts (from whichever plugin) is still useful while you are typing in code?

@thejohnfreeman
Copy link

@leafgarland Yes, the TypeScript indentation is still mildly useful. I believe it comes from this plugin (it is the only TypeScript-specific plugin I have, and I disabled vim-polyglot for TypeScript). However, JSX in TypeScript is not indented correctly, and so I rely on Prettier to fix it up for me.

@chemzqm
Copy link

chemzqm commented Feb 20, 2019

https://github.com/neoclide/coc-tsserver could provide on type format, which not only indent the lines, but also add/remove space according to your configuration when typing.

@geoyws
Copy link

geoyws commented Jun 28, 2019

Same. Forced to use Prettier to clear this up.

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

7 participants