aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliseo Martínez <eliseomarmol@gmail.com>2014-10-20 12:29:34 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-10-20 08:14:30 -0300
commitd9592fdbd03b925413c9ca26cadc9702aa6c115a (patch)
tree78a278f70f22045325c468ae7801647f9350074c
parent77e918bc1f0067e0d15de8db13bfbc64bf2cf82b (diff)
downloadrneovim-d9592fdbd03b925413c9ca26cadc9702aa6c115a.tar.gz
rneovim-d9592fdbd03b925413c9ca26cadc9702aa6c115a.tar.bz2
rneovim-d9592fdbd03b925413c9ca26cadc9702aa6c115a.zip
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.
-rw-r--r--contrib/YouCompleteMe/ycm_extra_conf.py12
1 files changed, 11 insertions, 1 deletions
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
}