Vscode-ruby: Sorry, but there is no formatter for 'ruby'-files installed.

Created on 19 Feb 2018  路  17Comments  路  Source: rubyide/vscode-ruby

Your environment

  • vscode-ruby version: master
  • Ruby version: 2.3.0
  • VS Code version: 1.20.1
  • Operating System: Ubuntu 16.04

Make sure you have ruby, ruby-debug-ide and ruby-debug-basex19 installed before submitting your issue -- thank you !

Expected behavior

I can use rubocop to do formatting

Actual behavior

I get the `sorry, but there is no formatter for 'ruby'-files installed.

Steps to reproduce the problem

On my machine, it is systematic. I've run under a debugger, and the line with registerDocumentFormattingEditProvider is executed.

Most helpful comment

I'm a VSCode noob and I just installed the Ruby extension and I'm seeing this error ("There is no selection formatter for 'ruby'-files installed.") whenever I do ==.

I understand progress is being tracked at #317, but I'm wondering if I'm fundamentally missing something here: am I to understand that there is no Ruby plugin in VSCode's ecosystem that knows how how to do basic auto-indentation in Ruby files, and that everyone doing Ruby in VSCode is forced to manually format/indent their code? I understand asking this question runs the risk of broadcasting open-source entitlement, but this is such a strange situation to me that I wonder if I'm somehow just misunderstand the ecosystem or how I'm "supposed" to be using VSCode with Ruby.

All 17 comments

same here

This is also happening to me.

Same here. :/

This will be addressed via #317. Please use that to track progress against it.

Did y'all figure this out?

Same happening here with me, however when I go to View > Command Palette and choose format it formats just fine.

Seems to be related just with my vim shortcut =G to format the whole file or if I select just a few lines and try to format it.

Using ALT+SHIFT+F for now to format the whole document works ok

seeing the same issue, even with format from view > command palette @jcarlos

This will be addressed via #317. Until then, if someone else debugs and submits a PR for a fix I'll be happy to take a look/merge.

Anyone have a workaround that they use?

This is sort of a key feature on an ide and this pops up on the google search result when looking for it.

Maybe someone has something working that we can use? Other than opening up Sublime text and using BeautifyRuby (which I hate to admit that I've been doing)

Same thing to here . If anyone fixes the issues/Found how to rectify this please update

I'm a VSCode noob and I just installed the Ruby extension and I'm seeing this error ("There is no selection formatter for 'ruby'-files installed.") whenever I do ==.

I understand progress is being tracked at #317, but I'm wondering if I'm fundamentally missing something here: am I to understand that there is no Ruby plugin in VSCode's ecosystem that knows how how to do basic auto-indentation in Ruby files, and that everyone doing Ruby in VSCode is forced to manually format/indent their code? I understand asking this question runs the risk of broadcasting open-source entitlement, but this is such a strange situation to me that I wonder if I'm somehow just misunderstand the ecosystem or how I'm "supposed" to be using VSCode with Ruby.

@machty The Ruby ecosystem in VSCode land is generally somewhat lacking, but its not as bad as one might think at first sight.

I guess you are using the Vim plugin because of ==. That one depends on a formatter that supports selections, which is currently not available (at least not that I'm aware of). But VScode's own indentation rules work fine, that's what triggers indentation when you simply press enter or use Reindent lines from the command palette.

Additionally, this extension here currently supports formatting via Rubocop (somewhat slow). There is also vscode-rufo, a plugin for an external formatter - that one works pretty good for stuff like "Format on save".

What is really non-existing, is proper support for formatting ERB files. (I'm currently working on a plugin for this myself, should be available in the near future, just need some free time to finish my prototype)

Thanks for the insight @kaiwood. I ended up remapping == to Reindent lines and that's more than enough for me right now. Hope you get the ERB plugin out soon!

Remapping == doesn't seem to be working. Can somebody paste their remapping configuration to make sure I have it right?

    "vim.normalModeKeyBindingsNonRecursive": [{
            "before": ["j"],
            "after": ["g", "j"]
        },
        {
            "before": ["k"],
            "after": ["g", "k"]
        },
        {
            "before": ["=", "="],
            "commands": ["editor.action.reindentselectedlines"]
        }
    ],

I've tried recursive and non-recursive (though it shouldn't make a difference for "commands" maps) as well as reindentlines and reindentselectedlines. My other mappings work so I know that remappings generally are taking effect, however I still get the selection formatter error when hitting ==.

Note to random Googlers (correct me if I'm wrong): you can follow this to get ruby formatting working: https://github.com/rubyide/vscode-ruby#formatting

If I understand correctly, #317 is targeted towards making some improvements to how it's implemented.

405 is the implementation for most of that ticket

Adding this setting in settings.js fixes that!

"files.associations": {
        "*.erb": "erb"
    }
Was this page helpful?
0 / 5 - 0 ratings