From 8e221d42a55e4822206142994572f2e52629c3b5 Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Mon, 15 Jul 2024 13:08:32 -0400 Subject: [PATCH] Unify ruby-lsp-doctor with ruby-lsp command --- .github/workflows/ci.yml | 2 +- exe/ruby-lsp | 25 +++++++++++++++++++++++++ exe/ruby-lsp-doctor | 22 ++-------------------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8810f850d9..b44a0c9e92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/exe/ruby-lsp b/exe/ruby-lsp index 2335b4535e..415b8ccd81 100755 --- a/exe/ruby-lsp +++ b/exe/ruby-lsp @@ -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 @@ -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 diff --git a/exe/ruby-lsp-doctor b/exe/ruby-lsp-doctor index 73a4477bc8..d42b7f226f 100755 --- a/exe/ruby-lsp-doctor +++ b/exe/ruby-lsp-doctor @@ -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)