ncm-clang


Ⅰ. 插件描述

DEPRECATED use https://github.com/ncm2/ncm2-pyclang instead

Ⅱ. 基本信息

创建日期:  2017-09-26
使用用户:  18
Github星:  30
插件作者:  rox

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'roxma/ncm-clang'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'roxma/ncm-clang'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'roxma/ncm-clang'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/roxma/ncm-clang

Ⅳ. 文档说明

## Introduction

clang completion integration for
nvim-completion-manager

ncm-clang

This plugin only support completion, for go to declaration support, and
others, you could try , for example,
Rip-Rip/clang_complete

Requirements

  • clang in your $PATH

Installation

Assuming you're using vim-plug

Plug 'roxma/ncm-clang'

Settings

If you're using cmake, add set(CMAKE_EXPORT_COMPILE_COMMANDS, 1) into
CMakeLists.txt so that compile_commands.json will be generated.

If your project is not using cmake, store the compile flags into a file named
.clang_complete.

g:ncm_clang#database_paths

THe paths for locating compile_commands.json. Default is
['compile_commands.json', 'build/compile_commands.json']

Utilities

ncm_clang#compilation_info()

Get compilation flags and directory for current file.

The following vimrc shows how to use
Rip-Rip/clang_complete's goto
declaration feature.

    " default key mapping is annoying
    let g:clang_make_default_keymappings = 0
    " ncm-clang is auto detecting compile_commands.json and .clang_complete
    " file
    let g:clang_auto_user_options = ''

    func WrapClangGoTo()
        let cwd = getcwd()
        let info = ncm_clang#compilation_info()
        exec 'cd ' . info['directory']
        try
            let b:clang_user_options = join(info['args'], ' ')
            call g:ClangGotoDeclaration()
        catch
        endtry
        " restore
        exec 'cd ' . cwd
    endfunc

    " map to gd key
    autocmd FileType c,cpp nnoremap <buffer> gd :call WrapClangGoTo()<CR>

The following vimrc shows how to work with w0rp/ale

    let g:ale_linters = {
        \   'cpp': ['clang'],
        \}
    autocmd BufEnter *.cpp,*.h,*.hpp,*.hxx let g:ale_cpp_clang_options = join(ncm_clang#compilation_info()['args'], ' ')

    " (optional, for completion performance) run linters only when I save files
    let g:ale_lint_on_text_changed = 'never'
    let g:ale_lint_on_enter = 0

添加新评论