/lsp-examples

Example configuration and test cases for language servers used with YCM

Primary LanguagePythonApache License 2.0Apache-2.0

Overview

This repo includes a simple way to install some language servers that might work with YouCompleteMe (strictly ycmd).

This repo comes with no warranty, and these engines are not officially supported by YCM, though they should work for the most part.

Quick start

Assuming you installed this repo in $HOME/Development/lsp:

  • For each of the servers you want, run the install script in that directory.
  • Add the following to your vimrc (remove any that you didn't install):
let g:ycm_language_server = [
  \   {
  \     'name': 'yaml',
  \     'cmdline': [ 'node', expand( '$HOME/Development/lsp/yaml/node_modules/.bin/yaml-language-server' ), '--stdio' ],
  \     'filetypes': [ 'yaml' ],
  \   },
  \   {
  \     'name': 'php',
  \     'cmdline': [ 'php', expand( '$HOME/Development/lsp/php/vendor/bin/php-language-server.php' ) ],
  \     'filetypes': [ 'php' ],
  \   },
  \   {
  \     'name': 'json',
  \     'cmdline': [ 'node', expand( '$HOME/Development/lsp/json/node_modules/.bin/vscode-json-languageserver' ), '--stdio' ],
  \     'filetypes': [ 'json' ],
  \   },
  \   {
  \     'name': 'ruby',
  \     'cmdline': [ expand( '$HOME/Development/lsp/ruby/bin/solargraph' ), 'stdio' ],
  \     'filetypes': [ 'ruby' ],
  \   },
  \   { 'name': 'kotlin',
  \     'filetypes': [ 'kotlin' ], 
  \     'cmdline': [ expand( '$HOME/Development/lsp/kotlin/server/build/install/server/bin/server' ) ],
  \   },
  \   { 'name': 'd',
  \     'filetypes': [ 'd' ], 
  \     'cmdline': [ expand( '$HOME/Development/lsp/d/serve-d' ) ],
  \   },
  \ ]
  • Adjust the directory as appropriate

Ruby

You need to be running a version of ruby that the parser understands: https://github.com/whitequark/parser#compatibility-with-ruby-mri

Recommend running in rbenv for that:

$ rbenv shell 2.3.8
$ cd ruby
$ ./install
$ vim test/test.rb

D

There is a number of external dependencies that you will want to install:

  • libphobos/liblphobos - the D standard library
  • dmd - the D compiler
  • dscanner - at the very least responsible for diagnostics
  • dcd - the D compiler daemon
  • Potentially dfmt - serve-d seems to be able to format code even without it.
  • dub - the D package manager

On top of that, you will want to configure the server, at least to let serve-d know about your modules. The configuration is done through ycmd's extra confs and the full list of serve-d's configuration options can be found here.

Note that the server executable on Windows is called serve-d.exe.

Kotlin

For whatever reason, the server expects you to have maven in your PATH and, just like serve-d, kotlin-language-server has its own configuration.

The server executable is actually a shell script and the build process produces server for Linux and server.bat for Windows.

Known Issues

  • yaml completer completions don't work because the server bugs always returns snippets, even though ycmd claims not to support them. Validation works though.
  • json completer completions don't work because the server bugs always returns snippets, even though ycmd claims not to support them. Validation works though.
  • php completer generally never works. It just seems broken.
  • kotlin completer currently requires merging of a pull request into master.