From cbb0f0144a5dd9a9959e4e5e326132e753094aa0 Mon Sep 17 00:00:00 2001 From: Andy Waite Date: Mon, 15 Jul 2024 16:11:48 -0400 Subject: [PATCH] Unify ruby-lsp-doctor with ruby-lsp command (#2310) --- .github/workflows/ci.yml | 2 +- exe/ruby-lsp | 25 +++++++++++++++++++++++++ exe/ruby-lsp-doctor | 23 ----------------------- ruby-lsp.gemspec | 2 +- 4 files changed, 27 insertions(+), 25 deletions(-) delete mode 100755 exe/ruby-lsp-doctor diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8810f850d..b44a0c9e9 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 2335b4535..415b8ccd8 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 deleted file mode 100755 index 73a4477bc..000000000 --- a/exe/ruby-lsp-doctor +++ /dev/null @@ -1,23 +0,0 @@ -#!/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 diff --git a/ruby-lsp.gemspec b/ruby-lsp.gemspec index ff703831a..f74638015 100644 --- a/ruby-lsp.gemspec +++ b/ruby-lsp.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |s| s.files = Dir.glob("lib/**/*.rb") + ["README.md", "VERSION", "LICENSE.txt"] s.bindir = "exe" - s.executables = ["ruby-lsp", "ruby-lsp-check", "ruby-lsp-doctor"] + s.executables = ["ruby-lsp", "ruby-lsp-check"] s.require_paths = ["lib"] s.add_dependency("language_server-protocol", "~> 3.17.0")