Giter Site home page Giter Site logo

Ruby extension wants to set Shopify.ruby-lsp as default formatter, but then complains it can't format Ruby about vscode-shopify-ruby HOT 9 CLOSED

unikitty37 avatar unikitty37 commented on June 24, 2024
Ruby extension wants to set Shopify.ruby-lsp as default formatter, but then complains it can't format Ruby

from vscode-shopify-ruby.

Comments (9)

andyw8 avatar andyw8 commented on June 24, 2024

Hi @unikitty37, which version of the ruby-lsp gem is in use?

(either in Gemfile.lock or .ruby-lsp/Gemfile.lock)

from vscode-shopify-ruby.

andyw8 avatar andyw8 commented on June 24, 2024

Also can you try disabling the ruby-rubocop-revived extension.

from vscode-shopify-ruby.

unikitty37 avatar unikitty37 commented on June 24, 2024

Thanks — the installed version is ruby-lsp (0.5.1)

I've disabled ruby-rubocop-revived and now don't get the error — but I also can't format the Ruby code; I just get "There is no formatter for 'ruby' files installed." when I try.

from vscode-shopify-ruby.

andyw8 avatar andyw8 commented on June 24, 2024

Can you try adding this your settings, if not already present:

  "[ruby]": {
    "editor.defaultFormatter": "Shopify.ruby-lsp"
  }

from vscode-shopify-ruby.

vinistock avatar vinistock commented on June 24, 2024

Is rubyLsp.formatter configured to anything? And in the application you're using, do you have RuboCop or Syntax Tree installed to format files?

from vscode-shopify-ruby.

unikitty37 avatar unikitty37 commented on June 24, 2024

@andyw8 Thanks — that was already present in the settings.

@vinistock rubyLsp.formatter is configured to rubocop. RuboCop is installed globally; if I save a file as /tmp/foo.rb and run rubocop /tmp/foo.rb, it runs. But opening that file in VSCode and running the format command still produces "There is no formatter for 'ruby' files installed."

It also comes up with "Ruby LSP formatter is set to rubocop but RuboCop was not found in the bundle". This is odd, as this is just a .rb file in a folder — Bundler is not being used in this case.

I'm using rbenv, if that matters.

from vscode-shopify-ruby.

vinistock avatar vinistock commented on June 24, 2024

The Ruby LSP doesn't support running RuboCop from a global installation. It must be a part of your Gemfile or else it just gets ignored.

The reason for this is consistency. If multiple developers are working on the same codebase and they're all running global installations of RuboCop, there's no guarantee that the developers aren't running different versions, which may lead to different formatting results.

Additionally, if there's a version mismatch between the global installation and CI, then linting will fail on CI despite formatting being enabled in the editor.

from vscode-shopify-ruby.

unikitty37 avatar unikitty37 commented on June 24, 2024

Thanks — that explains it!

I've added a skeleton Gemfile (containing just the rubocop gem) to the folder and now it works 👍

from vscode-shopify-ruby.

bibstha avatar bibstha commented on June 24, 2024

The Ruby LSP doesn't support running RuboCop from a global installation. It must be a part of your Gemfile or else it just gets ignored.

@vinistock can we add a documentation somewhere with this instruction. I read many docs and only this comment made it clear why formatting wasn't working despite all the trials and errors.

from vscode-shopify-ruby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.