diff --git a/.config/nvim/lua/overseer/template/user/cmake_build.lua b/.config/nvim/lua/overseer/template/user/cmake_build.lua new file mode 100644 index 0000000..f685b96 --- /dev/null +++ b/.config/nvim/lua/overseer/template/user/cmake_build.lua @@ -0,0 +1,27 @@ +return { + name = "CMake Build", + builder = function() + local file = vim.fn.expand("%:p") + return { + cmd = { + "cmake" + }, + args = { + "--build", + "build" + }, + components = { + { + "on_output_quickfix" + }, + "default" + } + } + end, + condition = { + filetype = { + "cmake", + "cpp" + } + } +} diff --git a/.config/nvim/lua/overseer/template/user/cmake_clean.lua b/.config/nvim/lua/overseer/template/user/cmake_clean.lua new file mode 100644 index 0000000..fed851d --- /dev/null +++ b/.config/nvim/lua/overseer/template/user/cmake_clean.lua @@ -0,0 +1,24 @@ +return { + name = "CMake Clean", + builder = function() + local file = vim.fn.expand("%:p") + return { + cmd = { + "rm" + }, + args = { + "-r", + "build", + }, + components = { + "default" + } + } + end, + condition = { + filetype = { + "cmake", + "cpp" + } + } +} diff --git a/.config/nvim/lua/overseer/template/user/cmake_generate.lua b/.config/nvim/lua/overseer/template/user/cmake_generate.lua new file mode 100644 index 0000000..cb3b406 --- /dev/null +++ b/.config/nvim/lua/overseer/template/user/cmake_generate.lua @@ -0,0 +1,58 @@ +return { + name = "CMake Generate", + params = { + build_type = { + type = "enum", + choices = { + "Debug", + "Release", + "RelWithDebInfo", + "MinSizeRel" + }, + default = "Debug" + }, + generator = { + type = "enum", + choices = { + "Ninja", + "Unix Makefiles" + }, + default = "Ninja" + }, + compiler = { + type = "enum", + choices = { + "g++", + "clang++" + }, + default = "g++" + } + }, + builder = function(params) + return { + cmd = { + "cmake" + }, + args = { + "-B", + "build", + "-S", + ".", + "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", + "-DCMAKE_BUILD_TYPE=" .. params.build_type, + "-DCMAKE_CXX_COMPILER=" .. params.compiler, + "-G", + params.generator + }, + components = { + "default" + } + } + end, + condition = { + filetype = { + "cmake", + "cpp" + } + } +} diff --git a/.config/nvim/lua/overseer/template/user/cmake_test.lua b/.config/nvim/lua/overseer/template/user/cmake_test.lua new file mode 100644 index 0000000..23bf155 --- /dev/null +++ b/.config/nvim/lua/overseer/template/user/cmake_test.lua @@ -0,0 +1,27 @@ +return { + name = "CMake Test", + builder = function() + return { + cmd = { + "ctest" + }, + args = { + "--test-dir", + "build", + "--output-on-failure", + }, + components = { + { + "on_output_quickfix" + }, + "default" + } + } + end, + condition = { + filetype = { + "cmake", + "cpp" + } + } +} diff --git a/.config/nvim/lua/overseer/template/user/python_run.lua b/.config/nvim/lua/overseer/template/user/python_run.lua new file mode 100644 index 0000000..860de41 --- /dev/null +++ b/.config/nvim/lua/overseer/template/user/python_run.lua @@ -0,0 +1,22 @@ +return { + name = "Python Run", + builder = function() + local file = vim.fn.expand("%:p") + return { + cmd = { + "python" + }, + args = { + file + }, + components = { + "default" + } + } + end, + condition = { + filetype = { + "python" + } + } +} diff --git a/.config/nvim/lua/plugins/dap.lua b/.config/nvim/lua/plugins/dap.lua new file mode 100644 index 0000000..14d7ca6 --- /dev/null +++ b/.config/nvim/lua/plugins/dap.lua @@ -0,0 +1,154 @@ +return { + { + 'mfussenegger/nvim-dap', + config = function() + local dap = require("dap") + dap.adapters.gdb = { + type = "executable", + command = "gdb", + args = { + "-i", + "dap" + } + } + dap.adapters.python = function(cb, config) + if config.request == 'attach' then + local port = (config.connect or config).port + local host = (config.connect or config).host or '127.0.0.1' + cb({ + type = 'server', + port = assert(port, '`connect.port` is required for a python `attach` configuration'), + host = host, + options = { + source_filetype = 'python' + } + }) + else + cb({ + type = 'executable', + command = 'python', + args = { + '-m', + 'debugpy.adapter' + }, + options = { + source_filetype = 'python' + } + }) + end + end + 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 + } + } + 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 + } + } + dap.configurations.python = { + { + type = 'python', + request = 'launch', + name = "Launch file", + + program = "${file}", + pythonPath = function() + local cwd = vim.fn.getcwd() + if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then + return cwd .. '/venv/bin/python' + elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then + return cwd .. '/.venv/bin/python' + else + return '/usr/bin/python' + end + end + } + } + + vim.keymap.set("n", "db", "DapToggleBreakpoint", { + desc = "Toggle breakpoint" + }) + vim.keymap.set("n", "dc", "DapContinue", { + desc = "Continue" + }) + vim.keymap.set("n", "dt", "DapTerminate", { + desc = "Terminate" + }) + vim.keymap.set("n", "di", "DapStepInto", { + desc = "Step into" + }) + vim.keymap.set("n", "dn", "DapStepOver", { + desc = "Step over" + }) + vim.keymap.set("n", "do", "DapStepOut", { + desc = "Step out" + }) + vim.keymap.set("n", 'dh', function() require('dap.ui.widgets').hover() end, { + desc = "Hover" + }) + end + }, + { + "rcarriga/nvim-dap-ui", + dependencies = { + "mfussenegger/nvim-dap", + "nvim-neotest/nvim-nio" + }, + config = function() + require("dapui").setup({ + controls = { + enabled = false + }, + layouts = { + { + elements = { + { + id = "scopes", + size = 0.33 + }, + { + id = "breakpoints", + size = 0.33 + }, + { + id = "stacks", + size = 0.33 + } + }, + position = "left", + size = 60 + }, + { + elements = { + { + id = "repl", + size = 1 + } + }, + position = "bottom", + size = 15 + } + } + }) + vim.keymap.set("n", "du", function() require("dapui").toggle() end, { + desc = " Toggle UI" + }) + end + } +} diff --git a/.config/nvim/lua/plugins/overseer.lua b/.config/nvim/lua/plugins/overseer.lua new file mode 100644 index 0000000..4d374e4 --- /dev/null +++ b/.config/nvim/lua/plugins/overseer.lua @@ -0,0 +1,28 @@ +return { + "stevearc/overseer.nvim", + config = function() + require("overseer").setup({ + templates = { + "builtin", + "user.cmake_generate", + "user.cmake_build", + "user.cmake_clean", + "user.cmake_test", + "user.python_run" + } + }) + + vim.keymap.set("n", "oo", function() require("overseer").toggle() end, { + desc = "Toggle" + }) + vim.keymap.set("n", "or", ":OverseerRun", { + desc = "Run" + }) + vim.keymap.set("n", "oq", ":OverseerQuickAction", { + desc = "Quick Action" + }) + vim.keymap.set("n", "of", ":OverseerQuickAction open float", { + desc = "Open Float" + }) + end +}