Skip to content

feat: update code to work with ruby-lsp-0.17.1#11

Open
aaronlifton wants to merge 1 commit into
jscharf:mainfrom
aaronlifton:main
Open

feat: update code to work with ruby-lsp-0.17.1#11
aaronlifton wants to merge 1 commit into
jscharf:mainfrom
aaronlifton:main

Conversation

@aaronlifton

Copy link
Copy Markdown
  • Update formatter runner to implement RubyLsp::Requests::Support::Formatter interface, implementing run_formatting
  • Update to register addon with global state, similar to the built-in Rubocop formatter in ruby-lsp
  • This allows the addon to work with version 0.17.1 of ruby-lsp, the latest version of ruby-lsp at time of writing

- Update formatter runner to implement RubyLsp::Requests::Support::Formatter
  interface, implementing `run_formatting`
- Update to register addon with global state, similar to the Rubocop
  formatter in `ruby-lsp`
- This allows the addon to work with version 0.17.1 of ruby-lsp
@cirdes

cirdes commented Jun 9, 2024

Copy link
Copy Markdown

I'm trying to make rubyfmt work with ruby-lsp on devcontainers but it's not working. I'm using ruby-lsp (0.17.2).

I have rubyfmt installed and can run it on the terminal and everything seems to be fine on ruby-lsp
Screenshot 2024-06-09 at 5 00 17 PM

This PR could solve my issue.

@schpet

schpet commented Jun 10, 2024

Copy link
Copy Markdown

just tried setting this up, and vscode shows me the following error:

Error loading addons: Ruby Fmt Formatter: wrong number of arguments (given 2, expected 0)

hoping confirmed this PR resolves it via

  # Gemfile
  gem 'ruby-lsp-rubyfmt', :git => 'https://github.com/aaronlifton/ruby-lsp-rubyfmt.git', :branch => 'main'

@cirdes

cirdes commented Jun 19, 2024

Copy link
Copy Markdown

@jscharf , any change to get this merged?

@jscharf

jscharf commented Oct 12, 2025

Copy link
Copy Markdown
Owner

@cirdes I would love to get this merged! One of my problems is that I've been away from this type of work for a while so I need to come up testing steps so I can test this locally before merging. I will try to get to this but any context you or others can help provide to get me caught up on what's changed in Ruby LSP integrations in the last year or so would be a big help.

@reese

reese commented Jan 13, 2026

Copy link
Copy Markdown

I'm also not terribly familiar with ruby-lsp, but at least a quick test of just bundling this commit works for me. As far as instructions go, all I think is needed is to

  1. Make sure your ruby-lsp extension is up to date.
  2. In the gemfile point it at this commit:
gem "ruby-lsp-rubyfmt", git: "https://github.com/jscharf/ruby-lsp-rubyfmt", ref: "cb26b5285bf254426d409148ae4ec22134aca324"
  1. bundle install
  2. Make sure rubyfmt is configured as your formatter in your VSCode settings. For me, it's the following in .vscode/settings.json:
{
    "[ruby]": {
        "editor.defaultFormatter": "Shopify.ruby-lsp",
        "editor.formatOnSave": true
    },
    "rubyLsp.formatter": "rubyfmt",
}
  1. Ruby LSP: Restart in the VSCode Command Palette
  2. Format a file on save and check that it works.

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

Successfully merging this pull request may close these issues.

5 participants