Finish up testing prep
This commit is contained in:
parent
b0a79ec273
commit
aac1f22b1d
@ -5,9 +5,11 @@ return {
|
|||||||
dependencies = {
|
dependencies = {
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
{ "antosha417/nvim-lsp-file-operations", config = true },
|
{ "antosha417/nvim-lsp-file-operations", config = true },
|
||||||
"mfussenegger/nvim-jdtls",
|
-- "mfussenegger/nvim-jdtls",
|
||||||
|
"nvim-java/nvim-java"
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
|
require('java').setup()
|
||||||
-- import lspconfig plugin
|
-- import lspconfig plugin
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
|
|
||||||
@ -64,6 +66,41 @@ return {
|
|||||||
opts.desc = "Restart LSP"
|
opts.desc = "Restart LSP"
|
||||||
keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts)
|
keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts)
|
||||||
|
|
||||||
|
-- Keybinds for testing, refactoring, java specific
|
||||||
|
opts.desc = "Java profiling"
|
||||||
|
keymap.set("n", "<leader>jp", ":JavaProfile<CR>", opts)
|
||||||
|
|
||||||
|
opts.desc = "Java Refactor: Extract Variable (create variable from cursor)"
|
||||||
|
keymap.set("n", "<leader>jev", ":JavaExtractVariable<CR>", opts)
|
||||||
|
|
||||||
|
opts.desc = "Java Refactor: Extract Variable all occurrences (create variable from cursor)"
|
||||||
|
keymap.set("n", "<leader>jea", ":JavaExtractVariableAllOccurrence<CR>", opts)
|
||||||
|
|
||||||
|
opts.desc = "Java Refactor: Extract Const (create const from cursor)"
|
||||||
|
keymap.set("n", "<leader>jec", ":JavaExtractConst<CR>", opts)
|
||||||
|
|
||||||
|
opts.desc = "Java Refactor: Extract Method (create method from cursor)"
|
||||||
|
keymap.set("n", "<leader>jev", ":JavaExtractMethod<CR>", opts)
|
||||||
|
|
||||||
|
opts.desc = "Java Refactor: Extract Field (create field from cursor)"
|
||||||
|
keymap.set("n", "<leader>jev", ":JavaExtractField<CR>", opts)
|
||||||
|
|
||||||
|
-- Java testing, Debugging
|
||||||
|
opts.desc = "Java Testing: Run test class in buffer"
|
||||||
|
keymap.set("n", "<leader>jtc", ":JavaTestRunCurrentClass<CR>", opts)
|
||||||
|
|
||||||
|
opts.desc = "Java Testing: Debug test class in buffer"
|
||||||
|
keymap.set("n", "<leader>jdc", ":JavaTestDebugCurrentClass<CR>", opts)
|
||||||
|
|
||||||
|
opts.desc = "Java Testing: Run current method in buffer"
|
||||||
|
keymap.set("n", "<leader>jtm", ":JavaTestRunCurrentMethod<CR>", opts)
|
||||||
|
|
||||||
|
opts.desc = "Java Testing: Debug current method in buffer"
|
||||||
|
keymap.set("n", "<leader>jdm", ":JavaTestDebugCurrentMethod<CR>", opts)
|
||||||
|
|
||||||
|
opts.desc = "Java Testing: View last report"
|
||||||
|
keymap.set("n", "<leader>jtv", ":JavaTestViewLastReport<CR>", opts)
|
||||||
|
|
||||||
vim.opt.signcolumn = "yes" -- reserve space for diagnostics
|
vim.opt.signcolumn = "yes" -- reserve space for diagnostics
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -130,26 +167,6 @@ return {
|
|||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- lspconfig.ts_ls.setup({
|
|
||||||
-- capabilities = capabilities,
|
|
||||||
-- on_attach = on_attach,
|
|
||||||
-- })
|
|
||||||
|
|
||||||
-- local mason_registry = require('mason-registry')
|
|
||||||
-- local vue_language_server_path = mason_registry.get_package('vue-language-server'):get_install_path() .. '/node_modules/@vue/language-server'
|
|
||||||
--
|
|
||||||
-- lspconfig.volar.setup({
|
|
||||||
-- capabilities = capabilities,
|
|
||||||
-- on_attach = on_attach,
|
|
||||||
-- -- cmd = { "vue-language-server", "--stdio" },
|
|
||||||
-- filetypes = { "vue" },
|
|
||||||
-- -- settings = {
|
|
||||||
-- -- typescript = {
|
|
||||||
-- -- tsdk = '/usr/lib/node_modules/typescript/lib'
|
|
||||||
-- -- }
|
|
||||||
-- -- }
|
|
||||||
-- })
|
|
||||||
|
|
||||||
lspconfig.jdtls.setup({
|
lspconfig.jdtls.setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
|
@ -11,8 +11,6 @@ return {
|
|||||||
-- For C, C++, Rust
|
-- For C, C++, Rust
|
||||||
"orjangj/neotest-ctest",
|
"orjangj/neotest-ctest",
|
||||||
"rouge8/neotest-rust",
|
"rouge8/neotest-rust",
|
||||||
--For Java
|
|
||||||
"rcasia/neotest-java"
|
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local neotest = require("neotest")
|
local neotest = require("neotest")
|
||||||
@ -29,41 +27,44 @@ return {
|
|||||||
require("neotest-ctest"),
|
require("neotest-ctest"),
|
||||||
-- Rust Adapter
|
-- Rust Adapter
|
||||||
require("neotest-rust"),
|
require("neotest-rust"),
|
||||||
-- Java Adapter
|
|
||||||
require("neotest-java"),
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Keybinding Setup
|
-- Keybinding Setup
|
||||||
local opts = { noremap = true, silent = true }
|
local opts = { noremap = true, silent = true }
|
||||||
|
|
||||||
-- Base Keybind for testing, starting with <leader><leader>t
|
|
||||||
keymap("n", "<leader><leader>t", "<cmd>Neotest<cr>", opts) -- Open neotest panel
|
|
||||||
|
|
||||||
-- Run nearest test
|
-- Run nearest test
|
||||||
keymap("n", "<leader><leader>tn", "<cmd>Neotest run nearest<cr>", opts)
|
opts.desc = "Run nearest test"
|
||||||
|
keymap("n", "<leader><leader>tr", require("neotest").run.run(), opts)
|
||||||
|
|
||||||
-- Run all tests in the current file
|
-- Run all tests in the current file
|
||||||
keymap("n", "<leader><leader>tf", "<cmd>Neotest run file<cr>", opts)
|
opts.desc = "Run all tests in current file"
|
||||||
|
keymap("n", "<leader><leader>tf", require("neotest").run.run(vim.fn.expand("%")), opts)
|
||||||
|
|
||||||
-- Run all tests in the entire project
|
-- Run all tests in the entire project
|
||||||
|
opts.desc = "Run all tests in project"
|
||||||
keymap("n", "<leader><leader>ta", "<cmd>Neotest run<cr>", opts)
|
keymap("n", "<leader><leader>ta", "<cmd>Neotest run<cr>", opts)
|
||||||
|
|
||||||
-- Stop running tests
|
-- Stop running tests
|
||||||
|
opts.desc = "Stop tests"
|
||||||
keymap("n", "<leader><leader>ts", "<cmd>Neotest stop<cr>", opts)
|
keymap("n", "<leader><leader>ts", "<cmd>Neotest stop<cr>", opts)
|
||||||
|
|
||||||
-- Jump to next test failure
|
opts.desc = "Jump to next test"
|
||||||
keymap("n", "<leader><leader>tj", "<cmd>Neotest jump to failure<cr>", opts)
|
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
|
-- Show test summary
|
||||||
keymap("n", "<leader><leader>tsm", "<cmd>Neotest summary<cr>", opts)
|
opts.desc = "Show neotest test summary"
|
||||||
|
keymap("n", "<leader><leader>tv", "<cmd>Neotest summary<cr>", opts)
|
||||||
|
|
||||||
-- Toggle the Neotest panel
|
-- Toggle the Neotest panel
|
||||||
keymap("n", "<leader><leader>tt", "<cmd>Neotest toggle panel<cr>", opts)
|
opts.desc = "Show neotest output"
|
||||||
|
keymap("n", "<leader><leader>to", "<cmd>Neotest output<cr>", opts)
|
||||||
|
|
||||||
-- Additional useful keybindings
|
opts.desc = "Show neotest output as panel"
|
||||||
keymap("n", "<leader><leader>tp", "<cmd>Neotest prev<cr>", opts) -- Jump to previous test failure
|
keymap("n", "<leader><leader>tn", "<cmd>Neotest output-panel<cr>", opts)
|
||||||
keymap("n", "<leader><leader>tnx", "<cmd>Neotest run ext<cr>", opts) -- Run test using external runner (useful for custom test setups)
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user