Skip to content

Commit

Permalink
Unify ruby-lsp-doctor with ruby-lsp command
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Jul 15, 2024
1 parent fa2e928 commit 8e221d4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: bundle exec rake

- name: Run index troubleshooting tool
run: bundle exec ruby-lsp-doctor
run: bundle exec ruby-lsp --doctor
lint_node:
runs-on: ubuntu-latest
steps:
Expand Down
25 changes: 25 additions & 0 deletions exe/ruby-lsp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ parser = OptionParser.new do |opts|
options[:experimental] = true
end

opts.on("--doctor", "Run troubleshooting steps") do
options[:doctor] = true
end

opts.on("-h", "--help", "Print this help") do
puts opts.help
puts
Expand Down Expand Up @@ -107,4 +111,25 @@ if options[:time_index]
return
end

if options[:doctor]
if File.exist?(".index.yml")
begin
config = YAML.parse_file(".index.yml").to_ruby
rescue => e
abort("Error parsing config: #{e.message}")
end
RubyIndexer.configuration.apply_config(config)
end

index = RubyIndexer::Index.new

puts "Globbing for indexable files"

RubyIndexer.configuration.indexables.each do |indexable|
puts "indexing: #{indexable.full_path}"
index.index_single(indexable)
end
return
end

RubyLsp::Server.new.start
22 changes: 2 additions & 20 deletions exe/ruby-lsp-doctor
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
require "ruby_lsp/internal"

if File.exist?(".index.yml")
begin
config = YAML.parse_file(".index.yml").to_ruby
rescue => e
abort("Error parsing config: #{e.message}")
end
RubyIndexer.configuration.apply_config(config)
end

index = RubyIndexer::Index.new

puts "Globbing for indexable files"

RubyIndexer.configuration.indexables.each do |indexable|
puts "indexing: #{indexable.full_path}"
index.index_single(indexable)
end
puts "The ruby-lsp-doctor command is deprecated. Please run `ruby-lsp --doctor` instead."
exit(1)

0 comments on commit 8e221d4

Please sign in to comment.