summaryrefslogtreecommitdiff
path: root/dot_config/nvim/lua/plugins/lsp/init.lua
blob: 01fb34ad4083ebff5cf1d97ed4a47091b9943f4a (plain) (blame)
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
local attach = require 'plugins.lsp.attach'
local caps   = require 'plugins.lsp.capabilities'

return {
	{
		'neovim/nvim-lspconfig',
		config = function(_, opts)
			for k, v in pairs(opts) do
				v.on_attach = v.on_attach or attach
				if type(caps) == 'table' then
					v.capabilities = v.capabilities or caps
				end
				local s = require 'lspconfig'[k]
				local c = v.cmd or s.document_config.default_config.cmd
				if vim.fn.executable(c[1]) ~= 0 then
					s.setup(v)
				end
			end
		end,
		opts = function()
			local plist = function(...)
				local p = require 'lspconfig.util'.root_pattern(...)
				return function(f) return p(f) end
			end
			return {
				clojure_lsp = {
					root_dir = plist('project.clj', 'deps.edn', 'bb.edn', 'build.boot', 'shadow-cljs.edn', '.git'),
				},
				denols = {
					root_dir = plist('deno.json', 'deno.jsonc'),
				},
				gopls = {},
				ltex  = {},
				lua_ls = {},
				tsserver = {
					root_dir = plist('tsconfig.json', 'package.json'),
				},
			}
		end
	},
}