ruby-lsp 0.26.9 → 0.26.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/ruby_lsp/addon.rb +19 -19
- data/lib/ruby_lsp/base_server.rb +2 -0
- data/lib/ruby_lsp/listeners/document_link.rb +4 -0
- data/lib/ruby_lsp/requests/on_type_formatting.rb +4 -0
- data/lib/ruby_lsp/server.rb +15 -1
- data/lib/ruby_lsp/setup_bundler.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8c98cbc9dfd7d9b5bd299f9dc258841c7b3e3cc69fb58b537a9df8f4332332b3
|
|
4
|
+
data.tar.gz: b627dd5f43911a8b11b469998f1b7ed539a8651e87f80d13d3fe65ac0614ff0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bbc993bf3cdfc2371d29b47812dbee2b39bab7b25bd8214be7fd289abff9c92f5eaa4b43d1da0f64c4e2f8170d616c260942e5e5adfa44a728a8573d059cd9fc
|
|
7
|
+
data.tar.gz: 2e3bb291df191f0ae3c71ccca73305852b93258468942e9cc5e1de29de36161bba4d0640941bb76a3bfdf2d7c8e80c99d599bf4dd930ce9342277e4731600398
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.26.
|
|
1
|
+
0.26.10
|
data/lib/ruby_lsp/addon.rb
CHANGED
|
@@ -56,26 +56,9 @@ module RubyLsp
|
|
|
56
56
|
addon_files = Gem.find_files("ruby_lsp/**/addon.rb")
|
|
57
57
|
|
|
58
58
|
if include_project_addons
|
|
59
|
-
project_addons = Dir.glob("#{global_state.workspace_path}/**/ruby_lsp/**/addon.rb")
|
|
60
59
|
bundle_path = Bundler.bundle_path.to_s
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
# Create an array of rejection glob patterns to ignore add-ons already discovered through Gem.find_files if
|
|
64
|
-
# they are also copied inside the workspace for whatever reason. We received reports of projects having gems
|
|
65
|
-
# installed in vendor/bundle despite BUNDLE_PATH pointing elsewhere. Without this mechanism, we will
|
|
66
|
-
# double-require the same add-on, potentially for different versions of the same gem, which leads to incorrect
|
|
67
|
-
# behavior
|
|
68
|
-
reject_glob_patterns = addon_files.map do |path|
|
|
69
|
-
relative_gem_path = Pathname.new(path).relative_path_from(gems_dir)
|
|
70
|
-
first_part, *parts = relative_gem_path.to_s.split(File::SEPARATOR)
|
|
71
|
-
first_part&.gsub!(/-([0-9.]+)$/, "*")
|
|
72
|
-
"**/#{first_part}/#{parts.join("/")}"
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
project_addons.reject! do |path|
|
|
76
|
-
path.start_with?(bundle_path) ||
|
|
77
|
-
reject_glob_patterns.any? { |pattern| File.fnmatch?(pattern, path, File::Constants::FNM_PATHNAME) }
|
|
78
|
-
end
|
|
60
|
+
project_addons = Dir.glob("#{global_state.workspace_path}/**/ruby_lsp/**/addon.rb")
|
|
61
|
+
project_addons.reject! { |path| path.start_with?(bundle_path) || gem_installation_path?(path) }
|
|
79
62
|
|
|
80
63
|
addon_files.concat(project_addons)
|
|
81
64
|
end
|
|
@@ -162,6 +145,23 @@ module RubyLsp
|
|
|
162
145
|
"Add-on is not compatible with this version of the Ruby LSP. Skipping its activation"
|
|
163
146
|
end
|
|
164
147
|
end
|
|
148
|
+
|
|
149
|
+
private
|
|
150
|
+
|
|
151
|
+
# Checks if a path appears to be inside a versioned gem installation directory (e.g., `rubocop-1.73.0/lib/...`) by
|
|
152
|
+
# looking for a directory segment matching `name-version` before the `lib` component
|
|
153
|
+
#
|
|
154
|
+
#: (String path) -> bool
|
|
155
|
+
def gem_installation_path?(path)
|
|
156
|
+
parts = path.split(%r{[/\\]})
|
|
157
|
+
lib_index = parts.rindex("lib")
|
|
158
|
+
return false unless lib_index
|
|
159
|
+
|
|
160
|
+
prefix = parts[0...lib_index] #: Array[String]?
|
|
161
|
+
return false unless prefix
|
|
162
|
+
|
|
163
|
+
prefix.any? { |part| part.match?(/-\d+(\.\d+)+$/) }
|
|
164
|
+
end
|
|
165
165
|
end
|
|
166
166
|
|
|
167
167
|
#: -> void
|
data/lib/ruby_lsp/base_server.rb
CHANGED
|
@@ -74,6 +74,8 @@ module RubyLsp
|
|
|
74
74
|
)
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
|
+
rescue URI::Error
|
|
78
|
+
# A client can send a document URI with a scheme Ruby's URI parser rejects, so we don't want to fail
|
|
77
79
|
rescue Store::NonExistingDocumentError
|
|
78
80
|
# If we receive a request for a file that no longer exists, we don't want to fail
|
|
79
81
|
end
|
|
@@ -21,6 +21,8 @@ module RubyLsp
|
|
|
21
21
|
|
|
22
22
|
Gem::Specification.stubs.each do |stub|
|
|
23
23
|
spec = stub.to_spec
|
|
24
|
+
next unless spec
|
|
25
|
+
|
|
24
26
|
lookup[spec.name] = {}
|
|
25
27
|
lookup[spec.name][spec.version.to_s] = {}
|
|
26
28
|
|
|
@@ -31,6 +33,8 @@ module RubyLsp
|
|
|
31
33
|
|
|
32
34
|
Gem::Specification.default_stubs.each do |stub|
|
|
33
35
|
spec = stub.to_spec
|
|
36
|
+
next unless spec
|
|
37
|
+
|
|
34
38
|
lookup[spec.name] = {}
|
|
35
39
|
lookup[spec.name][spec.version.to_s] = {}
|
|
36
40
|
prefix_matchers = Regexp.union(spec.require_paths.map do |rp|
|
|
@@ -120,6 +120,10 @@ module RubyLsp
|
|
|
120
120
|
|
|
121
121
|
return unless END_REGEXES.any? { |regex| regex.match?(@previous_line) }
|
|
122
122
|
|
|
123
|
+
# Endless method definitions (e.g., `def foo = 42`) are complete statements
|
|
124
|
+
# and should not have `end` added
|
|
125
|
+
return if @previous_line.match?(/\bdef\s+[\w.]+[!?=]?(\([^)]*\))?\s*=[^=~>]/)
|
|
126
|
+
|
|
123
127
|
indents = " " * @indentation
|
|
124
128
|
current_line = @lines[@position[:line]]
|
|
125
129
|
next_line = @lines[@position[:line] + 1]
|
data/lib/ruby_lsp/server.rb
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
module RubyLsp
|
|
5
5
|
class Server < BaseServer
|
|
6
|
-
NON_REPORTABLE_SETUP_ERRORS = [
|
|
6
|
+
NON_REPORTABLE_SETUP_ERRORS = [
|
|
7
|
+
Bundler::GemNotFound,
|
|
8
|
+
Bundler::GitError,
|
|
9
|
+
Bundler::Dsl::DSLError,
|
|
10
|
+
].freeze #: Array[singleton(StandardError)]
|
|
7
11
|
|
|
8
12
|
# Only for testing
|
|
9
13
|
#: GlobalState
|
|
@@ -120,6 +124,16 @@ module RubyLsp
|
|
|
120
124
|
@global_state.synchronize { @cancelled_requests << message[:params][:id] }
|
|
121
125
|
when nil
|
|
122
126
|
process_response(message) if message[:result]
|
|
127
|
+
else
|
|
128
|
+
id = message[:id]
|
|
129
|
+
|
|
130
|
+
if id
|
|
131
|
+
send_message(Error.new(
|
|
132
|
+
id: id,
|
|
133
|
+
code: Constant::ErrorCodes::METHOD_NOT_FOUND,
|
|
134
|
+
message: "Method not found: #{message[:method]}",
|
|
135
|
+
))
|
|
136
|
+
end
|
|
123
137
|
end
|
|
124
138
|
rescue DelegateRequestError
|
|
125
139
|
send_message(Error.new(id: message[:id], code: DelegateRequestError::CODE, message: "DELEGATE_REQUEST"))
|
|
@@ -445,7 +445,7 @@ module RubyLsp
|
|
|
445
445
|
requirement = Gem::Requirement.new(@bundler_version.to_s)
|
|
446
446
|
return if Gem::Specification.any? { |s| s.name == "bundler" && requirement =~ s.version }
|
|
447
447
|
|
|
448
|
-
Gem.install("bundler", @bundler_version.to_s)
|
|
448
|
+
Gem.install("bundler", @bundler_version.to_s, env_shebang: true)
|
|
449
449
|
end
|
|
450
450
|
|
|
451
451
|
#: -> bool
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-lsp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.26.
|
|
4
|
+
version: 0.26.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shopify
|
|
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
203
203
|
- !ruby/object:Gem::Version
|
|
204
204
|
version: '0'
|
|
205
205
|
requirements: []
|
|
206
|
-
rubygems_version: 4.0.
|
|
206
|
+
rubygems_version: 4.0.10
|
|
207
207
|
specification_version: 4
|
|
208
208
|
summary: An opinionated language server for Ruby
|
|
209
209
|
test_files: []
|