diff options
| author | Petri Hienonen <petri.hienonen@gmail.com> | 2026-01-12 10:33:52 +0200 |
|---|---|---|
| committer | Petri Hienonen <petri.hienonen@gmail.com> | 2026-01-12 10:33:52 +0200 |
| commit | 515b747a4273030e8bd145a6eac770c4de20f69c (patch) | |
| tree | f399fcbc55fb4a93abb099f9455e3b76e1fd4a77 /home/nvim/plugins/dap.lua | |
| parent | 9091ec72fe5ed12ae56a46f8580e0053d4b525fb (diff) | |
| download | nixos-515b747a4273030e8bd145a6eac770c4de20f69c.tar.zst | |
Use tabs to indent nvim configurations
Diffstat (limited to 'home/nvim/plugins/dap.lua')
| -rw-r--r-- | home/nvim/plugins/dap.lua | 246 |
1 files changed, 123 insertions, 123 deletions
diff --git a/home/nvim/plugins/dap.lua b/home/nvim/plugins/dap.lua index c20ae36..8a37318 100644 --- a/home/nvim/plugins/dap.lua +++ b/home/nvim/plugins/dap.lua @@ -1,128 +1,128 @@ -- Store DAP configuration in a function to load on demand local function setup_dap() - local dap = require("dap") - local dapview = require("dap-view") - local dapvt = require("nvim-dap-virtual-text") + local dap = require("dap") + local dapview = require("dap-view") + local dapvt = require("nvim-dap-virtual-text") - dapview.setup({}) + dapview.setup({}) - dapvt.setup { - enabled = true, - enabled_commands = true, - highlight_changed_variables = true, - highlight_new_as_changed = false, - show_stop_reason = true, - commented = false, - only_first_definition = true, - all_references = false, - clear_on_continue = false, - display_callback = function(variable, buf, stackframe, node, options) - if options.virt_text_pos == "inline" then - return " = " .. variable.value:gsub("%s+", " ") - else - return variable.name .. " = " .. variable.value:gsub("%s+", " ") - end - end, - all_frames = true, - virt_lines = true, - virt_text_win_col = nil, - } + dapvt.setup { + enabled = true, + enabled_commands = true, + highlight_changed_variables = true, + highlight_new_as_changed = false, + show_stop_reason = true, + commented = false, + only_first_definition = true, + all_references = false, + clear_on_continue = false, + display_callback = function(variable, buf, stackframe, node, options) + if options.virt_text_pos == "inline" then + return " = " .. variable.value:gsub("%s+", " ") + else + return variable.name .. " = " .. variable.value:gsub("%s+", " ") + end + end, + all_frames = true, + virt_lines = true, + virt_text_win_col = nil, + } - -- === PYTHON === - dap.adapters.python = { - type = "executable", - command = "python", - args = { "-m", "debugpy.adapter" }, - } - dap.configurations.python = { - { - type = "python", - request = "launch", - name = "Launch file", - program = "${file}", - console = "integratedTerminal", - justMyCode = true, - }, - { - type = "python", - request = "attach", - name = "Attach to process", - connect = { host = "127.0.0.1", port = 5678 }, - }, - } + -- === PYTHON === + dap.adapters.python = { + type = "executable", + command = "python", + args = { "-m", "debugpy.adapter" }, + } + dap.configurations.python = { + { + type = "python", + request = "launch", + name = "Launch file", + program = "${file}", + console = "integratedTerminal", + justMyCode = true, + }, + { + type = "python", + request = "attach", + name = "Attach to process", + connect = { host = "127.0.0.1", port = 5678 }, + }, + } - -- === RUST === - dap.adapters.lldb = { - type = "executable", - command = "lldb-dap", - name = "lldb", - } - dap.configurations.rust = { - { - name = "Launch (LLDB)", - type = "lldb", - request = "launch", - program = function() - return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file") - end, - cwd = "${workspaceFolder}", - stopOnEntry = false, - args = {}, - runInTerminal = false, - }, - { - name = "Attach to process (LLDB)", - type = "lldb", - request = "attach", - pid = require("dap.utils").pick_process, - args = {}, - }, - } + -- === RUST === + dap.adapters.lldb = { + type = "executable", + command = "lldb-dap", + name = "lldb", + } + dap.configurations.rust = { + { + name = "Launch (LLDB)", + type = "lldb", + request = "launch", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file") + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + args = {}, + runInTerminal = false, + }, + { + name = "Attach to process (LLDB)", + type = "lldb", + request = "attach", + pid = require("dap.utils").pick_process, + args = {}, + }, + } - -- === GO === - dap.adapters.go = { - type = "executable", - command = "dlv", - args = { "dap" }, - } - dap.configurations.go = { - { type = "go", name = "Debug main.go", request = "launch", program = "${file}" }, - { type = "go", name = "Debug package", request = "launch", program = "${workspaceFolder}" }, - { type = "go", name = "Attach to process", request = "attach", processId = require("dap.utils").pick_process }, - } + -- === GO === + dap.adapters.go = { + type = "executable", + command = "dlv", + args = { "dap" }, + } + dap.configurations.go = { + { type = "go", name = "Debug main.go", request = "launch", program = "${file}" }, + { type = "go", name = "Debug package", request = "launch", program = "${workspaceFolder}" }, + { type = "go", name = "Attach to process", request = "attach", processId = require("dap.utils").pick_process }, + } - -- === EVENT LISTENERS === - dap.listeners.after.event_initialized["dapview_config"] = function() dapview.open() end - dap.listeners.before.event_terminated["dapview_config"] = function() dapview.close() end - dap.listeners.before.event_exited["dapview_config"] = function() dapview.close() end + -- === EVENT LISTENERS === + dap.listeners.after.event_initialized["dapview_config"] = function() dapview.open() end + dap.listeners.before.event_terminated["dapview_config"] = function() dapview.close() end + dap.listeners.before.event_exited["dapview_config"] = function() dapview.close() end end -- Define custom commands to trigger DAP setup local function define_dap_commands() - vim.api.nvim_create_user_command("DapContinue", function() - setup_dap() - require("dap").continue() - end, {}) - vim.api.nvim_create_user_command("DapToggleBreakpoint", function() - setup_dap() - require("dap").toggle_breakpoint() - end, {}) - vim.api.nvim_create_user_command("DapStepOver", function() - setup_dap() - require("dap").step_over() - end, {}) - vim.api.nvim_create_user_command("DapStepInto", function() - setup_dap() - require("dap").step_into() - end, {}) - vim.api.nvim_create_user_command("DapStepOut", function() - setup_dap() - require("dap").step_out() - end, {}) - vim.api.nvim_create_user_command("DapTerminate", function() - setup_dap() - require("dap").terminate() - end, {}) + vim.api.nvim_create_user_command("DapContinue", function() + setup_dap() + require("dap").continue() + end, {}) + vim.api.nvim_create_user_command("DapToggleBreakpoint", function() + setup_dap() + require("dap").toggle_breakpoint() + end, {}) + vim.api.nvim_create_user_command("DapStepOver", function() + setup_dap() + require("dap").step_over() + end, {}) + vim.api.nvim_create_user_command("DapStepInto", function() + setup_dap() + require("dap").step_into() + end, {}) + vim.api.nvim_create_user_command("DapStepOut", function() + setup_dap() + require("dap").step_out() + end, {}) + vim.api.nvim_create_user_command("DapTerminate", function() + setup_dap() + require("dap").terminate() + end, {}) end -- Create autocommand group for DAP @@ -130,18 +130,18 @@ local augroup = vim.api.nvim_create_augroup("DapLazyLoad", { clear = true }) -- Load DAP on filetypes vim.api.nvim_create_autocmd("FileType", { - group = augroup, - pattern = { "python", "rust", "go" }, - callback = function() - define_dap_commands() - end, + group = augroup, + pattern = { "python", "rust", "go" }, + callback = function() + define_dap_commands() + end, }) -- Load DAP on specific commands vim.api.nvim_create_autocmd("CmdUndefined", { - group = augroup, - pattern = { "DapContinue", "DapToggleBreakpoint", "DapStepOver", "DapStepInto", "DapStepOut", "DapTerminate" }, - callback = function() - define_dap_commands() - end, + group = augroup, + pattern = { "DapContinue", "DapToggleBreakpoint", "DapStepOver", "DapStepInto", "DapStepOut", "DapTerminate" }, + callback = function() + define_dap_commands() + end, }) |
