neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Other
24.47k stars 954 forks source link

How do I get coc.nvim working with Swift files? #1178

Closed benwoodward closed 5 years ago

benwoodward commented 5 years ago

I have:

{
  "diagnostic.checkCurrentLine": true,
  "languageserver": {
    "swift": {
      "command": "sourcekit-lsp",
      "args": [],
      "filetypes": ["swift"],
      "initializationOptions": {},
      "settings": {
      }
    }
  }
}

Things seem to work, but they kind of don't. Some examples:

func expands to nothing: image

print doesn't evoke any completion options at all:

image

I also periodically see the following error in the status bar:

source languageserver.swift timeout after 2000ms

Do I have something configured incorrectly, or is this thing just not ready? Thanks.

chemzqm commented 5 years ago

You can increase timeout for completion.

benwoodward commented 5 years ago

Can you tell me how to do that please?

fannheyward commented 5 years ago

Add "suggest.timeout": 5000 to coc-settings.json to increase.

benwoodward commented 5 years ago

That fixed the timeout errors, however, sourcekit-lsp doesn't seem to be working properly. I tried rebuilding and changed my config to the following:

{
  "diagnostic.checkCurrentLine": true,
  "suggest.timeout": 2000,
  "languageserver": {
    "swift": {
      "command": "/Users/ben/dev/GitHub/sourcekit-lsp/.build/x86_64-apple-macosx/debug/sourcekit-lsp",
      "args": [],
      "filetypes": ["swift"],
      "initializationOptions": {},
      "settings": {
      }
    }
  }
}

I also think it only works on projects that have been compiled with swift build. Think I'm gonna forget about this for now and come back when the sourcekit-lsp is more mature.

chemzqm commented 5 years ago

You can checkout verbose output from language server: https://github.com/neoclide/coc.nvim/wiki/Debug-language-server#using-output-channel

benwoodward commented 5 years ago

So I updated my lsp config with "trace.server": "verbose" and if I view the logs with :CocCommand workspace.showOutput I see the following error:

[Trace - 2:59:42 PM] Received notification 'window/logMessage'.
Params: {
    "type": 4,
    "message": "could not find manifest, or not a SwiftPM package: /Users/ben/dev/swift/test"
}

Looks like sourcekit-lsp doesn't work with XCode projects, because there is currently no way for it to understand XCode project files.