Skip to content

Commit abf3fd4

Browse files
authored
Supprot RuboCop's LSP mode (#1453)
Resolves #1449. This PR applies `RuboCop::LSP.enable`, which is the minimal API for RuboCop to handle in the context of LSP: https://docs.rubocop.org/rubocop/1.61/usage/lsp.html#language-server-development Furthermore, `RuboCop::LSP.enable` method and `RuboCop::LSP` module were introduced in RuboCop 1.61.0. This PR ensures compatibility with existing versions of RuboCop dependencies. However, in older versions of RuboCop prior to 1.60, `AutoCorrect: contextual` behaves the same as `AutoCorrect: true`.
1 parent 01394af commit abf3fd4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/ruby_lsp/requests/support/rubocop_runner.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
raise StandardError, "Incompatible RuboCop version. Ruby LSP requires >= 1.4.0"
1414
end
1515

16+
if RuboCop.const_defined?(:LSP) # This condition will be removed when requiring RuboCop >= 1.61.
17+
RuboCop::LSP.enable
18+
end
19+
1620
module RubyLsp
1721
module Requests
1822
module Support

0 commit comments

Comments
 (0)