2 -- Add C/C++ to treesitter
4 "nvim-treesitter/nvim-treesitter",
5 opts = { ensure_installed = { "c", "cpp" } },
9 "p00f/clangd_extensions.nvim",
11 config = function() end,
17 --These require codicons (https://github.com/microsoft/vscode-codicons)
24 ["template argument"] = "",
29 TranslationUnit = "",
31 TemplateTypeParm = "",
32 TemplateTemplateParm = "",
33 TemplateParamObject = "",
39 -- Correctly setup lspconfig for clangd 🚀
41 "neovim/nvim-lspconfig",
44 -- Ensure mason installs the server
47 { "<leader>ch", "<cmd>ClangdSwitchSourceHeader<cr>", desc = "Switch Source/Header (C/C++)" },
49 root_dir = function(fname)
50 return require("lspconfig.util").root_pattern( "compile_commands.json", "compile_flags.txt")(fname)
51 or require("lspconfig.util").root_pattern(
60 or require("lspconfig.util").find_git_ancestor(fname)
63 offsetEncoding = { "utf-16" },
69 "--header-insertion=iwyu",
70 "--completion-style=detailed",
71 "--function-arg-placeholders",
72 "--fallback-style=llvm",
75 usePlaceholders = true,
76 completeUnimported = true,
77 clangdFileStatus = true,
82 clangd = function(_, opts)
83 local clangd_ext_opts = rmz.lazy.opts("clangd_extensions.nvim")
84 require("clangd_extensions").setup(vim.tbl_deep_extend("force", clangd_ext_opts or {}, { server = opts }))
91 -- opts = function(_, opts)
92 -- -- TODO: make sure this works
93 -- table.insert(opts.fuzzy.sorts, 1, require("clangd_extensions.cmp_scores"))
96 { "mfussenegger/nvim-dap",
98 -- Ensure C/C++ debugger is installed
99 "williamboman/mason.nvim",
100 opts = { ensure_installed = { "codelldb" } },
103 local dap = require("dap")
104 if not dap.adapters["codelldb"] then
105 require("dap").adapters["codelldb"] = {
110 command = "codelldb",
118 for _, lang in ipairs({ "c", "cpp" }) do
119 dap.configurations[lang] = {
123 name = "Launch file",
125 return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
127 cwd = "${workspaceFolder}",
132 name = "Attach to process",
133 pid = require("dap.utils").pick_process,
134 cwd = "${workspaceFolder}",