/
setup.lua
88 lines (74 loc) · 2.87 KB
/
setup.lua
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
-- Setup installer & lsp configs
require("nvim-lsp-installer").setup {
-- A list of servers to automatically install if they're not already installed
ensure_installed = { "bashls", "cssls", "eslint", "graphql", "html", "jsonls", "sumneko_lua", "tailwindcss", "tsserver", "vetur", "vuels" },
-- Whether servers that are set up (via lspconfig) should be automatically installed if they're not already installed
automatic_installation = true,
}
local lspconfig = require("lspconfig")
local handlers = {
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = EcoVim.ui.float.border }),
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = EcoVim.ui.float.border }),
}
local function on_attach(client, bufnr)
-- set up buffer keymaps, etc.
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
local cmp_nvim_lsp_ok, cmp_nvim_lsp = pcall(require, 'cmp_nvim_lsp')
if cmp_nvim_lsp_ok then
capabilities = cmp_nvim_lsp.update_capabilities(vim.lsp.protocol.make_client_capabilities())
end
-- Order matters
-- It enables tsserver automatically so no need to call lspconfig.tsserver.setup
local typescript_ok, typescript = pcall(require, 'typescript')
if typescript_ok then
typescript.setup({
disable_commands = false, -- prevent the plugin from creating Vim commands
disable_formatting = false, -- disable tsserver's formatting capabilities
debug = false, -- enable debug logging for commands
-- LSP Config options
server = {
capabilities = require('lsp.servers.tsserver').capabilities,
handlers = handlers,
on_attach = require('lsp.servers.tsserver').on_attach,
}
})
end
lspconfig.tailwindcss.setup {
capabilities = require('lsp.servers.tsserver').capabilities,
filetypes = require('lsp.servers.tailwindcss').filetypes,
handlers = handlers,
init_options = require('lsp.servers.tailwindcss').init_options,
on_attach = require('lsp.servers.tailwindcss').on_attach,
settings = require('lsp.servers.tailwindcss').settings,
}
lspconfig.eslint.setup {
capabilities = capabilities,
handlers = handlers,
on_attach = require('lsp.servers.eslint').on_attach,
settings = require('lsp.servers.eslint').settings,
}
lspconfig.jsonls.setup {
capabilities = capabilities,
handlers = handlers,
on_attach = on_attach,
settings = require('lsp.servers.jsonls').settings,
}
lspconfig.sumneko_lua.setup {
handlers = handlers,
on_attach = on_attach,
settings = require('lsp.servers.sumneko_lua').settings,
}
lspconfig.vuels.setup {
filetypes = require('lsp.servers.vuels').filetypes,
handlers = handlers,
init_options = require('lsp.servers.vuels').init_options,
on_attach = on_attach,
}
for _, server in ipairs { "bashls", "cssls", "graphql", "html", "volar" } do
lspconfig[server].setup {
on_attach = on_attach,
capabilities = capabilities,
handlers = handlers,
}
end