diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index fc17291..e2b6a66 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -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; [ diff --git a/nvim/ftplugin/c.lua b/nvim/ftplugin/c.lua index 679f5b6..5116d88 100644 --- a/nvim/ftplugin/c.lua +++ b/nvim/ftplugin/c.lua @@ -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, }, } diff --git a/nvim/plugin/dap.lua b/nvim/plugin/dap.lua index f536beb..e4bc87d 100644 --- a/nvim/plugin/dap.lua +++ b/nvim/plugin/dap.lua @@ -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({ + { "", function() require("dap").continue() end, desc = "debugger: Start" }, + { "", function() require("dap").pause() end, desc = "debugger: pause" }, + { "", function() require("dap").toggle_breakpoint() end, desc = "debugger: toggle breakpoint" }, + { "", function() require("dap").step_over() end, desc = "debugger: step over" }, + { "", function() require("dap").step_into() end, desc = "debugger: step into" }, + { "", function() require("dap").terminate() end, desc = "debugger: Stop" }, -- Shift+F + { "", function() require("dap").step_out() end, desc = "debugger: step out" }, -- Shift+F11 + { "", -- 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" }, + { "", function() require("dap").restart_frame() end, desc = "debugger: restart" }, -- Control+F5 + { "d", group = "[d]ebug", icon="" }, + { "db", function() require("dap").toggle_breakpoint() end, desc = "[d]ebugger: toggle [b]reakpoint (F9)" }, + { "dB", function() require("dap").clear_breakpoints() end, desc = "[d]ebugger: clear [B]reakpoints" }, + { "dc", function() require("dap").continue() end, desc = "[d]ebugger: start/[c]ontinue (F5)" }, + { "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)" }, + { "di", function() require("dap").step_into() end, desc = "[d]ebugger: step [i]nto (F11)" }, + { "do", function() require("dap").step_over() end, desc = "[d]ebugger: step [o]ver (F10)" }, + { "dO", function() require("dap").step_out() end, desc = "[d]ebugger: step [O]ut (S-F11)" }, + { "dq", function() require("dap").close() end, desc = "[d]ebugger: [q]uit" }, + { "dQ", function() require("dap").terminate() end, desc = "[d]ebugger: force [Q]uit(S-F5)" }, + { "dp", function() require("dap").pause() end, desc = "[d]ebugger: [p]ause (F6)" }, + { "dr", function() require("dap").restart_frame() end, desc = "[d]ebugger: [r]estart (C-F5)" }, + { "dR", function() require("dap").repl.toggle() end, desc = "[d]ebugger: toggle [R]EPL" }, + { "ds", function() require("dap").run_to_cursor() end, desc = "[d]ebugger: run to cur[s]or" }, + { "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 + { "du", function() require("dapui").toggle() end, desc = "[d]ebugger: toggle [u]i" }, + { "dh", function() require("dap.ui.widgets").hover() end, desc = "[d]ebugger: [h]over" }, + { mode = "v", "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" }) + diff --git a/nvim/plugin/neotree.lua b/nvim/plugin/neotree.lua index aac1404..42b74ba 100644 --- a/nvim/plugin/neotree.lua +++ b/nvim/plugin/neotree.lua @@ -299,12 +299,12 @@ require("neo-tree").setup({ vim.cmd([[nnoremap \ :Neotree reveal]]) vim.keymap.set('n', 'e', 'Neotree toggle', { desc = 'toggle explorer' }) -vim.keymap.set('n', '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', 'o', +-- function() +-- if vim.bo.filetype == "neo-tree" then +-- vim.cmd.wincmd "p" +-- else +-- vim.cmd.Neotree "focus" +-- end +-- end, +-- { desc = "toggle explorer focus" }) diff --git a/nvim/plugin/overseer.lua b/nvim/plugin/overseer.lua new file mode 100644 index 0000000..7612807 --- /dev/null +++ b/nvim/plugin/overseer.lua @@ -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({ + { "o", group = "[o]verseer", icon = "" }, + { "ot", "OverseerToggle", desc = "[o]verseer: [t]oggle " }, + { "oc", "OverseerRunCmd", desc = "[o]verseer: run [c]ommand" }, + { "or", "OverseerRun", desc = "[o]verseer: [r]un task" }, + { "oq", "OverseerQuickAction", desc = "[o]verseer: [q]uick action" }, + { "oa", "OverseerTaskAction", desc = "[o]verseer: task [a]ction" }, + { "oi", "OverseerInfo", 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 diff --git a/nvim/plugin/plugins.lua b/nvim/plugin/plugins.lua index 3bc9059..96fe244 100644 --- a/nvim/plugin/plugins.lua +++ b/nvim/plugin/plugins.lua @@ -14,3 +14,4 @@ require('which-key').setup() require('Comment').setup() require("better_escape").setup() require("todo-comments").setup() +require("toggleterm").setup()