Ruby solargraph: Difference between revisions
From wikinotes
(→rails) |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
A LSP gem. | A ruby LSP gem. | ||
= Documentation = | = Documentation = | ||
Line 12: | Line 12: | ||
|} | |} | ||
</blockquote><!-- Documentation --> | </blockquote><!-- Documentation --> | ||
= Locations = | |||
<blockquote> | |||
{| class="wikitable" | |||
|- | |||
| <code>${PROJECT}/.solargraph.yml</code> || project configuration | |||
|- | |||
|} | |||
</blockquote><!-- Locations --> | |||
= Configuration = | |||
<blockquote> | |||
<syntaxhighlight lang="bash"> | |||
solargraph config # generate a .solargraph.yml | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="yaml"> | |||
# ${PROJECT}/.solargraph.yml | |||
include: | |||
- "lib/**/*.rb" | |||
- "app/**/*.rb" | |||
</syntaxhighlight> | |||
</blockquote><!-- Configuration --> | |||
= Languages = | = Languages = | ||
Line 30: | Line 54: | ||
# ${PROJECT}/config/initializers/${ANYTHING}.rb | # ${PROJECT}/config/initializers/${ANYTHING}.rb | ||
# source: https://gist.github.com/castwide/28b349566a223dfb439a337aea29713e | # source: https://gist.github.com/castwide/28b349566a223dfb439a337aea29713e | ||
# | # | ||
# The following comments fill some of the gaps in Solargraph's understanding of | # 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 | # Rails apps. Since they're all in YARD, they get mapped in Solargraph but | ||
Line 73: | Line 97: | ||
=== solargraph-rails === | === solargraph-rails === | ||
<blockquote> | <blockquote> | ||
{{ NOTE | | |||
This hasn't worked for me so far, using old ruby/rails }} | |||
The solargraph-rails gem also helps. https://github.com/iftheshoefritz/solargraph-rails | The solargraph-rails gem also helps. https://github.com/iftheshoefritz/solargraph-rails | ||
Line 85: | Line 111: | ||
# ${PROJECT}/.solargraph.yml | # ${PROJECT}/.solargraph.yml | ||
plugins: | |||
- solargraph-rails | - solargraph-rails | ||
</source> | </source> |
Latest revision as of 18:30, 28 December 2021
A ruby LSP gem.
Documentation
homepage https://github.com/castwide/solargraph rails support gist https://gist.github.com/castwide/28b349566a223dfb439a337aea29713e rails support issue https://github.com/castwide/solargraph/issues/87
Locations
${PROJECT}/.solargraph.yml
project configuration
Configuration
solargraph config # generate a .solargraph.yml# ${PROJECT}/.solargraph.yml include: - "lib/**/*.rb" - "app/**/*.rb"
Languages
ruby
Just works.
rails
Yard Initializer File
Solargraph official docs suggest adding latest version of https://gist.github.com/castwide/28b349566a223dfb439a337aea29713e to your project.
# ${PROJECT}/config/initializers/${ANYTHING}.rb # source: https://gist.github.com/castwide/28b349566a223dfb439a337aea29713e # # 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>]Rather than committing to the project, you may want to add to a global <coce>~/.gitignore.
# ~/.gitignore **/config/initializers/solargraph.rb
solargraph-rails
NOTE:
This hasn't worked for me so far, using old ruby/rails
The solargraph-rails gem also helps. https://github.com/iftheshoefritz/solargraph-rails
It looks like model comments are required, built using ruby annotate gem.
gem install solargraph # v40+ gem install solargraph-rails --pre # '--pre' required# ${PROJECT}/.solargraph.yml plugins: - solargraph-rails
Debugging
# run to start solargraph in a console before starting vim # you'll be able to use the output to debug issues solargraph stdio