mirror of
https://github.com/SoPat712/dotfiles.git
synced 2025-08-21 18:38:46 -04:00
clangd fixes
This commit is contained in:
34
nvim/.config/nvim/lua/plugins/clangd-extensions.lua
Normal file
34
nvim/.config/nvim/lua/plugins/clangd-extensions.lua
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
return {
|
||||||
|
"p00f/clangd_extensions.nvim",
|
||||||
|
lazy = true,
|
||||||
|
clangd_config = function(_, opts)
|
||||||
|
local clangd_ext_opts = require("lazyvim.util").opts("clangd_extensions.nvim")
|
||||||
|
require("clangd_extensions").setup(vim.tbl_deep_extend("force", clangd_ext_opts or {}, { server = opts }))
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
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 = "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
@@ -1,98 +0,0 @@
|
|||||||
return {
|
|
||||||
|
|
||||||
-- Add C/C++ to treesitter
|
|
||||||
{
|
|
||||||
"nvim-treesitter/nvim-treesitter",
|
|
||||||
opts = function(_, opts)
|
|
||||||
if type(opts.ensure_installed) == "table" then
|
|
||||||
vim.list_extend(opts.ensure_installed, { "c", "cpp" })
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"p00f/clangd_extensions.nvim",
|
|
||||||
lazy = true,
|
|
||||||
config = function() end,
|
|
||||||
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 = "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Correctly setup lspconfig for clangd 🚀
|
|
||||||
{
|
|
||||||
"neovim/nvim-lspconfig",
|
|
||||||
opts = {
|
|
||||||
servers = {
|
|
||||||
-- Ensure mason installs the server
|
|
||||||
clangd = {
|
|
||||||
keys = {
|
|
||||||
{ "<leader>cR", "<cmd>ClangdSwitchSourceHeader<cr>", desc = "Switch Source/Header (C/C++)" },
|
|
||||||
},
|
|
||||||
root_dir = function(fname)
|
|
||||||
return require("lspconfig.util").root_pattern(
|
|
||||||
"Makefile",
|
|
||||||
"configure.ac",
|
|
||||||
"configure.in",
|
|
||||||
"config.h.in",
|
|
||||||
"meson.build",
|
|
||||||
"meson_options.txt",
|
|
||||||
"build.ninja"
|
|
||||||
)(fname) or require("lspconfig.util").root_pattern(
|
|
||||||
"compile_commands.json",
|
|
||||||
"compile_flags.txt"
|
|
||||||
)(fname) or require("lspconfig.util").find_git_ancestor(fname)
|
|
||||||
end,
|
|
||||||
capabilities = {
|
|
||||||
offsetEncoding = { "utf-16" },
|
|
||||||
},
|
|
||||||
cmd = {
|
|
||||||
"clangd",
|
|
||||||
"--background-index",
|
|
||||||
"--clang-tidy",
|
|
||||||
"--header-insertion=iwyu",
|
|
||||||
"--completion-style=detailed",
|
|
||||||
"--function-arg-placeholders",
|
|
||||||
"--fallback-style=llvm",
|
|
||||||
},
|
|
||||||
init_options = {
|
|
||||||
usePlaceholders = true,
|
|
||||||
completeUnimported = true,
|
|
||||||
clangdFileStatus = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
setup = {
|
|
||||||
clangd = function(_, opts)
|
|
||||||
local clangd_ext_opts = require("lazyvim.util").opts("clangd_extensions.nvim")
|
|
||||||
require("clangd_extensions").setup(
|
|
||||||
vim.tbl_deep_extend("force", clangd_ext_opts or {}, { server = opts })
|
|
||||||
)
|
|
||||||
return false
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
@@ -127,13 +127,11 @@ return {
|
|||||||
"--background-index",
|
"--background-index",
|
||||||
"--pch-storage=memory",
|
"--pch-storage=memory",
|
||||||
"--clang-tidy",
|
"--clang-tidy",
|
||||||
"--suggest-missing-includes",
|
|
||||||
"--all-scopes-completion",
|
"--all-scopes-completion",
|
||||||
"--pretty",
|
"--pretty",
|
||||||
"--header-insertion=iwyu",
|
"--header-insertion=iwyu",
|
||||||
"--fallback-style={ BasedOnStyle: Google, ColumnLimit: 200 }",
|
"--fallback-style={ BasedOnStyle: Google, ColumnLimit: 200 }",
|
||||||
"-j=12",
|
"-j=12",
|
||||||
"--inlay-hints",
|
|
||||||
"--header-insertion-decorators",
|
"--header-insertion-decorators",
|
||||||
},
|
},
|
||||||
settings = {
|
settings = {
|
||||||
@@ -148,6 +146,20 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
root_dir = function(fname)
|
||||||
|
return require("lspconfig.util").root_pattern(
|
||||||
|
"Makefile",
|
||||||
|
"configure.ac",
|
||||||
|
"configure.in",
|
||||||
|
"config.h.in",
|
||||||
|
"meson.build",
|
||||||
|
"meson_options.txt",
|
||||||
|
"build.ninja"
|
||||||
|
)(fname) or require("lspconfig.util").root_pattern(
|
||||||
|
"compile_commands.json",
|
||||||
|
"compile_flags.txt"
|
||||||
|
)(fname) or require("lspconfig.util").find_git_ancestor(fname)
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
require("ufo").setup()
|
require("ufo").setup()
|
||||||
|
@@ -8,8 +8,21 @@ return {
|
|||||||
auto_install = true,
|
auto_install = true,
|
||||||
highlight = { enable = true },
|
highlight = { enable = true },
|
||||||
indent = { enable = true },
|
indent = { enable = true },
|
||||||
ensure_installed = { "c", "css", "html", "javascript", "lua", "python", "typescript", "regex", "bash", "markdown", "markdown_inline"}
|
ensure_installed = {
|
||||||
|
"c",
|
||||||
|
"cpp",
|
||||||
|
"css",
|
||||||
|
"html",
|
||||||
|
"javascript",
|
||||||
|
"lua",
|
||||||
|
"python",
|
||||||
|
"typescript",
|
||||||
|
"regex",
|
||||||
|
"bash",
|
||||||
|
"markdown",
|
||||||
|
"markdown_inline",
|
||||||
|
},
|
||||||
})
|
})
|
||||||
end
|
end,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user