0
votes

EDITED.
Is there a way so that vim detects the path of the header files without using relative paths in the source files like #include "../foo.h"

How to set the path option correctly for the current project folder and how to make a rule for it so that every project with that folder structure can profit?

Are there plugins for it?

I have a multifile c project. int the project folder is one src and one include folder. the src directory contains all .c files, the include folder inhabits all .h files.

project
|_ src
|_ include

example: main.c

#include "..\foo.h"

..

Vim knows about foo.h if the file is within the src folder, but not if it is in the include folder

I have tried setting the path variable in the .vimrc file with no luck. All other includes from usr/include are working fine.

1
Why would Vim need to know about the paths? As long as your preprocessor/compiler knows about them with the -I .. argument - Cheatah
true. I recently switched from vscode to vim. In vscode you can set the include path, to get rid of the warnings. In vim, I use youcompleteme for autocompletion and it would be nice to get rid of the error warnings too. - FabianM
From your description, Vim is very unlikely to be the one throwing errors and warnings, here. Use that plugin's documentation/issue tracker. - romainl
See :h 'path' - Matt
@Matt can you describe how its done? i guess this is the answer im looking for - FabianM

1 Answers

0
votes

You must declare either a relative or Absolute path. So there is no "auto detection" just from a file name.

Side note: Vim doesn't care about your paths, the C Preprocessor Include cares about your paths