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

fix(rubocop): don't auto-detect bundler, to avoid surprising configuration behavior #2716

Merged
merged 2 commits into from
Jul 12, 2023

Conversation

gongfarmer
Copy link
Contributor

My earlier PR #2706 added an on_new_config handler which auto-detects whether bundler is used in a project, and calls rubocop through bundler or not based on the result.

This had some issues:

  • may override the user's custom configuration due to the use of on_new_config
  • has surprising side effect when overridden because the on_new_config handler runs twice
  • incorrectly configures 'bundle exec rubocop --lsp' command if the project has a Gemfile that does not include rubocop

After some discussion it seems that this simpler configuration is best.
This PR deletes the on_new_config handler, leaving the lsp command to be rubocop --lsp.
This will also match the behaviour of the solargraph and ruby_ls configurations.

Users who want to use 'bundle exec rubocop --lsp` can get this with a simple custom lsp configuration, or by using a plugin such as https://github.com/mihyaeru21/nvim-lspconfig-bundler .

@glepnir glepnir merged commit f88fc62 into neovim:master Jul 12, 2023
waiting-for-dev added a commit to waiting-for-dev/nvim-lspconfig that referenced this pull request Dec 5, 2023
…ation behavior

Ref. neovim#2716. The referenced PR changes got somehow lost when it came to the removal of the `on_new_config` function.
glepnir pushed a commit that referenced this pull request Dec 6, 2023
…ation behavior (#2923)

Ref. #2716. The referenced PR changes got somehow lost when it came to the removal of the `on_new_config` function.
andreaswachowski added a commit to andreaswachowski/dotfiles that referenced this pull request Dec 17, 2023
@janko
Copy link

janko commented Apr 15, 2024

I wanted to ensure that the Rubocop version in Gemfile.lock runs, because that's the version that the project uses. I also wanted to activate the Rubocop LSP only for projects that actually use Rubocop, so I chose to detect .rubocop.yml instead. I ended up with the following configuration:

-- init.lua
-- ...
local lspconfig = require("lspconfig")
lspconfig.rubocop.setup({
  cmd = { "bundle", "exec", "rubocop", "--lsp" },
  root_dir = lspconfig.util.root_pattern(".rubocop.yml"),
})

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.

3 participants