Skip to content

Instantly share code, notes, and snippets.

@castwide
Last active April 27, 2024 08:54
Show Gist options
  • Save castwide/28b349566a223dfb439a337aea29713e to your computer and use it in GitHub Desktop.
Save castwide/28b349566a223dfb439a337aea29713e to your computer and use it in GitHub Desktop.
Enhance Rails Intellisense in Solargraph
# 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.
#
# You can put this file anywhere in the project, as long as it gets included in
# the workspace maps. It's recommended that you keep it in a standalone file
# instead of pasting it into an existing one.
#
# @!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>]
@glaucocustodio
Copy link

glaucocustodio commented Oct 24, 2022

You might be interested on the solargraph-rails gem instead of relying on this ad-hoc config file

@pedz
Copy link

pedz commented Oct 24, 2022

You might be interested on the solargraph-rails gem instead of relying on this ad-hoc config file

There is no "Up vote" so... thanks!

@Samuelodan
Copy link

This doesn't appear to have made a difference for me. I'm just confused at this point.

@AndreiMotinga
Copy link

@Samuelodan I found answer in the entire rails thread castwide/solargraph#87

you might need to install docs. in my case what helped me was

gem install yard
yard docs
bundle add solargraph solargraph-rails
solargraph config

.solargraph.yml

---
include:
  - "**/*.rb"
exclude:
  - spec/**/*
  - test/**/*
  - vendor/**/*
  - ".bundle/**/*"
require:
  - actioncable
  - actionmailer
  - actionpack
  - actionview
  - activejob
  - activemodel
  - activerecord
  - activestorage
  - activesupport
domains: []
reporters:
  - rubocop
  - require_not_found
formatter:
  rubocop:
    cops: safe
    except: []
    only: []
    extra_args: []
require_paths: []
plugins:
  - solargraph-rails
max_files: 5000

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