]> git.rmz.io Git - dotfiles.git/commitdiff
nvim: update dap config
authorSamir Benmendil <me@rmz.io>
Sat, 20 Jan 2024 17:01:17 +0000 (17:01 +0000)
committerSamir Benmendil <me@rmz.io>
Wed, 21 Feb 2024 01:26:30 +0000 (01:26 +0000)
nvim/lua/plugins/dap.lua

index 302edc4fddca315b84130bb302f4b281b8921123..7df609459d59bc006ef3f9ae1bb258bf6e16beba 100644 (file)
@@ -39,7 +39,6 @@ return {
       opts = {
         defaults = {
           ["<leader>d"] = { name = "+debug" },
       opts = {
         defaults = {
           ["<leader>d"] = { name = "+debug" },
-          ["<leader>da"] = { name = "+adapters" },
         },
       },
     },
         },
       },
     },
@@ -52,36 +51,13 @@ return {
       opts = {
         -- Makes a best effort to setup the various debuggers with
         -- reasonable debug configurations
       opts = {
         -- Makes a best effort to setup the various debuggers with
         -- reasonable debug configurations
-        automatic_setup = true,
+        automatic_installation = true,
 
         -- You can provide additional configuration to the handlers,
         -- see mason-nvim-dap README for more information
         handlers = {},
 
         -- You can provide additional configuration to the handlers,
         -- see mason-nvim-dap README for more information
         handlers = {},
-
-        -- You'll need to check that you have the required things installed
-        -- online, please don't ask me how to install them :)
-        ensure_installed = {
-          "cpptools",
-        },
       },
       },
-      config = function(_, opts)
-        require("mason-nvim-dap").setup(opts)
-        local dap = require("dap")
-        dap.configurations.cpp = {
-          {
-            name = "Launch file",
-            type = "cppdbg",
-            request = "launch",
-            program = function()
-              return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
-            end,
-            cwd = "${workspaceFolder}",
-            stopAtEntry = true,
-          },
-        }
-      end,
     },
     },
-
     {
       "jbyuki/one-small-step-for-vimkind",
       -- stylua: ignore
     {
       "jbyuki/one-small-step-for-vimkind",
       -- stylua: ignore
@@ -92,13 +68,34 @@ return {
       config = function()
         local dap = require("dap")
         dap.adapters.nlua = function(callback, config)
       config = function()
         local dap = require("dap")
         dap.adapters.nlua = function(callback, config)
-          callback({ type = "server", host = config.host or "127.0.0.1", port = config.port or 8086 })
+          local adapter = {
+            type = "server",
+            host = config.host or "127.0.0.1",
+            port = config.port or 8086,
+          }
+          if config.start_neovim then
+            local dap_run = dap.run
+            dap.run = function(c)
+              adapter.port = c.port
+              adapter.host = c.host
+            end
+            require("osv").run_this()
+            dap.run = dap_run
+          end
+          callback(adapter)
         end
         dap.configurations.lua = {
           {
             type = "nlua",
             request = "attach",
         end
         dap.configurations.lua = {
           {
             type = "nlua",
             request = "attach",
-            name = "Attach to running Neovim instance",
+            name = "Run this file",
+            start_neovim = {},
+          },
+          {
+            type = "nlua",
+            request = "attach",
+            name = "Attach to running Neovim instance (port 8086)",
+            port = 8086,
           },
         }
       end,
           },
         }
       end,