HerringtonDarkholme / yats.vim

Yet Another TypeScript Syntax: The most advanced TypeScript Syntax Highlighting in Vim
Vim License
649 stars 68 forks source link

formatexpr is broken #261

Open romainl opened 1 year ago

romainl commented 1 year ago

Steps to reproduce

  1. Put the following content in foo.ts (TypeScript sample taken from https://prettier.io/playground/):

    interface MyInterface {
     foo(): string,
     bar: Array<number>,
    }
    
    export abstract class Foo implements MyInterface {
     foo() {
               // TODO: return an actual value here
           return 'hello'
         }
     get bar() {
       return [  1,
    
         2, 3,
       ]
     }
    }
    
    type RequestType = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'OPTIONS' | 'CONNECT' | 'DELETE' | 'TRACE'
  2. Open it in a clean Vim:

    $ vim --clean foo.ts
  3. Format the whole buffer with the built-in formatexpr:

    gggqG
  4. Enjoy:

    interface MyInterface { foo(): string, bar: Array<number>, } export abstract class Foo implements MyInterface { foo() { // TODO: return an actual value here return 'hello' } get bar() { return [  1, 2, 3, ] } } type RequestType = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'OPTIONS' | 'CONNECT' | 'DELETE' | 'TRACE'

Expected behaviour

Something that generally looks like the input, but with better formatting, alignment, etc. Anything but everything mashed into a single line, really.

Version of Vim

9.0.20, 9.0.472, 9.0.828, 9.0.1276, 9.01313

Environment

Operating system: macOS 12.6.1 and now 13.3.1 but irrelevant Terminal: irrelevant $TERM: irrelevant Shell: irrelevant

Other considerations

The FixedGq() in $VIMRUNTIME/indent/typescript.vim and the one in this repo are essentially (not exactly) identical but I am not sure if there is an official maintainer for Vim's TS runtime file or if there is some kind of official relationship between this repo and Vim's TS runtime files. Either way, the one in Vim and this one are both broken.

Mirror issue opened in Vim's issue tracker: https://github.com/vim/vim/issues/11493