-
Notifications
You must be signed in to change notification settings - Fork 285
Support for formatting/beautifying Ruby files #56
Comments
@HusseinElMotayam great idea! I'll put it on the list. |
@HusseinElMotayam, this seems like an easy win. I'll look at spinning up an option to use either For |
I'd be interested in implementing auto-correct functionality on the plugin. Rubocop supports the I'm thinking that I can pretty much copy the way linters are implemented for now, and mostly |
@slapresta IMO there are basically two ways of doing formatting or correction. The first one is Rubocop (or whatever library) telling us what part of content should be updated. The second one is Rubocop updates the local file and VS Code picks up the local update. I don't know whether Rubocop support the first solution but the second one concerns me as what if Rubocop changes local content and users change the buffer in VS Code as well? I don't have a clear idea about this but definitely you can give it a try, in whatever way. I like the idea of copying the way how linters do, you don't need to make this feature perfect at the very beginning :) |
any updates? |
@khuongduybui: Formatting is provided, as long as you have RuboCop installed. It doesn't touch the file on disk, so there is no need to worry about tainted editors or committing unsaved changes to disk. I've just made an update to the mechanics as well, so it will support |
@HusseinElMotayam, have you tried out my suggestion using my beautify extension for ERB? Also, are you happy with were the formatting for Ruby is at in this extension? |
@HookyQR how do I use that "formatting" feature? Using the normal Alt Shift F keyboard shortcut does not work. Ctrl Shift P does not reveal any "format" command either (with or without selection). |
If you right click on the document and the menu doesn't show "Format Document" then the extension doesn't know where to find If you can't run |
If you're getting linter responses, but can't use the formatting function, it's my fault. I've made a change today that should fix it, we'll have to wait for @rebornix to publish. |
@HookyQR yes, in fact I do get linter responses, along with my specific settings (such as ignoring some rules my team don't care about). |
Yep, that's my bad then. The previous version didn't check for the |
I updated to latest release and was able to get formatting to work. |
@HookyQR I noticed that Rubocop formatting didn't work before when inside vscode, that is why I logged this FR. |
It wasn't a thing when you opened this @HusseinElMotayam. Let me know if it's working for you. If the |
Well, the context menu is there and it is indeed formating. I'm currently using Ruby vscode extension version |
👍 +1 |
@HusseinElMotayam, the format that gets applied is dependant on the settings you have in your |
Any update on this? |
In the latest version I don't see the ruby.formatting option anymore. |
I'd be interested in a simpler way about this as well. |
Just wanna chime in that this doesn't work for me either - among other things, my project's
but when I attempt to format I get "the key combo cmd+K, cmd+F is not a command", suggesting that |
@suan actually we don't support format selections, which means right this moment, you can only use |
The task is a little dated, we're on v2.0.0 now for tasks |
@rebornix @HookyQR I’m still having an issue here – hoping you might be able to help. I installed the extension and added: "ruby.lint": {
"rubocop": true
} to my settings. I see inline listing, but I don’t have the |
Is it possible to trigger Ruby formatting inside of VS Code without having my |
@HookyQR hi, I've used your beautify extensions but it's still bad for .html.erb, it better if I rename the file to .html did you consider to add support for erb files like https://github.com/threedaymonk/htmlbeautifier? |
@buncismamen exactly, it's terrible when VSCode chews up our .html.erb files...hard to match proper closings, especially on larger files. Any updates @HookyQR ? |
I'm also very keen to hear more about this development in progress. Any update so far? |
@rebornix any plans to support format selections? |
@hackhowtofaq this is my PR for it microsoft/vscode#35594 @rebornix let me know if you have any suggestions or if I'm doing something non standard. I'm not too familiar with the vs code framework. Thanks |
It would be great to have support for Ruby formatting. Meanwhile I am also sharing my tasks JSON with tasks that support Ruby and Rails development.
|
Hey @interpegasus, thanks for sharing. These are neat. Keep in mind that vscode-ruby includes great support for reformatting with rubocop. Once set up it'll run rubocop -a for you automatically whenever you save a file. Just like your task, only using the builtin vscode formatting framework. Have fun! |
Hey I just created a extension for that so that we can format it naturally using vscode provided API. |
@aliariff would be nice if you can do it with ruby as well ;) |
@idoo there is rubocop for that |
@aliariff try to call |
@idoo which errror? |
@idoo That's likely due to how you've got it configured. I just merged #384 which aimed to improve that documentation. In addition, the branch |
This should be working correctly on |
Your environment
vscode-ruby
version: 0.5.6Expected behavior
It'd be great to have some formatting/beautifying functionality in the vscode-ruby plugin.
Actual behavior
As for now, there is no way to format/beautify .rb and .erb files inside vscode in a proper way.
Workaround
I worked around this by:
htmlbeautifier
andrbeautify
gems.Tasks
file as follows:The text was updated successfully, but these errors were encountered: