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 table.insert(opts.sorting.comparators, 1, require("clangd_extensions.cmp_scores"))
103 "mfussenegger/nvim-dap",
105 -- Ensure C/C++ debugger is installed
106 "williamboman/mason.nvim",
107 opts = function(_, opts)
108 if type(opts.ensure_installed) == "table" then
109 vim.list_extend(opts.ensure_installed, { "codelldb" })
114 local dap = require("dap")
115 if not dap.adapters["codelldb"] then
116 require("dap").adapters["codelldb"] = {
121 command = "codelldb",
129 for _, lang in ipairs({ "c", "cpp" }) do
130 dap.configurations[lang] = {
134 name = "Launch file",
136 return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
138 cwd = "${workspaceFolder}",
143 name = "Attach to process",
144 processId = require("dap.utils").pick_process,
145 cwd = "${workspaceFolder}",