Ruby

Solargraph

Install Syntax Highlighting

:TSInstall ruby
1

Install Language Server

:LspInstall solargraph
1

Project root is recognized by having one of the following files/folders in the root directory of the project: Gemfile , .git.

Formatting

Solargraph should automatically detect and use rubocop for formatting. To enable format on save add the following to your config

lvim.format_on_save = true
1

Older versions of LunarVim

Prior to commit d01ba08, the above did not work. If you have a commit older than d01ba08, the recommended way to install the language server for ruby is to do it locally, per project by either including it in your Gemfile or gem install solargraph.

LspInstall solargraph works for basic cases but will fail silently for more complex projects. This was an issueopen in new window with older builds of LunarVim

Also add the following to your config.lua

local util = require("lspconfig/util")
lvim.lang.ruby.lsp.setup = {
    cmd = { "solargraph", "stdio" },
    filetypes = { "ruby" },
    init_options = {
      formatting = true
    },
    root_dir = util.root_pattern("Gemfile", ".git"),
    settings = {
      solargraph = {
        diagnostics = true
      }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14