From 5619b9ba57507c9db551bc9c139b17185bc58a2b Mon Sep 17 00:00:00 2001 From: s1n7ax Date: Tue, 2 Jul 2024 23:08:12 +0530 Subject: [PATCH 1/2] feat: add nvim-java --- init.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 88658ef3033..d49cc3d7a5f 100644 --- a/init.lua +++ b/init.lua @@ -415,6 +415,7 @@ require('lazy').setup({ { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', + 'nvim-java/nvim-java', -- Useful status updates for LSP. -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` @@ -620,6 +621,15 @@ require('lazy').setup({ server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) require('lspconfig')[server_name].setup(server) end, + jdtls = function() + require('java').setup { + -- Your custom jdtls settings goes here + } + + require('lspconfig').jdtls.setup { + -- Your custom nvim-java configuration goes here + } + end, }, } end, @@ -835,7 +845,7 @@ require('lazy').setup({ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc', 'java' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -873,7 +883,7 @@ require('lazy').setup({ -- Here are some example plugins that I've included in the Kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug', + require 'kickstart.plugins.debug', -- require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.lint', -- require 'kickstart.plugins.autopairs', From 44a6642366436d12a1613a9938f3ee010d734ef6 Mon Sep 17 00:00:00 2001 From: Ktsierra Date: Wed, 23 Jul 2025 14:19:11 -0400 Subject: [PATCH 2/2] fix(lsp): updated config for mason to v2 The mason-lspconfig.nvim plugin removed the 'handlers' feature in its v2.0.0 release. This change adapts the LSP configuration to follow the new recommended setup and keeps using the nvim-lspconfig api to configure the servers --- init.lua | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/init.lua b/init.lua index b98ffc6198a..ccffd9a3e64 100644 --- a/init.lua +++ b/init.lua @@ -483,7 +483,7 @@ require('lazy').setup({ -- Mason must be loaded before its dependents so we need to set it up here. -- NOTE: `opts = {}` is the same as calling `require('mason').setup({})` { 'mason-org/mason.nvim', opts = {} }, - 'mason-org/mason-lspconfig.nvim', + { 'mason-org/mason-lspconfig.nvim' }, 'WhoIsSethDaniel/mason-tool-installer.nvim', -- Useful status updates for LSP. @@ -700,6 +700,14 @@ require('lazy').setup({ }, } + -- The following loop will configure each server with the capabilities we defined above. + -- This will ensure that all servers have the same base configuration, but also + -- allow for server-specific overrides. + for server_name, server_config in pairs(servers) do + server_config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server_config.capabilities or {}) + require('lspconfig')[server_name].setup(server_config) + end + -- Ensure the servers and tools above are installed -- -- To check the current status of installed tools and/or manually install @@ -718,21 +726,6 @@ require('lazy').setup({ 'stylua', -- Used to format Lua code }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } - - require('mason-lspconfig').setup { - ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer) - automatic_installation = false, - handlers = { - function(server_name) - local server = servers[server_name] or {} - -- This handles overriding only values explicitly passed - -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for ts_ls) - server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, - } end, },