ruby-lsp 0.14.4 → 0.14.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4fc74feb692f2c2e902e213dc61a4b3d58f14bcc4520fc7db60bdae022484e6f
4
- data.tar.gz: 98f6d5b939bb945119169e2ca3ce060f275b961d421e752774ebea1c25b74c2d
3
+ metadata.gz: '046081e0caf521f948f3952bd7a356ef6f0beb80c5a9ff72930a6d0c9fd8d9f4'
4
+ data.tar.gz: e65b5224342c412a0b28198af0e56b17a421eaacc7748a17d2ed30890c0a2d86
5
5
  SHA512:
6
- metadata.gz: 8c33776eb483463d1052cdd5a82d1f66d5d507325b09848d0c5d78cea310c218b056bef834f6f6f03e17d87088b65c8cd77f7c214735390e8b5d244a059ea9e7
7
- data.tar.gz: 7e57548a8dede5695774c27137b6ab23c8029f8ff8c0551bef8b1cf8f6dd920e9bdb423d4905c6a7f9ac360433da99cdec31efc885a120f4c1684acbd3da9582
6
+ metadata.gz: 682219fbef2c6e1483c0e6b0c36bf2ce8c3bd15aed88e53ee1a05623f5569c7e52227300b1a6fb4968a6ba2b0844a7e985a0b134af9e9498036199673d660117
7
+ data.tar.gz: a13eb33a1a41514819f4d0612a5d50eb170a0adb36158b799cebffae34781a5d41c1b07922f0bec8310cf6439ea8356305224bcf1de7423b96ff6e28c9e744c8
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.14.4
1
+ 0.14.5
@@ -27,6 +27,8 @@ module RubyLsp
27
27
 
28
28
  @addons = T.let([], T::Array[Addon])
29
29
  @addon_classes = T.let([], T::Array[T.class_of(Addon)])
30
+ # Addon instances that have declared a handler to accept file watcher events
31
+ @file_watcher_addons = T.let([], T::Array[Addon])
30
32
 
31
33
  class << self
32
34
  extend T::Sig
@@ -34,6 +36,9 @@ module RubyLsp
34
36
  sig { returns(T::Array[Addon]) }
35
37
  attr_accessor :addons
36
38
 
39
+ sig { returns(T::Array[Addon]) }
40
+ attr_accessor :file_watcher_addons
41
+
37
42
  sig { returns(T::Array[T.class_of(Addon)]) }
38
43
  attr_reader :addon_classes
39
44
 
@@ -57,6 +62,7 @@ module RubyLsp
57
62
 
58
63
  # Instantiate all discovered addon classes
59
64
  self.addons = addon_classes.map(&:new)
65
+ self.file_watcher_addons = addons.select { |addon| addon.respond_to?(:workspace_did_change_watched_files) }
60
66
 
61
67
  # Activate each one of the discovered addons. If any problems occur in the addons, we don't want to
62
68
  # fail to boot the server
@@ -229,6 +229,7 @@ module RubyLsp
229
229
  end
230
230
  end
231
231
 
232
+ Addon.file_watcher_addons.each { |addon| T.unsafe(addon).workspace_did_change_watched_files(changes) }
232
233
  VOID
233
234
  end
234
235
 
@@ -100,8 +100,6 @@ module RubyLsp
100
100
 
101
101
  sig { params(node: Prism::CallNode).void }
102
102
  def on_call_node_enter(node)
103
- return if @typechecker_enabled
104
-
105
103
  name = node.message
106
104
  return unless name
107
105
 
@@ -111,7 +109,7 @@ module RubyLsp
111
109
  when "require_relative"
112
110
  complete_require_relative(node)
113
111
  else
114
- complete_self_receiver_method(node, name) if self_receiver?(node)
112
+ complete_self_receiver_method(node, name) if !@typechecker_enabled && self_receiver?(node)
115
113
  end
116
114
  end
117
115
 
@@ -142,14 +140,17 @@ module RubyLsp
142
140
 
143
141
  origin_dir = Pathname.new(@uri.to_standardized_path).dirname
144
142
 
145
- path_query = path_node_to_complete.content
143
+ content = path_node_to_complete.content
146
144
  # if the path is not a directory, glob all possible next characters
147
145
  # for example ../somethi| (where | is the cursor position)
148
146
  # should find files for ../somethi*/
149
- path_query += "*/" unless path_query.end_with?("/")
150
- path_query += "**/*.rb"
147
+ path_query = if content.end_with?("/") || content.empty?
148
+ "#{content}**/*.rb"
149
+ else
150
+ "{#{content}*/**/*.rb,**/#{content}*.rb}"
151
+ end
151
152
 
152
- Dir.glob(path_query, base: origin_dir).sort!.each do |path|
153
+ Dir.glob(path_query, File::FNM_PATHNAME | File::FNM_EXTGLOB, base: origin_dir).sort!.each do |path|
153
154
  @response_builder << build_completion(
154
155
  path.delete_suffix(".rb"),
155
156
  path_node_to_complete,
@@ -34,7 +34,7 @@ module RubyLsp
34
34
  def provider
35
35
  Interface::CompletionOptions.new(
36
36
  resolve_provider: false,
37
- trigger_characters: ["/"],
37
+ trigger_characters: ["/", "\"", "'"],
38
38
  completion_item: {
39
39
  labelDetailsSupport: true,
40
40
  },
@@ -40,6 +40,9 @@ module RubyLsp
40
40
 
41
41
  sig { returns(Interface::Diagnostic) }
42
42
  def to_lsp_diagnostic
43
+ # highlighted_area contains the begin and end position of the first line
44
+ # This ensures that multiline offenses don't clutter the editor
45
+ highlighted = @offense.highlighted_area
43
46
  Interface::Diagnostic.new(
44
47
  message: message,
45
48
  source: "RuboCop",
@@ -49,11 +52,11 @@ module RubyLsp
49
52
  range: Interface::Range.new(
50
53
  start: Interface::Position.new(
51
54
  line: @offense.line - 1,
52
- character: @offense.column,
55
+ character: highlighted.begin_pos,
53
56
  ),
54
57
  end: Interface::Position.new(
55
- line: @offense.last_line - 1,
56
- character: @offense.last_column,
58
+ line: @offense.line - 1,
59
+ character: highlighted.end_pos,
57
60
  ),
58
61
  ),
59
62
  data: {
@@ -13,6 +13,10 @@ rescue LoadError
13
13
  raise StandardError, "Incompatible RuboCop version. Ruby LSP requires >= 1.4.0"
14
14
  end
15
15
 
16
+ if RuboCop.const_defined?(:LSP) # This condition will be removed when requiring RuboCop >= 1.61.
17
+ RuboCop::LSP.enable
18
+ end
19
+
16
20
  module RubyLsp
17
21
  module Requests
18
22
  module Support
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.4
4
+ version: 0.14.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-04 00:00:00.000000000 Z
11
+ date: 2024-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: language_server-protocol