lspconfig for C/C++ language

{ pkgs, ...}: {
  programs.neovim = {

C/C++

Why use clangd instead of ccls?

I encountered the problem below, when view https://github.com/xieby1/openc910 smart_run/logical/tb/sim_main1.cpp

LSP[ccls]: Error NO_RESULT_CALLBACK_FOUND: {
  error = {
    code = -32603,
    message = "failed to index /home/xieby1/Codes/openc910/smart_run/work/fputc.c"
  },
  id = 1,
  jsonrpc = "2.0"
}

After some searching, I found

GitHub: neovim: issue: lsp: NO_RESULT_CALLBACK_FOUND with ccls, rust-analyzer #15844

sapphire-arches found:

Something is causing the r-a LSP to send two replies with the same ID, see the attached log: lsp_debug.log

It would be nice for the neovim LSP to handle this more gracefully (not filling my screen with garbage and taking focus), but I do think the bug is in R-A here? The problem seems to be related to editor.action.triggerParameterHints?

GitHub: ccls: issue: I'm very confused about this question, it's about ccls or neovim built in LSP? #836

No one try to fix the two-replies problem in ccls. However, nimaipatel recommanded clangd_extensions.

    extraLuaConfig = ''
      require('lspconfig').clangd.setup{
        filetypes = { "c", "cc", "cpp", "c++", "objc", "objcpp", "cuda", "proto" }
      }
      require("clangd_extensions.inlay_hints").setup_autocmd()
      require("clangd_extensions.inlay_hints").set_inlay_hints()
      require('lspconfig')['clangd'].setup {
        capabilities = require("cmp_nvim_lsp").default_capabilities(),
      }
    '';
    plugins = [
      pkgs.vimPlugins.clangd_extensions-nvim
    ];
    extraPackages = with pkgs; [
      clang-tools
    ];
  };
}