I'm currently Studying Computer enginering and taking embeded systems class, My isuse is that we use a custom library then compile it in a old version of Codewarrior.
I was woundering how I would go about creating an include path for my lsp with nvim, when I am not compiling the code localy but later compiling it with an old IDE
any wisdom would be apreciated.
note: in class we are required to use an exterior editor and the older version of code warrior is verry bad it is used for compiling for our micro controler but is unusable for writting code.
compile_commands.json
by copying my VSCode config for path locationover all I was hopping to find a solution and have poured over the getting started page and stack overflow for several hours trying different method to no avail.
the .clangd
file I used:
CompileFlags: # Tweak the parse settings
Add: -I=[${workspaceFolder}/**]
-I=[${workspaceFolder}/lib/Inc]
-I=[~/Documents/github/libraries/lib/**]
-I=[~/Documents/github/libraries/lib\hc12c\lib/**]
The easiest approach is probably to use a .clangd
file. Based on the path in your comment, the .clangd
file should look like this:
CompileFlags:
Add: -I/home/bjc1269/Documents/github/libraries/lib/hc12c/include
A few things that I'm seeing in the .clangd
file in your comment that don't work are:
${workspaceFolder}
. This is a VSCode feature that works in some VSCode settings like "clangd.arguments"
, but is not supported in a .clangd
file, which is editor-agnostic (for example, it works with editors that don't have a concept of a "workspace").~
. Expanding ~
to /home/<username>
is a feature of your shell. Command-line arguments specified in .clangd
are passed directly to the compiler without being processed by the shell, so ~
will not work.**
. To be honest, I'm not even sure what the intended semantics for this could be in the context of specifying include directories.-I
. Square brackets may appear in a .clangd
file as YAML syntax for specifying multiple values in a list, for example you might have:
CompileFlags:
Add: [-I/path/to/directory1, -I/path/to/directory2]
But if you write -I=[/path/to/directory]
, the brackets just get passed on verbatim to the compiler, which does not understand this syntax.