Skip to content

Confusion with clangd in C++ files. #19126

Description

@hugocardante

Check for existing issues

  • Completed

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:

{
  "assistant": {
    "default_model": {
      "provider": "zed.dev",
      "model": "claude-3-5-sonnet-20240620"
    },
    "version": "2"
  },
  "theme": "Ayu Dark",
  "languages": {
    "C++": {
      "compiler_path": "g++-14",
      "extra_clang_arguments": [
        "-std=c++17",
        "-isystem${workspaceFolder}/**",
        "-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks",
        "-isystem/opt/homebrew/Cellar/gcc/14.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/14/../../../../../../include/c++/14",
        "-isystem/opt/homebrew/Cellar/gcc/14.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/14/../../../../../../include/c++/14/aarch64-apple-darwin23",
        "-isystem/opt/homebrew/Cellar/gcc/14.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/14/../../../../../../include/c++/14/backward",
        "-isystem/opt/homebrew/Cellar/gcc/14.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/14/include",
        "-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include"
      ]
    }
  },
  "lsp": {
    "clangd": {
      "binary": {
        "path": "/usr/bin/clangd",
        "arguments": [
          "--background-index",
          "--clang-tidy",
          "--completion-style=detailed",
          "--header-insertion=iwyu",
          "--header-insertion-decorators=0",
          "--suggest-missing-includes",
          "--cross-file-rename",
          "--header-insertion=iwyu",
          "--header-insertion-decorators=0",
          "--suggest-missing-includes",
          "--cross-file-rename",
          "--compile-commands-dir=${workspaceFolder}"
        ]
      }
    }
  }
}

I have tried to use g++-14 as the path in the clangd, but I get errors like:

Language server error: clangd

oneshot canceled
-- stderr--

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:language server/server failureLanguage server doesn't work as expectedarea:languages/c++C++ programming language supportbugDEPRECATED label: use issue type 'Bug' instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions