lsp completion selection behaviour now more similar to default vim completion.
- Selecting completion items now changes text in the buffer directly without having to confirm it with <C-y>.
This commit is contained in:
parent
864d76ed7d
commit
c5842ac5ec
@ -1,4 +1,14 @@
|
|||||||
local lsp = require('lsp-zero').preset({})
|
local lsp = require('lsp-zero').preset({})
|
||||||
|
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({
|
vim.diagnostic.config({
|
||||||
virtual_text = true
|
virtual_text = true
|
||||||
@ -16,3 +26,29 @@ end)
|
|||||||
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
|
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
|
||||||
|
|
||||||
lsp.setup()
|
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),
|
||||||
|
-- }
|
||||||
|
--})
|
||||||
|
Loading…
Reference in New Issue
Block a user