typescript-vim
typescript-vim copied to clipboard
Wrong indent with interfaces
Plugin corrects
interface foo {
a: number;
b: number;
}
to
interface foo {
a: number;
b: number;
}
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.
Same issue, it's disturbing.
I found the indent file from https://github.com/HerringtonDarkholme/yats.vim works well.
Is this project just unmaintained? Maybe time to start a fork.
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.
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.
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.
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.
@thejohnfreeman The indent support for ts (from whichever plugin) is still useful while you are typing in code?
@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.
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.
Same. Forced to use Prettier to clear this up.