diff --git a/nvim/lua/plugins/lspconfig.lua b/nvim/lua/plugins/lspconfig.lua index 64bc0e2..fcb3e6d 100755 --- a/nvim/lua/plugins/lspconfig.lua +++ b/nvim/lua/plugins/lspconfig.lua @@ -5,9 +5,11 @@ return { dependencies = { "hrsh7th/cmp-nvim-lsp", { "antosha417/nvim-lsp-file-operations", config = true }, - "mfussenegger/nvim-jdtls", + -- "mfussenegger/nvim-jdtls", + "nvim-java/nvim-java" }, config = function() + require('java').setup() -- import lspconfig plugin local lspconfig = require("lspconfig") @@ -130,29 +132,50 @@ return { on_attach = on_attach, }) - -- lspconfig.ts_ls.setup({ - -- capabilities = capabilities, - -- on_attach = on_attach, - -- }) + local java_on_attach = function(client, bufnr) + opts.buffer = bufnr - -- 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' - -- -- } - -- -- } - -- }) + -- Keybinds for testing, refactoring, java specific + opts.desc = "Java profiling" + keymap.set("n", "jp", ":JavaProfile", opts) + + opts.desc = "Java Refactor: Extract Variable (create variable from cursor)" + keymap.set("n", "jev", ":JavaExtractVariable", opts) + + opts.desc = "Java Refactor: Extract Variable all occurrences (create variable from cursor)" + keymap.set("n", "jea", ":JavaExtractVariableAllOccurrence", opts) + + opts.desc = "Java Refactor: Extract Const (create const from cursor)" + keymap.set("n", "jec", ":JavaExtractConst", opts) + + opts.desc = "Java Refactor: Extract Method (create method from cursor)" + keymap.set("n", "jev", ":JavaExtractMethod", opts) + + opts.desc = "Java Refactor: Extract Field (create field from cursor)" + keymap.set("n", "jev", ":JavaExtractField", opts) + + -- Java testing, Debugging + opts.desc = "Java Testing: Run test class in buffer" + keymap.set("n", "jtc", ":JavaTestRunCurrentClass", opts) + + opts.desc = "Java Testing: Debug test class in buffer" + keymap.set("n", "jdc", ":JavaTestDebugCurrentClass", opts) + + opts.desc = "Java Testing: Run current method in buffer" + keymap.set("n", "jtm", ":JavaTestRunCurrentMethod", opts) + + opts.desc = "Java Testing: Debug current method in buffer" + keymap.set("n", "jdm", ":JavaTestDebugCurrentMethod", opts) + + opts.desc = "Java Testing: View last report" + keymap.set("n", "jtv", ":JavaTestViewLastReport", opts) + + on_attach(client, bufnr) + end lspconfig.jdtls.setup({ capabilities = capabilities, - on_attach = on_attach, + on_attach = java_on_attach, }) lspconfig.texlab.setup{ diff --git a/nvim/lua/plugins/neotest.lua b/nvim/lua/plugins/neotest.lua new file mode 100755 index 0000000..e5907ea --- /dev/null +++ b/nvim/lua/plugins/neotest.lua @@ -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", "tr", 'lua require("neotest").run.run()', opts) + + -- Run all tests in the current file + opts.desc = "Run all tests in current file" + keymap("n", "tf", '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", "ta", "Neotest run", opts) + + -- Stop running tests + opts.desc = "Stop tests" + keymap("n", "ts", "Neotest stop", opts) + + opts.desc = "Jump to next test" + keymap("n", "tn", "Neotest jump next", opts) + + opts.desc = "Jump to previous test" + keymap("n", "tp", "Neotest jump prev", opts) + + -- Show test summary + opts.desc = "Show neotest test summary" + keymap("n", "tv", "Neotest summary", opts) + + -- Toggle the Neotest panel + opts.desc = "Show neotest output" + keymap("n", "to", "Neotest output", opts) + + opts.desc = "Show neotest output as panel" + keymap("n", "tn", "Neotest output-panel", opts) + end, + }, +}