klaaspieter / coc-sourcekit

Swift language server extension using sourcekit-lsp for coc.nvim.
MIT License
73 stars 9 forks source link
coc neovim sourcekit sourcekit-lsp swift vim

⚠️ I no longer use coc and therefore stopped maintaining coc-sourcekit.

coc-sourcekit

Sourcekit language server extension for coc.

Install

In vim or neovim, run command:

:CocInstall coc-sourcekit

Features

See sourcekit-lsp.

Configuration options

Key Description Default
sourcekit.enable Enable sourcekit extension true
sourcekit.commandPath Path to sourcekit-lsp binary Output of which sourcekit-lsp
sourcekit.trace.server Trace the communication between coc and the sourcekit language server
sourcekit.sdkPath The path to the desired SDK Nothing
sourcekit.sdk The name to the desired SDK to be fetched Nothing
sourcekit.targetArch The name of the target (e.g x86_64-apple-ios13.2-simulator) to generate code
sourcekit.args Extra arguments to pass to the lsp []
sourcekit.env Environment variables to pass to the lsp. {}

Environment Variables

You can configure SourceKit's logging and toolchain path through sourcekit.env:

"sourcekit.env": {
    "SOURCEKIT_TOOLCHAIN_PATH": "/home/USER/swift-DEVELOPMENT-SNAPSHOT-2021-07-30-a-ubuntu20.04/",
    "SOURCEKIT_LOGGING": "3" // verbose logging
}

Development

  1. Run yarn build or yarn build:watch
  2. Run yarn run link:add to link extension
  3. Open a Swift file in vim

To see that it worked use :CocOpenLog.

Alternatively a .env is provided which allows for tailing the logs outside of vim:

# In the split/tab you will open vim
source .env

# In another split/tab
tail -f coc.log

Or source it automatically.

Acknowledgements