From 6b14039e40033a56a8b2d6123e424238cbecc13c Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Mon, 5 Feb 2024 16:25:00 +0100 Subject: [PATCH] okay dbg with c --- lua/custom/configs/lspconfig.lua | 2 +- lua/custom/mappings.lua | 52 ++++++++++++++++++++++ lua/custom/plugins.lua | 74 ++++++++++++++++++++++++++++---- 3 files changed, 119 insertions(+), 9 deletions(-) diff --git a/lua/custom/configs/lspconfig.lua b/lua/custom/configs/lspconfig.lua index fad87e4..e180978 100644 --- a/lua/custom/configs/lspconfig.lua +++ b/lua/custom/configs/lspconfig.lua @@ -10,7 +10,7 @@ local servers = { "tsserver", "clangd", "pyright", - "rust_analyzer", + -- "rust_analyzer", "bashls", "cmake", } diff --git a/lua/custom/mappings.lua b/lua/custom/mappings.lua index 4b7ec90..1865fff 100644 --- a/lua/custom/mappings.lua +++ b/lua/custom/mappings.lua @@ -587,6 +587,58 @@ M.debug = { "debug open repl", noremap = true, }, + ["dws"] = { + function() + local widgets = require "dap.ui.widgets" + local my_sidebar = widgets.sidebar(widgets.scopes) + my_sidebar.open() + end, + "debug window scopes", + noremap = true, + }, + ["dwt"] = { + function() + local widgets = require "dap.ui.widgets" + local my_sidebar = widgets.sidebar(widgets.threads) + my_sidebar.open() + end, + "debug window threads", + noremap = true, + }, + ["dwe"] = { + function() + local widgets = require "dap.ui.widgets" + local my_sidebar = widgets.sidebar(widgets.expression) + my_sidebar.open() + end, + "debug window expressions", + noremap = true, + }, + ["dwi"] = { + function() + local widgets = require "dap.ui.widgets" + local my_sidebar = widgets.sidebar(widgets.sessions) + my_sidebar.open() + end, + "debug window sessions", + noremap = true, + }, + ["dwf"] = { + function() + local widgets = require "dap.ui.widgets" + local my_sidebar = widgets.sidebar(widgets.frames) + my_sidebar.open() + end, + "debug window scopes", + noremap = true, + }, + ["dK"] = { + function() + require('dap.ui.widgets').hover() + end, + "debug hover", + noremap = true, + }, }, } diff --git a/lua/custom/plugins.lua b/lua/custom/plugins.lua index 0406eff..42ee5f0 100644 --- a/lua/custom/plugins.lua +++ b/lua/custom/plugins.lua @@ -729,17 +729,18 @@ local plugins = { }, { "mfussenegger/nvim-dap", + lazy = false, init = function() require("core.utils").load_mappings "debug" end, config = function() local dap = require "dap" - dap.adapters.gdb = { - type = "executable", - command = "gdb", - args = { "-i", "dap" }, -- NOTE: gdb sometimes has no built in dap interface, LMDE6 has this i - -- think. Don't bother with compiling from source - } + -- dap.adapters.gdb = { + -- type = "executable", + -- command = "gdb", + -- args = { "-i", "dap" }, -- NOTE: gdb sometimes has no built in dap interface, LMDE6 has this i + -- -- think. Don't bother with compiling from source + -- } dap.adapters.codelldb = { type = "server", port = "${port}", @@ -747,11 +748,11 @@ local plugins = { -- CHANGE THIS to your path! command = "/home/plex/.local/share/codelldb/extension/adapter/codelldb", args = { "--port", "${port}" }, + -- On windows you may have to uncomment this: -- detached = false, }, } - dap.configurations.cpp = { { name = "Launch file", @@ -764,8 +765,65 @@ local plugins = { stopOnEntry = false, }, } - dap.configurations.rust = dap.configurations.cpp dap.configurations.c = dap.configurations.cpp + -- dap.configurations.rust = dap.configurations.cpp + end, + }, + { + "rcarriga/nvim-dap-ui", + enabled = false, + lazy = false, + dependencies = { + "mfussenegger/nvim-dap", + }, + config = function() + local dap, dapui = require "dap", require "dapui" + dap.listeners.before.attach.dapui_config = function() + dapui.open() + end + dap.listeners.before.launch.dapui_config = function() + dapui.open() + end + dap.listeners.before.event_terminated.dapui_config = function() + dapui.close() + end + dap.listeners.before.event_exited.dapui_config = function() + dapui.close() + end + require("neodev").setup { + library = { plugins = { "nvim-dap-ui" }, types = true }, + } + end, + }, + { "folke/neodev.nvim", opts = {} }, + { + "mrcjkb/rustaceanvim", + version = "^4", -- Recommended + ft = { "rust" }, + config = function() + vim.g.rustaceanvim = function() + -- Update this path + local extension_path = vim.env.HOME .. ".local/share/codelldb" + local codelldb_path = extension_path .. "adapter/codelldb" + local liblldb_path = extension_path .. "lldb/lib/liblldb" + local this_os = vim.uv.os_uname().sysname + + -- The path is different on Windows + if this_os:find "Windows" then + codelldb_path = extension_path .. "adapter\\codelldb.exe" + liblldb_path = extension_path .. "lldb\\bin\\liblldb.dll" + else + -- The liblldb extension is .so for Linux and .dylib for MacOS + liblldb_path = liblldb_path .. (this_os == "Linux" and ".so" or ".dylib") + end + + local cfg = require "rustaceanvim.config" + return { + dap = { + adapter = cfg.get_codelldb_adapter(codelldb_path, liblldb_path), + }, + } + end end, }, }