summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-16 02:19:39 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-16 02:19:42 +0200
commitd4bbff517b54383876e84204707fcb21cf69d48d (patch)
treee9a70dd2037cc200b2252014c4325becc422ec3b
parent36459bee543d1ea809bf66178b8ed933a44f77b5 (diff)
checkpoint
-rw-r--r--after/ftplugin/c.lua1
-rw-r--r--after/plugin/autoclose.lua1
-rw-r--r--after/plugin/dap.lua75
-rw-r--r--lua/config/lazy.lua8
-rw-r--r--lua/config/map.lua1
5 files changed, 86 insertions, 0 deletions
diff --git a/after/ftplugin/c.lua b/after/ftplugin/c.lua
index f3fcd6f..58f46a6 100644
--- a/after/ftplugin/c.lua
+++ b/after/ftplugin/c.lua
@@ -1,2 +1,3 @@
local map = vim.keymap.set
map("n", ",p", [[<cmd>s/\(\s*\)\(.\+\)/\1printf("\2: %d\\n", \2);<cr>]], { desc = "Surround var with printf" })
+vim.o.commentstring = "// %s"
diff --git a/after/plugin/autoclose.lua b/after/plugin/autoclose.lua
index 90a4e4b..6de29e0 100644
--- a/after/plugin/autoclose.lua
+++ b/after/plugin/autoclose.lua
@@ -35,5 +35,6 @@ local filetypes = require("autoclose").setup({
},
options = {
disable_when_touch = true,
+ disable_command_mode = true,
},
})
diff --git a/after/plugin/dap.lua b/after/plugin/dap.lua
new file mode 100644
index 0000000..fd141bb
--- /dev/null
+++ b/after/plugin/dap.lua
@@ -0,0 +1,75 @@
+local dap = require("dap")
+local dapui = require("dapui")
+local widgets = require("dap.ui.widgets")
+local map = vim.keymap.set
+
+dapui.setup()
+-- stylua: ignore start
+map("n", " bu", function() dapui.toggle() end, { desc = "Toggle dap-ui" })
+map("n", " bb", function() dap.toggle_breakpoint() end, { desc = "Toggle breakpoint" })
+map("n", " bc", function() dap.continue() end, {desc="Continue"})
+map("n", " bs", function() dap.step_over() end, {desc="Step over"})
+map("n", " bi", function() dap.step_into() end, {desc="Step into"})
+map("n", " bo", function() dap.step_out() end, {desc="Step out"})
+map({ "n", "v" }, " bh", function() widgets.hover() end, {desc="Show hover"})
+map({ "n", "v" }, " bv", function() widgets.preview() end, {desc="Show preview"})
+map("n", " bf", function() widgets.centered_float(widgets.frames) end, {desc="Show frames"})
+map("n", " bp", function() widgets.centered_float(widgets.scopes) end, {desc="Show scopes"})
+-- stylua: ignore end
+map("n", " bl", function()
+ dap.set_breakpoint(nil, nil, vim.fn.input("Log point message: "))
+end, { desc = "Break point with log" })
+
+dap.adapters.gdb = {
+ id = "gdb",
+ type = "executable",
+ command = "gdb",
+ args = { "--quiet", "--interpreter=dap" },
+}
+
+dap.configurations.c = {
+ {
+ name = "Run (GDB)",
+ type = "gdb",
+ request = "launch",
+ -- This requires special handling of 'run_last', see
+ -- https://github.com/mfussenegger/nvim-dap/issues/1025#issuecomment-1695852355
+ program = function()
+ local path = vim.fn.input({
+ prompt = "Path to executable: ",
+ default = vim.fn.getcwd() .. "/",
+ completion = "file",
+ })
+
+ return (path and path ~= "") and path or dap.ABORT
+ end,
+ },
+ {
+ name = "Run with arguments (GDB)",
+ type = "gdb",
+ request = "launch",
+ -- This requires special handling of 'run_last', see
+ -- https://github.com/mfussenegger/nvim-dap/issues/1025#issuecomment-1695852355
+ program = function()
+ local path = vim.fn.input({
+ prompt = "Path to executable: ",
+ default = vim.fn.getcwd() .. "/",
+ completion = "file",
+ })
+
+ return (path and path ~= "") and path or dap.ABORT
+ end,
+ args = function()
+ local args_str = vim.fn.input({
+ prompt = "Arguments: ",
+ })
+ return vim.split(args_str, " +")
+ end,
+ },
+ {
+ name = "Attach to process (GDB)",
+ type = "gdb",
+ request = "attach",
+ processId = require("dap.utils").pick_process,
+ },
+}
diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua
index 3a00367..15ac268 100644
--- a/lua/config/lazy.lua
+++ b/lua/config/lazy.lua
@@ -187,6 +187,14 @@ require("lazy").setup({
branch = "harpoon2",
requires = { "nvim-lua/plenary.nvim", lazy = true },
},
+
+ -- DAP
+ {
+ {
+ "mfussenegger/nvim-dap",
+ },
+ { "rcarriga/nvim-dap-ui", dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" } },
+ },
}, {
-- lazy options
diff --git a/lua/config/map.lua b/lua/config/map.lua
index 30a96c8..61bb952 100644
--- a/lua/config/map.lua
+++ b/lua/config/map.lua
@@ -62,6 +62,7 @@ vim.api.nvim_create_user_command("Hide", function()
end, {})
-- write
+map("n", " x", "!cx %", { desc = "Toggle file as executable" })
map("n", " w", "<cmd>write<cr>", { noremap = true })
map("n", " W", "<cmd>write!<cr>", { noremap = true })
map("n", " e", "<cmd>edit<cr>", { noremap = true })