Compare commits

..

3 Commits

Author SHA1 Message Date
Ward Truyen
06da50d051 Fixed: make instal 2025-05-24 12:24:02 +02:00
Ward Truyen
e54bc14409 Chore: Added DAP config 2025-05-24 12:20:45 +02:00
Ward Truyen
28d4fd2dc5 Chore: added makefile for regular tasks 2025-05-24 12:18:30 +02:00
6 changed files with 149 additions and 1 deletions

5
lua/ward/.luarc.json Normal file
View File

@@ -0,0 +1,5 @@
{
"diagnostics.globals": [
"vim"
]
}

View File

@@ -0,0 +1,22 @@
-- NOTE: Debug Adapter Protocol User interface, start and close automaticly config
return {
"rcarriga/nvim-dap-ui",
dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
config = function()
local dap, dapui = require("dap"), require("dapui")
dapui.setup()
dap.listeners.before.attach.dapui_config = function()
dapui.open()
end
dap.listeners.before.launch.dapui_config = function()
dapui.open()
end
dap.listeners.before.event_terminated.dapui_config = function()
dapui.close()
end
dap.listeners.before.event_exited.dapui_config = function()
dapui.close()
end
vim.keymap.set('n', '<Leader>dd', function() require('dapui').toggle() end)
end,
}

100
lua/ward/plugins/dap.lua Normal file
View File

@@ -0,0 +1,100 @@
---@type NvPluginSpec
-- NOTE: Debug Adapter Protocol
-- URL: https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation
return {
"mfussenegger/nvim-dap",
config = function()
-- NOTE: Check out this for guide
vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignError", linehl = "", numhl = "" })
local wk = require("which-key")
wk.add({
{"<leader>d", group = "DAP"},
{"<leader>dd", desc = "Toggle DAP UI"},
{"<leader>db", desc = "Toggle breakpoint"},
{"<leader>dB", desc = "Set breakpoint"},
{"<leader>dm", desc = "message point"},
{"<leader>dr", desc = "Open repl"},
{"<leader>dl", desc = "Run last"},
{"<leader>dh", desc = "Hover widgets"},
{"<leader>dp", desc = "Preview widgets"},
{"<leader>df", desc = "Float frames"},
{"<leader>ds", desc = "Float scopes"},
{"<leader>d<F5>", desc = "Debug start/continue"},
{"<leader>d<F6>", desc = "Debug step over"},
{"<leader>d<F7>", desc = "Debug step into"},
{"<leader>d<F8>", desc = "Debug step out"},
})
vim.keymap.set('n', '<F5>', function() require('dap').continue() end)
vim.keymap.set('n', '<F6>', function() require('dap').step_over() end)
vim.keymap.set('n', '<F7>', function() require('dap').step_into() end)
vim.keymap.set('n', '<F8>', function() require('dap').step_out() end)
vim.keymap.set('n', '<Leader>db', function() require('dap').toggle_breakpoint() end)
vim.keymap.set('n', '<Leader>dB', function() require('dap').set_breakpoint() end)
vim.keymap.set('n', '<Leader>dm',
function() require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) end)
vim.keymap.set('n', '<Leader>dr', function() require('dap').repl.open() end)
vim.keymap.set('n', '<Leader>dl', function() require('dap').run_last() end)
vim.keymap.set({ 'n', 'v' }, '<Leader>dh', function()
require('dap.ui.widgets').hover()
end)
vim.keymap.set({ 'n', 'v' }, '<Leader>dp', function()
require('dap.ui.widgets').preview()
end)
vim.keymap.set('n', '<Leader>df', function()
local widgets = require('dap.ui.widgets')
widgets.centered_float(widgets.frames)
end)
vim.keymap.set('n', '<Leader>ds', function()
local widgets = require('dap.ui.widgets')
widgets.centered_float(widgets.scopes)
end)
-- NOTE: Make sure to install the needed files/exectubles through mason
local dap = require("dap")
dap.adapters.gdb = {
type = "executable",
command = "gdb",
args = { "--interpreter=dap", "-eval-command", "set print pretty on" },
}
dap.configurations.cpp = {
{
name = "Launch",
type = "gdb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false,
},
{
name = "Select and attach to process",
type = "gdb",
request = "attach",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
pid = function()
local name = vim.fn.input('Executable name (filter): ')
return require("dap.utils").pick_process({ filter = name })
end,
cwd = '${workspaceFolder}'
},
{
name = 'Attach to gdbserver :1234',
type = 'gdb',
request = 'attach',
target = 'localhost:1234',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}'
},
}
dap.configurations.c = dap.configurations.cpp
end,
}

View File

@@ -13,7 +13,7 @@ return {
-- untracked = { text = "┆" },
},
numhl = true, -- Toggle with `:Gitsigns toggle_numhl`
linehl = true, -- Toggle with `:Gitsigns toggle_linehl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
}
end,
}

View File

@@ -10,6 +10,7 @@ return {
opts = {
ensure_installed = {
--C / C++
"clangd",
"clang-format",
"codelldb",

20
makefile Normal file
View File

@@ -0,0 +1,20 @@
NVIM_CONFIG=~/.config/nvim/#
default : print-help
help : print-help
print-help :
@echo -e "Help!?!?"
@echo -e "Use 'make instal' to instal this config to your home config"
@echo -e "Use 'make code' to get code from your config to this project"
@echo -e "ConfigPath=$(NVIM_CONFIG)"
instal :
@echo -e "Installing to $(NVIM_CONFIG)"
cp ./*.lua $(NVIM_CONFIG)
cp -r ./lua $(NVIM_CONFIG)
code :
@echo -e "Getting code from $(NVIM_CONFIG)"
cp $(NVIM_CONFIG)*.lua ./
cp -r $(NVIM_CONFIG)lua ./