aboutsummaryrefslogtreecommitdiff
path: root/lua/user/lsp/mason.lua
blob: 84259349c5668154f7eb0a8f66c24d5eed96ec52 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
local mason_status, mason = pcall(require, "mason")
if not mason_status then
	print("lsp/mason.lua: loading mason failed")
	return
end

local mason_lspconfig_status, mason_lspconfig = pcall(require, "mason-lspconfig")
if not mason_lspconfig_status then
	print("lsp/mason.lua: loading mason-lspconfig failed")
	return
end

local lspconfig_status, lspconfig = pcall(require, "lspconfig")
if not lspconfig_status then
	print("lsp/mason.lua: loading lspconfig failed")
	return
end

local mason_null_ls_status, mason_null_ls = pcall(require, "mason-null-ls")
if not mason_null_ls_status then
	print("lsp/mason.lua: loading mason-null-ls failed")
	return
end

local null_ls_status, null_ls = pcall(require, "null-ls")
if not null_ls_status then
	print("lsp/mason.lua: loading null-ls failed")
	return
end


local settings = {
	ui = {
		border = "none",
		icons = {
			package_installed = "◍",
			package_pending = "◍",
			package_uninstalled = "◍",
		},
	},
	log_level = vim.log.levels.INFO,
	max_concurrent_installers = 4,
}

local servers = {
	"pylsp", "bashls", "lua_ls", "cmake"
}


-- mason
mason.setup(settings)

-- mason-lspconfig
mason_lspconfig.setup({
	ensure_installed = servers,
	automatic_installation = true,
})

table.insert(servers, "ccls")
mason_lspconfig.setup_handlers {
	function(server_name)
		lspconfig[server_name].setup {
			on_attach = require("user.lsp.handlers").on_attach,
			capabilities = require("user.lsp.handlers").capabilities,
		}
	end,
}

-- mason-null-ls
mason_null_ls.setup({
	automatic_setup = true,
	ensure_installed = {},
})
mason_null_ls.setup_handlers {
	function(source_name, methods)
		require("mason-null-ls.automatic_setup")(source_name, methods)
	end,
}

-- null_ls
null_ls.setup()