2 -- Add C/C++ to treesitter
4 "nvim-treesitter/nvim-treesitter",
5 opts = function(_, opts)
6 if type(opts.ensure_installed) == "table" then
7 vim.list_extend(opts.ensure_installed, { "c", "cpp" })
13 "p00f/clangd_extensions.nvim",
15 config = function() end,
21 --These require codicons (https://github.com/microsoft/vscode-codicons)
28 ["template argument"] = "",
33 TranslationUnit = "",
35 TemplateTypeParm = "",
36 TemplateTemplateParm = "",
37 TemplateParamObject = "",
43 -- Correctly setup lspconfig for clangd 🚀
45 "neovim/nvim-lspconfig",
48 -- Ensure mason installs the server
51 { "<leader>cR", "<cmd>ClangdSwitchSourceHeader<cr>", desc = "Switch Source/Header (C/C++)" },
53 root_dir = function(fname)
54 return require("lspconfig.util").root_pattern( "compile_commands.json", "compile_flags.txt")(fname)
55 or require("lspconfig.util").root_pattern(
64 or require("lspconfig.util").find_git_ancestor(fname)
67 offsetEncoding = { "utf-16" },
73 "--header-insertion=iwyu",
74 "--completion-style=detailed",
75 "--function-arg-placeholders",
76 "--fallback-style=llvm",
79 usePlaceholders = true,
80 completeUnimported = true,
81 clangdFileStatus = true,
86 clangd = function(_, opts)
87 local clangd_ext_opts = require("lazyvim.util").opts("clangd_extensions.nvim")
88 require("clangd_extensions").setup(vim.tbl_deep_extend("force", clangd_ext_opts or {}, { server = opts }))
97 -- opts = function(_, opts)
98 -- -- TODO: make sure this works
99 -- table.insert(opts.fuzzy.sorts, 1, require("clangd_extensions.cmp_scores"))
104 "mfussenegger/nvim-dap",
106 -- Ensure C/C++ debugger is installed
107 "williamboman/mason.nvim",
108 opts = function(_, opts)
109 if type(opts.ensure_installed) == "table" then
110 vim.list_extend(opts.ensure_installed, { "codelldb" })
115 local dap = require("dap")
116 if not dap.adapters["codelldb"] then
117 require("dap").adapters["codelldb"] = {
122 command = "codelldb",
130 for _, lang in ipairs({ "c", "cpp" }) do
131 dap.configurations[lang] = {
135 name = "Launch file",
137 return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
139 cwd = "${workspaceFolder}",
144 name = "Attach to process",
145 processId = require("dap.utils").pick_process,
146 cwd = "${workspaceFolder}",