c++cneovimclangd

getting include paths to work with Neovim and LSP-zero/Clangd


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.

how I would go about creating an include path for my lsp with nvim

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.


things I have done

over 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/**]

Solution

  • 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: