diff --git a/lazy-lock.json b/lazy-lock.json index fcfe458..0f9ae96 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -6,7 +6,7 @@ "alpha-nvim": { "branch": "main", "commit": "bf3c8bb8c02ed3d9644cc5bbc48e2bdc39349cd7" }, "auto-bufferline.nvim": { "branch": "main", "commit": "f5835a4b62bfb6f6c829f8f050e5102ccf230b3e" }, "auto-conform.nvim": { "branch": "main", "commit": "5f0897235e84bf2f8ff9d634e81678d5bfa63ab8" }, - "auto-jdtls.nvim": { "branch": "main", "commit": "3851cb9539283972d53ac24a3fd00a9decfdc717" }, + "auto-jdtls.nvim": { "branch": "main", "commit": "5029bc563353d47d3ba27d4b30770bad167500af" }, "auto-lint.nvim": { "branch": "main", "commit": "aff13cb8eaa055e66e940d43b7d83166397e5413" }, "auto-lsp.nvim": { "branch": "main", "commit": "2a5ade9f78a1c60d747396445d4205352d2491db" }, "auto-lualine.nvim": { "branch": "main", "commit": "fc8557f61dc1da12a8b90167a49420958b991d8c" }, @@ -20,13 +20,14 @@ "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "code_runner.nvim": { "branch": "main", "commit": "dcedccbf969a0f3bc00db446172b4966e83101dd" }, "codeium.vim": { "branch": "main", "commit": "8c01979323b2b480c8bf160d3ff85bd1668baa49" }, - "conform.nvim": { "branch": "master", "commit": "1a7ff54dcfbe1af139b11829c6d58f5ffab87707" }, - "dressing.nvim": { "branch": "master", "commit": "43b8f74e0b1e3f41e51f640f8efa3bcd401cea0d" }, + "conform.nvim": { "branch": "master", "commit": "023f795dbcf32d4351b6a9ed2e613d471b5bb812" }, + "dressing.nvim": { "branch": "master", "commit": "fc78a3ca96f4db9f8893bb7e2fd9823e0780451b" }, "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, - "gitsigns.nvim": { "branch": "main", "commit": "4daf7022f1481edf1e8fb9947df13bb07c18e89a" }, + "gitsigns.nvim": { "branch": "main", "commit": "9521fe8be39255b9abc6ec54e352bf04c410f5cf" }, "inc-rename.nvim": { "branch": "main", "commit": "8ba77017ca468f3029bf88ef409c2d20476ea66b" }, "indent-blankline.nvim": { "branch": "master", "commit": "7871a88056f7144defca9c931e311a3134c5d509" }, "lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" }, + "lsp_signature.nvim": { "branch": "master", "commit": "fc38521ea4d9ec8dbd4c2819ba8126cea743943b" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, @@ -36,12 +37,12 @@ "minty": { "branch": "main", "commit": "1b604ed0d741294cfb56c0ce3aa6161e9ae7dd8b" }, "neotest": { "branch": "master", "commit": "6d3d22cdad49999ef774ebe1bc250a4994038964" }, "neotest-java": { "branch": "main", "commit": "320f31c71b183f2c584198f33f93542fd0e5a768" }, - "noice.nvim": { "branch": "main", "commit": "2087bbf8cd64482b47fb5f33b5e0eabf329ab14b" }, + "noice.nvim": { "branch": "main", "commit": "ca2e3fea9fb080dcb79d9129d73dac631294fe79" }, "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, "nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" }, "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, "nvim-colorizer.lua": { "branch": "master", "commit": "f134063618a65cad4d7415fddbd96ff7e0c5b4ae" }, - "nvim-dap": { "branch": "master", "commit": "8517126e9323e346f6a99b3b594c5a940b914dcd" }, + "nvim-dap": { "branch": "master", "commit": "6bf4de67dbe90271608e1c81797e5edc79ec6335" }, "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "76d80c3d171224315b61c006502a1e30c213a9ab" }, "nvim-jdtls": { "branch": "master", "commit": "c4279b8ffce9b64eb302056d78dfebc2968a49bc" }, @@ -53,7 +54,7 @@ "nvim-notify": { "branch": "master", "commit": "fbef5d32be8466dd76544a257d3f3dce20082a07" }, "nvim-scrollview": { "branch": "main", "commit": "f7f611330a8f7cd00dc81538fec369611be678ed" }, "nvim-tree.lua": { "branch": "master", "commit": "28eac2801b201f301449e976d7a9e8cfde053ba3" }, - "nvim-treesitter": { "branch": "master", "commit": "7646c1c12a3121562aa87fd79aace48c728ac096" }, + "nvim-treesitter": { "branch": "master", "commit": "e1e3108cd23d7f967842261bd66126b6734d8907" }, "nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "9c74db656c3d0b1c4392fc89a016b1910539e7c0" }, "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, @@ -62,6 +63,7 @@ "refactoring.nvim": { "branch": "master", "commit": "53ed6854e0bba64d467c58e87084dcf8b1c22d36" }, "smart-splits.nvim": { "branch": "master", "commit": "ea4702652cb1d18811d60f2e206787602a2e946c" }, "symbols-outline.nvim": { "branch": "master", "commit": "964c5902243446124417a3a9e9454f5ef032cc36" }, + "telescope-treesitter-info.nvim": { "branch": "master", "commit": "4bed952c3c33015c4402007f179b478843d5aa3b" }, "telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" }, "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "a39fa4c92268832f6034306793b8acbfec2a7549" }, "toggleterm.nvim": { "branch": "main", "commit": "87b2d6a3cab8e2bd9a0255427074285f0365398d" }, @@ -70,6 +72,6 @@ "virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" }, "volt": { "branch": "main", "commit": "1df6698f7e5d19db578063412d12322e53376f5e" }, "which-key.nvim": { "branch": "main", "commit": "68e37e12913a66b60073906f5d3f14dee0de19f2" }, - "yanky.nvim": { "branch": "main", "commit": "a86d33912017878a4cb18758cd863dd335873bf8" }, + "yanky.nvim": { "branch": "main", "commit": "f9b905994cccf3c55f41af3a0a1f4c76c844e411" }, "zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" } } diff --git a/lua/auto-jdtls2/init.lua b/lua/auto-jdtls2/init.lua index 1ffc62a..af1787a 100644 --- a/lua/auto-jdtls2/init.lua +++ b/lua/auto-jdtls2/init.lua @@ -2,6 +2,7 @@ local M = {} M.setup = function(opt) opt = opt or {} + require("auto-jdtls.utils").install() require("auto-jdtls.utils").attach_jdtls(opt) end diff --git a/lua/auto-jdtls2/utils.lua b/lua/auto-jdtls2/utils.lua index e1bccb2..ce6262a 100644 --- a/lua/auto-jdtls2/utils.lua +++ b/lua/auto-jdtls2/utils.lua @@ -165,7 +165,31 @@ M.attach_jdtls = function(op) opt.ts = 4 opt.expandtab = true + -- Check Ttriisittrer + + local function ensure_ts_install(lang) + local parsers = require("nvim-treesitter.parsers") + local installed = parsers.has_parser(lang) + + if not installed then + vim.cmd("TSInstall " .. lang) + require("notify")("Treesitter parser for " .. lang .. " installed successfully.") + end + end + + -- Memeriksa dan menginstal atau mengonfirmasi Treesitter untuk Java + ensure_ts_install("java") + local mason_registry = require("mason-registry") + if + not mason_registry.is_installed("jdtls") + or not mason_registry.is_installed("java-debug-adapter") + or not mason_registry.is_installed("java-test") + then + vim.cmd("Mason") + require("notify")("Mason Installed Dependency, please restart nvim after installation is completed") + return + end local bundles = {} ---@type string[] if M.opts.dap and mason_registry.is_installed("java-debug-adapter") then local java_dbg_pkg = mason_registry.get_package("java-debug-adapter") @@ -236,4 +260,30 @@ M.attach_jdtls = function(op) attach_jdtls() end +M.install = function() + local ensure_installed = { + "java-debug-adapter", + "java-test", + "jdtls", + } + local mr = require("mason-registry") + mr:on("package:install:success", function() + vim.defer_fn(function() + -- trigger FileType event to possibly load this newly installed LSP server + require("lazy.core.handler.event").trigger({ + event = "FileType", + buf = vim.api.nvim_get_current_buf(), + }) + end, 100) + end) + + mr.refresh(function() + for _, tool in ipairs(ensure_installed) do + local p = mr.get_package(tool) + if not p:is_installed() then + p:install() + end + end + end) +end return M diff --git a/lua/pcode/plugins/extras/lspsignatur.lua b/lua/pcode/plugins/extras/lspsignatur.lua new file mode 100644 index 0000000..436e687 --- /dev/null +++ b/lua/pcode/plugins/extras/lspsignatur.lua @@ -0,0 +1,23 @@ +return { + "ray-x/lsp_signature.nvim", + event = "VeryLazy", + opts = function() + local is_enabled = true + return { + -- Window mode + floating_window = is_enabled, -- Display it as floating window. + hi_parameter = "IncSearch", -- Color to highlight floating window. + handler_opts = { border = "rounded" }, -- Window style + + -- Hint mode + hint_enable = false, -- Display it as hint. + hint_prefix = "👈 ", + + -- Additionally, you can use uH to toggle inlay hints. + toggle_key_flip_floatwin_setting = is_enabled, + } + end, + config = function(_, opts) + require("lsp_signature").setup(opts) + end, +} diff --git a/lua/pcode/plugins/extras/telescopetreesiterinfo.lua b/lua/pcode/plugins/extras/telescopetreesiterinfo.lua new file mode 100644 index 0000000..487b930 --- /dev/null +++ b/lua/pcode/plugins/extras/telescopetreesiterinfo.lua @@ -0,0 +1,13 @@ +return { + "nvim-telescope/telescope.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "roycrippen4/telescope-treesitter-info.nvim", + }, + config = function() + require("telescope").load_extension("treesitter_info") + end, + keys = { + { "p", "Telescope treesitter_info", desc = "Treesitter Info" }, + }, +} diff --git a/lua/pcode/plugins/lang/java.lua b/lua/pcode/plugins/lang/java.lua index 67488bd..84642e0 100644 --- a/lua/pcode/plugins/lang/java.lua +++ b/lua/pcode/plugins/lang/java.lua @@ -2,29 +2,10 @@ local M = {} M = { { "williamboman/mason-lspconfig.nvim", - -- stylua: ignore opts = function(_, opts) opts.skip_config = opts.skip_config or {} vim.list_extend(opts.skip_config, { "jdtls" }) - vim.keymap.set({ "n", "v" }, "l", "", { desc = "LSP" }) - -- Set vim motion for + l + h to show code documentation about the code the cursor is currently over if available - vim.keymap.set("n", "lh", vim.lsp.buf.hover, { desc = "Code Hover Documentation" }) - -- Set vim motion for + l + d to go where the code/variable under the cursor was defined - vim.keymap.set("n", "ld", vim.lsp.buf.definition, { desc = "Code Goto Definition" }) - -- Set vim motion for + l + a for display code action suggestions for code diagnostics in both normal and visual mode - vim.keymap.set({ "n", "v" }, "la", vim.lsp.buf.code_action, { desc = "Code Actions" }) - -- Set vim motion for + l + r to display references to the code under the cursor - vim.keymap.set("n", "lr", require("telescope.builtin").lsp_references, { desc = "Code Goto References" }) - -- Set vim motion for + l + i to display implementations to the code under the cursor - vim.keymap.set("n", "li", require("telescope.builtin").lsp_implementations, { desc = "Code Goto Implementations" }) - -- Set a vim motion for + l + R to smartly rename the code under the cursor - vim.keymap.set("n", "lR", vim.lsp.buf.rename, { desc = "Code Rename" }) - -- Set a vim motion for + l + D to go to where the code/object was declared in the project (class file) - vim.keymap.set("n", "lD", vim.lsp.buf.declaration, { desc = "Code Goto Declaration" }) end, - keys = { - { "l", "", desc = "LSP", mode = { "n", "v" } }, - }, }, { "mfussenegger/nvim-jdtls", @@ -33,52 +14,10 @@ M = { enabled = true, -- your opts go here opts = {}, - -- stylua: ignore config = function(_, opts) require("auto-jdtls").setup(opts) - -- add keymaps - vim.keymap.set('n', 'J', "", { desc = "Java" }) - -- Set a Vim motion to + J + o to organize imports in normal mode - vim.keymap.set('n', 'Jo', " lua require('jdtls').organize_imports()", { desc = "Java Organize Imports" }) - -- Set a Vim motion to + J + v to extract the code under the cursor to a variable - vim.keymap.set('n', 'Jv', " lua require('jdtls').extract_variable()", { desc = "Java Extract Variable" }) - -- Set a Vim motion to + J + v to extract the code selected in visual mode to a variable - vim.keymap.set('v', 'Jv', " lua require('jdtls').extract_variable(true)", { desc = "Java Extract Variable" }) - -- Set a Vim motion to + J + C to extract the code under the cursor to a static variable - vim.keymap.set('n', 'JC', " lua require('jdtls').extract_constant()", { desc = "Java Extract Constant" }) - -- Set a Vim motion to + J + C to extract the code selected in visual mode to a static variable - vim.keymap.set('v', 'JC', " lua require('jdtls').extract_constant(true)", { desc = "Java Extract Constant" }) - -- Set a Vim motion to + J + t to run the test method currently under the cursor - vim.keymap.set('n', 'Jt', " lua require('jdtls').test_nearest_method()", { desc = "Java Test Method" }) - -- Set a Vim motion to + J + t to run the test method that is currently selected in visual mode - vim.keymap.set('v', 'Jt', " lua require('jdtls').test_nearest_method(true)", { desc = "Java Test Method" }) - -- Set a Vim motion to + J + T to run an entire test suite (class) - vim.keymap.set('n', 'JT', " lua require('jdtls').test_class()", { desc = "Java Test Class" }) - -- Set a Vim motion to + J + u to update the project configuration - vim.keymap.set('n', 'Ju', " JdtUpdateConfig", { desc = "Java Update Config" }) - end, - }, - { - "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - opts.ensure_installed = opts.ensure_installed or {} - vim.list_extend(opts.ensure_installed, { "java" }) - end, - }, - { - "williamboman/mason-lspconfig.nvim", - -- stylua: ignore - opts = function(_, opts) - opts.ensure_installed = opts.ensure_installed or {} - vim.list_extend(opts.ensure_installed, { "jdtls" }) - end, - }, - { - "pojokcodeid/auto-conform.nvim", - event = "VeryLazy", - opts = function(_, opts) - vim.list_extend(opts.ensure_installed, { "java-debug-adapter", "java-test" }) - opts.formatters_by_ft.java = { "lsp_fmt" } + require("auto-jdtls.utils").lsp_keymaps() + require("auto-jdtls.utils").jdtls_keymaps() end, }, { @@ -168,7 +107,7 @@ M = { }) end, keys = { - { "S", "SymbolsOutline", desc = "Toggle Outline" }, + { "Js", "SymbolsOutline", desc = "Toggle Outline" }, }, }, } diff --git a/lua/pcode/plugins/lang/java2.lua b/lua/pcode/plugins/lang/java2.lua index 6db9d45..8ed35bf 100644 --- a/lua/pcode/plugins/lang/java2.lua +++ b/lua/pcode/plugins/lang/java2.lua @@ -1,6 +1,13 @@ return { "nvim-java/nvim-java", - event = "VeryLazy", + -- event = "VeryLazy", + ft = { "java" }, + dependencies = { + "MunifTanjim/nui.nvim", + "neovim/nvim-lspconfig", + "mfussenegger/nvim-dap", + "williamboman/mason.nvim", + }, config = function() require("java").setup({ notifications = { diff --git a/lua/pcode/plugins/lang/java4.lua b/lua/pcode/plugins/lang/java4.lua new file mode 100644 index 0000000..cb144cf --- /dev/null +++ b/lua/pcode/plugins/lang/java4.lua @@ -0,0 +1,32 @@ +return { + "nvim-java/nvim-java", + -- ft = { "java" }, + dependencies = { + "MunifTanjim/nui.nvim", + "neovim/nvim-lspconfig", + "mfussenegger/nvim-dap", + "williamboman/mason.nvim", + }, + opts = { + notifications = { + dap = false, + }, + jdk = { + auto_install = false, + }, + + -- NOTE: One of these files must be in your project root directory. + -- Otherwise the debugger will end in the wrong directory and fail. + root_markers = { + "settings.gradle", + "settings.gradle.kts", + "pom.xml", + "build.gradle", + "mvnw", + "gradlew", + "build.gradle", + "build.gradle.kts", + ".git", + }, + }, +} diff --git a/lua/pcode/plugins/notify.lua b/lua/pcode/plugins/notify.lua index 639d0de..1c4ae83 100644 --- a/lua/pcode/plugins/notify.lua +++ b/lua/pcode/plugins/notify.lua @@ -17,7 +17,7 @@ return { return math.floor(vim.o.lines * 0.75) end, max_width = function() - return math.floor(vim.o.columns * 0.75) + return math.floor(vim.o.columns * 0.3) end, render = "wrapped-compact", -- background_colour = "#00000000", diff --git a/lua/pcode/user/default.lua b/lua/pcode/user/default.lua index ee24357..efd2f8a 100644 --- a/lua/pcode/user/default.lua +++ b/lua/pcode/user/default.lua @@ -8,6 +8,7 @@ pcode.lang = { java = true, java2 = false, java3 = false, + java4 = false, javascript = false, kotlin = false, markdown = false, @@ -44,6 +45,8 @@ pcode.extras = { visualmulti = true, yanky = true, zenmode = true, + lspsignatur = true, + telescopetreesiterinfo = true, } -- activate config themes pcode.themes = {