Coc in Neovim seems to be unable to see #include <avr/io.h>
since I'm guessing that it's include path isn't known by coc. How can I allow coc to see this include path?
Asked
Active
Viewed 2,799 times
0
-
This has nothing to do with coc. Which language server are you using? Check the language server documentation. – jdhao Dec 26 '21 at 08:07
-
@jdhao I'm using clangd – Kalcifer Dec 29 '21 at 09:13
-
This might be of some help: https://jdhao.github.io/2021/07/03/install_clangd_on_linux/#how-to-use-clangd. You need to set up the correct compilation flags, include paths etc. – jdhao Dec 29 '21 at 09:29
-
@jdhao what I cant figure out is how to get clangd to use `compilation_flags.txt` or `compile_commands.json`. I think it has to do with configureing `coc-settings.json` but I'm not sure at all where to start with that. I though that [this](https://github.com/neoclide/coc.nvim/wiki/Using-the-configuration-file) page would have some information, but it wasn't much help. – Kalcifer Dec 29 '21 at 09:33
-
For me, I just put `compile_flags.txt` in project (note it is **not** `compilation_flags.txt`) root and autocompletion starts to work. I am using the builtin nvim lsp client though. I have no knowledge about coc.nvim. My config is [here](https://github.com/jdhao/nvim-config), if you are interested. – jdhao Dec 29 '21 at 09:50
-
@jdhao Ok, so I tried putting the `compile_flags.txt` in the root of the folder, and added `-I /usr/avr/include` to it, but it still didn't add the autocompletion. – Kalcifer Dec 29 '21 at 10:11
1 Answers
1
A solution was found to be the following:
- In the root of your project directory (the base of compilation) add a file called
compile_flags.txt
. - To the
compile_flags.txt
file, for the AVR includes, add-I/usr/avr/include
.
NOTE: The compile_flags.txt
file only accepts a single argument per line, so the actual contents of this file should be
-I
/usr/avr/include
References: JSON Compilation Database Format Specification

Kalcifer
- 1,211
- 12
- 18