Skip to content

Commit

Permalink
feat: some dap stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
willruggiano committed Aug 23, 2023
1 parent 6d0b2a7 commit 761c273
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 39 deletions.
99 changes: 93 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};

Expand Down
20 changes: 19 additions & 1 deletion plugins/bombadil/plugin/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,26 @@ vnoremap("<M-k>", function()
vim.cmd [[m '<-2<CR>gv=gv]]
end, { desc = "Move line up" })

-- Toggle the quickfix list
nnoremap("<space>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" },
Expand Down
71 changes: 39 additions & 32 deletions plugins/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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,
},
}
Expand Down Expand Up @@ -84,7 +70,7 @@ return function()
},
}

dap.adapters.cppdbg = {
dap.adapters.lldb = {
type = "executable",
command = "lldb-vscode",
name = "lldb",
Expand Down Expand Up @@ -137,10 +123,6 @@ return function()
},
{
elements = {
-- {
-- id = "repl",
-- size = 0.5,
-- },
{
id = "console",
size = 1,
Expand All @@ -163,27 +145,52 @@ return function()
-- end

local nnoremaps = require("bombadil.lib.keymap").nnoremaps
local prefix = "<space>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" }
-- },
["<F5>"] = {
dap.continue,
{ desc = "[dap] Continue" },
},
[prefix .. "e"] = {
dapui.eval,
{ desc = "[dap] Evaluate expression" },
["<F8>"] = {
dap.run_to_cursor,
{ desc = "[dap] Run to cursor" },
},
[prefix .. "so"] = {
["<F9>"] = {
dap.toggle_breakpoint,
{ desc = "[dap] Toggle breakpoint" },
},
["<F10>"] = {
dap.step_over,
{ desc = "[dap] Step over" },
},
[prefix .. "si"] = {
["<F11>"] = {
dap.step_into,
{ desc = "[dap] Step into" },
},
["<F12>"] = {
dap.step_out,
{ desc = "[dap] Step out" },
},
["<space>db"] = {
function()
dap.list_breakpoints(true) -- open quickfix
end,
{ desc = "[dap] Breakpoints (quickfix)" },
},
["<space>de"] = {
dapui.eval,
{ desc = "[dap] Evaluate expression" },
},
}
end
4 changes: 4 additions & 0 deletions plugins/spec.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 761c273

Please sign in to comment.