Closed omennia closed 1 month ago
"-isystem${workspaceFolder}/**", "--compile-commands-dir=${workspaceFolder}"
workspaceFolder
is a vscode specific variable which does not exist in Zed.
Thank you, that last bit must have been added by GitHub copilot.
Right now I have created a file in ~/Library/Preferences/clangd/config.yaml, with the following structure:
CompileFlags:
Add:
[
--gcc-toolchain=g++-14,
-std=gnu++17,
bugprone-*,
modernize*,
-Wno-error=conflicting-declarations,
-Wno-conflicting-declarations,
-Wl,
-ld_classic,
-I/opt/homebrew/Cellar/gcc/14.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin24/14/../../../../../../include/c++/14,
-I/opt/homebrew/Cellar/gcc/14.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin24/14/../../../../../../include/c++/14/aarch64-apple-darwin24,
-I/opt/homebrew/Cellar/gcc/14.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin24/14/../../../../../../include/c++/14/backward,
-I/opt/homebrew/Cellar/gcc/14.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin24/14/include,
-I/opt/homebrew/Cellar/gcc/14.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin24/14/include-fixed,
# # -I/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include,
# # -I/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks,
]
Remove:
[
Library/Developer/CommandLineTools/usr/lib/clang/16/include,
Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include,
Library/Developer/CommandLineTools/usr/include,
Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks,
]
Compiler: g++-14
And I am still getting an error like:
clang: In included file: declaration conflicts with target of using declaration already in scope
I don't understand what I am doing wrong. Everything works flawlessly in VSCode and Sublime Text.
I have managed to temporarily solve the issue by using ccls instead of clang.
I have created the .ccls file in my project root directory with the following content:
g++-14
%c -std=c17
%c -std=c++17
%h %hpp --include=Global.h
-I/opt/homebrew/Cellar/gcc/14.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin24/14/../../../../../../include/c++/14
-I/opt/homebrew/Cellar/gcc/14.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin24/14/../../../../../../include/c++/14/aarch64-apple-darwin24
-I/opt/homebrew/Cellar/gcc/14.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin24/14/../../../../../../include/c++/14/backward
-I/opt/homebrew/Cellar/gcc/14.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin24/14/include
-I/opt/homebrew/Cellar/gcc/14.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin24/14/include-fixed
And I have changed my lsp settings in Zed to:
"lsp": {
"clangd": {
"binary": {
"path": "/opt/homebrew/bin/ccls"
}
}
}
It no longer gives import conflict errors, but I am also no longer using clangd. If anyone finds a fix for clangd, please let me know.
Ok, I'm going to go ahead and close. Without a minimal repo that triggers the problem, it isn't really possible to reproduce your issue nor suggest what change(s) would be required to make it work.
Glad you were able to switch to using ccls. I knew it was an LSP that had GCC-specific support (unlike clangd) but I wasn't aware of anyone else using it with Zed. Exciting that you got it working!
Check for existing issues
Describe the bug / provide steps to reproduce it
I really love zed as an editor, but I need to use it to edit singular cpp files. I need some features that are only available to the GNU compiler.
Although I can use the gnu compiler to compile and run my code, I am using the clangd language server. It complains that it can't find libraries and everything that is only gnu related. Is there any way around this? Is it possible to make clangd recognize the gnu libraries?
I have searched everywhere and can't seem to find a definitive answer.
Environment
Here are my current settings:
I have tried to use g++-14 as the path in the clangd, but I get errors like:
If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your Zed.log file to this issue.
Zed.log