Skip to content

Repository files navigation

ruby-lsp-rails-runtime-definitions

Ruby LSPで通常解決できないRailsの動的なViewヘルパーとController DSLを、実行時のsource_locationから定義元へ案内するアドオンです。

以下のような呼び出しから、gem内の定義へジャンプできます。

<%= javascript_importmap_tags %>
class ApplicationController < ActionController::Base
  stale_when_importmap_changes
end

Installation

GitHubリポジトリから利用する場合は、RailsプロジェクトのGemfileへ追加します。

group :development do
  gem "ruby-lsp-rails-runtime-definitions",
    github: "return-nil/ruby-lsp-rails-runtime-definitions",
    require: false
end

bundle install後にRuby LSPまたはエディタを再起動してください。

How it works

通常のRuby LSPが定義を返さなかった場合だけ、Ruby LSP Railsが起動しているRailsプロセスへ問い合わせます。

  • ERBではApplicationController.helpers.method(name).source_locationを使用します。
  • Controllerでは現在のControllerクラスのmethod(name).source_locationを使用します。
  • 定義ジャンプ時だけ問い合わせるため、入力中の解析処理には追加負荷をかけません。

Compatibility

  • Ruby 3.0以上
  • Ruby LSP 0.26.x
  • Ruby LSP Rails 0.4.x

Ruby LSPのアドオンAPIはexperimentalです。対応範囲外のバージョンではアドオンを読み込みません。

Development

bundle install
bundle exec rake

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages