]> git.rmz.io Git - dotfiles.git/blobdiff - nvim/lua/plugins/lang/cpp.lua
lazyvim: absorb all langs
[dotfiles.git] / nvim / lua / plugins / lang / cpp.lua
index a6f0303db40b31dd45fb0c5b41258a478e9dbb26..d3153dbdeb892f94bcc28f10b40f49278e19f75d 100644 (file)
@@ -2,11 +2,7 @@ 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,
+    opts = { ensure_installed = { "c", "cpp" } },
   },
 
   {
@@ -48,20 +44,20 @@ return {
         -- Ensure mason installs the server
         clangd = {
           keys = {
-            { "<leader>cR", "<cmd>ClangdSwitchSourceHeader<cr>", desc = "Switch Source/Header (C/C++)" },
+            { "<leader>ch", "<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)
+            return require("lspconfig.util").root_pattern( "compile_commands.json", "compile_flags.txt")(fname)
+              or 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").find_git_ancestor(fname)
           end,
           capabilities = {
             offsetEncoding = { "utf-16" },
@@ -84,31 +80,24 @@ return {
       },
       setup = {
         clangd = function(_, opts)
-          local clangd_ext_opts = require("lazyvim.util").opts("clangd_extensions.nvim")
+          local clangd_ext_opts = rmz.lazy.opts("clangd_extensions.nvim")
           require("clangd_extensions").setup(vim.tbl_deep_extend("force", clangd_ext_opts or {}, { server = opts }))
           return false
         end,
       },
     },
   },
-
-  {
-    "nvim-cmp",
-    opts = function(_, opts)
-      table.insert(opts.sorting.comparators, 1, require("clangd_extensions.cmp_scores"))
-    end,
-  },
-
-  {
-    "mfussenegger/nvim-dap",
+  -- { "blink.cmp",
+  --   opts = function(_, opts)
+  --     -- TODO: make sure this works
+  --     table.insert(opts.fuzzy.sorts, 1, require("clangd_extensions.cmp_scores"))
+  --   end,
+  -- },
+  { "mfussenegger/nvim-dap",
     dependencies = {
       -- Ensure C/C++ debugger is installed
       "williamboman/mason.nvim",
-      opts = function(_, opts)
-        if type(opts.ensure_installed) == "table" then
-          vim.list_extend(opts.ensure_installed, { "codelldb" })
-        end
-      end,
+      opts = { ensure_installed = { "codelldb" } },
     },
     opts = function()
       local dap = require("dap")
@@ -141,7 +130,7 @@ return {
             type = "codelldb",
             request = "attach",
             name = "Attach to process",
-            processId = require("dap.utils").pick_process,
+            pid = require("dap.utils").pick_process,
             cwd = "${workspaceFolder}",
           },
         }