Skip to content

Commit

Permalink
raddbg stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
wrapperup committed Feb 5, 2025
1 parent d766d4a commit 2577035
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 32 deletions.
7 changes: 6 additions & 1 deletion lua/wrap/lazy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ require("lazy").setup({
{
"nvim-telescope/telescope.nvim",
tag = "0.1.8",
dependencies = { "nvim-lua/plenary.nvim" }
dependencies = {
"nvim-lua/plenary.nvim",
{ "nvim-telescope/telescope-fzf-native.nvim", build = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release" },
}
},

-- the goat
Expand Down Expand Up @@ -176,4 +179,6 @@ require("lazy").setup({
require("hlsearch").setup()
end
},

{ 'mistweaverco/kulala.nvim', opts = {} },
})
55 changes: 40 additions & 15 deletions lua/wrap/raddbg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,25 @@ local function to_posix_path(path)
end

local function read_entire_file(file)
local f = io.open(file, "rb")
if f then
local content = f:read("*all")
f:close()
return content
local attempts = 5
local delay = 5 -- milliseconds

for i = 1, attempts do
local f = io.open(file, "rb")
if f then
local content = f:read("*all")
f:close()
return content
end
vim.loop.sleep(delay) -- Give some time before retrying
end

return ""
end


vim.api.nvim_set_hl(0, raddbg_breakpoint_ns, { fg="#EE6969" })
vim.fn.sign_define(raddbg_breakpoint_ns, { text="", texthl=raddbg_breakpoint_ns, linehl="", numhl="" })
vim.fn.sign_define(raddbg_breakpoint_ns, { text="", texthl=raddbg_breakpoint_ns, linehl="", numhl="" })

local raddbg_root = to_posix_path(os.getenv("APPDATA") .. "\\raddbg\\")

Expand Down Expand Up @@ -119,14 +126,6 @@ fs_watcher:start(
end)
)

local function raddbg_toggle_breakpoint(in_line_number)
local file_path = to_posix_path(vim.fn.expand("%:p"))
local line_number = in_line_number or vim.api.nvim_win_get_cursor(0)[1]

raddbg_cmd("toggle_breakpoint", { file_path .. ":" .. line_number });
raddbg_cmd("write_project_data");
end

local function raddbg_goto_current_file()
local file_path = to_posix_path(vim.fn.expand("%:p"))
print(file_path)
Expand All @@ -136,8 +135,30 @@ local function raddbg_goto_current_file()
raddbg_cmd("goto_line", { line_number });
end

vim.keymap.set("n", "<F9>", ":RaddbgToggleBreakpoint<cr>", { silent = true })
local function raddbg_toggle_breakpoint(in_line_number)
local file_path = to_posix_path(vim.fn.expand("%:p"))
local line_number = in_line_number or vim.api.nvim_win_get_cursor(0)[1]

raddbg_cmd("toggle_breakpoint", { file_path .. ":" .. line_number });

local timer = vim.loop.new_timer()
timer:start(20, 0, vim.schedule_wrap(function()
raddbg_cmd("write_project_data");
end))
end

local function raddbg_run(in_line_number)
raddbg_cmd("run");
end


vim.keymap.set("n", "<F9>", ":RaddbgToggleBreakpoint<cr>", { silent = true })
-- vim.keymap.set("n", "<F5>", ":RaddbgRun<cr>", { silent = true })
vim.keymap.set("n", "<F5>", function()
if pcall(function() vim.cmd.make() end) then
vim.cmd "RaddbgRun"
end
end, { silent = true })

-- Commands

Expand All @@ -149,6 +170,10 @@ vim.api.nvim_create_user_command("RaddbgToggleBreakpoint", function()
raddbg_toggle_breakpoint()
end, {})

vim.api.nvim_create_user_command("RaddbgRun", function()
raddbg_run()
end, {})

vim.api.nvim_create_autocmd("BufReadPost", {
pattern = "*",
callback = read_breakpoints_from_project
Expand Down
32 changes: 16 additions & 16 deletions lua/wrap/remaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,22 @@ end
-- Overseer.nvim
----------------------------------------------------------------------------

local overseer = require("overseer")

if overseer then
vim.api.nvim_create_user_command("OverseerRestartLast", function()
local tasks = overseer.list_tasks({ recent_first = true })
if vim.tbl_isempty(tasks) then
-- no tasks to restart, let the user pick
overseer.run_template()
else
overseer.run_action(tasks[1], "restart")
end
end, {})

vim.keymap.set("n", "<F5>", function() vim.cmd "OverseerRestartLast" end)
vim.keymap.set("n", "<S-F5>", function() vim.cmd "OverseerRun" end)
end
-- local overseer = require("overseer")
--
-- if overseer then
-- vim.api.nvim_create_user_command("OverseerRestartLast", function()
-- local tasks = overseer.list_tasks({ recent_first = true })
-- if vim.tbl_isempty(tasks) then
-- -- no tasks to restart, let the user pick
-- overseer.run_template()
-- else
-- overseer.run_action(tasks[1], "restart")
-- end
-- end, {})
--
-- vim.keymap.set("n", "<F5>", function() vim.cmd "OverseerRestartLast" end)
-- vim.keymap.set("n", "<S-F5>", function() vim.cmd "OverseerRun" end)
-- end

----------------------------------------------------------------------------
-- Formatting / Code Completion /Misc
Expand Down

0 comments on commit 2577035

Please sign in to comment.