Skip to content
Ryan Olson edited this page Jan 14, 2019 · 2 revisions

Swift

Apple has recently released sourcekit-lsp, which provides LSP support for Swift and C-style languages.

Installing Server

In order to install the sourcekit-lsp language server, please follow the instructions found in the sourcekit-lsp README. Please ensure that the sourcekit-lsp in in your path.

Setup vim-lsp

  1. Install vim-lsp-swift (which automatically registers the language server for Swift) OR
  2. Register the sourcekit-lsp yourself in your .vimrc

Installing vim-lsp-swift

If you'd like the vim-lsp-swift plugin to register the sourcekit-lsp for you, install the vim-lsp-swift plugin:

" After vim-lsp, etc
Plug 'ryanolsonx/vim-lsp-swift'

For more information, check out ryanolsonx/vim-lsp-swift.

Registering in .vimrc

Here's an example that shows how to manually setup a language server for Swift.

if executable('sourcekit-lsp')
    au User lsp_setup call lsp#register_server({
        \ 'name': 'sourcekit-lsp',
        \ 'cmd': {server_info->['sourcekit-lsp']},
        \ 'whitelist': ['swift'],
        \ })
endif

Clone this wiki locally