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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode formatOnSave #113

Closed
chevinbrown opened this issue Feb 15, 2019 · 12 comments

Comments

Projects
None yet
4 participants
@chevinbrown
Copy link

commented Feb 15, 2019

Metadata

  • Ruby version: 2.5.1
  • @prettier/plugin-ruby version: 0.6.1

Errything looks good from cmd/cli! 馃憦

The vs-code prettier plugin seems to reach for another tool? I've fooled around with a .prettierrc also, but I'm assuming this is still too new for the vscode plugin to have this parser integrated?

@dusty

This comment has been minimized.

Copy link

commented Feb 15, 2019

I use the vs-code prettier plugin and it works for me with plugin-ruby. However, you have to install the plugin in the vscode plugin directory as it appears it doesn't look inside your project or even globally for plugins.

cd ~/.vscode/extensions/esbenp.prettier-vscode-1.8.1/
npm install @prettier/plugin-ruby
@chevinbrown

This comment has been minimized.

Copy link
Author

commented Feb 15, 2019

@dusty

I've got this line in my settings.json:

  "[ruby]": {
    "editor.formatOnSave": true
  },

After your recommended step, I still get no action after "running save participants". 鈽癸笍

@dusty

This comment has been minimized.

Copy link

commented Feb 15, 2019

@chevinbrown

If I were to guess, I'd make sure that you have the most recent vscode-prettier plugin installed because I believe you will need prettier > 1.14. Also be sure to restart vscode after you added plugin-ruby to the vscode-prettier dir.

I don't have a specific ruby section in my config, but I do have editor.formatOnSave to true. I also don't have any other ruby plugins in vscode. Not sure if something else is taking over?

I found the tip from this thread

prettier/prettier-vscode#395

@chevinbrown

This comment has been minimized.

Copy link
Author

commented Feb 16, 2019

I've narrowed it down a bit--looks like the rubocop extension has some conflict?

[renderer1] [warning] Aborted format on save after 750ms is output in my window log when rubocop is enabled.
Everything works as expected when rubocop is disabled.

@kddeisz

This comment has been minimized.

Copy link
Member

commented Feb 17, 2019

I have no idea what's going on with this and I don't use vscode, so any help on this would be appreciated!

@kddeisz kddeisz added the help wanted label Feb 17, 2019

@chevinbrown

This comment has been minimized.

Copy link
Author

commented Feb 18, 2019

I'm also probably 0 help on the vs-code front. I suspect it's more an issue with the prettier plugin & rubocop.
I'll open an issue over here: https://github.com/prettier/prettier-vscode.

@somebody32

This comment has been minimized.

Copy link

commented Feb 19, 2019

@chevinbrown there is a setting in vscode called Format On Save Timeout, try to bump it to see if that helps. I suspect that running prettier and then rubocop together does not fit into 750ms

@chevinbrown

This comment has been minimized.

Copy link
Author

commented Feb 19, 2019

@somebody32 馃挄 that's about it...For some reason, rubocop is still is the "preferred" formatter (it seems to just ignore prettier)? In any case, with an opinionated linter I can accept not having rubocop lint... We'll probably lean towards throwing rubocop in CI instead of the editor.

@kddeisz

This comment has been minimized.

Copy link
Member

commented Feb 19, 2019

For yall that are using vscode, do I understand it correctly that you have https://github.com/rubyide/vscode-ruby installed and that its automatically running rubocop and that's timing out?

@chevinbrown

This comment has been minimized.

Copy link
Author

commented Feb 19, 2019

Not for me--I use solargraph...but I've just toggled between solargraph and vscode-ruby. Both run well alongside prettier plugin-ruby. 馃憤
It (prettier) fails to run properly as soon as I enable rubocop even when I have formatting "off" for soloargraph/vscode-ruby.

@kddeisz

This comment has been minimized.

Copy link
Member

commented Feb 25, 2019

I'm going to close this one in favor of tracking it over at prettier/prettier-vscode#731

@kddeisz kddeisz closed this Feb 25, 2019

@chevinbrown

This comment has been minimized.

Copy link
Author

commented Feb 25, 2019

Thanks for your work on this, @kddeisz!

czosel added a commit to czosel/plugin-php that referenced this issue Mar 2, 2019

Docs: Describe workaround for prettier-vscode
I found this workaround in
prettier/plugin-ruby#113 and confirmed that it
works. "Run on save" stopped working for me a while ago, so I'd
recommend using prettier-vscode with the workaround instead.

evilebottnawi added a commit to prettier/plugin-php that referenced this issue Mar 4, 2019

docs: describe workaround for prettier-vscode (#976)
I found this workaround in
prettier/plugin-ruby#113 and confirmed that it
works. "Run on save" stopped working for me a while ago, so I'd
recommend using prettier-vscode with the workaround instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.