I am trying to configure coc.nvim for my vim 8.2. I mapped my formatting to leader-d with:

nnoremap <Leader>d :call CocAction('format') <CR>

which works fine for ruby filetype. However, when I load _spec.rb files, with ruby.rspec filetype, my diagnostics are not being shown and my format mapping returns:

Error on request (format): Format provider not found for buffer: ...

My coc-config.json:

  "codeLens.enable": true,
  "solargraph.useBundler": false,
  "solargraph.commandPath": "/Users/dontmatter/.rbenv/shims/solargraph",
  "solargraph.formatting": true,
  "solargraph.diagnostics": true,
  "solargraph.checkGemVersion": true

and I am using standardrb config for rubocop:

  - standard
  - rubocop-rspec

  # First check this: https://github.com/testdouble/standard#how-do-i-run-standard-in-my-editor
  # If your editor invokes 'rubocop' directly and knows nothing about 'standard' gem, 
  # it can be useful to inherit 'standard' set of rules
  standard: config/base.yml
# You can also override standardrb rules
  EnforcedStyle: double_quotes

# Or enable additional Cops
  Enabled: true

Is there a way to enable solargraph to run on ruby.rspec filetype?

  • 1
    Welcome to Vi and Vim! You might want to reach out to the coc.nvim maintainers/community as well. If you get an answer, be sure to post it in the answer section below!
    – D. Ben Knoble
    Aug 14 '21 at 16:11

The setting I was looking for is called coc_fileype_map(doc). To make solargraph lint and autofix rspec.ruby file types, the following setting had to be added to my vimrc:

let g:coc_filetype_map = {
  \ 'rspec.ruby': 'ruby',
  \ }

Unfortunately, I didn't help me because Solargraph would crash trying to parse RSpec DSL as Ruby. I ended up uninstalling rspec-vim and letting vim treat *_spec.rb files as "normal" ruby files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.