nvim-lsp-installer
nvim-lsp-installer copied to clipboard
demo: migrate to new way of setting up LSP servers
This is a demo of how a migration to the new setup structure could look like. This example will set up the following servers:
- sumneko_lua
- tsserver (+ integrate with nvim-lsp-ts-utils)
- graphql
- jsonls
- cssls
Just a heads up for anyone still using nvim-lsp-ts-utils: it has been put into maintenance mode and the replacement is typescript.nvim
Feel free to update https://github.com/neovim/nvim-lspconfig/wiki/Installing-language-servers#automatically, I just threw some stuff down. Thanks, these changes are great.
The function .get_installed_servers()
will still be supported in the future?
The function
.get_installed_servers()
will still be supported in the future?
That function will remain!
The function
.get_installed_servers()
will still be supported in the future?That function will remain!
Does that include server:on_ready(function() ... end)
as in:
local servers = {
['tsserver'] = {
on_attach = function() ... end,
root_dir = ...,
settings = ...
},
}
-- Loop through the servers listed above.
-- installing each, then if install succeeded,
-- setup the server with the options specified in server_opts,
-- or just use the default options
--
for name, opts in ipairs(servers) do
opts = opts or {}
opts.on_attach = opts.on_attach or default_on_attach
local available, server = lsp_installer_servers.get_server(name)
if available then
server:on_ready(function ()
server:setup(opts)
end)
-- Queue the server to be installed.
if not server:is_installed() then
server:install()
end
end
end
Does that include
server:on_ready(function() ... end)
as in:
The on_ready()
function is deprecated as well! Note that you can now remove that snippet of code in your example that loops through your desired server and replace it with the new ensure_installed
feature:
require("nvim-lsp-installer").setup {
ensure_installed = { "tsserver", "graphql" }
}
Once #638 lands you can also configure nvim-lsp-installer to automatically do this for every server that you set up.