d-language-server / dls

A Language Server implementation for D
http://dls.dub.pm
106 stars 15 forks source link

vim coc support #55

Closed burner closed 4 years ago

burner commented 5 years ago

I tried getting vscode-dlang to work with neovim and coc using Plug to install it. Installing seemed to have worked as vscode-dlang was activated by neovim when opening an .d file. But dcd-server does not receive any completion requests.

It would be awesome if vscode-dlang would become a first class coc citizen.

LaurentTreguier commented 5 years ago

vscode-dlang is the extension for VSCode, for coc you should use DLS directly. You can install it with:

dub fetch dls
dub run dls:bootstrap

Then you should be able to configure it in coc's configuration file with a custom language server definition. It should probably look like something like this:

"languageserver": {
    "d": {
      "command": "/home/burner/.dub/packages/.bin/dls-latest/dls", // this path should be printed with the previous commands
      "args": ["--stdio"],
      "filetypes": ["d"],
      "trace.server": "off",
      "rootPatterns": ["dub.json", "dub.sdl"],
      "initializationOptions": {
      },
      "settings": {
      }
    }
  }

Initialization options and settings are listed in README.md.

burner commented 5 years ago

that got me closer but

2019-07-22T14:16:56.282 INFO (pid:22358) [language-client-index] - languageserver.d started with 22402
2019-07-22T14:16:56.567 DEBUG (pid:22358) [events] - Event: CursorHold [ 1 ]
2019-07-22T14:16:56.743 DEBUG (pid:22358) [events] - Event: CursorMoved [ 1, [ 1039, 1 ] ]
2019-07-22T14:16:57.062 DEBUG (pid:22358) [events] - Event: CursorHold [ 1 ]
2019-07-22T14:16:57.431 DEBUG (pid:22358) [events] - Event: CursorMoved [ 1, [ 1038, 1 ] ]
2019-07-22T14:16:57.606 DEBUG (pid:22358) [events] - Event: CursorMoved [ 1, [ 1037, 1 ] ]
2019-07-22T14:16:57.867 INFO (pid:22358) [services] - d state change: starting => stopped
2019-07-22T14:16:57.880 ERROR (pid:22358) [server] - unhandledRejection  Promise {
  <rejected> { ResponseError: Server not initialized
      at handleResponse (/home/burner/DotFiles/nvim/plugged/coc.nvim/build/index.js:38027:48)
      at processMessageQueue (/home/burner/DotFiles/nvim/plugged/coc.nvim/build/index.js:37854:17)
      at Immediate.setImmediate (/home/burner/DotFiles/nvim/plugged/coc.nvim/build/index.js:37838:13)
      at processImmediate (internal/timers.js:443:21) code: -32002, data: null } } { ResponseError: Server not initialized
    at handleResponse (/home/burner/DotFiles/nvim/plugged/coc.nvim/build/index.js:38027:48)
    at processMessageQueue (/home/burner/DotFiles/nvim/plugged/coc.nvim/build/index.js:37854:17)
    at Immediate.setImmediate (/home/burner/DotFiles/nvim/plugged/coc.nvim/build/index.js:37838:13)
    at processImmediate (internal/timers.js:443:21) code: -32002, data: null }

it dies with the above message.

burner commented 5 years ago

it seems to work on another project of mine.