aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/neovim/default.nix3
-rw-r--r--modules/neovim/nvim/init.lua1
-rw-r--r--modules/neovim/nvim/lua/config/colorscheme.lua4
-rw-r--r--modules/neovim/nvim/lua/config/dap.lua81
-rw-r--r--modules/neovim/nvim/lua/config/keybinds.lua1
5 files changed, 89 insertions, 1 deletions
diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix
index 4acac91..294c746 100644
--- a/modules/neovim/default.nix
+++ b/modules/neovim/default.nix
@@ -118,6 +118,9 @@ in
'';
}
+ nvim-dap
+ nvim-dap-ui
+
# colorschemes. TODO: delete
# base16-nvim
tinted-nvim
diff --git a/modules/neovim/nvim/init.lua b/modules/neovim/nvim/init.lua
index 900d505..7453ac2 100644
--- a/modules/neovim/nvim/init.lua
+++ b/modules/neovim/nvim/init.lua
@@ -2,6 +2,7 @@ require("config.settings")
require("config.keybinds")
require("config.colorscheme")
require("config.lsp")
+require("config.dap")
require("config.treesitter")
require("config.tmux")
require("config.textobjects")
diff --git a/modules/neovim/nvim/lua/config/colorscheme.lua b/modules/neovim/nvim/lua/config/colorscheme.lua
index 553276f..4946a78 100644
--- a/modules/neovim/nvim/lua/config/colorscheme.lua
+++ b/modules/neovim/nvim/lua/config/colorscheme.lua
@@ -15,6 +15,10 @@ vim.api.nvim_create_autocmd("ColorScheme", { callback = function(args)
vim.api.nvim_set_hl(0, 'TSOperator', { fg = colors.base08 })
vim.api.nvim_set_hl(0, 'TSLabel', { fg = colors.base0C })
vim.api.nvim_set_hl(0, 'Label', { fg = colors.base0C })
+
+ vim.api.nvim_set_hl(0, 'DapBreakpoint', { bg = colors.base00, fg = colors.base08 })
+ vim.api.nvim_set_hl(0, 'DapStopped', { bg = colors.base00, fg = colors.base0B })
+
vim.cmd[[
"hi Normal guibg=NONE
"hi NormalNC guibg=NONE
diff --git a/modules/neovim/nvim/lua/config/dap.lua b/modules/neovim/nvim/lua/config/dap.lua
new file mode 100644
index 0000000..05fb748
--- /dev/null
+++ b/modules/neovim/nvim/lua/config/dap.lua
@@ -0,0 +1,81 @@
+local dap = require("dap")
+local ui = require("dapui")
+
+ui.setup()
+
+local map = vim.keymap.set
+
+local function nmap(lhs, rhs, opts)
+ map("n", lhs, rhs, opts)
+end
+
+nmap("<leader>b", dap.toggle_breakpoint, { desc = "Toggle Breakpoint" })
+nmap("<leader>B", dap.run_to_cursor, { desc = "Run to cursor" })
+nmap("<leader>dso", dap.step_over, { desc = "Step Over" })
+nmap("<leader>dsi", dap.step_into, { desc = "Step Into" })
+nmap("<leader>df", dap.step_out, { desc = "Step Out" })
+nmap("<leader>dr", dap.restart, { desc = "Restart DAP session" })
+
+vim.fn.sign_define("DapBreakpoint", { text = "●", texthl = "DapBreakpoint" })
+vim.fn.sign_define("DapLogPoint", { text = "", texthl = "DapBreakpoint" })
+vim.fn.sign_define("DapStopped", { text = "", texthl = "DapStopped" })
+vim.fn.sign_define("DapBreakpointCondition", { text = "", texthl = "DapBreakpoint" })
+vim.fn.sign_define("DapBreakpointRejected", { text = "", texthl = "DapBreakpoint" })
+
+dap.listeners.before.attach.dapui_config = function()
+ ui.open()
+end
+dap.listeners.before.launch.dapui_config = function()
+ ui.open()
+end
+dap.listeners.before.event_terminated.dapui_config = function()
+ ui.close()
+end
+dap.listeners.before.event_exited.dapui_config = function()
+ ui.close()
+end
+
+dap.adapters.gdb = {
+ type = "executable",
+ command = "gdb",
+ args = { "--interpreter=dap", "--eval-command", "set print pretty on" },
+}
+
+dap.configurations.c = {
+ {
+ name = "Launch",
+ type = "gdb",
+ request = "launch",
+ program = function()
+ return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
+ end,
+ args = {}, -- provide arguments if needed
+ 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.cpp = dap.configurations.c
diff --git a/modules/neovim/nvim/lua/config/keybinds.lua b/modules/neovim/nvim/lua/config/keybinds.lua
index 8dbc0fc..69c5ce3 100644
--- a/modules/neovim/nvim/lua/config/keybinds.lua
+++ b/modules/neovim/nvim/lua/config/keybinds.lua
@@ -23,7 +23,6 @@ end
-- swapnv('N', 'J')
-- swapnv('E', 'K')
-- swapnv('I', 'L')
-
nmap('<leader>tn', ':tabnew<CR>', { desc = "Open a new tab" })
nmap('<leader>tc', ':tabc<CR>', { desc = "Close the current tab" })
nmap('<leader>tm', ':tabp<CR>', { desc = "Go to previous tab" })