diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-10-20 08:14:36 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-10-20 08:14:44 -0300 |
commit | 1eb3dae04a8fd703dcbc6257a3cf22a460e0d967 (patch) | |
tree | 39677e665e7d8db258656fdd0084cdb8d45b7f75 | |
parent | 77e918bc1f0067e0d15de8db13bfbc64bf2cf82b (diff) | |
parent | 20649051dd8245e2dc2ed84047f92d6ec25eca67 (diff) | |
download | rneovim-1eb3dae04a8fd703dcbc6257a3cf22a460e0d967.tar.gz rneovim-1eb3dae04a8fd703dcbc6257a3cf22a460e0d967.tar.bz2 rneovim-1eb3dae04a8fd703dcbc6257a3cf22a460e0d967.zip |
Merge PR #1310 'Improve YCM contrib.'
-rw-r--r-- | contrib/YouCompleteMe/README.md | 15 | ||||
-rw-r--r-- | contrib/YouCompleteMe/ycm_extra_conf.py | 14 |
2 files changed, 23 insertions, 6 deletions
diff --git a/contrib/YouCompleteMe/README.md b/contrib/YouCompleteMe/README.md index 85bbe29dec..940f49363b 100644 --- a/contrib/YouCompleteMe/README.md +++ b/contrib/YouCompleteMe/README.md @@ -1,4 +1,8 @@ -# YouCompleteMe +# YouCompleteMe Integration + +## What is this? + +This provides the necessary to configure vim's YCM plugin to provide C semantic support (completion, go-to-definition, etc) for the neovim project. ## Installation @@ -9,7 +13,10 @@ Install [YouCompleteMe](https://github.com/Valloric/YouCompleteMe). ### Step 2 ```bash -cp ycm_extra_conf.py ../../src/nvim/.ycm_extra_conf.py -echo src/nvim/.ycm_extra_conf.py >> ../../.git/info/exclude -make -C ../.. cmake +cp contrib/YouCompleteMe/ycm_extra_conf.py src/.ycm_extra_conf.py +echo .ycm_extra_conf.py >> .git/info/exclude +make + +(somewhere in you .vimrc files) +autocmd FileType c nnoremap <buffer> <silent> <C-]> :YcmCompleter GoTo<cr> ``` diff --git a/contrib/YouCompleteMe/ycm_extra_conf.py b/contrib/YouCompleteMe/ycm_extra_conf.py index 249220bb2b..ae5d3d1a36 100644 --- a/contrib/YouCompleteMe/ycm_extra_conf.py +++ b/contrib/YouCompleteMe/ycm_extra_conf.py @@ -8,7 +8,7 @@ def DirectoryOfThisScript(): def GetDatabase(): - compilation_database_folder = DirectoryOfThisScript() + '/../../build' + compilation_database_folder = DirectoryOfThisScript() + '/../build' if os.path.exists(compilation_database_folder): return ycm_core.CompilationDatabase(compilation_database_folder) return None @@ -26,6 +26,9 @@ def GetCompilationInfoForFile(filename): if IsHeaderFile(filename): basename = os.path.splitext(filename)[0] c_file = basename + '.c' + # for pure headers (no c file), default to main.c + if not os.path.exists(c_file): + c_file = os.path.join(DirectoryOfThisScript(), 'main.c') if os.path.exists(c_file): compilation_info = database.GetCompilationInfoForFile(c_file) if compilation_info.compiler_flags_: @@ -38,7 +41,14 @@ def FlagsForFile(filename): compilation_info = GetCompilationInfoForFile(filename) if not compilation_info: return None + # Add flags not needed for clang-the-binary, + # but needed for libclang-the-library (YCM uses this last one). + flags = (list(compilation_info.compiler_flags_) + if compilation_info.compiler_flags_ + else []) + extra_flags = ['-Wno-newline-eof'] + final_flags = flags + extra_flags return { - 'flags': compilation_info.compiler_flags_, + 'flags': final_flags, 'do_cache': True } |