Skip to content

Instantly share code, notes, and snippets.

@ZilvinasKucinskas
Forked from DRBragg/.solargraph.yml
Created January 31, 2023 20:29
Show Gist options
  • Save ZilvinasKucinskas/ab044b75557463aaedef6d536e3ee27f to your computer and use it in GitHub Desktop.
Save ZilvinasKucinskas/ab044b75557463aaedef6d536e3ee27f to your computer and use it in GitHub Desktop.
My config with steps to use solargraph for Rails projects in VS Code (WIP)
---
include:
- "app/**/*.rb"
- "config/**/*.rb"
- "lib/**/*.rb"
exclude:
- spec/**/*
- vendor/**/*
- ".bundle/**/*"
require:
- actionmailer
- actionpack
- actionview
- activejob
- activemodel
- activerecord
- activesupport
domains: []
reporters:
- rubocop
- require_not_found
- typecheck
- update_errors
formatter:
rubocop:
cops: safe
except: []
only: []
extra_args: []
require_paths: []
plugins:
- solargraph-rails
max_files: 5000
# The following comments fill some of the gaps in Solargraph's understanding of
# Rails apps. Since they're all in YARD, they get mapped in Solargraph but
# ignored at runtime.
#
# @!parse
# class ActionController::Base
# include ActionController::MimeResponds
# extend ActiveSupport::Callbacks::ClassMethods
# extend AbstractController::Callbacks::ClassMethods
# end
# class ActiveRecord::Base
# extend ActiveRecord::QueryMethods
# extend ActiveRecord::FinderMethods
# extend ActiveRecord::Associations::ClassMethods
# extend ActiveRecord::Inheritance::ClassMethods
# include ActiveRecord::Persistence
# end
# @!override ActiveRecord::FinderMethods#find
# @overload find(id)
# @param id [Integer]
# @return [self]
# @overload find(list)
# @param list [Array]
# @return [Array<self>]
# @overload find(*args)
# @return [Array<self>]
# @return [self, Array<self>]
  • Install the Ruby Solargraph VS Code extension and configure to your projects bundler path.
  • Run $ gem install solargraph solargraph-rails
  • Update the Ruby Solargraph VS Code extension's command path to point to the abolute path of your solargraph install.
  • In your Project root run $ solargraph config
    • Optional: Update the generated file with the config above (This is for my project YMMV)
  • In your Project root run $ solargraph bundle
  • Add the contents of this gist to your project (or see above). I keep mine in config/definitions.rb
  • In your Project root run $ yard gems
  • Restart VS Code
  • Profit?

These steps are mostly from memory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment