diff --git a/.index.yml b/.ruby-lsp.yml similarity index 100% rename from .index.yml rename to .ruby-lsp.yml diff --git a/lib/ruby_indexer/lib/ruby_indexer/configuration.rb b/lib/ruby_indexer/lib/ruby_indexer/configuration.rb index 9e00e5d4e4..abbfb0c0d7 100644 --- a/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +++ b/lib/ruby_indexer/lib/ruby_indexer/configuration.rb @@ -45,16 +45,20 @@ def initialize sig { void } def load_config - return unless File.exist?(".index.yml") + config_file = if File.exist?(".ruby-lsp.yml") + ".ruby-lsp.yml" + elsif File.exist?(".index.yml") # previously used name. Add a deprecation warning? + ".index.yml" + end - config = YAML.parse_file(".index.yml") - return unless config + config = YAML.parse_file(config_file) + return unless config # TODO: why would this be nil? config_hash = config.to_ruby validate_config!(config_hash) apply_config(config_hash) rescue Psych::SyntaxError => e - raise e, "Syntax error while loading .index.yml configuration: #{e.message}" + raise e, "Syntax error while loading #{config_file} configuration: #{e.message}" end sig { returns(T::Array[IndexablePath]) } diff --git a/lib/ruby_indexer/test/configuration_test.rb b/lib/ruby_indexer/test/configuration_test.rb index 31722a06c8..b0429b399e 100644 --- a/lib/ruby_indexer/test/configuration_test.rb +++ b/lib/ruby_indexer/test/configuration_test.rb @@ -20,6 +20,23 @@ def test_load_configuration_executes_configure_block assert(indexables.none? { |indexable| indexable.full_path == __FILE__ }) end + def test_supports_older_index_configuration + FileUtils.mv(".ruby-lsp.yml", ".ruby-lsp.yml.tmp") + s = <<~YAML + excluded_patterns: + - "**/test/fixtures/**/*.rb" + YAML + File.write(".index.yml", s) + + @config.load_config + indexables = @config.indexables + + assert(indexables.none? { |indexable| indexable.full_path.include?("test/fixtures") }) + ensure + FileUtils.rm_f(".index.yml") + FileUtils.mv(".ruby-lsp.yml.tmp", ".ruby-lsp.yml") + end + def test_indexables_only_includes_gem_require_paths @config.load_config indexables = @config.indexables