Solargraph

A Ruby Language Server

Improving Performance

Here are a few tips that can help you get the best possible performance from the Solargraph language server.

Limit the Included Files

Add a .solargraph.yml file to the root directory of your project’s workspace. You can generate a file with the default configuration by running solargraph config.

The config file has two sections that determine which files to map in your workspace. The include section defines the files to map. The exclude section defines file patterns to remove from the inclusions.

Limiting which files are included is significantly faster than excluding files after the inclusions have been calculated. The default include section looks something like this:

include:
- "**/*.rb"

This rule will include all .rb files in your workspace. The exclude section will then exclude files that don’t usually need to be mapped, such as test/** and vendor/**.

If you know you only need to map specific folders, such as lib or app, you can limit the include section for faster workspace mapping:

include:
- "lib/**/*.rb"
- "app/**/*.rb"

See Configuration for more information about .solargraph.yml settings.

Use Multiple Workspaces

If you’re working in a very large project and your editor supports multi-root workspaces, you can split the workspace into separate folders. For example, let’s say you have two distinct codebases in the same project, one for an API server and one for a web server:

api/
  lib/
  app.rb
  Gemfile
web/
  lib/
  app.rb
  Gemfile

Add the api and web folders to your workspace. The language server will treat them as two separate projects. When you change something in api, the server will not need to perform any processing on web. Each workspace folder can also have its own .solargraph.yml file.

Maintain YARD Documentation

Although Solargraph can work with projects that have no YARD documentation at all, using tags like @return will not only give you better intellisense results, it will improve the overall performance of the language server by requiring less code analysis during editing. See Solargraph and YARD to learn how to use YARD effectively.

Troubleshoot the Workspace

Sometimes performance can degrade due to code that Solargraph is unable to map properly. Try scanning your workspace for problems.