61 lines
1.5 KiB
Lua
61 lines
1.5 KiB
Lua
local lsp = require('lsp-zero').preset({
|
|
manage_nvim_cmp = {
|
|
set_sources = 'recommended',
|
|
}
|
|
})
|
|
local cmp = require('cmp');
|
|
|
|
-- Set the lsp autocomplete to put text from selection into the buffer.
|
|
--
|
|
-- This setup_nvim_cmp function is deprecated, though this seems to be
|
|
-- the cleanest solution as of lsp-zero v2.x. A fallback solution is
|
|
-- commented out below.
|
|
lsp.setup_nvim_cmp({
|
|
select_behavior = cmp.SelectBehavior.Insert
|
|
})
|
|
|
|
vim.diagnostic.config({
|
|
virtual_text = true
|
|
})
|
|
|
|
lsp.on_attach(function(client, bufnr)
|
|
lsp.default_keymaps({buffer = bufnr})
|
|
-- Set tagfunc back to empty instead of vim.lsp.tagfunc(),
|
|
-- to use default tag jumping behaviour withouth going through the lsp.
|
|
-- - see https://neovim.io/doc/user/lsp.html
|
|
vim.opt.tagfunc = ""
|
|
end)
|
|
|
|
-- (Optional) Configure lua language server for neovim
|
|
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
|
|
|
|
-- lsp.skip_server_setup({'ltex'})
|
|
|
|
lsp.setup()
|
|
|
|
-- Below commented code is a fallback for when the setup_nvim_cmp()
|
|
-- is gone
|
|
--
|
|
-- This is adapted from the defaults provided by lsp-zero
|
|
-- - see https://github.com/VonHeikemen/lsp-zero.nvim/blob/v2.x/lua/lsp-zero/cmp.lua
|
|
--
|
|
--local select_opts = { behavior = cmp.SelectBehavior.Insert }
|
|
--cmp.setup({
|
|
-- mapping = {
|
|
-- ['<C-p>'] = cmp.mapping(function()
|
|
-- if cmp.visible() then
|
|
-- cmp.select_prev_item(select_opts)
|
|
-- else
|
|
-- cmp.complete()
|
|
-- end
|
|
-- end),
|
|
-- ['<C-n>'] = cmp.mapping(function()
|
|
-- if cmp.visible() then
|
|
-- cmp.select_next_item(select_opts)
|
|
-- else
|
|
-- cmp.complete()
|
|
-- end
|
|
-- end),
|
|
-- }
|
|
--})
|