ruby-lsp 0.21.2 → 0.22.0
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/exe/ruby-lsp +1 -1
- data/exe/ruby-lsp-launcher +0 -3
- data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +6 -0
- data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +136 -58
- data/lib/ruby_indexer/lib/ruby_indexer/enhancement.rb +31 -28
- data/lib/ruby_indexer/lib/ruby_indexer/index.rb +10 -10
- data/lib/ruby_indexer/test/classes_and_modules_test.rb +2 -2
- data/lib/ruby_indexer/test/configuration_test.rb +10 -0
- data/lib/ruby_indexer/test/constant_test.rb +8 -8
- data/lib/ruby_indexer/test/enhancements_test.rb +134 -38
- data/lib/ruby_indexer/test/index_test.rb +39 -0
- data/lib/ruby_indexer/test/method_test.rb +34 -1
- data/lib/ruby_lsp/global_state.rb +10 -3
- data/lib/ruby_lsp/internal.rb +1 -0
- data/lib/ruby_lsp/listeners/document_highlight.rb +91 -4
- data/lib/ruby_lsp/requests/definition.rb +2 -0
- data/lib/ruby_lsp/requests/document_highlight.rb +7 -1
- data/lib/ruby_lsp/requests/hover.rb +2 -0
- data/lib/ruby_lsp/requests/support/rubocop_runner.rb +1 -0
- data/lib/ruby_lsp/server.rb +13 -0
- data/lib/ruby_lsp/setup_bundler.rb +20 -20
- metadata +3 -3
@@ -12,7 +12,7 @@ require "digest"
|
|
12
12
|
require "time"
|
13
13
|
require "uri"
|
14
14
|
|
15
|
-
# This file is a script that will configure a
|
15
|
+
# This file is a script that will configure a composed bundle for the Ruby LSP. The composed bundle allows developers to use
|
16
16
|
# the Ruby LSP without including the gem in their application's Gemfile while at the same time giving us access to the
|
17
17
|
# exact locked versions of dependencies.
|
18
18
|
|
@@ -62,7 +62,7 @@ module RubyLsp
|
|
62
62
|
@retry = T.let(false, T::Boolean)
|
63
63
|
end
|
64
64
|
|
65
|
-
# Sets up the
|
65
|
+
# Sets up the composed bundle and returns the `BUNDLE_GEMFILE`, `BUNDLE_PATH` and `BUNDLE_APP_CONFIG` that should be
|
66
66
|
# used for running the server
|
67
67
|
sig { returns(T::Hash[String, String]) }
|
68
68
|
def setup!
|
@@ -73,12 +73,12 @@ module RubyLsp
|
|
73
73
|
ignore_file = @custom_dir + ".gitignore"
|
74
74
|
ignore_file.write("*") unless ignore_file.exist?
|
75
75
|
|
76
|
-
# Do not set up a
|
76
|
+
# Do not set up a composed bundle if LSP dependencies are already in the Gemfile
|
77
77
|
if @dependencies["ruby-lsp"] &&
|
78
78
|
@dependencies["debug"] &&
|
79
79
|
(@rails_app ? @dependencies["ruby-lsp-rails"] : true)
|
80
80
|
$stderr.puts(
|
81
|
-
"Ruby LSP> Skipping
|
81
|
+
"Ruby LSP> Skipping composed bundle setup since LSP dependencies are already in #{@gemfile}",
|
82
82
|
)
|
83
83
|
|
84
84
|
return run_bundle_install
|
@@ -96,7 +96,7 @@ module RubyLsp
|
|
96
96
|
|
97
97
|
if @custom_lockfile.exist? && @lockfile_hash_path.exist? && @lockfile_hash_path.read == current_lockfile_hash
|
98
98
|
$stderr.puts(
|
99
|
-
"Ruby LSP> Skipping
|
99
|
+
"Ruby LSP> Skipping composed bundle setup since #{@custom_lockfile} already exists and is up to date",
|
100
100
|
)
|
101
101
|
return run_bundle_install(@custom_gemfile)
|
102
102
|
end
|
@@ -110,8 +110,8 @@ module RubyLsp
|
|
110
110
|
private
|
111
111
|
|
112
112
|
sig { returns(T::Hash[String, T.untyped]) }
|
113
|
-
def
|
114
|
-
@
|
113
|
+
def composed_bundle_dependencies
|
114
|
+
@composed_bundle_dependencies ||= T.let(
|
115
115
|
begin
|
116
116
|
original_bundle_gemfile = ENV["BUNDLE_GEMFILE"]
|
117
117
|
|
@@ -136,8 +136,8 @@ module RubyLsp
|
|
136
136
|
"",
|
137
137
|
]
|
138
138
|
|
139
|
-
# If there's a top level Gemfile, we want to evaluate from the
|
140
|
-
# Gemfile, so if there isn't one we need to add a default source
|
139
|
+
# If there's a top level Gemfile, we want to evaluate from the composed bundle. We get the source from the top
|
140
|
+
# level Gemfile, so if there isn't one we need to add a default source
|
141
141
|
if @gemfile&.exist? && @lockfile&.exist?
|
142
142
|
parts << "eval_gemfile(File.expand_path(\"../#{@gemfile_name}\", __dir__))"
|
143
143
|
else
|
@@ -187,7 +187,7 @@ module RubyLsp
|
|
187
187
|
env = bundler_settings_as_env
|
188
188
|
env["BUNDLE_GEMFILE"] = bundle_gemfile.to_s
|
189
189
|
|
190
|
-
# If the user has a
|
190
|
+
# If the user has a composed bundle path configured, we need to ensure that we will use the absolute and not
|
191
191
|
# relative version of it when running `bundle install`. This is necessary to avoid installing the gems under the
|
192
192
|
# `.ruby-lsp` folder, which is not the user's intention. For example, if the path is configured as `vendor`, we
|
193
193
|
# want to install it in the top level `vendor` and not `.ruby-lsp/vendor`
|
@@ -244,7 +244,7 @@ module RubyLsp
|
|
244
244
|
base_bundle = base_bundle_command(env)
|
245
245
|
|
246
246
|
# If `ruby-lsp` and `debug` (and potentially `ruby-lsp-rails`) are already in the Gemfile, then we shouldn't try
|
247
|
-
# to upgrade them or else we'll produce undesired source control changes. If the
|
247
|
+
# to upgrade them or else we'll produce undesired source control changes. If the composed bundle was just created
|
248
248
|
# and any of `ruby-lsp`, `ruby-lsp-rails` or `debug` weren't a part of the Gemfile, then we need to run `bundle
|
249
249
|
# install` for the first time to generate the Gemfile.lock with them included or else Bundler will complain that
|
250
250
|
# they're missing. We can only update if the custom `.ruby-lsp/Gemfile.lock` already exists and includes all gems
|
@@ -274,16 +274,16 @@ module RubyLsp
|
|
274
274
|
command << "1>&2"
|
275
275
|
|
276
276
|
# Add bundle update
|
277
|
-
$stderr.puts("Ruby LSP> Running bundle install for the
|
277
|
+
$stderr.puts("Ruby LSP> Running bundle install for the composed bundle. This may take a while...")
|
278
278
|
$stderr.puts("Ruby LSP> Command: #{command}")
|
279
279
|
|
280
|
-
# Try to run the bundle install or update command. If that fails, it normally means that the
|
281
|
-
# a bad state that no longer reflects the top level one. In that case, we can remove the whole directory, try
|
280
|
+
# Try to run the bundle install or update command. If that fails, it normally means that the composed lockfile is
|
281
|
+
# in a bad state that no longer reflects the top level one. In that case, we can remove the whole directory, try
|
282
282
|
# another time and give up if it fails again
|
283
283
|
if !system(env, command) && !@retry && @custom_gemfile.exist?
|
284
284
|
@retry = true
|
285
285
|
@custom_dir.rmtree
|
286
|
-
$stderr.puts("Ruby LSP> Running bundle install failed. Trying to re-generate the
|
286
|
+
$stderr.puts("Ruby LSP> Running bundle install failed. Trying to re-generate the composed bundle from scratch")
|
287
287
|
return setup!
|
288
288
|
end
|
289
289
|
|
@@ -330,14 +330,14 @@ module RubyLsp
|
|
330
330
|
if @rails_app
|
331
331
|
return false if @dependencies.values_at("ruby-lsp", "ruby-lsp-rails", "debug").all?
|
332
332
|
|
333
|
-
# If the
|
334
|
-
# before updating
|
335
|
-
return false if
|
333
|
+
# If the composed lockfile doesn't include `ruby-lsp`, `ruby-lsp-rails` or `debug`, we need to run bundle
|
334
|
+
# install before updating
|
335
|
+
return false if composed_bundle_dependencies.values_at("ruby-lsp", "debug", "ruby-lsp-rails").any?(&:nil?)
|
336
336
|
else
|
337
337
|
return false if @dependencies.values_at("ruby-lsp", "debug").all?
|
338
338
|
|
339
|
-
# If the
|
340
|
-
return false if
|
339
|
+
# If the composed lockfile doesn't include `ruby-lsp` or `debug`, we need to run bundle install before updating
|
340
|
+
return false if composed_bundle_dependencies.values_at("ruby-lsp", "debug").any?(&:nil?)
|
341
341
|
end
|
342
342
|
|
343
343
|
# If the last updated file doesn't exist or was updated more than 4 hours ago, we should update
|
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.
|
4
|
+
version: 0.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: language_server-protocol
|
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
217
|
- !ruby/object:Gem::Version
|
218
218
|
version: '0'
|
219
219
|
requirements: []
|
220
|
-
rubygems_version: 3.5.
|
220
|
+
rubygems_version: 3.5.23
|
221
221
|
signing_key:
|
222
222
|
specification_version: 4
|
223
223
|
summary: An opinionated language server for Ruby
|