Solargraph: Reporters aren't with LanguageServer in Neovim

Created on 24 Oct 2019  路  5Comments  路  Source: castwide/solargraph

Hello, thanks for the nice tool. I'm having troubles with my setup. I'm use the LanguageClient for Neovim and solargraph. Having troubles with Rubocop setup. I have this in my project root directotry:

---
include:
- "**/*.rb"
exclude:
- spec/**/*
- test/**/*
- vendor/**/*
- ".bundle/**/*"
require: []
domains: []
reporters:
- rubocop
- require_not_found
require_paths: []
max_files: 5000

Autocomplete works perfectly but there are not any kinds of warnings from Rubocop. What is the problem? For example javascript-typescript-stdio works perfectly and shows all there
errors. NVIM detects LC root directory correctly. There are no errors in LanguageServer logs.
Ruby - 2.6.5
Solargraph - 0.37.2
Neovim - 0.4.2
Rubocop -0.75.1

$ solargraph reporters
rubocop
require_not_found
typecheck
update_errors

Also serverCommands settings from my .vimrc

let g:LanguageClient_serverCommands = {
    \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
    \ 'javascript.jsx': ['/usr/local/bin/javascript-typescript-stdio'],
    \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
    \ 'ruby.spec': ['~/.rbenv/shims/solargraph', 'stdio'],
    \ }

Most helpful comment

Of course, as soon as I write up the issue I discover the solution. 馃う Clearly my understanding of lua and how to configure these plugins leaves a lot to be desired.

Here's how I ended up getting it working in case anyone in the future is searching this repo...

:lua << END
  local on_attach_vim = function()
    require'completion'.on_attach()
    require'diagnostic'.on_attach()
  end

  require'nvim_lsp'.solargraph.setup{
    on_attach = on_attach_vim,
    settings = {
      solargraph = {
        diagnostics = { true }
      }
    }
  }
END

All 5 comments

Diagnostics reporting is disabled by default. There are two ways it can be enabled through the language server protocol:

  1. Set diagnostics: true in the initializationOptions parameter of the client's initialize request.
  2. Set diagnostics: true in the solargraph parameter of the client's workspace/didChangeConfiguration request.

I think LanguageClient-neovim at least has a way to configure initializationOptions in .vim/settings.json or something similar, but I don't know it well enough to say anything for certain. You might need to open an issue over there for more information.

The above configuration notes should enable diagnostics for any language client. If anyone still has problems, please comment or open a new issue.

First, thank you for the amazing project @castwide! I've been using solargrah for some time with coc.nvim and it's been working great.

Recently I thought I'd try to move to the native lsp support in Neovim (nightlies) and have been able to get solargraph integrated well via https://github.com/nvim-lua/completion-nvim. My next step was to try to get diagnostic information (RuboCop mostly, via https://github.com/nvim-lua/diagnostic-nvim) and I haven't had any success so far with that. I'm not seeing errors in logs, maybe I'm looking at the wrong logs?

I came across this issue and thought it seems similar to my experience with diagnostic-nvim. If you feel this is likely a problem with that plugin I'll happily open an Issue on that repo.

@johnallen3d Thanks!

If your workspace has a .solargraph.yml file, it should include rubocop in the reporters section, e.g.:

reporters:
- rubocop

More info about configurations: https://solargraph.org/guides/configuration

If you don't have that file or you're not opening a workspace, the default configuration includes rubocop, so it should still work.

I'm afraid I don't know enough about nvim to comment on specifics.

Of course, as soon as I write up the issue I discover the solution. 馃う Clearly my understanding of lua and how to configure these plugins leaves a lot to be desired.

Here's how I ended up getting it working in case anyone in the future is searching this repo...

:lua << END
  local on_attach_vim = function()
    require'completion'.on_attach()
    require'diagnostic'.on_attach()
  end

  require'nvim_lsp'.solargraph.setup{
    on_attach = on_attach_vim,
    settings = {
      solargraph = {
        diagnostics = { true }
      }
    }
  }
END
Was this page helpful?
0 / 5 - 0 ratings