Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to avoid automatically adding header files after complete in Youcompleteme

I'm using vim on ubuntu 16.04 platform, I found the Youcompleteme plugin always automatically add some unnecessary header file.

A simple example like I use libtorch, the torch/torch.h header file contains all headers the package needed, and don't need specifying any other related header. Just like the pictures below:

enter image description here

The completion works well, but after I use space select the completion, the unwanted header torch/nn/module.h> was added automatically. enter image description here

I want to get a configure to disable automatically adding header files like this.

Any reply will be appreciated!

like image 935
Wechar Yu Avatar asked Feb 17 '20 11:02

Wechar Yu


People also ask

Is it correct to include all header files in AC program?

In C program should necessarily contain the header file which stands for standard input and output used to take input with the help of scanf() and printf() function respectively.

Which header file automatically includes in source code?

In the C and C++ programming languages, a header file is a file whose text may be automatically included in another source file by the C preprocessor by the use of a preprocessor directive in the source file.

What is Vim YouCompleteMe?

< Vim. YouCompleteMe (shortened as YCM) is a code-completion engine for Vim. It supports the following languages: C/C++/Objective-C/Objective-C++ Python.


1 Answers

I stumbled upon this problem when I switched from libclang based YCM to clangd based. The guys on the community chat helped to figure out the solution: you can add the following line into your ~/.vimrc file:

let g:ycm_clangd_args=['--header-insertion=never']

Read :help g:ycm_clangd_args and ./clangd --help-list for details on these options. It turns out there are plenty of cool configuration tweaks for clangd.

like image 148
Oleg Andriyanov Avatar answered Oct 18 '22 19:10

Oleg Andriyanov