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

demo: migrate to new way of setting up LSP servers #635

Draft
wants to merge 1 commit into
base: demo/old-setup
Choose a base branch
from

Conversation

williamboman
Copy link
Owner

@williamboman williamboman commented Apr 28, 2022

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

@vuki656
Copy link

vuki656 commented Apr 28, 2022

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

@mjlbach
Copy link

mjlbach commented Apr 28, 2022

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.

@VonHeikemen
Copy link

The function .get_installed_servers() will still be supported in the future?

@williamboman
Copy link
Owner Author

The function .get_installed_servers() will still be supported in the future?

That function will remain!

@bennypowers
Copy link

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

@williamboman
Copy link
Owner Author

williamboman commented Apr 29, 2022

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants