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

Autoformatting Stops Working #228

Closed
nalanj opened this issue Feb 25, 2020 · 6 comments
Closed

Autoformatting Stops Working #228

nalanj opened this issue Feb 25, 2020 · 6 comments

Comments

@nalanj
Copy link

nalanj commented Feb 25, 2020

Do you want to request a feature or report a bug?

Bug

What is the current/expected behavior?

Autoformat for some reason stops working randomly for me. Restarting vim seems to restore it to the expected behavior. I haven't noticed any patterns around when it stops working. I've had this happen maybe 2 or 3 times in the past few weeks.

I'm only using a couple of very basic config options:

let g:prettier#autoformat = 1 
let g:prettier#autoformat_require_pragma = 0

What version of vim-prettier are you using - (output of :PrettierVersion) ?

1.0.0-alpha

What version of prettier are you using - (output of :PrettierCliVersion) ?

1.19.1

What is your prettier executable path - (output of :PrettierCliPath) ?

prettier

Did this work in previous versions of vim-prettier and/or prettier ?

I'm not completely sure due to the randomness of it not working.

@mitermayer
Copy link
Member

Hi there,

I'm not completely sure due to the randomness of it not working.

Can you describe a bit around this randomness ?

I've had this happen maybe 2 or 3 times in the past few weeks.

Is that with files that was previously working ? Do you recall any actions done prior such as changing buffers or having split windows ?

Can you also maybe provide vim version ?

Would love to help looking into this issue

@nalanj
Copy link
Author

nalanj commented Feb 28, 2020

Is that with files that was previously working ? Do you recall any actions done prior such as changing buffers or having split windows ?

It's definitely with files that were previously working. Typically I'll immediately check with :Prettier when I notice it didn't format and it will format, but the autoformatting will be disabled until I completely close vim. I'm not sure if it specifically relates to changing buffers or splitting windows, but I definitely do both of those things very frequently.

Can you also maybe provide vim version ?

8.1.1401. It's the Debian packaged vim.

Would love to help looking into this issue

Thanks! I'd love to help however I can, but I wasn't sure if there are any typical debugging steps from here.

@nalanj
Copy link
Author

nalanj commented Feb 29, 2020

So I switched to manually setting up an autocmd for it, and that seems to have resolved the issue (just in case anyone else hits this as well).

@mitermayer
Copy link
Member

Glad @nalanj was able to unblock himself, and apologies for not getting into this issue earlier. I have moved countries and now we are all facing this covid pandemic.

Slowly catching up with issues in this repo and hopefuly will be resolving all of them soon

@mitermayer
Copy link
Member

Closing this for now as I tried to reproduce this locally without success. If anybody else is able to reproduce this and can supply some steps on how to do so I can reopen this issue and work on it again

@gadkadosh
Copy link

I have had this problem too and I now think it is related to the ftplugins vim-prettier ships.
I'm not a vim expert, but it seems when vim-prettier loads the first time it declares autocmds for all supported file types. Then when I open a file for which an ftplugin (in vim-prettier) exists, if overrides the general autocmd (augroup Prettier) and I am left with an autocmd for just this single filetype, i.e. the last filetype to have been opened. Switching between hidden buffers (which is most of my vim workflow) does not lead to new autocmds being redeclared.
I'm not sure, but I feel like since we have the general autocmd, we don't need all of the ftplugin files. Does the parser need to be explicitly set for different filetypes? Doesn't prettier detect those automatically anyways?

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

3 participants