summaryrefslogtreecommitdiff
path: root/lua/bee/LSPs/init.lua
blob: 3bc86a51d079c9b21d951dd1bf268929e4006b08 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
local MP = ...
local get_nixd_opts = nixInfo(nil, "info", "nixdExtras", "get_configs")
return {
	{
		"mason.nvim",
		auto_enable = true,
		priority = 55,
		on_plugin = { "nvim-lspconfig" },
		lsp = function(plugin)
			vim.cmd.MasonInstall(plugin.name)
		end,
	},
	{
		"nvim-lspconfig",
		auto_enable = true,
		priority = 50,
		lsp = function(plugin)
			vim.lsp.config(plugin.name, plugin.lsp or {})
			vim.lsp.enable(plugin.name)
		end,
		before = function(_)
			vim.lsp.config("*", {
				on_attach = require(MP:relpath("on_attach")),
			})
		end,
	},
	{
		"lua_ls",
		for_cat = "lua",
		lsp = {
			filetypes = { "lua" },
			settings = {
				Lua = {
					runtime = { version = "LuaJIT" },
					formatters = {
						ignoreComments = true,
					},
					signatureHelp = { enabled = true },
					diagnostics = {
						globals = { "vim", "make_test" },
						disable = {},
					},
					workspace = {
						checkThirdParty = false,
						library = {
							-- '${3rd}/luv/library',
							-- unpack(vim.api.nvim_get_runtime_file('', true)),
						},
					},
					completion = {
						callSnippet = "Replace",
					},
					telemetry = { enabled = false },
				},
			},
		},
	},
	{
		"nixd",
		for_cat = "nix",
		after = function(_)
			vim.api.nvim_create_user_command("StartNilLSP", function()
				vim.lsp.start(vim.lsp.config.nil_ls)
			end, { desc = "Run nil-ls (when you really need docs for the builtins and nixd refuse)" })
		end,
		lsp = {
			filetypes = { "nix" },
			settings = {
				nixd = {
					nixpkgs = {
						expr = nixInfo("import <nixpkgs> {}", "info", "nixdExtras", "nixpkgs"),
					},
					formatting = {
						command = { "nixfmt" },
					},
					options = {
						-- (builtins.getFlake "path:${builtins.toString <path_to_system_flake>}").legacyPackages.<system>.nixosConfigurations."<user@host>".options
						nixos = {
							expr = get_nixd_opts
								and get_nixd_opts("nixos", nixInfo(nil, "info", "nixdExtras", "flake-path")),
						},
						-- (builtins.getFlake "path:${builtins.toString <path_to_system_flake>}").legacyPackages.<system>.homeConfigurations."<user@host>".options
						["home-manager"] = {
							expr = get_nixd_opts
								and get_nixd_opts("home-manager", nixInfo(nil, "info", "nixdExtras", "flake-path")), -- <-  if flake-path is nil it will be lsp root dir
						},
					},
					diagnostic = {
						suppress = {
							"sema-escaping-with",
						},
					},
				},
			},
		},
	},
	{
		"clangd",
		for_cat = "C",
		lsp = {
			filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto" },
			on_attach = function(client, bufnr)
				require(MP:relpath("on_attach"))(client, bufnr)
				-- the stuff they were adding that was overriding my on_attach
				dofile(nixInfo.utils.get_nix_plugin_path("nvim-lspconfig") .. "/lsp/clangd.lua").on_attach(
					client,
					bufnr
				)
			end,
			-- unneded thanks to clangd_extensions-nvim I think
			-- settings = {
			--   clangd_config = {
			--     init_options = {
			--       compilationDatabasePath="./build",
			--     },
			--   }
			-- }
		},
	},
	{
		"gopls",
		for_cat = "go",
		lsp = {
			filetypes = { "go", "gomod", "gowork", "gotmpl", "templ" },
		},
	},
	{
		"zls",
		for_cat = "zig",
		lsp = {
			filetypes = { "zig", "zir" },
		},
	},
	{
		"rust_analyzer",
		for_cat = "rust",
		lsp = {
			filetypes = { "rust" },
		},
	},
	{
		"bashls",
		for_cat = "bash",
		lsp = {
			filetypes = { "bash", "sh" },
		},
	},
}