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

Comment-formatting is completely broken, both due to Fixedgq and GetTypescriptIndent #247

Open
ELLIOTTCABLE opened this issue Aug 31, 2021 · 2 comments

Comments

@ELLIOTTCABLE
Copy link

At the moment, the Fixedqg function for formatexpr completely breaks comment-formatting.

If I place the cursor as indicated in the below snippet,

class Foo {
  /*
   * ⁁I love chocolate oat cake apple pie ice cream jelly-o sweet. Sweet roll jujubes gummi bears soufflé cotton candy. Shortbread muffin bear claw muffin marshmallow donut I love bonbon jelly. Gingerbread sweet chocolate oat cake I love I love.
   */
  constructor(){}
}

... and attempt to use Vim's built-in gq comment-formatting mechanism (:set textwidth=80 fo+=cq], then use gqq or gq{motion}) … absolutely nothing happens. The extremely-long line stays all in one line.

If I disable the Fixedgq added by this plugin (:set formatexpr&), then it formats, but it gets super-weird and janky, because the indentexpr setting is attempting to take control inside comments:

class Foo {
  /*
   * I love chocolate oat cake apple pie ice cream jelly-o sweet. Sweet roll jujubes gummi bears
  * soufflé cotton candy. Shortbread muffin bear claw muffin marshmallow donut I love bonbon jelly.
    * Gingerbread sweet chocolate oat cake I love I love.
   */
  constructor(){}
}

The only way I've found to restore natural gq functionality is to disable both, which requires creating two separate dang files, unfortunately:

" $XDG_CONFIG_HOME/after/ftplugin/typescript.vim
setl formatexpr&
" $XDG_CONFIG_HOME/after/indent/typescript.vim
setl indentexpr&

Then I get sane output:

class Foo {
  /*
   * I love chocolate oat cake apple pie ice cream jelly-o sweet. Sweet roll jujubes gummi bears
   * soufflé cotton candy. Shortbread muffin bear claw muffin marshmallow donut I love bonbon jelly.
   * Gingerbread sweet chocolate oat cake I love I love.
   */
  constructor(){}
}

Getting gq working in comments properly is probably going to require a couple of changes to the indent-handling function; but I strongly suggest the user be allowed to entirely desable the "fixed" gq function. I'm perfectly happy with how vim's built-in gq operates; I don't what whatever 'fixes' this plugin is trying to apply! D:

@HerringtonDarkholme
Copy link
Owner

Thanks for reporting!

@raine
Copy link

raine commented Feb 8, 2023

What problem is Fixedqg supposed to solve? Quite annoying when you're used to formatting comments to tw with gq.

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

3 participants