NvChad-2.5 icon indicating copy to clipboard operation
NvChad-2.5 copied to clipboard

Configuring Clangd linting

Open talowicz opened this issue 8 months ago • 9 comments

I am currently learning C++ but dont know how to configure clangd to not display these errors as I think it is trying to lint a newer C++ standard. The program compiles and runs fine so the erroneous linting is off-putting.

Image

Hope this is the appropriate channel to ask for help. Have a nice day!

talowicz avatar Apr 02 '25 14:04 talowicz

Are you using my neovim config? I'm away from the computer but those warnings look strange.

ProgrammingRainbow avatar Apr 02 '25 15:04 ProgrammingRainbow

Are you using my neovim config? I'm away from the computer but those warnings look strange.

Yeah, followed the github 1:1 and double checked it. Im stumped, im new to nvchad and modding nvim in general.

talowicz avatar Apr 02 '25 23:04 talowicz

So i think you are not going to like this answer or maybe you will. This had me scratching my head because i think i did the exact same thing you did without thinking. for fun using "shift + ;" to bring up the ":" do this

:echo &filetype

or

:set filetype?

if they come back as C then that is your issue. You have probably saved your file as .c not .cpp. at least that is what i just did not even thinking.

ProgrammingRainbow avatar Apr 03 '25 12:04 ProgrammingRainbow

So i think you are not going to like this answer or maybe you will. This had me scratching my head because i think i did the exact same thing you did without thinking. for fun using "shift + ;" to bring up the ":" do this

:echo &filetype

or

:set filetype?

if they come back as C then that is your issue. You have probably saved your file as .c not .cpp. at least that is what i just did not even thinking.

Thanks for replying, the commands you provided return cpp. Maybe its a clangd config issue? It might be trying to lint for a newer C++ standard but I have no idea how to configure clangd to use another standard. Ive never written C++ before so my observations may be off. Again thanks for the reply))

talowicz avatar Apr 03 '25 15:04 talowicz

do you have a .clangd file? or something that is configuring clangd? maybe something is setup for c. Because when my was a .c file i had the exact same messages as you do.

ProgrammingRainbow avatar Apr 03 '25 16:04 ProgrammingRainbow

:LspInfo

does that say this? - Detected filetype: cpp

ProgrammingRainbow avatar Apr 03 '25 16:04 ProgrammingRainbow

I copied my entire .config/nvim .local/share/nvim and .local/state/nvim directories to another machine, and have no errors. Ill have a proper look today when I am back on the desktop but atleast that narrows it down to maybe the clangd version??? or some other config files and is not necessarily an issue in your nvchad config repo! Both machines are running arch, and have all the dependencies for nvchad and such.

talowicz avatar Apr 04 '25 09:04 talowicz

Before you do that please check what i said above about :LspInfo I really think that even though nvim may know it's a cpp that clangd thinks it's a c file. So that should tell. you. And and you absolutely sure you don't have a hidden .clangd file that is setting the target to say std=c99 or something.

ProgrammingRainbow avatar Apr 04 '25 12:04 ProgrammingRainbow

Before you do that please check what i said above about :LspInfo I really think that even though nvim may know it's a cpp that clangd thinks it's a c file. So that should tell. you. And and you absolutely sure you don't have a hidden .clangd file that is setting the target to say std=c99 or something.

Will do!

talowicz avatar Apr 04 '25 17:04 talowicz