From 75cebeaa7a0fca260fe2dc43f633785581093654 Mon Sep 17 00:00:00 2001 From: Smaug123 Date: Sun, 24 Mar 2024 21:08:06 +0000 Subject: [PATCH] Stop for today --- home-manager/home.nix | 6 +++ home-manager/nvim/nvim-dap-python.lua | 1 + home-manager/nvim/nvim-dap.lua | 59 ++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 home-manager/nvim/nvim-dap-python.lua diff --git a/home-manager/home.nix b/home-manager/home.nix index 5678577..d68bf13 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -162,6 +162,7 @@ ps.pyyaml ps.std2 ]); + debugPyEnv = nixpkgs.python3.withPackages (ps: [ps.debugpy]); in { enable = true; plugins = [ @@ -247,6 +248,11 @@ config = builtins.readFile ./nvim/nvim-dap.lua; type = "lua"; } + { + plugin = nixpkgs.vimPlugins.nvim-dap-python; + config = builtins.replaceStrings ["%PYTHONENV%"] ["${debugPyEnv}"] (builtins.readFile ./nvim/nvim-dap-python.lua); + type = "lua"; + } ]; viAlias = true; vimAlias = true; diff --git a/home-manager/nvim/nvim-dap-python.lua b/home-manager/nvim/nvim-dap-python.lua new file mode 100644 index 0000000..cd88bac --- /dev/null +++ b/home-manager/nvim/nvim-dap-python.lua @@ -0,0 +1 @@ +require("dap-python").setup("%PYTHONENV%/bin/python") diff --git a/home-manager/nvim/nvim-dap.lua b/home-manager/nvim/nvim-dap.lua index 0bec72a..269a962 100644 --- a/home-manager/nvim/nvim-dap.lua +++ b/home-manager/nvim/nvim-dap.lua @@ -1,8 +1,9 @@ local dap = require("dap") +local dap_ui = require("dap.ui.widgets") dap.adapters.coreclr = { type = "executable", command = "netcoredbg", - args = { "--interpreter=vscode" }, + args = { "--interpreter=vscode", "--", "dotnet" }, } dap.configurations.fsharp = { @@ -15,3 +16,59 @@ dap.configurations.fsharp = { end, }, } + +local status, whichkey = pcall(require, "which-key") +if status then + whichkey.register({ + d = { + o = { dap.step_over, "Step over" }, + i = { dap.step_into, "Step into" }, + c = { dap.continue, "Continue" }, + C = { dap.run_last, "Run with last debug configuration" }, + b = { dap.toggle_breakpoint, "Toggle breakpoint" }, + r = { dap.repl.open, "Open debug repl" }, + v = { + v = { + function() + dap_ui.hover() + end, + "View value of expression under cursor", + }, + s = { + function() + dap_ui.sidebar(dap_ui.scopes).open() + end, + "View values of all variables in all scopes", + }, + f = { + function() + dap_ui.sidebar(dap_ui.frames).open() + end, + "View stack frames", + }, + }, + t = { dap.terminate, "Terminate/stop/end debug session" }, + }, + }, { prefix = vim.api.nvim_get_var("maplocalleader") }) +else + vim.api.nvim_set_keymap("n", "do", ":lua require('dap').step_over()", { noremap = true }) + vim.api.nvim_set_keymap("n", "di", ":lua require('dap').step_into()", { noremap = true }) + vim.api.nvim_set_keymap("n", "dc", ":lua require('dap').continue()", { noremap = true }) + vim.api.nvim_set_keymap("n", "dC", ":lua require('dap').run_last()", { noremap = true }) + vim.api.nvim_set_keymap("n", "db", ":lua require('dap').toggle_breakpoint()", { noremap = true }) + vim.api.nvim_set_keymap("n", "dr", ":lua require('dap').repl.open()", { noremap = true }) + vim.api.nvim_set_keymap("n", "dvv", ":lua require('dap.ui.widgets').hover()", { noremap = true }) + vim.api.nvim_set_keymap( + "n", + "dvs", + ":lua require('dap.ui.widgets').sidebar(require('dap.ui.widgets').scopes).open()", + { noremap = true } + ) + vim.api.nvim_set_keymap( + "n", + "dvf", + ":lua require('dap.ui.widgets').sidebar(require('dap.ui.widgets').frames).open()", + { noremap = true } + ) + vim.api.nvim_set_keymap("n", "dt", ":lua require('dap').terminate()", { noremap = true }) +end