From 08afb639f6cbac03892fe6515fde143f36751c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Schr=C3=B6ter?= Date: Sat, 30 Jul 2022 08:38:47 +0200 Subject: [PATCH] feat(neovim): set up dap for rust & .NET --- home/editors/dap.nix | 13 ++++++++++-- home/editors/neovim/dap/dap.lua | 36 +++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/home/editors/dap.nix b/home/editors/dap.nix index 440d9e5..5a42a28 100644 --- a/home/editors/dap.nix +++ b/home/editors/dap.nix @@ -1,9 +1,18 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: -{ +let vscodeExtensions = with pkgs; [ vscode-extensions.ms-vscode.cpptools ]; +in { home.packages = with pkgs; [ netcoredbg # vscode-firefox-debug # TODO not packaged haskellPackages.haskell-dap ]; + + home.file = builtins.listToAttrs (map (x: { + name = ".vscode/extensions/${x.vscodeExtUniqueId}"; + value = { + source = "${x}/share/vscode/extensions/${x.vscodeExtUniqueId}"; + recursive = true; + }; + }) vscodeExtensions); } diff --git a/home/editors/neovim/dap/dap.lua b/home/editors/neovim/dap/dap.lua index cfc3d71..afd6761 100644 --- a/home/editors/neovim/dap/dap.lua +++ b/home/editors/neovim/dap/dap.lua @@ -2,6 +2,12 @@ local dap = require("dap") local function pwd() return io.popen("pwd"):lines()() end +dap.adapters.cppdbg = { + id = "cppdbg", + type = "executable", + command = os.getenv("HOME") .. "/.vscode/extensions/ms-vscode.cpptools/debugAdapters/bin/OpenDebugAD7", +} + dap.adapters.netcoredbg = { type = "executable", command = "netcoredbg", @@ -12,14 +18,40 @@ dap.adapters.netcoredbg = { }, } +dap.configurations.cpp = { + { + name = "Launch file", + type = "cppdbg", + request = "launch", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + cwd = "${workspaceFolder}", + stopOnEntry = true, + }, + { + name = "Attach to gdbserver :1234", + type = "cppdbg", + request = "launch", + MIMode = "gdb", + miDebuggerServerAddress = "localhost:1234", + miDebuggerPath = "/usr/bin/gdb", + cwd = "${workspaceFolder}", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + }, +} +dap.configurations.c = dap.configurations.cpp +dap.configurations.rust = dap.configurations.cpp + dap.configurations.cs = { { type = "netcoredbg", name = "launch - netcoredbg", request = "launch", program = function() - local dll = io.popen("find bin/Debug/ -maxdepth 2 -name \"*.dll\"") - return pwd() .. "/" .. dll:lines()() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") end, stopAtEntry = true, },