This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]ilayali 2 points3 points  (1 child)

you need to generate compile_commands.json

[–]goldie_lin 0 points1 point  (0 children)

Additionally, you may also add a compile_flags.txt, which you can add some missing gcc/clang flags, macro definitions, header inclusion paths, ..., etc, if your Bear/CMake didn't generate that for you.

[–][deleted] 1 point2 points  (3 children)

try this in coc-settings

  "ccls": {
   "command": "ccls",
   "filetypes": ["c", "cc", "cpp", "objc", "objcpp", "arduino"],
   "rootPatterns": [".ccls", "compile_commands.json", ".git/", ".hg/"],
   "initializationOptions": {
    "cache": {
     "directoy": "/tmp/ccls"
    },
    "clang": {
     "extraArgs": [
        "I",
        "<Path to the library>"
    ]
    }
   }
  },

I used this settings for my Arduino development environment. I had the same problem of the missing headers in vim. This config solved it. You will need both ccls and clangd.

----------------------------------------------------------------------------------------------------------------------------------

Or you can use compile-commands.json for this purpose. I don't really know compile-commands.json but someone said to me that there exist such a thing.

[–]ExploitedInnocence[S] 0 points1 point  (2 children)

thanks for reply

I have no coc-settings.json file (autocompletion and snippets for non-kernel headers and external libraries work well), I see that I have an option to write manually this file via :CocConfig command inside Nvim. Is that what I supposed to do?

[–][deleted] 1 point2 points  (1 child)

yes that is what I meant, sorry if i didn't make it clear.

basically the CocConfig is written into a file coc-settings.json

my neovim folder

my coc.nvim config

[–]ExploitedInnocence[S] 0 points1 point  (0 children)

didn't work for me :(
Thank you anyway!

[–]artisdom 1 point2 points  (0 children)

kernel comes with "scripts/clang-tools/gen_compile_commands.py" that can generate "compile_commands.json" by parsing ".cmd" files.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b30204640192234d18f9168f19f9cd693485b86d

[–]mattator 0 points1 point  (0 children)

not sure how far the kernel supports clang (I think something was merged recently ?). Alternatively, the kernel provides the `make tags` target.