Skip to content
This repository was archived by the owner on Nov 12, 2022. It is now read-only.

Commit 2bb6bb8

Browse files
committed
demo: migrate to new way of setting up LSP servers
1 parent aae1c38 commit 2bb6bb8

File tree

1 file changed

+24
-29
lines changed

1 file changed

+24
-29
lines changed

a.lua

+24-29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
local lsp_installer = require("nvim-lsp-installer")
2-
3-
lsp_installer.settings {
1+
require("nvim-lsp-installer").setup {
42
ui = {
53
icons = {
64
server_installed = "",
@@ -9,40 +7,37 @@ lsp_installer.settings {
97
},
108
},
119
}
10+
local lspconfig = require("lspconfig")
1211

1312
local function on_attach(client, bufnr)
1413
-- set up buffer keymaps, etc.
1514
end
1615

17-
lsp_installer.on_server_ready(function (server)
18-
local opts = {
19-
on_attach = on_attach
20-
}
16+
local rust_tools = require("rust-tools")
17+
rust_tools.setup {
18+
server = { on_attach = on_attach }
19+
}
2120

22-
if server.name == "rust_analyzer" then
23-
require("rust-tools").setup {
24-
server = vim.tbl_deep_extend("force", server:get_default_options(), opts),
25-
}
26-
server:attach_buffers()
27-
return
21+
local tsutils = require "nvim-lsp-ts-utils"
22+
lspconfig.tsserver.setup {
23+
init_options = { hostInfo = "neovim" },
24+
on_attach = function (client, bufnr)
25+
tsutils.setup {}
26+
tsutils.setup_client(client)
2827
end
28+
}
2929

30-
if server.name == "tsserver" then
31-
local tsutils = require "nvim-lsp-ts-utils"
32-
opts.init_options = { hostInfo = "neovim" }
33-
opts.on_attach = function (client, bufnr)
34-
tsutils.setup {}
35-
tsutils.setup_client(client)
36-
end
37-
elseif server.name == "sumneko_lua" then
38-
opts.settings = {
39-
Lua = {
40-
diagnostics = {
41-
globals = { "vim" }
42-
}
30+
lspconfig.sumneko_lua.setup {
31+
on_attach = on_attach,
32+
settings = {
33+
Lua = {
34+
diagnostics = {
35+
globals = { "vim" }
4336
}
4437
}
45-
end
38+
}
39+
}
4640

47-
server:setup(opts)
48-
end)
41+
lspconfig.graphql.setup { on_attach = on_attach }
42+
lspconfig.jsonls.setup { on_attach = on_attach }
43+
lspconfig.cssls.setup { on_attach = on_attach }

0 commit comments

Comments
 (0)