2023-04-10 07:55:36 +08:00
|
|
|
local lsp = require('lsp-zero').preset({
|
|
|
|
manage_nvim_cmp = {
|
|
|
|
set_sources = 'recommended',
|
|
|
|
}
|
|
|
|
})
|
2023-04-08 08:37:35 +08:00
|
|
|
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
|
|
|
|
})
|
2023-04-06 05:57:40 +08:00
|
|
|
|
|
|
|
vim.diagnostic.config({
|
|
|
|
virtual_text = true
|
|
|
|
})
|
|
|
|
|
|
|
|
lsp.on_attach(function(client, bufnr)
|
|
|
|
lsp.default_keymaps({buffer = bufnr})
|
2023-04-06 09:22:23 +08:00
|
|
|
-- 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
|
2023-04-06 05:57:40 +08:00
|
|
|
vim.opt.tagfunc = ""
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- (Optional) Configure lua language server for neovim
|
|
|
|
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
|
|
|
|
|
2024-01-11 23:45:24 +08:00
|
|
|
-- lsp.skip_server_setup({'ltex'})
|
2023-09-05 17:49:31 +08:00
|
|
|
|
2023-04-06 05:57:40 +08:00
|
|
|
lsp.setup()
|
2023-04-08 08:37:35 +08:00
|
|
|
|
|
|
|
-- 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),
|
|
|
|
-- }
|
|
|
|
--})
|