-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect warning "no newline at end of file" #950
Comments
Does it happen only for that particular file or with every file? Could you specify some reproducible steps along with your settings as mentioned in CONTRIBUTING.md? |
Hi, I know my issue report was very weak. I'm sorry for that. Here you have a link to a folder with some files belong to neovim's source code: (Note: This problems happens with regular vim. I'm using vim to edit neovim's code). From those files:
fail with the "no newline at end of file" warning. The other ones don't. Can you reproduce it? Thanks. |
I just downloaded |
Great that you could reproduce it. I honestly didn't think it was going to be so easily reproducible. Thanks! |
The error is coming from libclang, not YCM. I'm sure you could provide a compiler flag (in ycm_extra_conf.py) to turn off this warning. |
Well, of course I can disable the warning, but that's not a solution. |
It is as far as YCM is concerned since if there's a bug here, it's in clang, not YCM. Nothing in YCM produced that error message.
When you call clang-the-binary, it uses some default compilation flags that you probably aren't setting in your extra conf file. We can't set them for you because they differ based on OS, configuration etc. See #303 for that. |
I understand what you say. But I still think there's something weird somewhere. Let me explain. |
At a quick glance, I see nothing obviously wrong in the extra conf file you linked. After you get the compile commands from the json file, you may need to add some more flags to them before returning them to YCM. You are assuming that whatever flags you use with clang-the-binary to compile successfully should automatically work without changes when given to libclang-the-library through YCM. I'd love it if that were the case, but it often isn't (again, see #303 for examples and background detail). Get the flags from the cmake-provided json file and then modify them as needed to compile without errors through libclang. Then pass the flags to YCM. |
Now I get you. I'll give that a try. Thanks!. |
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 ycm-core/YouCompleteMe#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.
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 ycm-core/YouCompleteMe#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.
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 ycm-core/YouCompleteMe#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.
How do I try compiling with "libclang-the-library through YCM"? YCM is displaying some errors that I don't see when passing the same compilation flags to clang(-the-binary). (Sorry if its a silly question, but I didn't see how to do this on a glance through the docs.) |
I'm receiving a "no newline at end of file" warning on a file that I positively know it has one (I can see it with xxd / hexdump). I would attach the file but I don't see how.
The text was updated successfully, but these errors were encountered: