Let's talk about v3.x #286
Replies: 8 comments 20 replies
-
The transition was easy for me. I think it's only important to communicate that BTW. Do we need any of:
Mentioned in the recommended setup from v2.x:
|
Beta Was this translation helpful? Give feedback.
-
When you want to configure a language using
require('mason-lspconfig').setup({
ensure_installed = {'tsserver', 'rust_analyzer'},
handlers = {
lsp.default_setup,
lua_ls = function()
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
end,
},
})
require('mason-lspconfig').setup({
ensure_installed = {'tsserver', 'rust_analyzer'},
handlers = {
lsp.default_setup,
lua_ls = lsp.noop,
},
})
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls()) I like that the first option enforces the order of functions. Also, you won't get an error if the server is not installed. But I don't like the extra nesting. The second options looks better, but then people would have to know the order in which to call each function. I would like to know which one is "new user friendly". |
Beta Was this translation helpful? Give feedback.
-
This is what primeagen's config would look like using local lsp_zero = require('lsp-zero')
lsp_zero.on_attach(function(client, bufnr)
local opts = {buffer = bufnr, remap = false}
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
end)
require('mason').setup({})
require('mason-lspconfig').setup({
ensure_installed = {'tsserver', 'rust_analyzer'},
handlers = {
lsp_zero.default_setup,
lua_ls = function()
local lua_opts = lsp_zero.nvim_lua_ls()
require('lspconfig').lua_ls.setup(lua_opts)
end,
}
})
local cmp = require('cmp')
cmp.setup({
sources = {
{name = 'path'},
{name = 'nvim_lsp'},
{name = 'nvim_lua'},
},
mapping = cmp.mapping.preset.insert({
['<C-Space>'] = cmp.mapping.complete(),
}),
}) |
Beta Was this translation helpful? Give feedback.
-
Just made the transition from v1 to dev-v3, and it went well (mind you, I'm not good at this). Though a little lost at first, the documentation helped a lot and now not only do I think my lsp setup is way more organized, I also feel that I understand how it works a lot better. I'm very grateful for all the guidance.
|
Beta Was this translation helpful? Give feedback.
-
Another one who migrated without any issues to dev-v3 here. |
Beta Was this translation helpful? Give feedback.
-
If anyone out there is using a debian based distro, which has Neovim v0.7 in the official repo, you can use the branch compat-07. That branch will have the same api as |
Beta Was this translation helpful? Give feedback.
-
@VonHeikemen, I'm trying to put together a minimal config including local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)
local plugins = {
{
"VonHeikemen/lsp-zero.nvim",
branch = "dev-v3",
dependencies = {
"neovim/nvim-lspconfig",
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
},
config = function()
local lsp = require("lsp-zero")
lsp.on_attach(function(client, bufnr)
lsp.default_keymaps({buffer = bufnr})
end)
require("mason").setup {}
require("mason-lspconfig").setup {
ensure_installed = { "clangd" },
handlers = { lsp.default_setup }
}
end
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
}) |
Beta Was this translation helpful? Give feedback.
-
The v3.x branch has been created. The default branch right now is still |
Beta Was this translation helpful? Give feedback.
-
The branch for v3.x has been created. I'm thinking on making
v3.x
the default branch onSeptember 20
, so there is plenty of time to discuss.v3.x
is the branch that will have all the breaking changes I didn't want to make inv2.x
(the ones listed in the Future Changes/Deprecation notice section).The "goal" for
v3.x
is to delete code and move away from the.setup()
function that does too many things.Biggest change here is that lsp-zero will not manage the setup for
mason.nvim
anymore. No more.ensure_installed()
function either. The ecosystem around mason.nvim is growing, and having a hidden setup in lsp-zero feels wrong. A duplicate setup of mason.nvim doesn't do any harm right now (I think), but that can change at any moment.Moving on to the configuration. This is the equivalent of the old recommended config.
If people don't install mason.nvim they can just list the servers using
.setup_servers()
.The setup with mason.nvim looks kind of scary, but hopefully people won't care. They will get the same features, and the snippet is still copy/paste friendly (it will work without modifications). I made a guide that explains how to use mason.nvim with lsp-zero, hopefully that covers all the details people should know.
If the user doesn't configure nvim-cmp, lsp-zero will provide the essential configuration for it to work.
Moving from
v2.x
should not be painful. People who use the.ensure_installed()
function will get this warning message.The help page will have the same info as the guide on how to use mason.nvim with lsp-zero. I'm actually thinking of adding a link too, I know people new to Neovim don't know how to use the help page.
And there are migration guides:
migrate from v1.x to v3.x
migrate from v2.x to v3.x
If you have any feedback about this new version, now is the time to say something.
Beta Was this translation helpful? Give feedback.
All reactions