Ⅰ. 插件描述
Autocompletion for Swift in NeoVim with deoplete.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'mitsuse/autocomplete-swift'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'mitsuse/autocomplete-swift'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'mitsuse/autocomplete-swift'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/mitsuse/autocomplete-swift
Ⅳ. 文档说明
# autocomplete-swift
Autocompletion for Swift in NeoVim with deoplete.

Announcement
- The support for completion on SPM-based project is added.
- Autocompletion-swift droped support for Vim and completion with omni-function.
Please use this plugin in NeoVim with deoplete.nvim.
Installation
Autocomplete-swift uses SourceKitten as its back-end.
SourceKitten can be installed with Homebrew.
This plugin also requires PyYaml.
Please execute the following commands:
$ brew install sourcekitten
$ pip install pyyamlTo install autocomplete-swift,
it is recommended to use plugin manager such as dein.vim.
In the case of dein.vim, please add the following codes into init.vim and configure them:
call dein#add('Shougo/deoplete.nvim')
call dein#add('mitsuse/autocomplete-swift')This plugin also supports jumping to placeholders in arguments of method.
The following configuration is required:
" Jump to the first placeholder by typing `<C-k>`.
autocmd FileType swift imap <buffer> <C-k> <Plug>(autocomplete_swift_jump_to_placeholder)If you use neosnippet,
you should enable key-mappings of neosnippets instead of using the above code.
Autocomplete-swift gets along with neosnippet by converting placeholders into its ones.
swift filetype
If your vim setup doesn't set *.swift file's filetype to swift
you need to put this line in your config:
autocmd BufNewFile,BufRead *.swift set filetype=swiftFeatures
Completion
Autocomplete-swift supports types of completion as follow:
- Type name
- Type/Instance member
- Function/method/initializer parameter
- Top-level function/constant/variable
- Keyword such as
protocol,extensionetc. - Method definition
Placeholder
This plugin supports jumping to placeholders in arguments of method.
Please read Installation.
Custom Toolchain
The custom toolchain is available for completion.
For example, if you want to use Swift 4.2,
call autocomplete_swift#use_toolchain('Swift_4_2') orautocomplete_swift#use_custom_toolchain('com.apple.dt.toolchain.Swift_4_2').
Support for Swift Package Manager (SPM)
When you are editing a file managed with SPM, autocomplete-swift enables SPM-based completion.
It means that you can obtain candidates which come from dependencies (other files or libraries).
Xcode Project Support
The previous version supported completion with framework/SDK experimentally,
but the feature is removed because the completion server has fatal bugs.
TODO
- Make configurable. For example, autocomplete-swift will get
max_candiatesfor deoplete from a variable.
Related project
In the GIF on the beginning,
I use snippets for Swift contained in neosnippet-snippets
in addition to autocomplete-swift.
License
Please read LICENSE.