feat(plugins): Add nvim-dap and overseer

Added:
  - [nvim-dap](https://github.com/mfussenegger/nvim-dap)
  - [nvim-dap-ui](https://github.com/rcarriga/nvim-dap-ui)
  - [overseer.nvim](https://github.com/stevearc/overseer.nvim)
Removed:
  - NeoTree `<leader>o` keymap (it's now used for overseer)
This commit is contained in:
Jiří Štefka 2024-09-23 23:22:44 +02:00
parent 65dea4ed80
commit e256516fe7
Signed by: jiriks74
GPG Key ID: 1D5E30D3DB2264DE
6 changed files with 153 additions and 17 deletions

@ -24,6 +24,7 @@ with final.pkgs.lib; let
all-plugins = with pkgs.vimPlugins; [
nvim-dap # Debuggerhttps://github.com/mfussenegger/nvim-dap
nvim-dap-ui # Debugger UI https://github.com/rcarriga/nvim-dap-ui/
overseer-nvim # A task runner and job management plugin for Neovim | https://github.com/stevearc/overseer.nvim
# Themes
tokyonight-nvim # https://github.com/folke/tokyonight.nvim
@ -72,6 +73,7 @@ with final.pkgs.lib; let
nvim-treesitter-context # nvim-treesitter-context
indent-blankline-nvim # Indent guides for Neovim | https://github.com/lukas-reineke/indent-blankline.nvim
nvim-notify # A fancy, configurable, notification manager for NeoVim | https://github.com/rcarriga/nvim-notify
which-key-nvim # WhichKey helps you remember your Neovim keymaps | https://github.com/folke/which-key.nvim
# ^ UI
# language support
@ -92,6 +94,7 @@ with final.pkgs.lib; let
todo-comments-nvim # Highlight, list and search todo comments in your projects | https://github.com/folke/todo-comments.nvim
nvim-unception # Prevent nested neovim sessions | nvim-unception
better-escape-nvim # Map keys without delay when typing | https://github.com/max397574/better-escape.nvim
toggleterm-nvim # A neovim lua plugin to help easily manage multiple terminal windows | https://github.com/akinsho/toggleterm.nvim?tab=readme-ov-file
# ^ Useful utilities
# libraries that other plugins depend on
@ -107,7 +110,6 @@ with final.pkgs.lib; let
(mkNvimPlugin inputs.presence-nvim "presence.nvim")
# (mkNvimPlugin inputs.wf-nvim "wf.nvim") # (example) keymap hints | https://github.com/Cassin01/wf.nvim
# ^ bleeding-edge plugins from flake inputs
which-key-nvim
];
extraPackages = with pkgs; [

@ -3,9 +3,9 @@ if vim.fn.executable('clangd') ~= 1 then
return
end
require'lspconfig'.clangd.setup{}
-- require'lspconfig'.clangd.setup{}
--[[ local root_files = {
local root_files = {
'compile_commands.json',
'.vscode',
'.git',
@ -16,9 +16,14 @@ vim.lsp.start {
cmd = { 'clangd' },
root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
capabilities = require('user.lsp').make_client_capabilities(),
} ]]
}
local dap = require("dap")
local pickers = require("telescope.pickers")
local finders = require("telescope.finders")
local conf = require("telescope.config").values
local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")
if require('user.file_exists').file_exists(vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]) .. "/.vscode/launch.json") then
require("dap.ext.vscode").load_launchjs(nil, { cppdbg = { "c", "cpp", "asm" } })
@ -31,14 +36,40 @@ dap.adapters.gdb = {
}
dap.configurations.c = {
-- {
-- 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 = "Launch",
name = "Launch an executable",
type = "gdb",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = "${workspaceFolder}",
program = function()
return coroutine.create(function(coro)
local opts = {}
pickers
.new(opts, {
prompt_title = "Path to executable",
finder = finders.new_oneshot_job({ "fd", "--hidden", "--no-ignore", "--type", "x" }, {}),
sorter = conf.generic_sorter(opts),
attach_mappings = function(buffer_number)
actions.select_default:replace(function()
actions.close(buffer_number)
coroutine.resume(coro, action_state.get_selected_entry()[1])
end)
return true
end,
})
:find()
end)
end,
stopAtBeginningOfMainSubprogram = false,
},
}

@ -3,3 +3,77 @@ if vim.g.did_load_dap_plugin then
end
vim.g.did_load_dap_plugin = true
local dap, dapui = require("dap"), require("dapui")
-- UI hooks
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
require('which-key').add({
{ "<F5>", function() require("dap").continue() end, desc = "debugger: Start" },
{ "<F6>", function() require("dap").pause() end, desc = "debugger: pause" },
{ "<F9>", function() require("dap").toggle_breakpoint() end, desc = "debugger: toggle breakpoint" },
{ "<F10>", function() require("dap").step_over() end, desc = "debugger: step over" },
{ "<F11>", function() require("dap").step_into() end, desc = "debugger: step into" },
{ "<F17>", function() require("dap").terminate() end, desc = "debugger: Stop" }, -- Shift+F
{ "<F23>", function() require("dap").step_out() end, desc = "debugger: step out" }, -- Shift+F11
{ "<F21>", -- Shift+F9
function()
vim.ui.input({ prompt = "Condition: " }, function(condition)
if condition then require("dap").set_breakpoint(condition) end
end)
end,
desc = "debugger: Conditional Breakpoint" },
{ "<F29>", function() require("dap").restart_frame() end, desc = "debugger: restart" }, -- Control+F5
{ "<leader>d", group = "[d]ebug", icon="" },
{ "<leader>db", function() require("dap").toggle_breakpoint() end, desc = "[d]ebugger: toggle [b]reakpoint (F9)" },
{ "<leader>dB", function() require("dap").clear_breakpoints() end, desc = "[d]ebugger: clear [B]reakpoints" },
{ "<leader>dc", function() require("dap").continue() end, desc = "[d]ebugger: start/[c]ontinue (F5)" },
{ "<leader>dC",
function()
vim.ui.input({ prompt = "Condition: " }, function(condition)
if condition then require("dap").set_breakpoint(condition) end
end)
end,
desc = "[d]ebugger: [C]onditional breakpoint (S-F9)" },
{ "<leader>di", function() require("dap").step_into() end, desc = "[d]ebugger: step [i]nto (F11)" },
{ "<leader>do", function() require("dap").step_over() end, desc = "[d]ebugger: step [o]ver (F10)" },
{ "<leader>dO", function() require("dap").step_out() end, desc = "[d]ebugger: step [O]ut (S-F11)" },
{ "<leader>dq", function() require("dap").close() end, desc = "[d]ebugger: [q]uit" },
{ "<leader>dQ", function() require("dap").terminate() end, desc = "[d]ebugger: force [Q]uit(S-F5)" },
{ "<leader>dp", function() require("dap").pause() end, desc = "[d]ebugger: [p]ause (F6)" },
{ "<leader>dr", function() require("dap").restart_frame() end, desc = "[d]ebugger: [r]estart (C-F5)" },
{ "<leader>dR", function() require("dap").repl.toggle() end, desc = "[d]ebugger: toggle [R]EPL" },
{ "<leader>ds", function() require("dap").run_to_cursor() end, desc = "[d]ebugger: run to cur[s]or" },
{ "<leader>dE",
function()
vim.ui.input({ prompt = "Expression: " }, function(expr)
if expr then require("dapui").eval(expr, { enter = true }) end
end)
end,
desc = "[d]ebugger: [E]valuate input",
},
-- DapUI
{ "<leader>du", function() require("dapui").toggle() end, desc = "[d]ebugger: toggle [u]i" },
{ "<leader>dh", function() require("dap.ui.widgets").hover() end, desc = "[d]ebugger: [h]over" },
{ mode = "v", "<leader>dE", function() require("dapui").eval() end, desc = "[d]ebugger: [E]valuate input" },
})
vim.fn.sign_define('DapBreakpoint', { text="", texthl="white" })
vim.fn.sign_define('DapBreakpointCondition', { text='', texthl="white" })
vim.fn.sign_define('DapBreakpointRejected', { text='', texthl="bright_red" })
vim.fn.sign_define('DapLogPoint', { text='󰛿', texthl="white" })
vim.fn.sign_define('DapStopped', { text='󰁕', texthl="orange" })

@ -299,12 +299,12 @@ require("neo-tree").setup({
vim.cmd([[nnoremap \ :Neotree reveal<cr>]])
vim.keymap.set('n', '<leader>e', '<Cmd>Neotree toggle<CR>', { desc = 'toggle explorer' })
vim.keymap.set('n', '<leader>o',
function()
if vim.bo.filetype == "neo-tree" then
vim.cmd.wincmd "p"
else
vim.cmd.Neotree "focus"
end
end,
{ desc = "toggle explorer focus" })
-- vim.keymap.set('n', '<leader>o',
-- function()
-- if vim.bo.filetype == "neo-tree" then
-- vim.cmd.wincmd "p"
-- else
-- vim.cmd.Neotree "focus"
-- end
-- end,
-- { desc = "toggle explorer focus" })

28
nvim/plugin/overseer.lua Normal file

@ -0,0 +1,28 @@
if vim.g.did_load_overseer_plugin then
return
end
vim.g.did_load_overseer_plugin = true
require("which-key").add({
{ "<leader>o", group = "[o]verseer", icon = "" },
{ "<leader>ot", "<Cmd>OverseerToggle<CR>", desc = "[o]verseer: [t]oggle " },
{ "<leader>oc", "<Cmd>OverseerRunCmd<CR>", desc = "[o]verseer: run [c]ommand" },
{ "<leader>or", "<Cmd>OverseerRun<CR>", desc = "[o]verseer: [r]un task" },
{ "<leader>oq", "<Cmd>OverseerQuickAction<CR>", desc = "[o]verseer: [q]uick action" },
{ "<leader>oa", "<Cmd>OverseerTaskAction<CR>", desc = "[o]verseer: task [a]ction" },
{ "<leader>oi", "<Cmd>OverseerInfo<CR>", desc = "[o]verseer: [i]nfo" },
})
local root_files = {
'.vscode',
'.git',
}
if require('user.file_exists').file_exists(vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]) .. "/.vscode/tasks.json") then
require('overseer').setup({
strategy = {
"toggleterm",
quit_on_exit = "success",
},
})
end

@ -14,3 +14,4 @@ require('which-key').setup()
require('Comment').setup()
require("better_escape").setup()
require("todo-comments").setup()
require("toggleterm").setup()