Skip to content

Instantly share code, notes, and snippets.

@gmcabrita
Last active June 5, 2024 14:21
Show Gist options
  • Save gmcabrita/b0912beaa6a1deee016e9e57fb160402 to your computer and use it in GitHub Desktop.
Save gmcabrita/b0912beaa6a1deee016e9e57fb160402 to your computer and use it in GitHub Desktop.
ruby-lsp .index.yml excluded_gems generator
require "yaml"
require "bundler"
config_file = ".index.yml"
config = if File.exist?(config_file)
YAML.load_file(config_file)
else
{}
end
bundler_gems = Bundler.locked_gems&.specs.map { _1.name }
ruby_gems = Dir.glob(File.join(RbConfig::CONFIG["rubylibdir"], "*")).map { Pathname.new(_1).basename.to_s.delete_suffix(".rb") }
config["excluded_gems"] = (bundler_gems + ruby_gems).uniq.sort
File.open(config_file, "w") { |f| YAML.dump(config, f) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment