From d9592fdbd03b925413c9ca26cadc9702aa6c115a Mon Sep 17 00:00:00 2001 From: Eliseo Martínez Date: Mon, 20 Oct 2014 12:29:34 +0200 Subject: Improve YCM contrib: Fix 'no newline at end of file' issue. Problem: YCM was reporting a much disturbing warning about a missing newline at the end of some files. This was odd, as the newlines were there and the warning only was shown for some files, not for all of them. Cause: After discussing this issue with @Valloric (see https://github.com/Valloric/YouCompleteMe/issues/950), it turned out that not YCM, but libclang is responsible for it. This is, same compilation flags that produce no warnings with clang-the-binary on the command line, do produce them with libclang-the-library when used by YCM. Solution: Add an extra flag (-Wno_newline_eof) to those extracted from configuration database before passing them to YCM. --- contrib/YouCompleteMe/ycm_extra_conf.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'contrib/YouCompleteMe') diff --git a/contrib/YouCompleteMe/ycm_extra_conf.py b/contrib/YouCompleteMe/ycm_extra_conf.py index 249220bb2b..65b5b29099 100644 --- a/contrib/YouCompleteMe/ycm_extra_conf.py +++ b/contrib/YouCompleteMe/ycm_extra_conf.py @@ -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 } -- cgit From 20649051dd8245e2dc2ed84047f92d6ec25eca67 Mon Sep 17 00:00:00 2001 From: Eliseo Martínez Date: Mon, 20 Oct 2014 12:31:02 +0200 Subject: Improve YCM contrib: Improve documentation. --- contrib/YouCompleteMe/README.md | 15 +++++++++++---- contrib/YouCompleteMe/ycm_extra_conf.py | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'contrib/YouCompleteMe') 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 :YcmCompleter GoTo ``` diff --git a/contrib/YouCompleteMe/ycm_extra_conf.py b/contrib/YouCompleteMe/ycm_extra_conf.py index 65b5b29099..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 -- cgit