From 9b9eab0b94e1aa7202226002d8774603677d23ba Mon Sep 17 00:00:00 2001 From: Naz Date: Sat, 8 Feb 2025 11:49:10 +0100 Subject: =?UTF-8?q?=E2=9C=A8feat:=20add=20LSP=20and=20IDEish=20plugins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/plugins/debugging.lua | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 lua/plugins/debugging.lua (limited to 'lua/plugins/debugging.lua') diff --git a/lua/plugins/debugging.lua b/lua/plugins/debugging.lua new file mode 100644 index 0000000..0479f28 --- /dev/null +++ b/lua/plugins/debugging.lua @@ -0,0 +1,68 @@ +return { + "mfussenegger/nvim-dap", + dependencies = { + "rcarriga/nvim-dap-ui", + "nvim-neotest/nvim-nio", + }, + + config = function() + local dap, dapui = require("dap"), require("dapui") + + require("dapui").setup() + + 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 + + dap.adapters.lldb = { + type = "executable", + command = "/usr/bin/lldb-vscode", + name = "lldb", + } + + dap.configurations.rust = { + { + name = "Launch", + type = "lldb", + request = "launch", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + args = {}, + + initCommands = function() + -- Find out where to look for the pretty printer Python module + local rustc_sysroot = vim.fn.trim(vim.fn.system("rustc --print sysroot")) + + local script_import = 'command script import "' + .. rustc_sysroot + .. '/lib/rustlib/etc/lldb_lookup.py"' + local commands_file = rustc_sysroot .. "/lib/rustlib/etc/lldb_commands" + + local commands = {} + local file = io.open(commands_file, "r") + if file then + for line in file:lines() do + table.insert(commands, line) + end + file:close() + end + table.insert(commands, 1, script_import) + + return commands + end, + }, + } + end, +} -- cgit v1.2.3