summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins/nvim-dap.lua
diff options
context:
space:
mode:
authorCryxtalix <fgx8p9t@protonmail.com>2024-11-08 21:58:55 +0800
committerCryxtalix <fgx8p9t@protonmail.com>2024-11-08 21:58:55 +0800
commitdc839e971ad6a724bc99bccc6dfaa11ee8a1eaa9 (patch)
tree79e1ee75429a5ef500f716d3675aeec6c52dcda1 /.config/nvim/lua/plugins/nvim-dap.lua
Init gnu stow
Diffstat (limited to '.config/nvim/lua/plugins/nvim-dap.lua')
-rw-r--r--.config/nvim/lua/plugins/nvim-dap.lua140
1 files changed, 140 insertions, 0 deletions
diff --git a/.config/nvim/lua/plugins/nvim-dap.lua b/.config/nvim/lua/plugins/nvim-dap.lua
new file mode 100644
index 0000000..7720526
--- /dev/null
+++ b/.config/nvim/lua/plugins/nvim-dap.lua
@@ -0,0 +1,140 @@
+return {
+ "mfussenegger/nvim-dap",
+ event = "BufRead",
+ dependencies = {
+ "rcarriga/nvim-dap-ui",
+ "theHamsta/nvim-dap-virtual-text",
+ "nvim-telescope/telescope-dap.nvim",
+ "nvim-neotest/nvim-nio"
+ },
+ config = function()
+ local dap = require("dap")
+ local dapui = require("dapui")
+ local virtual_text = require("nvim-dap-virtual-text")
+
+ dap.adapters.lldb = {
+ type = 'executable',
+ command = '/usr/bin/lldb-dap',
+ name = 'lldb'
+ }
+
+ local lldb = {
+ name = "Launch lldb",
+ type = "lldb",
+ request = "launch",
+ program = function()
+ return vim.fn.input(
+ "Path to executable: ", vim.fn.getcwd() .. "/", "file"
+ )
+ end,
+ cwd = "${workspaceFolder}",
+ stopOnEntry = false,
+ args = {},
+ runInTerminal = false,
+ }
+
+ dap.configurations.rust = {lldb}
+ dap.configurations.c = {lldb}
+
+ dapui.setup(
+ {
+ controls = {
+ element = "repl",
+ enabled = true,
+ icons = {
+ disconnect = "🔗❌",
+ pause = "⏸",
+ play = "▶",
+ run_last = "⏭",
+ step_back = "↶",
+ step_into = "↓",
+ step_out = "↑",
+ step_over = "↷",
+ terminate = "⏹"
+ }
+ },
+ element_mappings = {},
+ expand_lines = true,
+ floating = {
+ border = "single",
+ mappings = {
+ close = { "q", "<Esc>" }
+ }
+ },
+ force_buffers = true,
+ icons = {
+ collapsed = "",
+ current_frame = "",
+ expanded = ""
+ },
+ layouts = {
+ {
+ elements = {
+ {
+ id = "scopes",
+ size = 0.25
+ },
+ {
+ id = "breakpoints",
+ size = 0.25
+ },
+ {
+ id = "stacks",
+ size = 0.25
+ },
+ {
+ id = "watches",
+ size = 0.25
+ }
+ },
+ position = "left",
+ size = 40
+ },
+ {
+ elements = {
+ {
+ id = "repl",
+ size = 0.5
+ },
+ {
+ id = "console",
+ size = 0.5
+ }
+ },
+ position = "bottom",
+ size = 10
+ }
+ },
+ mappings = {
+ edit = "e",
+ expand = { "<CR>", "<2-LeftMouse>" },
+ open = "o",
+ remove = "d",
+ repl = "r",
+ toggle = "t"
+ },
+ render = {
+ indent = 1,
+ max_value_lines = 100
+ }
+ }
+ )
+
+ virtual_text.setup()
+
+ vim.api.nvim_create_user_command(
+ "Debug",
+ function()
+ dapui.toggle()
+ end,
+ {}
+ )
+ vim.keymap.set('n', "<Leader>b", dap.toggle_breakpoint, {})
+ vim.keymap.set('n', "<F2>", dap.continue, {})
+ vim.keymap.set('n', "<F3>", dap.step_over, {})
+ vim.keymap.set('n', "<F4>", dap.step_back, {})
+ vim.keymap.set('n', "<F5>", dap.step_into, {})
+ vim.keymap.set('n', "<F6>", dap.step_out, {})
+ vim.keymap.set('n', "<Leader>n", dap.restart, {})
+ end
+}