2

I recently switched from ctags to clangd for better lsp support in neovim. Now clangd doesn't recognize my local include directories.

I tried the following .clangd files without success (with the first one at least the macros worked which is something)

CompileFlags:
    Add:
        - -I./include
        - -I./lib
        - -D_GNU_SOURCE
        - -DSHELL="/bin/sh"
CompileFlags:
  Add: [-D_GNU_SOURCE, -DSHELL="/bin/sh", -I./include, -I./lib]

the .clangd file is at the project root, but it just won't work. What gives?

1 Answer 1

2

clangd does not support relative paths in CompileFlags; see https://github.com/clangd/clangd/issues/1038.

The proper solution apparently is to use a compile_flags.txt or compile_commands.json file.

Related posts on Stack Overflow (where answers recommend to use CompileFlags in .clangd, they seem to neglect to mention that this only works for absolute paths):

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.