From 761c2735fd539aff252495f7209f808d62310315 Mon Sep 17 00:00:00 2001 From: Will Ruggiano Date: Wed, 23 Aug 2023 10:07:57 -0600 Subject: [PATCH] feat: some dap stuff --- flake.lock | 99 +++++++++++++++++++++++++++-- flake.nix | 1 + plugins/bombadil/plugin/keymaps.lua | 20 +++++- plugins/dap.lua | 71 +++++++++++---------- plugins/spec.nix | 4 ++ 5 files changed, 156 insertions(+), 39 deletions(-) diff --git a/flake.lock b/flake.lock index eb31bc1..127d56e 100644 --- a/flake.lock +++ b/flake.lock @@ -204,6 +204,24 @@ } }, "flake-utils_10": { + "inputs": { + "systems": "systems_6" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_11": { "locked": { "lastModified": 1659877975, "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", @@ -340,11 +358,11 @@ "systems": "systems_5" }, "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "lastModified": 1692799911, + "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", "owner": "numtide", "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", "type": "github" }, "original": { @@ -760,6 +778,22 @@ } }, "nixpkgs_11": { + "locked": { + "lastModified": 1692684269, + "narHash": "sha256-zJk2pyF4Cuhtor0khtPlf+hfJIh22rzAUC+KU3Ob31Q=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "9d757ec498666cc1dcc6f2be26db4fd3e1e9ab37", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_12": { "locked": { "lastModified": 1683594133, "narHash": "sha256-iUhLhEAgOCnexSGDsYT2ouydis09uDoNzM7UC685XGE=", @@ -985,6 +1019,7 @@ "nix2container": "nix2container", "nixpkgs": "nixpkgs_6", "sg-nvim": "sg-nvim", + "vscode-js-debug": "vscode-js-debug", "zls": "zls" } }, @@ -1156,6 +1191,21 @@ "type": "github" } }, + "systems_6": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "tres": { "flake": false, "locked": { @@ -1168,10 +1218,47 @@ "url": "https://github.com/ziglibs/tres/archive/220d01f3931595e3a2e2a6a0693363c0bfaf47e9.tar.gz" } }, + "vscode-js-debug": { + "inputs": { + "flake-utils": "flake-utils_9", + "nixpkgs": "nixpkgs_11", + "vscode-js-debug": "vscode-js-debug_2" + }, + "locked": { + "lastModified": 1692804146, + "narHash": "sha256-32FBPFAd3RDJVZ3X2m7J6vIlN75BZk0gwqj9mBS4EYQ=", + "owner": "willruggiano", + "repo": "vscode-js-debug.nix", + "rev": "8d299b27ce6412989719282d1104d34f5c2149eb", + "type": "github" + }, + "original": { + "owner": "willruggiano", + "repo": "vscode-js-debug.nix", + "type": "github" + } + }, + "vscode-js-debug_2": { + "flake": false, + "locked": { + "lastModified": 1690242329, + "narHash": "sha256-L7MFECy0KKJUsnObqLepPnrkDHwm28iQhjm5D9a0BV0=", + "owner": "microsoft", + "repo": "vscode-js-debug", + "rev": "df0247e2df0dc816e0b2b8a38a37867673a75815", + "type": "github" + }, + "original": { + "owner": "microsoft", + "ref": "v1.81.0", + "repo": "vscode-js-debug", + "type": "github" + } + }, "zig-overlay": { "inputs": { "flake-compat": "flake-compat_5", - "flake-utils": "flake-utils_10", + "flake-utils": "flake-utils_11", "nixpkgs": [ "zls", "nixpkgs" @@ -1194,10 +1281,10 @@ "zls": { "inputs": { "diffz": "diffz", - "flake-utils": "flake-utils_9", + "flake-utils": "flake-utils_10", "gitignore": "gitignore_4", "known_folders": "known_folders", - "nixpkgs": "nixpkgs_11", + "nixpkgs": "nixpkgs_12", "tres": "tres", "zig-overlay": "zig-overlay" }, diff --git a/flake.nix b/flake.nix index 2da456b..ffb7864 100644 --- a/flake.nix +++ b/flake.nix @@ -12,6 +12,7 @@ nix2container.url = "github:nlewo/nix2container"; nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; sg-nvim.url = "github:sourcegraph/sg.nvim"; + vscode-js-debug.url = "github:willruggiano/vscode-js-debug.nix"; zls.url = "github:willruggiano/zls"; }; diff --git a/plugins/bombadil/plugin/keymaps.lua b/plugins/bombadil/plugin/keymaps.lua index 51f1258..dc82c4d 100644 --- a/plugins/bombadil/plugin/keymaps.lua +++ b/plugins/bombadil/plugin/keymaps.lua @@ -90,8 +90,26 @@ vnoremap("", function() vim.cmd [[m '<-2gv=gv]] end, { desc = "Move line up" }) +-- Toggle the quickfix list +nnoremap("q", function() + local open = (function() + for _, win in ipairs(vim.fn.getwininfo()) do + if win["quickfix"] == 1 then + return true + end + end + return false + end)() + if open then + vim.cmd.cclose() + else + if not vim.tbl_isempty(vim.fn.getqflist()) then + vim.cmd.copen() + end + end +end, { desc = "Toggle quickfix" }) + require("which-key").register({ - g = { name = "+Git" }, h = { name = "+Hunk" }, m = { name = "+Mark" }, t = { name = "+Toggle" }, diff --git a/plugins/dap.lua b/plugins/dap.lua index f426ff5..ccdc45a 100644 --- a/plugins/dap.lua +++ b/plugins/dap.lua @@ -12,23 +12,11 @@ return function() dap.configurations.cpp = { { name = "Attach", - type = "cppdbg", + type = "lldb", request = "attach", pid = utils.pick_process, args = {}, }, - { - name = "Launch", - type = "cppdbg", - request = "launch", - program = function() - return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") - end, - cwd = "${workspaceFolder}", - stopOnEntry = false, - args = {}, - runInTerminal = false, - }, } dap.configurations.lua = { @@ -40,9 +28,7 @@ return function() return "127.0.0.1" end, port = function() - local val = tonumber(vim.fn.input "Port: ") - assert(val, "Please provide a port number") - return val + return tonumber(vim.fn.input "Port: ") end, }, } @@ -84,7 +70,7 @@ return function() }, } - dap.adapters.cppdbg = { + dap.adapters.lldb = { type = "executable", command = "lldb-vscode", name = "lldb", @@ -137,10 +123,6 @@ return function() }, { elements = { - -- { - -- id = "repl", - -- size = 0.5, - -- }, { id = "console", size = 1, @@ -163,27 +145,52 @@ return function() -- end local nnoremaps = require("bombadil.lib.keymap").nnoremaps - local prefix = "d" nnoremaps { - [prefix .. "bt"] = { - dap.toggle_breakpoint, - { desc = "[dap] Toggle breakpoint" }, - }, - [prefix .. "c"] = { + -- ["]b"] = { + -- function() + -- -- + -- end, + -- { desc = "[dap] Next breakpoint" } + -- }, + -- ["[b"] = { + -- function() + -- -- + -- end, + -- { desc = "[dap] Previous breakpoint" } + -- }, + [""] = { dap.continue, { desc = "[dap] Continue" }, }, - [prefix .. "e"] = { - dapui.eval, - { desc = "[dap] Evaluate expression" }, + [""] = { + dap.run_to_cursor, + { desc = "[dap] Run to cursor" }, }, - [prefix .. "so"] = { + [""] = { + dap.toggle_breakpoint, + { desc = "[dap] Toggle breakpoint" }, + }, + [""] = { dap.step_over, { desc = "[dap] Step over" }, }, - [prefix .. "si"] = { + [""] = { dap.step_into, { desc = "[dap] Step into" }, }, + [""] = { + dap.step_out, + { desc = "[dap] Step out" }, + }, + ["db"] = { + function() + dap.list_breakpoints(true) -- open quickfix + end, + { desc = "[dap] Breakpoints (quickfix)" }, + }, + ["de"] = { + dapui.eval, + { desc = "[dap] Evaluate expression" }, + }, } end diff --git a/plugins/spec.nix b/plugins/spec.nix index 3ab6097..726e929 100644 --- a/plugins/spec.nix +++ b/plugins/spec.nix @@ -136,6 +136,10 @@ in rec { }; nvim-dap-vscode-js = { src = sources.nvim-dap-vscode-js; + # config = { + # adapters = ["pwa-node" "pwa-chrome" "pwa-extensionHost" "pwa-msedge" "node-terminal"]; + # debugger_cmd = ["node" "${inputs'.vscode-js-debug.packages.default}/src/dapDebugServer.js"]; + # }; }; inherit rapidjson; };