Ⅰ. 插件描述
Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'tweekmonster/deoplete-clang2'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'tweekmonster/deoplete-clang2'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'tweekmonster/deoplete-clang2'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/tweekmonster/deoplete-clang2
Ⅳ. 文档说明
<h1>deoplete-clang2
Electric Boogaloo</h1>
This is a clang completer for [deoplete.nvim][] that's faster than
[deoplete-clang][]. Instead of using libclang, it just uses clang -cc1
like most other clang plugins. Unlike other plugins, Objective-C was given a
little more attention.

If you are like me, you:
- want completions to be relatively easy to setup
- are not entirely sure how to use
clang -cc1 just want the damned completions
for Objective-C
- with the ability to fill in method arguments without having an aneurysm
and type
]to wrap method calls (within reason)- (you also think Xcode's method of doing this sucks)
also, magically get completions for the MacOSX SDKs
without Xcode
- on Linux
This was developed mainly to scratch an old itch. I'm currently not committed
to continuing development beyond fixing obvious bugs. Pull requests to add
useful features are welcome, though.
With that said, you may want to keep an eye on [clang-server][] that @zchee is
working on.
Requirements
- [Neovim][] or vim8 with if_python3
- [deoplete.nvim][]
clang
I'm using clang 3.8.0. Lower versions may work, but are untested.
Vim8 support:
- install nvim-yarp plugin for Vim8.
- install neovim python client:
pip install neovim - install vim-hug-neovim-rpc plugin for Vim8.
Install
Follow your package manager's instructions.
Usage
Completions will insert functions with argument placeholders in the form of<#Type var#>. While the cursor is on a line with one of these placeholders,
pressing <tab> will enter select mode with the next placeholder selected.
Pressing <tab> again will move to the next placeholder and pressing <s-tab>
will cycle backwards.
In Objective-C sources, pressing ] will try to place a [ in the appropriate
- While it isn't perfect, it's a whole lot better than how Xcode works.
You will have the best results by avoiding nested multi-argument method calls.
Config
Note: For simple projects, you probably don't need to configure anything. You
definitely shouldn't need to configure anything if your project uses a
[compilation database][].
Create a .clang file at your project root. You should be able to just paste
most of your compile flags in there (the parts that make sense at least).
Mainly, it should have the relevant -I, -D, -F flags. The plugin will
try to fill in the blanks for system include paths and discard the flags that
are causing completions to not work.
You can also use let g:deoplete#sources#clang#flags = ['-Iwhatever', ...] in
your nvim configs.
g:deoplete#sources#clang#executable sets the path to the clang executable.
g:deoplete#sources#clang#autofill_neomake is a boolean that tells this plugin
to fill in the g:neomake_<filetype>_clang_maker variable with the clang
executable path and flags. You will still need to enable it withg:neomake_<filetype>_enabled_makers = ["clang"].
g:deoplete#sources#clang#std is a dict containing the standards you want to
- It's not used if you already have
-std=whateverin your flags. The - are:
{
'c': 'c11',
'cpp': 'c++1z',
'objc': 'c11',
'objcpp': 'c++1z',
}g:deoplete#sources#clang#preproc_max_lines sets the maximum number of lines to
search for a #ifdef or #endif line. #ifdef lines are discarded to get
completions within conditional preprocessor blocks. The default is 50,
setting it to 0 disables this feature.
MacOSX10._ SDK completions
(You may find it funny that I haven't tested this on macOS)
Just add -darwin=10.XX to your flags (where XX is the release, e.g.10.8). It will be turned into the following flags:
-D__MACH__
-D__MAC_OS_X_VERSION_MAX_ALLOWED=10XX
-D__APPLE_CPP__
-DTARGET_CPU_X86_64
-fblocks
-fasm-blocks
-fno-builtin
-isysroot<sdk_path>
-iframework<sdk_path>/System/Library/Frameworks
-isystem<sdk_path>/usr/includeThe above is the minimum flags to get SDK completions without clang spewing a
litany of errors. If you're working on a simple project, -darwin=10.XX
should be the only flag you need.
On macOS, the following directories are searched for the SDK:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/Developer/SDKs~/Library/Developer/Frameworks(download destination)
On non-macOS:
$XDG_DATA_HOME/SDKsor~/.local/share/SDKs(download destination)
If the SDK is not found on the system or SDK paths, it will be downloaded from
[phracker/MacOSX-SDKs][] in the background.