diff --git a/lazy-lock.json b/lazy-lock.json index ef90325..5ee0b4f 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,5 +1,6 @@ { "Comment.nvim": { "branch": "master", "commit": "e51f2b142d88bb666dcaa77d93a07f4b419aca70" }, + "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" }, "bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" }, @@ -17,7 +18,7 @@ "dressing.nvim": { "branch": "master", "commit": "71349f24c6e07b39f33600985843c289ca735308" }, "friendly-snippets": { "branch": "main", "commit": "682157939e57bd6a2c86277dfd4d6fbfce63dbac" }, "gitsigns.nvim": { "branch": "main", "commit": "0b04035bb7b3c83e999b9676e2fb46fd0aa9f910" }, - "indent-blankline.nvim": { "branch": "master", "commit": "4288ce8128a52650e401dda42fd7651a6038f262" }, + "indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" }, "lazy.nvim": { "branch": "main", "commit": "37c7163f8d27243993ac07db8477e44cd5275027" }, "lsp-progress.nvim": { "branch": "main", "commit": "55a04895ea20c365b670051a3128265d43bdfa3d" }, "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, @@ -26,6 +27,8 @@ "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, "mini.indentscope": { "branch": "main", "commit": "56d42be090e8fcc68eda69cfe55af8c5e562300e" }, "neoscroll.nvim": { "branch": "master", "commit": "a731f66f1d39ec6175fd201c5bf849e54abda99c" }, + "neotest": { "branch": "master", "commit": "f30bab1faef13d47f3905e065215c96a42d075ad" }, + "neotest-java": { "branch": "main", "commit": "320f31c71b183f2c584198f33f93542fd0e5a768" }, "noice.nvim": { "branch": "main", "commit": "03c6a75661e68012e30b0ed81f050358b1e2233c" }, "nui.nvim": { "branch": "main", "commit": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733" }, "nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" }, @@ -42,7 +45,7 @@ "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-scrollview": { "branch": "main", "commit": "06563ae0c9928a2df42aefe66f2aed2f2943e32e" }, "nvim-tree.lua": { "branch": "master", "commit": "2086e564c4d23fea714e8a6d63b881e551af2f41" }, - "nvim-treesitter": { "branch": "master", "commit": "984604288d56265d7cfc443fa9dc9f67ec19d60d" }, + "nvim-treesitter": { "branch": "master", "commit": "cf7baac35aa5c103b960bcb3f15c690a4aa5c6f1" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, "nvim-ts-autotag": { "branch": "main", "commit": "ddfccbf0df1b9349c2b9e9b17f4afa8f9b6c1ed1" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" }, diff --git a/lua/custom/default.lua b/lua/custom/default.lua index d6e5c71..4ea9586 100644 --- a/lua/custom/default.lua +++ b/lua/custom/default.lua @@ -45,7 +45,7 @@ pcode.format_timeout_ms = 5000 -- https://github.com/mfussenegger/nvim-lint -- https://github.com/stevearc/conform.nvim -- use conform and nvim-lint if set true -pcode.disable_null_ls = false +pcode.disable_null_ls = true pcode.treesitter_ensure_installed = {} pcode.tscontext = false @@ -70,7 +70,7 @@ pcode.mason_ensure_installed = { -- sebelumnya register_lsp -- tambahkan di bawah sini setelah melakukan :masoninstall } pcode.unregister_lsp = { - -- "jdtls", -- tambahkan di bawah ini + "jdtls", -- tambahkan di bawah ini } -- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md @@ -172,6 +172,6 @@ pcode.active_golang_config = false pcode.active_python_config = false pcode.active_cpp_config = false pcode.active_java_config = { - active = false, + active = true, project = "gradle", -- gradle or maven } diff --git a/lua/plugins/lsp.lua b/lua/plugins/_lsp.lua similarity index 98% rename from lua/plugins/lsp.lua rename to lua/plugins/_lsp.lua index cfcf790..a1fa120 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/_lsp.lua @@ -1,11 +1,11 @@ return { { "williamboman/mason-lspconfig.nvim", + event = "VeryLazy", dependencies = { { "neovim/nvim-lspconfig", lazy = true, - event = "BufRead", cmd = { "LspInfo", "LspInstall", @@ -62,7 +62,6 @@ return { end, }, }, - event = "BufReadPre", opts = function() local servers = { "lua_ls" } local mason_install = pcode.mason_ensure_installed or {} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/_treesitter.lua similarity index 100% rename from lua/plugins/treesitter.lua rename to lua/plugins/_treesitter.lua diff --git a/lua/plugins/treesitter_blade.lua b/lua/plugins/_treesitter_blade.lua similarity index 82% rename from lua/plugins/treesitter_blade.lua rename to lua/plugins/_treesitter_blade.lua index 1026804..e44d2e1 100644 --- a/lua/plugins/treesitter_blade.lua +++ b/lua/plugins/_treesitter_blade.lua @@ -9,9 +9,10 @@ end return { { "nvim-treesitter/nvim-treesitter", - opts = { - ensure_installed = ts_list, - }, + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, ts_list) + end, config = function(_, opts) local parser_config = require("nvim-treesitter.parsers").get_parser_configs() diff --git a/lua/plugins/java.lua b/lua/plugins/java.lua index 56b375d..f1c1fa8 100644 --- a/lua/plugins/java.lua +++ b/lua/plugins/java.lua @@ -4,6 +4,29 @@ if pcode.active_java_config.active then -- { -- "mfussenegger/nvim-jdtls", -- }, + { + "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", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "jdtls" }) + end, + }, + { + "stevearc/conform.nvim", + event = "VeryLazy", + opts = function(_, opts) + local package="google-java-format" + require("user.utils.mason").try_install(package) + opts.formatters_by_ft.java = { package } + end, + }, { "nvim-neotest/neotest", dependencies = { diff --git a/lua/plugins/nonels.lua b/lua/plugins/nonels.lua index c700a78..3ef6473 100644 --- a/lua/plugins/nonels.lua +++ b/lua/plugins/nonels.lua @@ -6,6 +6,7 @@ return { dependencies = { { "jayp0521/mason-null-ls.nvim", + event = "VeryLazy", opts = { ensure_installed = pcode.null_ls_ensure_installed or {}, automatic_setup = true, diff --git a/lua/plugins/themes/_globalvar.lua b/lua/plugins/themes/_globalvar.lua index be69a19..c5bed85 100644 --- a/lua/plugins/themes/_globalvar.lua +++ b/lua/plugins/themes/_globalvar.lua @@ -110,11 +110,11 @@ if pcode.active_cpp_config then pcode.nvim_dap = true end -- run if java config true -if pcode.active_java_config.active then - table.insert(pcode.treesitter_ensure_installed, "java") - table.insert(pcode.mason_ensure_installed, "jdtls") - table.insert(pcode.null_ls_ensure_installed, "google_java_format") - -- table.insert(pcode.dap_ensure_installed, "javadbg") - -- table.insert(pcode.unregister_lsp, "jdtls") -end +-- if pcode.active_java_config.active then +-- table.insert(pcode.treesitter_ensure_installed, "java") +-- table.insert(pcode.mason_ensure_installed, "jdtls") +-- table.insert(pcode.null_ls_ensure_installed, "google_java_format") +-- table.insert(pcode.dap_ensure_installed, "javadbg") +-- table.insert(pcode.unregister_lsp, "jdtls") +-- end return {} diff --git a/lua/user/utils/mason.lua b/lua/user/utils/mason.lua new file mode 100644 index 0000000..7ff3f7b --- /dev/null +++ b/lua/user/utils/mason.lua @@ -0,0 +1,56 @@ +local registry = require("mason-registry") + +local M = {} + +local function resolve_package(mason_package_name) + local Optional = require("mason-core.optional") + + local ok, pkg = pcall(registry.get_package, mason_package_name) + if ok then + return Optional.of_nilable(pkg) + end +end + +local function install_package(pkg, version) + local linter_name = pkg.name + + vim.notify(("[mason-conform] installing %s"):format(linter_name)) + + return pkg:install({ version = version }):once( + "closed", + vim.schedule_wrap(function() + if pkg:is_installed() then + vim.notify(("[mason-conform] %s was successfully installed"):format(linter_name)) + else + vim.notify( + ("[mason-conform] failed to install %s. Installation logs are available in :Mason and :MasonLog"):format( + linter_name + ), + vim.log.levels.ERROR + ) + end + end) + ) +end + +function M.try_install(mason_package_name) + local Package = require("mason-core.package") + local package_name, version = Package.Parse(mason_package_name) + + resolve_package(package_name) + :if_present(function(pkg) + if not pkg:is_installed() then + install_package(pkg, version) + end + end) + :if_not_present(function() + vim.notify( + ("[mason-conform] Formatter %q is not a valid entry in ensure_installed. Make sure to only provide valid formatter names."):format( + package_name + ), + vim.log.levels.WARN + ) + end) +end + +return M