Update lsp-zero to branch 2.x
This commit is contained in:
parent
f75fd7c376
commit
e71e23ef5a
@ -1,14 +1,22 @@
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.shiftwidth = 4
|
||||
vim.opt.smartindent = true
|
||||
|
||||
vim.opt.wrap = false
|
||||
vim.opt.incsearch = true
|
||||
vim.opt.termguicolors = true
|
||||
vim.opt.scrolloff = 8
|
||||
|
||||
vim.opt.signcolumn = "yes"
|
||||
vim.opt.colorcolumn = "100"
|
||||
vim.opt.foldcolumn = "0"
|
||||
|
||||
vim.opt.foldlevel = 99
|
||||
vim.opt.foldlevelstart = 99
|
||||
vim.opt.foldenable = true
|
||||
|
||||
vim.api.nvim_create_autocmd({"InsertEnter", "InsertLeave", "BufEnter"}, {
|
||||
callback = function(args)
|
||||
|
@ -90,7 +90,7 @@ local function spec(use)
|
||||
|
||||
use {
|
||||
"VonHeikemen/lsp-zero.nvim",
|
||||
branch = "v1.x",
|
||||
branch = "v2.x",
|
||||
requires = {
|
||||
{ "neovim/nvim-lspconfig" },
|
||||
-- completion
|
||||
|
@ -1,52 +1,21 @@
|
||||
local lsp = require("lsp-zero")
|
||||
local lsp_zero = require("lsp-zero").preset({})
|
||||
local ufo = require("ufo")
|
||||
local tsb = require("telescope.builtin")
|
||||
|
||||
lsp.preset("recommended")
|
||||
|
||||
lsp.ensure_installed {
|
||||
lsp_zero.ensure_installed {
|
||||
"rust_analyzer"
|
||||
}
|
||||
|
||||
lsp.nvim_workspace()
|
||||
|
||||
local cmp = require("cmp")
|
||||
local cmp_select = { behavior = cmp.SelectBehavior.Select }
|
||||
local cmp_mapping = lsp.defaults.cmp_mappings({
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
|
||||
["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
})
|
||||
|
||||
-- Hitting tab should indent, not complete
|
||||
cmp_mapping["<Tab>"] = nil
|
||||
cmp_mapping["<S-Tab>"] = nil
|
||||
|
||||
lsp.setup_nvim_cmp({ mapping = cmp_mapping })
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<Leader>ci", vim.diagnostic.open_float, { desc = "Display diagnostic Code Info" })
|
||||
|
||||
-- Gimme pretty icons
|
||||
lsp.set_sign_icons({
|
||||
error = '✘',
|
||||
warn = '▲',
|
||||
hint = '⚑',
|
||||
info = '»'
|
||||
})
|
||||
|
||||
lsp.on_attach(function(_, buffnr)
|
||||
lsp_zero.on_attach(function(_, buffnr)
|
||||
local opts = { buffer = buffnr, remap = false }
|
||||
|
||||
ufo.attach(buffnr)
|
||||
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||
vim.keymap.set("n", "gd", tsb.lsp_definitions, opts)
|
||||
vim.keymap.set("n", "gr", tsb.lsp_references, opts)
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set("n", "<Leader>ca", vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set("n", "<Leader>ci", vim.diagnostic.open_float, opts)
|
||||
vim.keymap.set("n", "<Leader>re", vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set({ "n", "i" }, "<C-h>", vim.lsp.buf.signature_help, opts)
|
||||
|
||||
@ -57,29 +26,55 @@ end)
|
||||
|
||||
|
||||
-- NOTE: Format on save does not support async formatting
|
||||
lsp.format_on_save({
|
||||
lsp_zero.format_on_save({
|
||||
servers = {
|
||||
["rust_analyzer"] = { "rust" }
|
||||
}
|
||||
})
|
||||
|
||||
lsp.configure("rust_analyzer", {
|
||||
local lsp_config = require("lspconfig")
|
||||
|
||||
lsp_config.lua_ls.setup(lsp_zero.nvim_lua_ls())
|
||||
|
||||
lsp_config.rust_analyzer.setup {
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
rustfmt = {
|
||||
-- needs to use nightly channel to use unstable options
|
||||
extraArgs = { "+nightly" }
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
vim.opt.foldcolumn = "0"
|
||||
vim.opt.foldlevel = 99
|
||||
vim.opt.foldlevelstart = 99
|
||||
vim.opt.foldenable = true
|
||||
}
|
||||
|
||||
ufo.setup {
|
||||
close_fold_kinds = {"comment", "imports"},
|
||||
}
|
||||
|
||||
lsp.setup()
|
||||
lsp_zero.setup()
|
||||
|
||||
local cmp = require("cmp")
|
||||
|
||||
local cmp_select = { behavior = cmp.SelectBehavior.Select }
|
||||
cmp.setup {
|
||||
mapping = {
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
|
||||
["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<Tab>"] = nil,
|
||||
["<S-Tab>"] = nil,
|
||||
}
|
||||
}
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
})
|
||||
|
||||
-- Gimme pretty icons
|
||||
lsp_zero.set_sign_icons({
|
||||
error = '✘',
|
||||
warn = '▲',
|
||||
hint = '⚑',
|
||||
info = '»'
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user