Ruby LSP Rails

Public
An opinionated language server for Ruby on Rails
Icons/chart bar
Used 18 times
Created by
V Viktor Schmidt

Usage

Run this command in your Rails app directory in the terminal:

rails app:template LOCATION="https://railsbytes.com/script/x9QsmG"
Template Source

Review the code before running this template on your machine.

def do_bundle
  Bundler.with_unbundled_env { run "bundle install" }
end

def print_green(heredoc)
  puts set_color heredoc, :green
end

def do_commit
  git :init
  git add: "."
  Bundler.with_unbundled_env { git commit: " -m 'Add language server for Ruby' " }
end

say "\nApplying language server for Ruby..."
inject_into_file 'Gemfile', after: 'group :development do' do
  <<-RUBY

  # Language server for Ruby
  gem "ruby-lsp-rails", require: false
  RUBY
end

do_bundle

say "\nAdding documentation for developers..."
create_file "docs/quality_assurance.md", "# Source code quality assurance and best praxis\n" unless File.exist? "docs/quality_assurance.md"
append_file "docs/quality_assurance.md" do
  <<~EOF 

  ## Ruby LSP

  [Ruby LSP Rails](https://rubygems.org/gems/ruby-lsp-rails) for code completion, inline documentation, and static analysis.

  Also check out Microsoft Visual Studio Code Extension:

  [Ruby LSP](https://marketplace.visualstudio.com/items?itemName=Shopify.ruby-lsp)
  or 
  [Shopify Ruby](https://marketplace.visualstudio.com/items?itemName=Shopify.ruby-extensions-pack)
  EOF
end

do_commit

print_green "\nAdded language server for Ruby successfully!"
Comments

Sign up or Login to leave a comment.