Migrate to lsp-zero 3.x branch

This commit is contained in:
CronyAkatsuki 2023-12-24 14:19:45 +01:00
parent 3dbf7b8ed4
commit 5f44b663e3
3 changed files with 47 additions and 19 deletions

15
.luarc.json Normal file
View File

@ -0,0 +1,15 @@
{
"runtime.version": "LuaJIT",
"runtime.path": [
"lua/?.lua",
"lua/?/init.lua"
],
"diagnostics.globals": [
"vim"
],
"workspace.checkThirdParty": false,
"workspace.library": [
"$VIMRUNTIME",
"./lua"
]
}

View File

@ -2,27 +2,30 @@ local lsp = require("lsp-zero")
lsp.preset("recommended") lsp.preset("recommended")
lsp.ensure_installed({ lsp.extend_cmp()
'lua_ls',
})
-- Fix Undefined global 'vim'
lsp.nvim_workspace()
local cmp = require('cmp') local cmp = require('cmp')
local cmp_select = { behavior = cmp.SelectBehavior.Select } local cmp_select = { behavior = cmp.SelectBehavior.Select }
local cmp_mappings = lsp.defaults.cmp_mappings({
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select), cmp.setup({
['<C-n>'] = cmp.mapping.select_next_item(cmp_select), window = {
['<C-y>'] = cmp.mapping.confirm({ select = true }), completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-k>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-j>'] = cmp.mapping.select_next_item(cmp_select),
['<C-l>'] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping.complete(),
}) ['<Tab>'] = nil,
['<S-Tab>'] = nil,
cmp_mappings['<Tab>'] = nil }),
cmp_mappings['<S-Tab>'] = nil sources = {
{ name = 'nvim_lsp' },
lsp.setup_nvim_cmp({ { name = 'buffer' },
mapping = cmp_mappings { name = 'path' },
{ name = 'nvim_lua' },
{ name = 'luasnip' },
}
}) })
lsp.set_preferences({ lsp.set_preferences({
@ -35,6 +38,8 @@ lsp.set_preferences({
} }
}) })
lsp.extend_lspconfig()
lsp.on_attach(function(client, bufnr) lsp.on_attach(function(client, bufnr)
local opts = { buffer = bufnr, remap = false } local opts = { buffer = bufnr, remap = false }
@ -55,3 +60,11 @@ lsp.setup()
vim.diagnostic.config({ vim.diagnostic.config({
virtual_text = true virtual_text = true
}) })
require("mason").setup({})
require("mason-lspconfig").setup({
ensure_installed = { 'lua_ls' },
handlers = {
lsp.default_setup,
}
})

View File

@ -19,7 +19,7 @@ require('lazy').setup({
{ {
'VonHeikemen/lsp-zero.nvim', 'VonHeikemen/lsp-zero.nvim',
branch = 'v1.x', branch = 'v3.x',
dependencies = { dependencies = {
-- LSP Support -- LSP Support
{ 'neovim/nvim-lspconfig' }, { 'neovim/nvim-lspconfig' },