Solargraph

一个 Ruby 语言服务器。Solargraph 为 Ruby 编程提供了一套全面的工具:智能检测、诊断、内联文档和类型检查。「A Ruby language server. Solargraph provides a comprehensive suite of tools for Ruby programming: intellisense, diagnostics, inline documentation, and type checking.」

Github星跟蹤圖

Solargraph

RSpec

A Ruby Language Server

Solargraph provides a comprehensive suite of tools for Ruby programming: intellisense, diagnostics, inline documentation, and type checking.

Online Demo

A web-based demonstration of Solargraph's autocomplete is available at https://solargraph.org/demo.

Installation

Install the gem from the command line:

gem install solargraph

Or add it to your Gemfile:

gem 'solargraph', group: :development

Using Solargraph

Plug-ins and extensions are available for the following editors:

Configuration

Solargraph's behavior can be controlled via optional configuration files. The highest priority file is a .solargraph.yml file at the root of the project. If not present, any global configuration at ~/.config/solargraph/config.yml will apply. The path to the global configuration can be overridden with the SOLARGRAPH_GLOBAL_CONFIG environment variable.

Rails Support

For better Rails support, please consider using solargraph-rails

Gem Support

Solargraph is capable of providing code completion and documentation for gems that have YARD documentation. You can make sure your gems are documented by running yard gems from the command line. (YARD is included as one of Solargraph's gem dependencies. The first time you run it might take a while if you have a lot of gems installed).

When editing code, a require call that references a gem will pull the documentation into the code maps and include the gem's API in code completion and intellisense.

If your project automatically requires bundled gems (e.g., require 'bundler/require'), Solargraph will add all of the Gemfile's default dependencies to the map.

Type Checking

As of version 0.33.0, Solargraph includes a type checker that uses a combination of YARD tags and code analysis to report missing type definitions. In strict mode, it performs type inference to determine whether the tags match the types it detects from code.

Updating Core Documentation

The Solargraph gem ships with documentation for Ruby 2.2.2. You can download documentation for other Ruby versions from the command line.

$ solargraph list-cores      # List the installed documentation versions
$ solargraph available-cores # List the versions available for download
$ solargraph download-core   # Install the best match for your Ruby version
$ solargraph clear           # Reset the documentation cache

The Documentation Cache

Solargraph uses a cache directory to store documentation for the Ruby core and customized documentation for certain gems. The default location is ~/.solargraph/cache, e.g., /home/<username>/.solargraph/cache on Linux or C:\Users\<username>\.solargraph on Windows.

You can change the location of the cache directory with the SOLARGRAPH_CACHE environment variable. This can be useful if you want the cache to comply with the XDG Base Directory Specification.

Solargraph and Bundler

If you're using the language server with a project that uses Bundler, the most comprehensive way to use your bundled gems is to bundle Solargraph.

In the Gemfile:

gem 'solargraph', group: :development

Run bundle install and use bundle exec yard gems to generate the documentation. This process documents cached or vendored gems, or even gems that are installed from a local path.

In order to make sure you're using the correct dependencies, you can start the language server with Bundler. In VS Code, there's a solargraph.useBundler option. Other clients will vary, but the command you probably want to run is bundle exec solargraph socket or bundle exec solargraph stdio.

Rubocop Version

If you have multiple versions of rubocop installed and you would like to choose a version other than the latest to use, this specific version can be configured.

In .solargraph.yml:

---
reporters:
- rubocop:version=0.61.0  # diagnostics
formatter:
  rubocop:
    version: 0.61.0       # formatting

Integrating Other Editors

The language server protocol is the recommended way for integrating Solargraph into editors and IDEs. Clients can connect using either stdio or TCP. Language client developers should refer to https://solargraph.org/guides/language-server.

More Information

See https://solargraph.org/guides for more tips and tutorials about Solargraph.

Contributing to Solargraph

Bug Reports and Feature Requests

GitHub Issues are the best place to ask questions, report problems, and suggest improvements.

Development

Code contributions are always appreciated. Feel free to fork the repo and submit pull requests. Check for open issues that could use help. Start new issues to discuss changes that have a major impact on the code or require large time commitments.

Sponsorship and Donation

Use Patreon to support ongoing development of Solargraph at https://www.patreon.com/castwide.

You can also make one-time donations via PayPal at https://www.paypal.me/castwide.

主要指標

概覽
名稱與所有者castwide/solargraph
主編程語言Ruby
編程語言Ruby (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2017-03-18 13:15:12
推送於2024-07-03 05:00:57
最后一次提交2024-02-21 17:14:45
發布數154
最新版本名稱v0.50.0 (發布於 2023-12-05 15:47:03)
第一版名稱v0.7.5 (發布於 2017-05-16 07:41:15)
用户参与
星數1.9k
關注者數32
派生數158
提交數3.8k
已啟用問題?
問題數561
打開的問題數120
拉請求數109
打開的拉請求數19
關閉的拉請求數13
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?