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

formatexpr is broken #261

Open
romainl opened this issue Nov 3, 2022 · 0 comments
Open

formatexpr is broken #261

romainl opened this issue Nov 3, 2022 · 0 comments
Assignees

Comments

@romainl
Copy link

romainl commented Nov 3, 2022

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: vim/vim#11493

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

No branches or pull requests

2 participants