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

Commit

Permalink
demo: migrate to new way of setting up LSP servers
Browse files Browse the repository at this point in the history
  • Loading branch information
williamboman committed Apr 30, 2022
1 parent aae1c38 commit 2bb6bb8
Showing 1 changed file with 24 additions and 29 deletions.
53 changes: 24 additions & 29 deletions a.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
local lsp_installer = require("nvim-lsp-installer")

lsp_installer.settings {
require("nvim-lsp-installer").setup {
ui = {
icons = {
server_installed = "",
Expand All @@ -9,40 +7,37 @@ lsp_installer.settings {
},
},
}
local lspconfig = require("lspconfig")

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

lsp_installer.on_server_ready(function (server)
local opts = {
on_attach = on_attach
}
local rust_tools = require("rust-tools")
rust_tools.setup {
server = { on_attach = on_attach }
}

if server.name == "rust_analyzer" then
require("rust-tools").setup {
server = vim.tbl_deep_extend("force", server:get_default_options(), opts),
}
server:attach_buffers()
return
local tsutils = require "nvim-lsp-ts-utils"
lspconfig.tsserver.setup {
init_options = { hostInfo = "neovim" },
on_attach = function (client, bufnr)
tsutils.setup {}
tsutils.setup_client(client)
end
}

if server.name == "tsserver" then
local tsutils = require "nvim-lsp-ts-utils"
opts.init_options = { hostInfo = "neovim" }
opts.on_attach = function (client, bufnr)
tsutils.setup {}
tsutils.setup_client(client)
end
elseif server.name == "sumneko_lua" then
opts.settings = {
Lua = {
diagnostics = {
globals = { "vim" }
}
lspconfig.sumneko_lua.setup {
on_attach = on_attach,
settings = {
Lua = {
diagnostics = {
globals = { "vim" }
}
}
end
}
}

server:setup(opts)
end)
lspconfig.graphql.setup { on_attach = on_attach }
lspconfig.jsonls.setup { on_attach = on_attach }
lspconfig.cssls.setup { on_attach = on_attach }

0 comments on commit 2bb6bb8

Please sign in to comment.