add clangd to lspconfig

This commit is contained in:
2025-11-30 16:11:27 -07:00
parent ca3f573ffc
commit 050d923644
2 changed files with 83 additions and 19 deletions
+63
View File
@@ -139,6 +139,36 @@ return {
},
})
vim.lsp.config("clangd", {
cmd = {
"clangd",
"--background-index",
"--clang-tidy",
"--header-insertion=iwyu",
"--completion-style=detailed",
"--function-arg-placeholders",
"--fallback-style=llvm",
},
root_markers = {
"compile_commands.json",
"compile_flags.txt",
"configure.ac", -- AutoTools
"Makefile",
"configure.ac",
"configure.in",
"config.h.in",
"meson.build",
"meson_options.txt",
"build.ninja",
".git",
},
init_options = {
usePlaceholders = true,
completeUnimported = true,
clangdFileStatus = true,
},
})
vim.lsp.enable({ "lua_ls",
"clangd",
"ts_ls",
@@ -190,5 +220,38 @@ return {
'hrsh7th/nvim-cmp',
"L3MON4D3/LuaSnip",
},
},
{
'p00f/clangd_extensions.nvim',
dependencies = { 'nvim-lspconfig' },
keys = {
{ "<leader>ch", "<cmd>LspClangdSwitchSourceHeader<cr>", desc = "Switch Source/Header (C/C++)" },
},
ft = { 'c', 'cpp', 'objc', 'objcpp' },
opts = {
inlay_hints = {
inline = false,
},
ast = {
--These require codicons (https://github.com/microsoft/vscode-codicons)
role_icons = {
type = "",
declaration = "",
expression = "",
specifier = "",
statement = "",
["template argument"] = "",
},
kind_icons = {
Compound = "",
Recovery = "",
TranslationUnit = "",
PackExpansion = "",
TemplateTypeParm = "",
TemplateTemplateParm = "",
TemplateParamObject = "",
},
},
},
}
}