Skip to content

Instantly share code, notes, and snippets.

@danest
Forked from DRBragg/.solargraph.yml
Last active April 13, 2024 01:42
Show Gist options
  • Save danest/5e9604775e3a6de6fc2d69ab3cb48495 to your computer and use it in GitHub Desktop.
Save danest/5e9604775e3a6de6fc2d69ab3cb48495 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:
- standardrb
formatter:
- standardrb
require_paths: []
plugins:
- solargraph-rails
- solargraph-standardrb
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