Merge pull request 'remove mason' (#27) from remove-mason into main

Reviewed-on: #27
This commit is contained in:
Salar Rahmanian 2024-09-07 11:12:35 -07:00
commit b25a90efbc

View file

@ -1,10 +1,6 @@
return { return {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
dependencies = { dependencies = {
-- Automatically install LSPs to stdpath for neovim
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
-- Useful status updates for LSP -- Useful status updates for LSP
"j-hui/fidget.nvim", "j-hui/fidget.nvim",
@ -13,6 +9,8 @@ return {
}, },
config = function() config = function()
-- LSP settings. -- LSP settings.
-- Require the lspconfig module
local lspconfig = require("lspconfig")
-- This function gets run when an LSP connects to a particular buffer. -- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(_, bufnr) local on_attach = function(_, bufnr)
-- NOTE: Remember that lua is a real programming language, and as such it is possible -- NOTE: Remember that lua is a real programming language, and as such it is possible
@ -101,30 +99,18 @@ return {
ts_ls = {}, ts_ls = {},
yamlls = {}, yamlls = {},
} }
--
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers -- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
-- Setup mason so it can manage external tooling -- Iterate over the servers table and configure each one
require("mason").setup() for server, config in pairs(servers) do
-- Set up the server using the `config` if provided, otherwise just `on_attach` and `capabilities`
-- Ensure the servers above are installed lspconfig[server].setup({
local mason_lspconfig = require("mason-lspconfig")
mason_lspconfig.setup({
ensure_installed = vim.tbl_keys(servers),
})
mason_lspconfig.setup_handlers({
function(server_name)
require("lspconfig")[server_name].setup({
capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
settings = servers[server_name], capabilities = capabilities,
}) settings = config, -- Pass the specific server settings here
end,
}) })
end
end, end,
} }