All Projects → ncm2 → ncm2-pyclang

ncm2 / ncm2-pyclang

Licence: MIT license
Cached, fast C/C++ completion for ncm2

Programming Languages

python
139335 projects - #7 most used programming language
Vim Script
2826 projects

Projects that are alternatives of or similar to ncm2-pyclang

ncm2-path
No description or website provided.
Stars: ✭ 22 (-53.19%)
Mutual labels:  ncm2-plugin, ncm2-source
ncm2-jedi
No description or website provided.
Stars: ✭ 24 (-48.94%)
Mutual labels:  ncm2-plugin, ncm2-source
ncm2-bufword
completion words from current buffer
Stars: ✭ 22 (-53.19%)
Mutual labels:  ncm2-plugin, ncm2-source
ncm2-ultisnips
No description or website provided.
Stars: ✭ 46 (-2.13%)
Mutual labels:  ncm2-plugin
async-clj-omni
Async Clojure Completion for various (n)vim completion engines
Stars: ✭ 51 (+8.51%)
Mutual labels:  ncm2-source
ncm2-otherbuf
ncm2 plugin for completing words in other buffers
Stars: ✭ 19 (-59.57%)
Mutual labels:  ncm2-source

Introduction

C/C++ code completion plugin for ncm2

This plugin is based on libclang python binding. Inspired by clang_complete.

Features:

  • Support CMake or similar build systems that generate compile_commands.json
  • Support .clang_complete like clang-complete
  • Support Kbuild for linux kernel and u-boot, it generates something like init/.main.o.cmd
  • Support goto declaration. (not goto definition)
  • Support #include completion.

Config

g:ncm2_pyclang#library_path

Use g:ncm2_pyclang#library_path to specify the directory of libclang library or the file itself, e.g., for Linux:

" path to directory where libclang.so can be found
let g:ncm2_pyclang#library_path = '/usr/lib/llvm-5.0/lib'

" or path to the libclang.so file
let g:ncm2_pyclang#library_path = '/usr/lib64/libclang.so.5.0'

Notes:

  • Different operating systems normally have their own extensions for the libclang file.

    • Linux: libclang.so
    • macOS: libclang.dylib
    • Windows: libclang.dll
  • Sometimes ncm2-pyclang still works even you don't set g:ncm2_pyclang#library_path, that's because another libclang is found, which is probably the system libclang. The system libclang is often a bit old and is not guranteed to always be found, so I highly recommend set g:ncm_clang#library_path explicitly.

g:ncm2_pyclang#database_path

Usually, invoking cmake with option -DCMAKE_EXPORT_COMPILE_COMMANDS=ON generates the compilation database compile_commands.json.

The config g:ncm2_pyclang#database_path tells this plugin where to look for compilation database.

" a list of relative paths for compile_commands.json
let g:ncm2_pyclang#database_path = [
            \ 'compile_commands.json',
            \ 'build/compile_commands.json'
            \ ]

g:ncm2_pyclang#args_file_path

If your build system doesn't generate compile_commands.json, you could put a .clang_complete file into your project directory, which sould contain something like:

-DDEBUG
-include ../config.h
-I../common
" a list of relative paths looking for .clang_complete
let g:ncm2_pyclang#args_file_path = ['.clang_complete']

g:ncm2_pyclang#gcc_path

This option defaults to gcc. For some reason (I don't know), clang does not handle c++ builtin headers. This plugin uses gcc -xc++ -E -Wp,-v - to get a list of system header path.

If gcc is not available on your system, this plugin fallbacks to options definged in g:ncm2_pyclang#sys_inc_args_fallback.

You can open a C/C++ file, then execute :echo ncm2_pyclang#get_args_dir() to print the compiler arguments picked and passed to libclang.

Goto Declaration

    autocmd FileType c,cpp nnoremap <buffer> gd :<c-u>call ncm2_pyclang#goto_declaration()<cr>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].