Skip to content

Commit c33ce39

Browse files
committed
debugger
+ added support for external debugger in same window/pane options as build and run
1 parent 598c9b4 commit c33ce39

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

lua/tmux-compile/init.lua

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ local function get_file_extension()
4444
return filename:match("^.+(%..+)$"):sub(2)
4545
end
4646

47-
-- get build and run commands based on file extension
47+
-- get build, run & debug commands based on file extension
4848
local function get_commands_for_extension(extension)
4949
if extension then
5050
for _, cfg in ipairs(M.config.build_run_config) do
5151
if vim.tbl_contains(cfg.extension, extension) then
52-
return cfg.build, cfg.run
52+
return cfg.build, cfg.run, cfg.debug
5353
end
5454
end
5555
print("Error: No build and run commands found for this extension")
5656
else
5757
print("Error: No file extension found")
5858
end
59-
return nil, nil
59+
return nil, nil, nil
6060
end
6161

6262
-- check if a tmux window with the given name exists
@@ -143,29 +143,36 @@ function M.dispatch(option)
143143
end
144144

145145
local extension = get_file_extension()
146-
local make, run = get_commands_for_extension(extension)
146+
local make, run, debug = get_commands_for_extension(extension)
147147

148148
if option == "lazygit" then
149149
lazygit()
150-
elseif option == "Make" then
151-
overlay(make, M.config.overlay_sleep)
152150
elseif option == "Run" then
153-
overlay(run, M.config.overlay_sleep)
151+
overlay(run, M.config.overlay_sleep, "Run")
154152
elseif option == "RunV" then
155-
split_window(run, "-v")
153+
split_window(run, "-v", "Run")
156154
elseif option == "RunH" then
157-
split_window(run, "-h")
155+
split_window(run, "-h", "Run")
156+
elseif option == "RunBG" then
157+
new_window(run, "Run")
158+
elseif option == "Make" then
159+
overlay(make, M.config.overlay_sleep, "Make")
158160
elseif option == "MakeV" then
159-
split_window(make, "-v")
161+
split_window(make, "-v", "Make")
160162
elseif option == "MakeH" then
161-
split_window(make, "-h")
163+
split_window(make, "-h", "Make")
162164
elseif option == "MakeBG" then
163-
new_window(make)
164-
elseif option == "RunBG" then
165-
new_window(run)
165+
new_window(make, "Make")
166+
elseif option == "Debug" then
167+
overlay(debug, M.config.overlay_sleep, "Debug")
168+
elseif option == "DebugV" then
169+
split_window(debug, "-v", "Debug")
170+
elseif option == "DebugH" then
171+
split_window(debug, "-h", "Debug")
172+
elseif option == "DebugBG" then
173+
new_window(debug, "Debug")
166174
else
167175
print("Error: Invalid option.")
168-
print("Please use one of: Make, Run, RunV, RunH, MakeBG, RunBG, lazygit")
169176
end
170177
end
171178

@@ -175,7 +182,11 @@ vim.api.nvim_create_user_command('TMUXcompile', function(args)
175182
end, {
176183
nargs = 1,
177184
complete = function()
178-
return { "Make", "Run", "RunV", "RunH", "RunBG", "MakeBG", "lazygit"}
185+
return { "lazygit",
186+
"Run", "RunV", "RunH", "RunBG",
187+
"Make", "MakeV", "MakeH", "MakeBG",
188+
"Debug", "DebugV", "DebugH", "DebugBG"
189+
}
179190
end,
180191
})
181192

0 commit comments

Comments
 (0)