Add coc basic config, not fully working yet
This commit is contained in:
103
nvim-coc/lua/plugins/testing/dap.lua
Executable file
103
nvim-coc/lua/plugins/testing/dap.lua
Executable file
@@ -0,0 +1,103 @@
|
||||
return {
|
||||
"mfussenegger/nvim-dap",
|
||||
dependencies = {
|
||||
{ "nvim-neotest/nvim-nio" },
|
||||
{ "rcarriga/nvim-dap-ui" },
|
||||
{ "theHamsta/nvim-dap-virtual-text" },
|
||||
{ "nvim-telescope/telescope-dap.nvim" },
|
||||
},
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>bR", function() require("dap").run_to_cursor() end, desc = "Run to Cursor", },
|
||||
{ "<leader>bE", function() require("dapui").eval(vim.fn.input "[Expression] > ") end, desc = "Evaluate Input", },
|
||||
{ "<leader>bC", function() require("dap").set_breakpoint(vim.fn.input "[Condition] > ") end, desc = "Conditional Breakpoint", },
|
||||
{ "<leader>bU", function() require("dapui").toggle() end, desc = "Toggle UI", },
|
||||
{ "<leader>bb", function() require("dap").step_back() end, desc = "Step Back", },
|
||||
{ "<leader>bc", function() require("dap").continue() end, desc = "Continue", },
|
||||
{ "<leader>bd", function() require("dap").disconnect() end, desc = "Disconnect", },
|
||||
{ "<leader>be", function() require("dapui").eval() end, desc = "Evaluate", },
|
||||
{ "<leader>bg", function() require("dap").session() end, desc = "Get Session", },
|
||||
{ "<leader>bh", function() require("dap.ui.widgets").hover() end, desc = "Hover Variables", },
|
||||
{ "<leader>bS", function() require("dap.ui.widgets").scopes() end, desc = "Scopes", },
|
||||
{ "<leader>bi", function() require("dap").step_into() end, desc = "Step Into", },
|
||||
{ "<leader>bo", function() require("dap").step_over() end, desc = "Step Over", },
|
||||
{ "<leader>bp", function() require("dap").pause.toggle() end, desc = "Pause", },
|
||||
{ "<leader>bq", function() require("dap").close() end, desc = "Quit", },
|
||||
{ "<leader>br", function() require("dap").repl.toggle() end, desc = "Toggle REPL", },
|
||||
{ "<leader>bs", function() require("dap").continue() end, desc = "Start", },
|
||||
{ "<leader>bt", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint", },
|
||||
{ "<leader>bx", function() require("dap").terminate() end, desc = "Terminate", },
|
||||
{ "<leader>bu", function() require("dap").step_out() end, desc = "Step Out", },
|
||||
},
|
||||
config = function()
|
||||
require("nvim-dap-virtual-text").setup({
|
||||
commented = true,
|
||||
})
|
||||
|
||||
local dap, dapui = require("dap"), require("dapui")
|
||||
dapui.setup({})
|
||||
|
||||
dap.listeners.after.event_initialized["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
|
||||
|
||||
vim.fn.sign_define("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = ""})
|
||||
vim.fn.sign_define("DapBreakpointCondition", { text = "●", texthl = "DapBreakpointCondition", linehl = "", numhl = ""})
|
||||
vim.fn.sign_define("DapLogPoint", { text = "◆", texthl = "DapLogPoint", linehl = "", numhl = ""})
|
||||
vim.fn.sign_define('DapStopped', { text='', texthl='DapStopped', linehl='DapStopped', numhl= 'DapStopped' })
|
||||
|
||||
dap.configurations.python = {
|
||||
{
|
||||
type = "python",
|
||||
request = "launch",
|
||||
name = "Launch file",
|
||||
|
||||
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
|
||||
|
||||
program = "${file}", -- This configuration will launch the current file if used.
|
||||
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,
|
||||
},
|
||||
}
|
||||
|
||||
dap.adapters.python = function(cb, config)
|
||||
if config.request == "attach" then
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local port = (config.connect or config).port
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
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 = vim.fn.stdpath("data") .. '/mason/packages/debugpy/venv/bin/python',
|
||||
args = { "-m", "debugpy.adapter" },
|
||||
options = {
|
||||
source_filetype = "python",
|
||||
},
|
||||
})
|
||||
end
|
||||
end
|
||||
end,
|
||||
}
|
70
nvim-coc/lua/plugins/testing/neotest.lua
Executable file
70
nvim-coc/lua/plugins/testing/neotest.lua
Executable file
@@ -0,0 +1,70 @@
|
||||
-- plugins/neotest_config.lua
|
||||
return {
|
||||
-- Load neotest
|
||||
{
|
||||
"nvim-neotest/neotest",
|
||||
dependencies = {
|
||||
-- For JavaScript, TypeScript (Vite)
|
||||
"marilari88/neotest-vitest",
|
||||
-- For Python
|
||||
"nvim-neotest/neotest-python",
|
||||
-- For C, C++, Rust
|
||||
"orjangj/neotest-ctest",
|
||||
"rouge8/neotest-rust",
|
||||
},
|
||||
config = function()
|
||||
local neotest = require("neotest")
|
||||
local keymap = vim.keymap.set
|
||||
|
||||
-- General setup for neotest
|
||||
neotest.setup({
|
||||
adapters = {
|
||||
-- Vite Adapter for JavaScript/TypeScript
|
||||
require("neotest-vitest"),
|
||||
-- Python Adapter
|
||||
require("neotest-python"),
|
||||
-- C/C++ Adapter
|
||||
require("neotest-ctest"),
|
||||
-- Rust Adapter
|
||||
require("neotest-rust"),
|
||||
},
|
||||
})
|
||||
|
||||
-- Keybinding Setup
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
-- Run nearest test
|
||||
opts.desc = "Run nearest test"
|
||||
keymap("n", "<leader><leader>tr", '<cmd>lua require("neotest").run.run()<cr>', opts)
|
||||
|
||||
-- Run all tests in the current file
|
||||
opts.desc = "Run all tests in current file"
|
||||
keymap("n", "<leader><leader>tf", '<cmd>lua require("neotest").run.run(vim.fn.expand("%"))', opts)
|
||||
|
||||
-- Run all tests in the entire project
|
||||
opts.desc = "Run all tests in project"
|
||||
keymap("n", "<leader><leader>ta", "<cmd>Neotest run<cr>", opts)
|
||||
|
||||
-- Stop running tests
|
||||
opts.desc = "Stop tests"
|
||||
keymap("n", "<leader><leader>ts", "<cmd>Neotest stop<cr>", opts)
|
||||
|
||||
opts.desc = "Jump to next test"
|
||||
keymap("n", "<leader><leader>tn", "<cmd>Neotest jump next<cr>", opts)
|
||||
|
||||
opts.desc = "Jump to previous test"
|
||||
keymap("n", "<leader><leader>tp", "<cmd>Neotest jump prev<cr>", opts)
|
||||
|
||||
-- Show test summary
|
||||
opts.desc = "Show neotest test summary"
|
||||
keymap("n", "<leader><leader>tv", "<cmd>Neotest summary<cr>", opts)
|
||||
|
||||
-- Toggle the Neotest panel
|
||||
opts.desc = "Show neotest output"
|
||||
keymap("n", "<leader><leader>to", "<cmd>Neotest output<cr>", opts)
|
||||
|
||||
opts.desc = "Show neotest output as panel"
|
||||
keymap("n", "<leader><leader>tn", "<cmd>Neotest output-panel<cr>", opts)
|
||||
end,
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user