aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/nvim/.config/nvim/lua/tobyvin/plugins/mason-lspconfig.lua
blob: e0b4ab632610d5c2620b1c9520dbef29ff585728 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
local M = {}

M.setup = function()
	local status_ok, mason_lspconfig = pcall(require, "mason-lspconfig")
	if not status_ok then
		vim.notify("Failed to load module 'mason-lspconfig'", vim.log.levels.ERROR)
		return
	end

	mason_lspconfig.setup()

	vim.api.nvim_create_autocmd("LspAttach", {
		callback = function(args)
			local client = vim.lsp.get_client_by_id(args.data.client_id)
			if client.name == "null-ls" then
				return
			end
			local bufnr = args.buf
			vim.keymap.set("n", "<leader>lI", "<CMD>LspInstall<CR>", { desc = "LSP Install", buffer = bufnr })
		end,
	})
end

return M