diff --git a/init.lua b/init.lua index 3f6486e..3f02466 100644 --- a/init.lua +++ b/init.lua @@ -102,6 +102,12 @@ dap.adapters.godot = { port = 6006, } +dap.adapters.gdb = { + type = "executable", + command = "gdb", + args = { "--interpreter=dap", "--eval-command", "set print pretty on" } +} + dap.configurations.gdscript = { { type = "godot", @@ -111,3 +117,44 @@ dap.configurations.gdscript = { scene = "main" } } + +dap.configurations.c = { + { + name = "Launch", + type = "gdb", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + args = {}, -- provide arguments if needed + cwd = "${workspaceFolder}", + stopAtBeginningOfMainSubprogram = false, + }, + { + name = "Select and attach to process", + type = "gdb", + request = "attach", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + pid = function() + local name = vim.fn.input('Executable name (filter): ') + return require("dap.utils").pick_process({ filter = name }) + end, + cwd = '${workspaceFolder}' + }, + { + name = 'Attach to gdbserver :1234', + type = 'gdb', + request = 'attach', + target = 'localhost:1234', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}' + } +} + +dap.configurations.cpp = dap.configurations.c +-- TODO: could do rust, zig, odin, jai (?) + diff --git a/lua/keybindings.lua b/lua/keybindings.lua index eb3a91f..4607c7f 100644 --- a/lua/keybindings.lua +++ b/lua/keybindings.lua @@ -23,6 +23,9 @@ vim.keymap.set('n', 'ss', 'Telescope spell_suggest', opts) vim.keymap.set('n', 't', 'Telescope', opts) local dap = require('dap') +local widgets = require('dap.ui.widgets') +local frame_bar = widgets.sidebar(widgets.frames) +local session_bar = widgets.sidebar(widgets.sessions) local on_attach = function(client, bufnr) client.server_capabilities.semanticTokensProvider = nil @@ -44,6 +47,8 @@ local on_attach = function(client, bufnr) vim.keymap.set('n', '', dap.step_into, bufopts) vim.keymap.set('n', '', dap.step_out, bufopts) --TODO: dap.ui.widgets, widgets.sidebar + vim.keymap.set('n', 'df', frame_bar.toggle, bufopts) + vim.keymap.set('n', 'ds', session_bar.toggle, bufopts) end local godot_port = os.getenv 'GDScript_Port' or '6005'