I have just installed YCM and when i open a cpp file with vim and enable syntax i get the error:
"No .ycm_extra_conf.py file detected, so no compile flags are available. Thus no semantic support for C/C++/ObjC/ObjC++. See the docs for details."
I've found the file ".ycm_extra_conf.py" in "~/.vim/bundle/YouCompleteMe/cpp/ycm/"
does it belong to somewhere else?
YCM loads the file from the current dir plus you have to adapt it to your own project.
See: h: youcompleteme
Please read the docs more carefully.
thanks, a very helpful tip
If it's possible, could you find a way to print those error messages on multiple lines? When I went through this myself, I was only able to read two parts of the error message "you need to recompile" and "DONT FILE A BUG REPORT" -- until I resized my terminal to about 75 times the normal screen width.
For me, g:ycm_confirm_extra_conf was already set to 1, but I was still approving the ycm config py every time and it never 'remembered'. Eventually I just set g:ycm_global_ycm_extra_conf but if I ever need more than one of these config files for different projects, I'll have to read further and figure out how to get it to stop asking.
If it's possible, could you find a way to print those error messages on multiple lines?
I don't think that's possible, sadly.
For me, g:ycm_confirm_extra_conf was already set to 1, but I was still approving the ycm config py every time and it never 'remembered'. Eventually I just set g:ycm_global_ycm_extra_conf but if I ever need more than one of these config files for different projects, I'll have to read further and figure out how to get it to stop asking.
See g:ycm_extra_conf_globlist.
+1
@Valloric
Front-page documentation puts "usage" after installation - generally user will install and then play :) it would save you grief to create a topmost section called "IMPORTANT", or the like, to callout specific things that must be done in addition to installing. Even better would be that you add this step to the installation instructions for every OS (it's essentially part of the installation).
the instructions are not very helpful
the important instructions that need to be carried out along with the installation are buried deep somewhere under User Guide and that too after a handful of topics, between client-server architecture and writing you own completion engine. These are topics a first-timer now way expects to touch and mostly skips. Also it would be better if minimal setup instructions are listed out that just help in making it work first and then let people dive deep. I am trying to set-up this thing since a week now without any luck, and most probably will ditch it because its so complex and feels messed-up.
Bummer. I had a similar experience but I stuck with it long enough to make it work I think. Haven't used it since, but glad for this reminder it exists. Cause when our corporate overlords take over, it's something like this or it's Visual Studio, I guess! Everyone should really just have access to an expert to help with things like this.
What language(s) are you completing for?
I started the install script in folder
~/.vim/bundle/YouCompleteMe
like this
sudo bash ./install.sh
the error message no longer appears
i hope you are right
why don't make it generic? it doesn't work in any project out of the box, is a bug... Of course, you can pretend all the people trying to use the plugin are idiots and close the issue, but wouldn't be better to make it easier for users to get YCM functionalities out of the box?
It's impossible to make it generic. Every non-trivial C or C++ project needs a different set of flags. Think like this. One example project is Vim. It has support for many OS's and many features could be turned on or off with compiler flags. Another project could be anything bare-metal - you would need flags that support the sepcific hardware, but there is on OS is sight (unless you count minimal rt kernel as an OS). These two will never be satisfied with the same set of flags.
The YCM team does prefer configurationless setup, but here it's unavoidable. Check any C linting or completion engine. All of them require flags custom tailored by the user. The only difference is, others might silently fail to work. YCM is loud and clear about what is wrong.
Leaving aside all the fancy plugins, to point out more that custom flags are needed, let's have a look at build systems.
At the lowest level we have the compiler itself. Thousands upon thousands of switches for enabling/disabling specific flags. Then we have the minimal abstraction called make (no matter which flavour). But many think even that is too tedious to write by hand, so today we have cmake, scons, autoconf and automake and others. If it were possible to have common flags a ton of tools wouldn't have ever existed ad everyone would have been using their compiler directly. But (unfortunately?) with low level languages (not just C and C++) the user needs to know what he himself needs/wants.
Sorry if I'm failing to see how syntax completion (IntelliSense like) have anything to do with the user Having to specify in every project a file with x configuration, should be language wise, as code::blocks, clion, NetBeans, eclipse,... does, I DO appreciate the effort and still believe this plugin is awesome, and I would like to contribute to it, what I'm trying to say is: You don't say to people who took their time to raise a bug "Go read the documentation!", We should provide solutions instead...
But it's not "language-wise" even in the IDE's you mentioned. I have personally been in situations where I had to go through loads of menus and dialogs to make the IDE work with a project I'm developing. It's the same thing here, you just don't get the fancy GUI.
Here are a few examples:
So no tool works out of the box. Further more, I had to read up on configuring all of those IDEs, just like I had to read up on writing .ycm_extra_conf.py.
If we add different standards into thte mix, things get even worse. Vim requires ANSI-C (C89), while ycmd requires C++11.
Then there are optimization flags. Enabling some optimization flags will make some software able to compile while doing the opposite for other. If you look at the man gcc there will be a section about -O3 and -Ofast. Enable those and see things like curl, opus and protobuf failing to build for obscure reasons.
In case it's not clear why I'm talking about compiling so much, it's because successful compilation is required for semantic completion (intellisense).
That said, if you can find a way to improve the current situation, make a pull request.
This is explained here https://github.com/Valloric/YouCompleteMe#c-family-semantic-completion
Simply put: If libclang can't parse your code, YouCompleteMe can't provide semantic analysis.
This is true of any IDE or static analysis tool which parses your code. Without exception.
I suggest if it isn't obvious why, you could watch his video where Casey explains how compilers and c work in excruciating detail: https://www.youtube.com/watch?v=n4fI4eUTTKM
I have added the following line to my ~/.vim/vimrc
let g:ycm_global_ycm_extra_conf = "~/.vim/ycm_extra_conf.py"
And copied the minimal extra conf from the docs into the file. I still get the message. I have also tried adding the same minimal extra conf to the .ycm_extra_conf.py in the directory where I am trying to edit a C++ file. And I still get the message. I am confused.
@MadWombat I guess this might be a bit late, but your .vimrc should be in your home directory, not in the .vim directory.
Vim supports both ~/.vimrc and ~/.vim/vimrc locations for the main config file. You can see that by running :version, here is partial output from mine
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
serup above is completely correct. Running the install.sh script simply works - out-of-the-box on ubuntu 16.04
Didn't work for me... still getting the pop-up window.
I just want to add that as of 2017, the "install.sh" script is deprecated. Now, you have to use the install.py script instead by typing
./install.py --clang-completer
Also, in your .vimrc file, instead of ".vim/bundle/blahblahblah", you'll need to add a "~/" in front of the address by adding:
let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py"
to your .vimrc file, to give it an absolute path from the Home directory so that Vim can find the ".ycm_extra_conf.py" file. Otherwise, you might experience some funny behavior.
let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py
You should not do this, as explained in the documentation.
This thread is old and misleading, so I have locked it.
Most helpful comment
I started the install script in folder
like this
the error message no longer appears