ruby-lsp 0.4.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -86
  3. data/VERSION +1 -1
  4. data/lib/ruby_lsp/check_docs.rb +112 -0
  5. data/lib/ruby_lsp/document.rb +13 -2
  6. data/lib/ruby_lsp/event_emitter.rb +84 -18
  7. data/lib/ruby_lsp/executor.rb +126 -48
  8. data/lib/ruby_lsp/internal.rb +1 -0
  9. data/lib/ruby_lsp/listener.rb +6 -13
  10. data/lib/ruby_lsp/requests/base_request.rb +0 -5
  11. data/lib/ruby_lsp/requests/code_action_resolve.rb +1 -1
  12. data/lib/ruby_lsp/requests/code_actions.rb +1 -1
  13. data/lib/ruby_lsp/requests/code_lens.rb +82 -66
  14. data/lib/ruby_lsp/requests/diagnostics.rb +2 -2
  15. data/lib/ruby_lsp/requests/document_highlight.rb +1 -1
  16. data/lib/ruby_lsp/requests/document_link.rb +17 -15
  17. data/lib/ruby_lsp/requests/document_symbol.rb +51 -31
  18. data/lib/ruby_lsp/requests/folding_ranges.rb +1 -1
  19. data/lib/ruby_lsp/requests/formatting.rb +10 -11
  20. data/lib/ruby_lsp/requests/hover.rb +20 -20
  21. data/lib/ruby_lsp/requests/inlay_hints.rb +1 -1
  22. data/lib/ruby_lsp/requests/on_type_formatting.rb +1 -1
  23. data/lib/ruby_lsp/requests/path_completion.rb +21 -57
  24. data/lib/ruby_lsp/requests/selection_ranges.rb +1 -1
  25. data/lib/ruby_lsp/requests/semantic_highlighting.rb +1 -1
  26. data/lib/ruby_lsp/requests/support/common.rb +36 -0
  27. data/lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb +0 -1
  28. data/lib/ruby_lsp/requests/support/rubocop_formatting_runner.rb +0 -1
  29. data/lib/ruby_lsp/requests/support/syntax_tree_formatting_runner.rb +5 -2
  30. data/lib/ruby_lsp/requests.rb +15 -15
  31. data/lib/ruby_lsp/server.rb +44 -20
  32. data/lib/ruby_lsp/store.rb +1 -1
  33. data/lib/ruby_lsp/utils.rb +2 -7
  34. metadata +3 -2
@@ -5,7 +5,7 @@ require "ruby_lsp/requests/support/source_uri"
5
5
 
6
6
  module RubyLsp
7
7
  module Requests
8
- # ![Document link demo](../../misc/document_link.gif)
8
+ # ![Document link demo](../../document_link.gif)
9
9
  #
10
10
  # The [document link](https://microsoft.github.io/language-server-protocol/specification#textDocument_documentLink)
11
11
  # makes `# source://PATH_TO_FILE#line` comments in a Ruby/RBI file clickable if the file exists.
@@ -18,8 +18,11 @@ module RubyLsp
18
18
  # def format(source, maxwidth = T.unsafe(nil))
19
19
  # end
20
20
  # ```
21
- class DocumentLink < BaseRequest
21
+ class DocumentLink < Listener
22
22
  extend T::Sig
23
+ extend T::Generic
24
+
25
+ ResponseType = type_member { { fixed: T::Array[Interface::DocumentLink] } }
23
26
 
24
27
  GEM_TO_VERSION_MAP = T.let(
25
28
  [*::Gem::Specification.default_stubs, *::Gem::Specification.stubs].map! do |s|
@@ -69,25 +72,24 @@ module RubyLsp
69
72
  end
70
73
  end
71
74
 
72
- sig { params(document: Document).void }
73
- def initialize(document)
74
- super(document)
75
+ sig { override.returns(ResponseType) }
76
+ attr_reader :response
77
+
78
+ sig { params(uri: String, emitter: EventEmitter, message_queue: Thread::Queue).void }
79
+ def initialize(uri, emitter, message_queue)
80
+ super(emitter, message_queue)
75
81
 
76
82
  # Match the version based on the version in the RBI file name. Notice that the `@` symbol is sanitized to `%40`
77
83
  # in the URI
78
- version_match = /(?<=%40)[\d.]+(?=\.rbi$)/.match(document.uri)
84
+ version_match = /(?<=%40)[\d.]+(?=\.rbi$)/.match(uri)
79
85
  @gem_version = T.let(version_match && version_match[0], T.nilable(String))
80
- @links = T.let([], T::Array[Interface::DocumentLink])
81
- end
86
+ @response = T.let([], T::Array[Interface::DocumentLink])
82
87
 
83
- sig { override.returns(T.all(T::Array[Interface::DocumentLink], Object)) }
84
- def run
85
- visit(@document.tree) if @document.parsed?
86
- @links
88
+ emitter.register(self, :on_comment)
87
89
  end
88
90
 
89
- sig { override.params(node: SyntaxTree::Comment).void }
90
- def visit_comment(node)
91
+ sig { params(node: SyntaxTree::Comment).void }
92
+ def on_comment(node)
91
93
  match = node.value.match(%r{source://.*#\d+$})
92
94
  return unless match
93
95
 
@@ -96,7 +98,7 @@ module RubyLsp
96
98
  file_path = self.class.gem_paths.dig(uri.gem_name, gem_version, uri.path)
97
99
  return if file_path.nil?
98
100
 
99
- @links << Interface::DocumentLink.new(
101
+ @response << Interface::DocumentLink.new(
100
102
  range: range_from_syntax_tree_node(node),
101
103
  target: "file://#{file_path}##{uri.line_number}",
102
104
  tooltip: "Jump to #{file_path}##{uri.line_number}",
@@ -3,7 +3,7 @@
3
3
 
4
4
  module RubyLsp
5
5
  module Requests
6
- # ![Document symbol demo](../../misc/document_symbol.gif)
6
+ # ![Document symbol demo](../../document_symbol.gif)
7
7
  #
8
8
  # The [document
9
9
  # symbol](https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol) request
@@ -26,8 +26,11 @@ module RubyLsp
26
26
  # end
27
27
  # end
28
28
  # ```
29
- class DocumentSymbol < BaseRequest
29
+ class DocumentSymbol < Listener
30
30
  extend T::Sig
31
+ extend T::Generic
32
+
33
+ ResponseType = type_member { { fixed: T::Array[Interface::DocumentSymbol] } }
31
34
 
32
35
  SYMBOL_KIND = T.let(
33
36
  {
@@ -75,40 +78,53 @@ module RubyLsp
75
78
  end
76
79
  end
77
80
 
78
- sig { params(document: Document).void }
79
- def initialize(document)
81
+ sig { override.returns(T::Array[Interface::DocumentSymbol]) }
82
+ attr_reader :response
83
+
84
+ sig { params(emitter: EventEmitter, message_queue: Thread::Queue).void }
85
+ def initialize(emitter, message_queue)
80
86
  super
81
87
 
82
88
  @root = T.let(SymbolHierarchyRoot.new, SymbolHierarchyRoot)
89
+ @response = T.let(@root.children, T::Array[Interface::DocumentSymbol])
83
90
  @stack = T.let(
84
91
  [@root],
85
92
  T::Array[T.any(SymbolHierarchyRoot, Interface::DocumentSymbol)],
86
93
  )
87
- end
88
94
 
89
- sig { override.returns(T.all(T::Array[Interface::DocumentSymbol], Object)) }
90
- def run
91
- visit(@document.tree) if @document.parsed?
92
- @root.children
95
+ emitter.register(
96
+ self,
97
+ :on_class,
98
+ :after_class,
99
+ :on_command,
100
+ :on_const_path_field,
101
+ :on_def,
102
+ :after_def,
103
+ :on_module,
104
+ :after_module,
105
+ :on_top_const_field,
106
+ :on_var_field,
107
+ )
93
108
  end
94
109
 
95
- sig { override.params(node: SyntaxTree::ClassDeclaration).void }
96
- def visit_class(node)
97
- symbol = create_document_symbol(
110
+ sig { params(node: SyntaxTree::ClassDeclaration).void }
111
+ def on_class(node)
112
+ @stack << create_document_symbol(
98
113
  name: full_constant_name(node.constant),
99
114
  kind: :class,
100
115
  range_node: node,
101
116
  selection_range_node: node.constant,
102
117
  )
118
+ end
103
119
 
104
- @stack << symbol
105
- visit(node.bodystmt)
120
+ sig { params(node: SyntaxTree::ClassDeclaration).void }
121
+ def after_class(node)
106
122
  @stack.pop
107
123
  end
108
124
 
109
- sig { override.params(node: SyntaxTree::Command).void }
110
- def visit_command(node)
111
- return visit(node.arguments) unless ATTR_ACCESSORS.include?(node.message.value)
125
+ sig { params(node: SyntaxTree::Command).void }
126
+ def on_command(node)
127
+ return unless ATTR_ACCESSORS.include?(node.message.value)
112
128
 
113
129
  node.arguments.parts.each do |argument|
114
130
  next unless argument.is_a?(SyntaxTree::SymbolLiteral)
@@ -122,8 +138,8 @@ module RubyLsp
122
138
  end
123
139
  end
124
140
 
125
- sig { override.params(node: SyntaxTree::ConstPathField).void }
126
- def visit_const_path_field(node)
141
+ sig { params(node: SyntaxTree::ConstPathField).void }
142
+ def on_const_path_field(node)
127
143
  create_document_symbol(
128
144
  name: node.constant.value,
129
145
  kind: :constant,
@@ -132,8 +148,8 @@ module RubyLsp
132
148
  )
133
149
  end
134
150
 
135
- sig { override.params(node: SyntaxTree::DefNode).void }
136
- def visit_def(node)
151
+ sig { params(node: SyntaxTree::DefNode).void }
152
+ def on_def(node)
137
153
  target = node.target
138
154
 
139
155
  if target.is_a?(SyntaxTree::VarRef) && target.value.is_a?(SyntaxTree::Kw) && target.value.value == "self"
@@ -152,26 +168,30 @@ module RubyLsp
152
168
  )
153
169
 
154
170
  @stack << symbol
155
- visit(node.bodystmt)
171
+ end
172
+
173
+ sig { params(node: SyntaxTree::DefNode).void }
174
+ def after_def(node)
156
175
  @stack.pop
157
176
  end
158
177
 
159
- sig { override.params(node: SyntaxTree::ModuleDeclaration).void }
160
- def visit_module(node)
161
- symbol = create_document_symbol(
178
+ sig { params(node: SyntaxTree::ModuleDeclaration).void }
179
+ def on_module(node)
180
+ @stack << create_document_symbol(
162
181
  name: full_constant_name(node.constant),
163
182
  kind: :module,
164
183
  range_node: node,
165
184
  selection_range_node: node.constant,
166
185
  )
186
+ end
167
187
 
168
- @stack << symbol
169
- visit(node.bodystmt)
188
+ sig { params(node: SyntaxTree::ModuleDeclaration).void }
189
+ def after_module(node)
170
190
  @stack.pop
171
191
  end
172
192
 
173
- sig { override.params(node: SyntaxTree::TopConstField).void }
174
- def visit_top_const_field(node)
193
+ sig { params(node: SyntaxTree::TopConstField).void }
194
+ def on_top_const_field(node)
175
195
  create_document_symbol(
176
196
  name: node.constant.value,
177
197
  kind: :constant,
@@ -180,8 +200,8 @@ module RubyLsp
180
200
  )
181
201
  end
182
202
 
183
- sig { override.params(node: SyntaxTree::VarField).void }
184
- def visit_var_field(node)
203
+ sig { params(node: SyntaxTree::VarField).void }
204
+ def on_var_field(node)
185
205
  value = node.value
186
206
  kind = case value
187
207
  when SyntaxTree::Const
@@ -3,7 +3,7 @@
3
3
 
4
4
  module RubyLsp
5
5
  module Requests
6
- # ![Folding ranges demo](../../misc/folding_ranges.gif)
6
+ # ![Folding ranges demo](../../folding_ranges.gif)
7
7
  #
8
8
  # The [folding ranges](https://microsoft.github.io/language-server-protocol/specification#textDocument_foldingRange)
9
9
  # request informs the editor of the ranges where and how code can be folded.
@@ -6,13 +6,17 @@ require "ruby_lsp/requests/support/syntax_tree_formatting_runner"
6
6
 
7
7
  module RubyLsp
8
8
  module Requests
9
- # ![Formatting symbol demo](../../misc/formatting.gif)
9
+ # ![Formatting symbol demo](../../formatting.gif)
10
10
  #
11
11
  # The [formatting](https://microsoft.github.io/language-server-protocol/specification#textDocument_formatting)
12
12
  # request uses RuboCop to fix auto-correctable offenses in the document. This requires enabling format on save and
13
13
  # registering the ruby-lsp as the Ruby formatter.
14
14
  #
15
- # If RuboCop is not available, the request will fall back to SyntaxTree.
15
+ # The `rubyLsp.formatter` setting specifies which formatter to use.
16
+ # If set to `auto`` then it behaves as follows:
17
+ # * It will use RuboCop if it is part of the bundle.
18
+ # * If RuboCop is not available, and `syntax_tree` is a direct dependency, it will use that.
19
+ # * Otherwise, no formatting will be applied.
16
20
  #
17
21
  # # Example
18
22
  #
@@ -32,14 +36,7 @@ module RubyLsp
32
36
  super(document)
33
37
 
34
38
  @uri = T.let(document.uri, String)
35
- @formatter = T.let(
36
- if formatter == "auto"
37
- defined?(Support::RuboCopFormattingRunner) ? "rubocop" : "syntax_tree"
38
- else
39
- formatter
40
- end,
41
- String,
42
- )
39
+ @formatter = formatter
43
40
  end
44
41
 
45
42
  sig { override.returns(T.nilable(T.all(T::Array[Interface::TextEdit], Object))) }
@@ -72,7 +69,9 @@ module RubyLsp
72
69
  def formatted_file
73
70
  case @formatter
74
71
  when "rubocop"
75
- Support::RuboCopFormattingRunner.instance.run(@uri, @document)
72
+ if defined?(Support::RuboCopFormattingRunner)
73
+ Support::RuboCopFormattingRunner.instance.run(@uri, @document)
74
+ end
76
75
  when "syntax_tree"
77
76
  Support::SyntaxTreeFormattingRunner.instance.run(@uri, @document)
78
77
  else
@@ -3,7 +3,7 @@
3
3
 
4
4
  module RubyLsp
5
5
  module Requests
6
- # ![Hover demo](../../misc/rails_document_link_hover.gif)
6
+ # ![Hover demo](../../rails_document_link_hover.gif)
7
7
  #
8
8
  # The [hover request](https://microsoft.github.io/language-server-protocol/specification#textDocument_hover)
9
9
  # renders a clickable link to the code's official documentation.
@@ -35,10 +35,12 @@ module RubyLsp
35
35
  sig { override.returns(ResponseType) }
36
36
  attr_reader :response
37
37
 
38
- sig { void }
39
- def initialize
38
+ sig { params(emitter: EventEmitter, message_queue: Thread::Queue).void }
39
+ def initialize(emitter, message_queue)
40
+ super
41
+
40
42
  @response = T.let(nil, ResponseType)
41
- super()
43
+ emitter.register(self, :on_command, :on_const_path_ref, :on_call)
42
44
  end
43
45
 
44
46
  # Merges responses from other hover listeners
@@ -56,25 +58,23 @@ module RubyLsp
56
58
  self
57
59
  end
58
60
 
59
- listener_events do
60
- sig { params(node: SyntaxTree::Command).void }
61
- def on_command(node)
62
- message = node.message
63
- @response = generate_rails_document_link_hover(message.value, message)
64
- end
61
+ sig { params(node: SyntaxTree::Command).void }
62
+ def on_command(node)
63
+ message = node.message
64
+ @response = generate_rails_document_link_hover(message.value, message)
65
+ end
65
66
 
66
- sig { params(node: SyntaxTree::ConstPathRef).void }
67
- def on_const_path_ref(node)
68
- @response = generate_rails_document_link_hover(full_constant_name(node), node)
69
- end
67
+ sig { params(node: SyntaxTree::ConstPathRef).void }
68
+ def on_const_path_ref(node)
69
+ @response = generate_rails_document_link_hover(full_constant_name(node), node)
70
+ end
70
71
 
71
- sig { params(node: SyntaxTree::CallNode).void }
72
- def on_call(node)
73
- message = node.message
74
- return if message.is_a?(Symbol)
72
+ sig { params(node: SyntaxTree::CallNode).void }
73
+ def on_call(node)
74
+ message = node.message
75
+ return if message.is_a?(Symbol)
75
76
 
76
- @response = generate_rails_document_link_hover(message.value, message)
77
- end
77
+ @response = generate_rails_document_link_hover(message.value, message)
78
78
  end
79
79
 
80
80
  private
@@ -3,7 +3,7 @@
3
3
 
4
4
  module RubyLsp
5
5
  module Requests
6
- # ![Inlay hint demo](../../misc/inlay_hint.gif)
6
+ # ![Inlay hint demo](../../inlay_hint.gif)
7
7
  #
8
8
  # [Inlay hints](https://microsoft.github.io/language-server-protocol/specification#textDocument_inlayHint)
9
9
  # are labels added directly in the code that explicitly show the user something that might
@@ -3,7 +3,7 @@
3
3
 
4
4
  module RubyLsp
5
5
  module Requests
6
- # ![On type formatting demo](../../misc/on_type_formatting.gif)
6
+ # ![On type formatting demo](../../on_type_formatting.gif)
7
7
  #
8
8
  # The [on type formatting](https://microsoft.github.io/language-server-protocol/specification#textDocument_onTypeFormatting)
9
9
  # request formats code as the user is typing. For example, automatically adding `end` to class definitions.
@@ -3,7 +3,7 @@
3
3
 
4
4
  module RubyLsp
5
5
  module Requests
6
- # ![Path completion demo](../../misc/path_completion.gif)
6
+ # ![Path completion demo](../../path_completion.gif)
7
7
  #
8
8
  # The [completion](https://microsoft.github.io/language-server-protocol/specification#textDocument_completion)
9
9
  # request looks up Ruby files in the $LOAD_PATH to suggest path completion inside `require` statements.
@@ -13,29 +13,28 @@ module RubyLsp
13
13
  # ```ruby
14
14
  # require "ruby_lsp/requests" # --> completion: suggests `base_request`, `code_actions`, ...
15
15
  # ```
16
- class PathCompletion < BaseRequest
16
+ class PathCompletion < Listener
17
17
  extend T::Sig
18
+ extend T::Generic
18
19
 
19
- sig { params(document: Document, position: Document::PositionShape).void }
20
- def initialize(document, position)
21
- super(document)
20
+ ResponseType = type_member { { fixed: T::Array[Interface::CompletionItem] } }
22
21
 
23
- @tree = T.let(Support::PrefixTree.new(collect_load_path_files), Support::PrefixTree)
24
- @position = position
25
- end
22
+ sig { override.returns(ResponseType) }
23
+ attr_reader :response
26
24
 
27
- sig { override.returns(T.all(T::Array[Interface::CompletionItem], Object)) }
28
- def run
29
- # We can't verify if we're inside a require when there are syntax errors
30
- return [] if @document.syntax_error?
25
+ sig { params(emitter: EventEmitter, message_queue: Thread::Queue).void }
26
+ def initialize(emitter, message_queue)
27
+ super
28
+ @response = T.let([], ResponseType)
29
+ @tree = T.let(Support::PrefixTree.new(collect_load_path_files), Support::PrefixTree)
31
30
 
32
- target = T.let(find, T.nilable(SyntaxTree::TStringContent))
33
- # no target means the we are not inside a `require` call
34
- return [] unless target
31
+ emitter.register(self, :on_tstring_content)
32
+ end
35
33
 
36
- text = target.value
37
- @tree.search(text).sort.map! do |path|
38
- build_completion(path, path.delete_prefix(text))
34
+ sig { params(node: SyntaxTree::TStringContent).void }
35
+ def on_tstring_content(node)
36
+ @tree.search(node.value).sort.each do |path|
37
+ @response << build_completion(path, node)
39
38
  end
40
39
  end
41
40
 
@@ -50,48 +49,13 @@ module RubyLsp
50
49
  end
51
50
  end
52
51
 
53
- sig { returns(T.nilable(SyntaxTree::TStringContent)) }
54
- def find
55
- char_position = @document.create_scanner.find_char_position(@position)
56
- matched, parent = @document.locate(
57
- T.must(@document.tree),
58
- char_position,
59
- node_types: [SyntaxTree::Command, SyntaxTree::CommandCall, SyntaxTree::CallNode],
60
- )
61
-
62
- return unless matched && parent
63
-
64
- case matched
65
- when SyntaxTree::Command, SyntaxTree::CallNode, SyntaxTree::CommandCall
66
- message = matched.message
67
- return if message.is_a?(Symbol)
68
- return unless message.value == "require"
69
-
70
- args = matched.arguments
71
- args = args.arguments if args.is_a?(SyntaxTree::ArgParen)
72
- return if args.nil? || args.is_a?(SyntaxTree::ArgsForward)
73
-
74
- argument = args.parts.first
75
- return unless argument.is_a?(SyntaxTree::StringLiteral)
76
-
77
- path_node = argument.parts.first
78
- return unless path_node.is_a?(SyntaxTree::TStringContent)
79
- return unless (path_node.location.start_char..path_node.location.end_char).cover?(char_position)
80
-
81
- path_node
82
- end
83
- end
84
-
85
- sig { params(label: String, insert_text: String).returns(Interface::CompletionItem) }
86
- def build_completion(label, insert_text)
52
+ sig { params(label: String, node: SyntaxTree::TStringContent).returns(Interface::CompletionItem) }
53
+ def build_completion(label, node)
87
54
  Interface::CompletionItem.new(
88
55
  label: label,
89
56
  text_edit: Interface::TextEdit.new(
90
- range: Interface::Range.new(
91
- start: @position,
92
- end: @position,
93
- ),
94
- new_text: insert_text,
57
+ range: range_from_syntax_tree_node(node),
58
+ new_text: label,
95
59
  ),
96
60
  kind: Constant::CompletionItemKind::REFERENCE,
97
61
  )
@@ -3,7 +3,7 @@
3
3
 
4
4
  module RubyLsp
5
5
  module Requests
6
- # ![Selection ranges demo](../../misc/selection_ranges.gif)
6
+ # ![Selection ranges demo](../../selection_ranges.gif)
7
7
  #
8
8
  # The [selection ranges](https://microsoft.github.io/language-server-protocol/specification#textDocument_selectionRange)
9
9
  # request informs the editor of ranges that the user may want to select based on the location(s)
@@ -3,7 +3,7 @@
3
3
 
4
4
  module RubyLsp
5
5
  module Requests
6
- # ![Semantic highlighting demo](../../misc/semantic_highlighting.gif)
6
+ # ![Semantic highlighting demo](../../semantic_highlighting.gif)
7
7
  #
8
8
  # The [semantic
9
9
  # highlighting](https://microsoft.github.io/language-server-protocol/specification#textDocument_semanticTokens)
@@ -49,6 +49,42 @@ module RubyLsp
49
49
  loc = node.location
50
50
  range.cover?(loc.start_line - 1) && range.cover?(loc.end_line - 1)
51
51
  end
52
+
53
+ sig do
54
+ params(
55
+ node: SyntaxTree::Node,
56
+ title: String,
57
+ command_name: String,
58
+ path: String,
59
+ name: String,
60
+ test_command: String,
61
+ type: String,
62
+ ).returns(Interface::CodeLens)
63
+ end
64
+ def create_code_lens(node, title:, command_name:, path:, name:, test_command:, type:)
65
+ range = range_from_syntax_tree_node(node)
66
+ arguments = [
67
+ path,
68
+ name,
69
+ test_command,
70
+ {
71
+ start_line: node.location.start_line - 1,
72
+ start_column: node.location.start_column,
73
+ end_line: node.location.end_line - 1,
74
+ end_column: node.location.end_column,
75
+ },
76
+ ]
77
+
78
+ Interface::CodeLens.new(
79
+ range: range,
80
+ command: Interface::Command.new(
81
+ title: title,
82
+ command: command_name,
83
+ arguments: arguments,
84
+ ),
85
+ data: { type: type },
86
+ )
87
+ end
52
88
  end
53
89
  end
54
90
  end
@@ -1,7 +1,6 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require "ruby_lsp/requests/support/rubocop_runner"
5
4
  return unless defined?(RubyLsp::Requests::Support::RuboCopRunner)
6
5
 
7
6
  require "cgi"
@@ -1,7 +1,6 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require "ruby_lsp/requests/support/rubocop_runner"
5
4
  return unless defined?(RubyLsp::Requests::Support::RuboCopRunner)
6
5
 
7
6
  require "cgi"
@@ -25,8 +25,11 @@ module RubyLsp
25
25
  )
26
26
  end
27
27
 
28
- sig { params(_uri: String, document: Document).returns(T.nilable(String)) }
29
- def run(_uri, document)
28
+ sig { params(uri: String, document: Document).returns(T.nilable(String)) }
29
+ def run(uri, document)
30
+ relative_path = Pathname.new(URI(uri).path).relative_path_from(T.must(WORKSPACE_URI.path))
31
+ return if @options.ignore_files.any? { |pattern| File.fnmatch(pattern, relative_path) }
32
+
30
33
  SyntaxTree.format(
31
34
  document.source,
32
35
  @options.print_width,
@@ -4,21 +4,21 @@
4
4
  module RubyLsp
5
5
  # Supported features
6
6
  #
7
- # - {RubyLsp::Requests::DocumentSymbol}
8
- # - {RubyLsp::Requests::DocumentLink}
9
- # - {RubyLsp::Requests::Hover}
10
- # - {RubyLsp::Requests::FoldingRanges}
11
- # - {RubyLsp::Requests::SelectionRanges}
12
- # - {RubyLsp::Requests::SemanticHighlighting}
13
- # - {RubyLsp::Requests::Formatting}
14
- # - {RubyLsp::Requests::OnTypeFormatting}
15
- # - {RubyLsp::Requests::Diagnostics}
16
- # - {RubyLsp::Requests::CodeActions}
17
- # - {RubyLsp::Requests::CodeActionResolve}
18
- # - {RubyLsp::Requests::DocumentHighlight}
19
- # - {RubyLsp::Requests::InlayHints}
20
- # - {RubyLsp::Requests::PathCompletion}
21
- # - {RubyLsp::Requests::CodeLens}
7
+ # - [DocumentSymbol](rdoc-ref:RubyLsp::Requests::DocumentSymbol)
8
+ # - [DocumentLink](rdoc-ref:RubyLsp::Requests::DocumentLink)
9
+ # - [Hover](rdoc-ref:RubyLsp::Requests::Hover)
10
+ # - [FoldingRange](rdoc-ref:RubyLsp::Requests::FoldingRanges)
11
+ # - [SelectionRange](rdoc-ref:RubyLsp::Requests::SelectionRanges)
12
+ # - [SemanticHighlighting](rdoc-ref:RubyLsp::Requests::SemanticHighlighting)
13
+ # - [Formatting](rdoc-ref:RubyLsp::Requests::Formatting)
14
+ # - [OnTypeFormatting](rdoc-ref:RubyLsp::Requests::OnTypeFormatting)
15
+ # - [Diagnostic](rdoc-ref:RubyLsp::Requests::Diagnostics)
16
+ # - [CodeAction](rdoc-ref:RubyLsp::Requests::CodeActions)
17
+ # - [CodeActionResolve](rdoc-ref:RubyLsp::Requests::CodeActionResolve)
18
+ # - [DocumentHighlight](rdoc-ref:RubyLsp::Requests::DocumentHighlight)
19
+ # - [InlayHint](rdoc-ref:RubyLsp::Requests::InlayHints)
20
+ # - [PathCompletion](rdoc-ref:RubyLsp::Requests::PathCompletion)
21
+ # - [CodeLens](rdoc-ref:RubyLsp::Requests::CodeLens)
22
22
 
23
23
  module Requests
24
24
  autoload :BaseRequest, "ruby_lsp/requests/base_request"