mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
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.
This commit is contained in:
committed by
Thiago de Arruda
parent
77e918bc1f
commit
d9592fdbd0
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user