aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/nvim/.config/nvim/lua/tobyvin/lsp/configs.lua
blob: 7ca8b0006156db8b5a3eb0635f9e68a821ab054e (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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
local M = {
	bashls = {
		settings = {
			bashIde = {
				explainshellEndpoint = "https://explainshell.com",
				includeAllWorkspaceSymbols = true,
				shellcheckArguments = {
					string.format("--source-path=%s", vim.loop.cwd()),
				},
			},
		},
	},
	clangd = {},
	cssls = {},
	cssmodules_ls = {},
	dockerls = {},
	gopls = {
		cmd = {
			"gopls",
			"serve",
		},
		settings = {
			gopls = {
				analyses = {
					unusedparams = true,
				},
				staticcheck = true,
			},
		},
	},
	html = {
		init_options = {
			provideFormatter = false,
		},
		filetypes = {
			"html",
			"htmldjango",
		},
	},
	jsonls = {
		settings = {
			json = {
				format = {
					enable = true,
				},
				validate = {
					enable = true,
				},
			},
		},
	},
	lua_ls = {
		settings = {
			Lua = {
				workspace = {
					checkThirdParty = false,
				},
				completion = {
					callSnippet = "Replace",
				},
				diagnostics = {
					globals = {
						"vim",
					},
				},
				format = {
					enable = false,
				},
			},
		},
	},
	omnisharp = {
		-- cmd = { "dotnet", "/home/tobyv/.local/share/nvim/mason/packages/omnisharp/OmniSharp.dll" },
		cmd = { "omnisharp", "--languageserver", "--hostPID", tostring(vim.fn.getpid()) },
		on_attach = function(client)
			-- HACK: https://github.com/OmniSharp/omnisharp-roslyn/issues/2483
			local tokenModifiers = client.server_capabilities.semanticTokensProvider.legend.tokenModifiers
			for i, v in ipairs(tokenModifiers) do
				tokenModifiers[i] = v:gsub(" ", "_"):gsub("-_", "")
			end

			local tokenTypes = client.server_capabilities.semanticTokensProvider.legend.tokenTypes
			for i, v in ipairs(tokenTypes) do
				tokenTypes[i] = v:gsub(" ", "_"):gsub("-_", "")
			end
		end,
	},
	perlnavigator = {
		settings = {
			perlnavigator = {
				enableWarnings = false,
			},
		},
	},
	powershell_es = {},
	pylsp = {},
	rust_analyzer = {
		root_dir = function(fname)
			local util = require("lspconfig.util")

			local cargo_home = os.getenv("CARGO_HOME") or util.path.join(vim.env.HOME, ".cargo")
			local registry = util.path.join(cargo_home, "registry", "src")

			local rustup_home = os.getenv("RUSTUP_HOME") or util.path.join(vim.env.HOME, ".rustup")
			local toolchains = util.path.join(rustup_home, "toolchains")

			for _, item in ipairs({ toolchains, registry }) do
				if fname:sub(1, #item) == item then
					local clients = vim.lsp.get_active_clients({ name = "rust_analyzer" })
					return clients[#clients].config.root_dir
				end
			end

			return require("lspconfig.server_configurations.rust_analyzer").default_config.root_dir(fname)
		end,
		handlers = {
			["experimental/externalDocs"] = function(err, result)
				if result then
					vim.fn["netrw#BrowseX"](result, 0)
				end
				return result, err
			end,
		},
		standalone = true,
		settings = {
			["rust-analyzer"] = {
				cargo = {
					features = "all",
					buildScripts = {
						enable = true,
					},
				},
				check = {
					command = "clippy",
				},
				completion = {
					postfix = {
						enable = false,
					},
				},
				imports = {
					granularity = {
						enforce = true,
					},
				},
				procMacro = {
					enable = true,
					ignored = {
						["tracing-attributes"] = {
							"instrument",
						},
					},
				},
			},
		},
	},
	taplo = {},
	texlab = {
		settings = {
			texlab = {
				build = {
					args = {
						"-interaction=nonstopmode",
						"-synctex=1",
						"%f",
					},
					onSave = true,
				},
				forwardSearch = {
					executable = "zathura",
					args = {
						"--synctex-editor-command",
						[[nvim-texlabconfig -file '%{input}' -line %{line}]],
						"--synctex-forward",
						"%l:1:%f",
						"%p",
					},
				},
				chktex = {
					onEdit = true,
					onOpenAndSave = true,
				},
				latexindent = {
					["local"] = string.format("%s/latexindent/indentconfig.yaml", vim.env.XDG_CONFIG_HOME),
					modifyLineBreaks = true,
				},
			},
		},
		on_attach = function(_, bufnr)
			vim.b[bufnr].tex_flavor = "latex"
			vim.wo.spell = true

			local preview_autocmd
			local augroup = vim.api.nvim_create_augroup("texlab", {})

			vim.api.nvim_create_user_command("TexlabPreview", function()
				preview_autocmd = vim.api.nvim_create_autocmd("CursorMoved", {
					group = augroup,
					command = "TexlabForward",
				})

				vim.cmd.TexlabForward()
			end, { desc = "Texlab preview start" })

			vim.api.nvim_create_user_command("TexlabPreviewStop", function()
				if preview_autocmd then
					vim.api.nvim_del_autocmd(preview_autocmd)
				end
			end, { desc = "Texlab preview stop" })
		end,
	},
	tsserver = {},
	yamlls = {
		settings = {
			yaml = {
				keyOrdering = false,
			},
		},
	},
}

return M