diff --git a/lua/configs/dap.lua b/lua/configs/dap.lua index b5d80b7..b625d0c 100644 --- a/lua/configs/dap.lua +++ b/lua/configs/dap.lua @@ -1,18 +1,34 @@ local dap = require("dap") -dap.adapters.gdb = { +-- dap.configurations.c = { +-- { +-- name = "Launch", +-- type = "gdb", +-- request = "launch", +-- program = function() +-- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') +-- end, +-- cwd = "${workspaceFolder}", +-- }, +-- } + +dap.adapters.cppdbg = { type = "executable", command = "gdb", - args = { "-i", "dap" } + args = { "-i", "dap" }, + console = 'externalTerminal', + -- terminal_win_cmd = "tabnew", } -dap.configurations.c = { - { - name = "Launch", - type = "gdb", - request = "launch", - program = function() - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') - end, - cwd = "${workspaceFolder}", - }, + +dap.adapters.lldb = { + type = 'executable', + command = 'lldb-vscode', -- adjust as needed, must be absolute path + name = 'lldb' } + +require('dap.ext.vscode').load_launchjs("dap_config.json", { + cppdbg = { 'c', 'cpp' }, + lldb = { 'c', 'cpp' } +}) + +dap.set_log_level("TRACE") diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index 81b3f65..c53f933 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -78,7 +78,7 @@ end vim.diagnostic.config({ - virtual_text = false, + -- virtual_text = false, -- signs = true, -- underline = true, -- update_in_insert = false, diff --git a/lua/configs/lualine.lua b/lua/configs/lualine.lua index 20cf1c0..3300480 100644 --- a/lua/configs/lualine.lua +++ b/lua/configs/lualine.lua @@ -1,3 +1,4 @@ +local hydra = require("hydra.statusline") local opts = { options = { icons_enabled = true, @@ -18,7 +19,7 @@ local opts = { } }, sections = { - lualine_a = { 'mode' }, + lualine_a = { 'mode', {hydra.get_name, cond = hydra.is_active}}, lualine_b = { 'branch', 'diff' }, lualine_c = { 'filename', diff --git a/lua/mappings.lua b/lua/mappings.lua index b3d3eae..6f2c0d7 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -41,11 +41,11 @@ vim.keymap.set('x', 'p', 'P') -- Luasnip local ls = require("luasnip") -vim.keymap.set({"i", "s"}, "", function() ls.jump( 1) end, {silent = true}) -vim.keymap.set({"i", "s"}, "", function() ls.jump(-1) end, {silent = true}) +vim.keymap.set({ "i", "s" }, "", function() ls.jump(1) end, { silent = true }) +vim.keymap.set({ "i", "s" }, "", function() ls.jump(-1) end, { silent = true }) -- Hop -vim.keymap.set({'n', 'v'}, 'f', " HopWord ", { desc = "HopWord" }) +vim.keymap.set({ 'n', 'v' }, 'f', " HopWord ", { desc = "HopWord" }) -- Global mappings. @@ -104,12 +104,49 @@ wk.register({ -- DAP local dap = require('dap') -local dapui = require('dapui') -vim.keymap.set('n', 'dc', dap.continue, { desc = "Continue" }) -vim.keymap.set('n', '', dap.continue, { desc = "Continue" }) -vim.keymap.set('n', 's', dap.step_into, { desc = "Step into" }) -vim.keymap.set('n', 'n', dap.step_over, { desc = "Step over" }) -vim.keymap.set('n', 'o', dap.step_out, { desc = "Step out" }) +local dap_widget = require('dap.ui.widgets') +local dap_sb_frames = dap_widget.sidebar(dap_widget.frames) +local dap_sb_scopes = dap_widget.sidebar(dap_widget.scopes) +local dap_sb_session = dap_widget.sidebar(dap_widget.sessions) + vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = "Toggle breakpoint" }) -vim.keymap.set('n', '', dap.toggle_breakpoint, { desc = "Toggle breakpoint" }) -vim.keymap.set('n', 'du', dapui.toggle, { desc = "Toggle UI" }) + +local Hydra = require("hydra") +Hydra({ + name = 'Debugger', + config = { + buffer = bufnr, + color = "pink", + invoke_on_body = true, + on_enter = function() + dap.continue() + end, + on_exit = function() + dap.terminate() + dap_sb_frames.close() + dap_sb_scopes.close() + dap_sb_session.close() + dap.repl.close() + end, + hint = { + type = "window", + }, + }, + mode = 'n', + body = 'g', + heads = { + { 'c', dap.continue, { desc = "Continue" } }, + { 'r', dap.restart, { desc = "Restart" } }, + { 's', dap.step_into, { desc = "Step into" } }, + { 'n', dap.step_over, { desc = "Step over" } }, + { 'o', dap.step_out, { desc = "Step out" } }, + { 'x', dap.repl.toggle, { desc = "repl" } }, + { 'f', dap_sb_frames.toggle, { desc = "Frames" } }, + { 'v', dap_sb_scopes.toggle, { desc = "Scopes" } }, + { 'z', dap_sb_session.toggle, { desc = "Session" } }, + { 'b', dap.toggle_breakpoint, { desc = "Breakpoint" } }, + { 'u', dap.up, { desc = "Up" } }, + { 'd', dap.down, { desc = "Down" } }, + { 'q', nil, { exit = true, nowait = true, desc = 'Exit' } }, + } +}) diff --git a/lua/plugins.lua b/lua/plugins.lua index 8e570cb..5ceadb0 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -460,12 +460,21 @@ local plugins = { } }, }, - { - "rcarriga/nvim-dap-ui", - dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" }, - config = function() + -- { + -- "rcarriga/nvim-dap-ui", + -- dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" }, + -- config = function() + -- require("configs.dap") + -- require("dapui").setup() + -- end + -- }, + { + "theHamsta/nvim-dap-virtual-text", + lazy = false, + dependencies = { "mfussenegger/nvim-dap", "nvim-treesitter/nvim-treesitter" }, + config = function () require("configs.dap") - require("dapui").setup() + require("nvim-dap-virtual-text").setup() end }, { @@ -507,6 +516,9 @@ local plugins = { build = function() vim.fn["firenvim#install"](0) end + }, + { + 'nvimtools/hydra.nvim', } } diff --git a/snippets/json.snippets b/snippets/json.snippets new file mode 100644 index 0000000..fe6fcd3 --- /dev/null +++ b/snippets/json.snippets @@ -0,0 +1,13 @@ +snippet launch template of dap_config.json + { + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Launch", + "program": "./${exe}", + "args": [], + } + ] + }