CoC LSP

Go through CoC docs to install it and do the basic, general configuration.

Ruby

Install coc-diagnostics or have something like this in .vimrc or init.lua:

let g:coc_global_extensions = [
      \ 'coc-diagnostic',
      \ 'coc-json',
      \ 'coc-yaml',
      \ 'coc-tsserver',
      \ 'coc-eslint',
      \ 'coc-solargraph',
      \ 'coc-css',
      \ ]

For nvim and lua init file, add the lines above inside vim.cmd [[ ... ]]:

vim.cmd [[
  normal vim config stuff here
]]

Then, in your Ruby project, suppose you have this Gemfile:

source "https://rubygems.org"

gem 'solargraph'
gem 'rubocop'
gem 'rspec'

Run bundle install, run vim/nvim and open a .rb file (inside from the project), and run command in nvim:

:CocLocalConfig

Then add some content like this inside the JSON file:

{
  "codeLens.enable": true,
  "solargraph.useBundler": true,
  "diagnostic-languageserver.linters": {
    "rubocop": {
      "command": "bundle",
      "sourceName": "rubocop",
      "debounce": 101,
      "args": [
        "exec",
        "rubocop",
        "--format",
        "json",
        "--force-exclusion",
        "%filepath"
      ],
      "parseJson": {
        "errorsRoot": "files[0].offenses",
        "line": "location.line",
        "column": "location.column",
        "message": "[${cop_name}] ${message}",
        "security": "severity"
      },
      "securities": {
        "fatal": "error",
        "warning": "warning"
      }
    }
  },
  "diagnostic-languageserver.filetypes": {
    "ruby": "rubocop"
  }
}

You should start seeing diagnostics (like syntax errors) and intellisense as you work on the ruby files.

References