From: Samir Benmendil Date: Sat, 20 Jan 2024 17:01:17 +0000 (+0000) Subject: nvim: update dap config X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/6b7257e9c5c2a51b67a89979cb1476732d082151 nvim: update dap config --- diff --git a/nvim/lua/plugins/dap.lua b/nvim/lua/plugins/dap.lua index 302edc4..7df6094 100644 --- a/nvim/lua/plugins/dap.lua +++ b/nvim/lua/plugins/dap.lua @@ -39,7 +39,6 @@ return { opts = { defaults = { ["d"] = { name = "+debug" }, - ["da"] = { name = "+adapters" }, }, }, }, @@ -52,36 +51,13 @@ return { 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'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 @@ -92,13 +68,34 @@ return { 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", - 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,