clangd / coc-clangd

clangd extension for coc.nvim
Apache License 2.0
757 stars 34 forks source link

doesn't take ~/.clangd into account #679

Closed GopherJ closed 2 months ago

GopherJ commented 2 months ago

Please describe the problem. For hints on what information is helpful, see: https://clangd.llvm.org/troubleshooting.html

  1. https://github.com/GopherJ/dotfiles/tree/master/cmake
  2. edit cmake/src/kernel.cu

Logs image

System information Clangd version (from the log, or clangd --version): 15.0.7 clangd extension version (from :CocInfo): 0.30.2 Operating system: x86_64-pc-linux-gnu

GopherJ commented 2 months ago

I encountered a clangd issue: https://github.com/clangd/clangd/issues/1142, so I tried to create ~/.clangd file with the following content:

CompileFlags:
  Add: -Wno-unknown-warning-option
  Remove: [-m*, -f*, -forward-unknown-to-host-compiler, --generate-code*]
Diagnostics:
  Suppress: [drv_unknown_argument,drv_unsupported_opt]

but it didn't fix the issue

fannheyward commented 2 months ago

The .clangd configuration file should be located in project root https://clangd.llvm.org/config.html#files.

You can use :CocCommand clangd.projectConfig to open it.

GopherJ commented 2 months ago

@fannheyward I used this command to create this config file but it wasn't working yet, I still have the error

fannheyward commented 2 months ago

The .clangd file is in the project root, not your $HOME directory.

GopherJ commented 2 months ago

@fannheyward I used your command so it's not in $HOME directory, specifically it's in dotfiles root directory, I tried to copy to cmake directory as well

GopherJ commented 2 months ago

@fannheyward FYI, I think coc-setting's diagnostic = false still works. Though I don't think it uses .clangd

GopherJ commented 2 months ago

@fannheyward I tried to configure:

"clangd.arguments": ["--enable-config"],

but it doesn't work either, anything specific to my version of clangd? I use clangd-15

fannheyward commented 2 months ago

specifically it's in dotfiles root directory

Why? The :CocCommand clangd.projectConfig command should open the .clangd file in your project root, never in any other locations.

coc-clangd provides this command only used to create or open the configuration file, clangd will search and use it, coc-clangd won't use it.

Check the https://clangd.llvm.org/config.html#files docs.

GopherJ commented 2 months ago

@fannheyward I don't understand, the command works and it's in correct location but as I said it doesn't have any effect

No matter if you edit the config or not, it just didn't take effect. I don't know if I misconfigured anything or not, but I really dont have any custom config

I say dotfiles is because it's the project root of my test cmake project.

dotfiles/

fannheyward commented 2 months ago

where's the .clangd file? Under dotfiles or in cmake folder?