Coc.nvim language servers: Difference between revisions

From wikinotes
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
COC exposes language servers to vim, you'll need them to perform completion etc.
You can have multiple language-servers running at once on the same language/file (ex: ruby solargraph+sorbet).
= Language Servers =
= Language Servers =
<blockquote>
<blockquote>
== Extensions ==
== Extensions ==
<blockquote>
<blockquote>
Language Servers may have a wrapper built for COC. These are called extensions.
Language Servers may have a wrapper built for COC. These are called extensions.<br>
They can be installed in a variety of ways:


You may install them dynamically with <code>:CocInstall coc-python</code><br>
<syntaxhighlight lang="vim">
and ''sometimes'' automatically like <code>Plug 'neoclide/coc-tsserver', {'do': 'yarn install --frozen-lockfile'}</code>.
" configured (install if not present)
let g:coc_global_extensions = ["coc-json", "coc-pyright", "coc-solargraph"]
 
" interactive
:CocInstall coc-python
</syntaxhighlight>


{| class="wikitable"
{| class="wikitable"
|-
!colspan=2| vim snippets
|-
| active || [[coc-snippets]]
|-
|-
!colspan=2| python
!colspan=2| python
Line 27: Line 42:
|-
|-
| active || [[coc-graphql]]
| active || [[coc-graphql]]
|-
!colspan=2| go
|-
| active || [[coc-go]]
|-
|-
|}
|}
Line 47: Line 66:
}
}
</source>
</source>
=== sorbet ===
<blockquote>
Shows type info in docs, very accurate completion.
<syntaxhighlight lang="json">
// ~/.config/nvim/coc-settings.json
{
  "languageserver": {
      "sorbet": {
        "command": "bundle",
        "args": ["exec", "srb", "tc", "--lsp"],
        "filetypes": ["ruby"]
      }
  }
}
</syntaxhighlight>
</blockquote><!-- sorbet -->
</blockquote><!-- Custom -->
</blockquote><!-- Custom -->
</blockquote><!-- Language Servers -->
</blockquote><!-- Language Servers -->

Latest revision as of 20:17, 22 July 2022

COC exposes language servers to vim, you'll need them to perform completion etc.

You can have multiple language-servers running at once on the same language/file (ex: ruby solargraph+sorbet).

Language Servers

Extensions

Language Servers may have a wrapper built for COC. These are called extensions.
They can be installed in a variety of ways:

" configured (install if not present)
let g:coc_global_extensions = ["coc-json", "coc-pyright", "coc-solargraph"]

" interactive
:CocInstall coc-python
vim snippets
active coc-snippets
python
unmaintained coc-python
active coc-pyright
sh, bash
active coc-sh
ruby
active, ruby/rails coc-solargraph
graphql
active coc-graphql
go
active coc-go

Custom

Some programs may be able to function as an LSP, and can be registered to do so.
see https://github.com/neoclide/coc.nvim/wiki/Language-servers#register-custom-language-servers

{
   "languageserver": {
      "sorbet": {
        "command": "srb",
        "args": ["tc", "--lsp"],
        "filetypes": ["ruby"]
      }
   }
}

sorbet

Shows type info in docs, very accurate completion.

// ~/.config/nvim/coc-settings.json
{
   "languageserver": {
      "sorbet": {
        "command": "bundle",
        "args": ["exec", "srb", "tc", "--lsp"],
        "filetypes": ["ruby"]
      }
   }
}