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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add custom plugin to ruby-lsp without changing app Gemfile #3055

Open
djtal opened this issue Jan 13, 2025 · 4 comments
Open

How to add custom plugin to ruby-lsp without changing app Gemfile #3055

djtal opened this issue Jan 13, 2025 · 4 comments

Comments

@djtal
Copy link

djtal commented Jan 13, 2025

Hello

I would like to add some plugins to,my ruby-lsp install.
I use neovim with the lsp-config plugin as said in the doc.
The ruby-lsp is not in our app Gemfile and we cannot change that. If I understand properly, it use the .ruby-lsp/Gemfile which is auto-generated at startup time.

I've try adding the brakeman lsp plugin as stated by the post https://dev.to/presidentbeef/brakeman-lsp-support-15i3 in the generated Gemfile. But each time ruby-lsp start it re-create the proper Gemfile and ignore any of my additions.

How to achieve this behaviour, can we customize the Gemfile generation or can I provide a personal custom Gemfile for ruby lsp ?

Is there a way to specifiy something like that in a ruby-lsp statup flag or environment variable ?

Thanks

@adam12
Copy link
Contributor

adam12 commented Jan 13, 2025

Can you try adding the Brakeman LSP plugin to your application's Gemfile? The Ruby LSP creates a Gemfile which will evaluate your application Gemfile as well, which should allow the plugin to be detected.

@djtal
Copy link
Author

djtal commented Jan 14, 2025

Hello

Thanks for the response.

Yes it work if I add it to our app.
But we don't want to add gem related to lint (and developper tooling in general) to the gemfile. In the same way that we don't add ruby-lsp in the app Gemfile.
Not all the team use the same tools and we prefer to avoid each one add gems other than the one required by the app.

@adam12
Copy link
Contributor

adam12 commented Jan 14, 2025

In that case, I believe your only option is to use a custom Gemfile.

To have the Neovim LSP start with that custom Gemfile, you'll need to modify the lspconfig table and set an environment variable.

Untested.

local lspconfig = require('lspconfig')

lspconfig.ruby_lsp.setup({
  cmd_env = {
    BUNDLE_GEMFILE = '/path/to/your/custom/gemfile'
  }
})

@vinistock
Copy link
Member

Hello!

As Adam mentioned, there's currently no way to add add-ons other than the custom Gemfile. We are considering allowing declaring add-ons through editor settings, so that people can use add-ons without adding them as dependencies of the app, but we haven't gotten to working on that yet.

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

No branches or pull requests

3 participants