Skip to content

fix(lsp): updated config for mason to v2 #1663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ktsierra
Copy link

This pull request updates the LSP configuration to align with the changes in mason-lspconfig.nvim v2.0.0.

The handlers feature has been removed from mason-lspconfig.nvim. The PR adapts to that change by iterating through the servers table and calling require('lspconfig')[server_name].setup(server_config) for each server. This approach maintains the use of the nvim-lspconfig API for server configuration.

This change simplifies the LSP configuration and ensures compatibility with the latest version of mason-lspconfig.nvim.

init.lua Outdated
@@ -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', opts = {} },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not only unnecessary, it causes mason-lspconfig to setup LSP's when other plugins might have been interested in doing that prior to it. For example, for nvim-java this causes two jdtls instances where the first one is setup by mason-lspconfig and prevents the second one which is properly steup from functioning properly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for letting me know, it was setting up luals twice as well. It should be fixed now.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for having done this job! It actually helped me with something else.

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
@evanlesmez
Copy link

evanlesmez commented Aug 1, 2025

This seems to do a similar thing as 1590 which already has some traction

@Ktsierra
Copy link
Author

Ktsierra commented Aug 1, 2025

This seems to do a similar thing as 1590 which already has some traction

There are a couple of similars pr, but 1590 and 1475 both swap to the new LSP built in API besides fixing mason, which is only availabe in version >0.11. I think is the same reason we still have blink and lazy instead of using vim.lsp and vim.pack.

@logrusx
Copy link

logrusx commented Aug 3, 2025

This seems to do a similar thing as 1590 which already has some traction

Traction does not mean quality.

There are a couple of similars pr, but 1590 and 1475 both swap to the new LSP built in API besides fixing mason, which is only availabe in version >0.11. I think is the same reason we still have blink and lazy instead of using vim.lsp and vim.pack.

I don't like them. Both state a different goal than they are achieving. Both are pushing their authors preferences.

On the other hand this one does exactly what it says and does it correctly.

SimoneCheng added a commit to SimoneCheng/kickstart.nvim that referenced this pull request Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants