deprecate lsp_signature for cmp

This commit is contained in:
Daniel Lundin 2022-11-30 12:57:01 +01:00
parent e7b64d1347
commit 079f45a54a
3 changed files with 92 additions and 114 deletions

View file

@ -3,7 +3,6 @@ return require("packer").startup(function()
use("pierreglaser/folding-nvim") use("pierreglaser/folding-nvim")
use("tjdevries/colorbuddy.vim") use("tjdevries/colorbuddy.vim")
use("wbthomason/packer.nvim") use("wbthomason/packer.nvim")
use("ray-x/lsp_signature.nvim")
use("jose-elias-alvarez/nvim-lsp-ts-utils") use("jose-elias-alvarez/nvim-lsp-ts-utils")
use("rafamadriz/friendly-snippets") use("rafamadriz/friendly-snippets")
use({ "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap" } }) use({ "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap" } })
@ -64,6 +63,7 @@ return require("packer").startup(function()
"hrsh7th/cmp-buffer", "hrsh7th/cmp-buffer",
"hrsh7th/cmp-path", "hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline", "hrsh7th/cmp-cmdline",
"hrsh7th/cmp-nvim-lsp-signature-help",
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip", "saadparwaiz1/cmp_luasnip",
}, },

View file

@ -41,7 +41,6 @@ end
local on_attach = function() local on_attach = function()
require("folding").on_attach() require("folding").on_attach()
require("lsp_signature").on_attach() -- Note: add in lsp client on-attach
end end
-- simple setups -- -- simple setups --
@ -190,30 +189,6 @@ require("lspconfig").tsserver.setup({})
-- client.resolved_capabilities.document_formatting = false -- client.resolved_capabilities.document_formatting = false
-- on_attach(client) -- on_attach(client)
-- require("lsp_signature").on_attach({
-- bind = false, -- This is mandatory, otherwise border config won't get registered.
-- -- If you want to hook lspsaga or other signature handler, pls set to false
-- doc_lines = 2, -- will show two lines of comment/doc(if there are more than two lines in doc, will be truncated);
-- -- set to 0 if you DO NOT want any API comments be shown
-- -- This setting only take effect in insert mode, it does not affect signature help in normal
-- -- mode, 10 by default
-- floating_window = true, -- show hint in a floating window, set to false for virtual text only mode
-- fix_pos = false, -- set to true, the floating window will not auto-close until finish all parameters
-- hint_enable = false, -- virtual hint enable
-- hint_prefix = "🐼 ", -- Panda for parameter
-- hint_scheme = "String",
-- use_lspsaga = true, -- set to true if you want to use lspsaga popup
-- hi_parameter = "Search", -- how your parameter will be highlight
-- max_height = 12, -- max height of signature floating_window, if content is more than max_height, you can scroll down
-- -- to view the hiding contents
-- max_width = 120, -- max_width of signature floating_window, line will be wrapped if exceed max_width
-- handler_opts = {
-- border = "single", -- double, single, shadow, none
-- },
-- extra_trigger_chars = {}, -- Array of extra characters that will trigger signature completion, e.g., {"(", ","}
-- })
-- local ts_utils = require("nvim-lsp-ts-utils") -- local ts_utils = require("nvim-lsp-ts-utils")
-- ts_utils.setup({ -- ts_utils.setup({

View file

@ -1,98 +1,101 @@
local cmp = require'cmp' local cmp = require("cmp")
local luasnip = require'luasnip' local luasnip = require("luasnip")
local has_words_before = function() local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0)) local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end end
cmp.setup({ cmp.setup({
formatting = { formatting = {
format = require('lspkind').cmp_format({ format = require("lspkind").cmp_format({
with_text = true, with_text = true,
menu = { menu = {
buffer = "[Buffer]", buffer = "[Buffer]",
tmux = "[Tmux]", tmux = "[Tmux]",
luasnip = "[LuaSnip]", luasnip = "[LuaSnip]",
nvim_lsp = "[LSP]", nvim_lsp = "[LSP]",
nvim_lua = "[Lua]", nvim_lua = "[Lua]",
path = "[Path]", path = "[Path]",
}, },
}), }),
}, },
window = { window = {
completion = cmp.config.window.bordered({ completion = cmp.config.window.bordered({
winhighlight = 'Normal:PMenu,FloatBorder:PMenuBorder,CursorLine:PMenuSel,Search:None', winhighlight = "Normal:PMenu,FloatBorder:PMenuBorder,CursorLine:PMenuSel,Search:None",
}), }),
documentation = cmp.config.window.bordered({ documentation = cmp.config.window.bordered({
winhighlight = 'Normal:PMenu,FloatBorder:PMenu,CursorLine:PMenuSel,Search:None', winhighlight = "Normal:PMenu,FloatBorder:PMenu,CursorLine:PMenuSel,Search:None",
}), }),
}, },
snippet = { snippet = {
expand = function(args) expand = function(args)
luasnip.lsp_expand(args.body) luasnip.lsp_expand(args.body)
end, end,
}, },
mapping = { mapping = {
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), ["<Up>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }),
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), ["<Down>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),
['<C-p>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), ["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }),
['<C-n>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), ["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),
["<C-d>"] = cmp.mapping.scroll_docs(-4), ["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-u>"] = cmp.mapping.scroll_docs(4), ["<C-u>"] = cmp.mapping.scroll_docs(4),
['<C-e>'] = cmp.mapping({ ["<C-e>"] = cmp.mapping({
i = cmp.mapping.abort(), i = cmp.mapping.abort(),
c = cmp.mapping.close(), c = cmp.mapping.close(),
}), }),
['<CR>'] = cmp.mapping(cmp.mapping.confirm({ select = false }), { 'i', 'c' }), ["<CR>"] = cmp.mapping(cmp.mapping.confirm({ select = false }), { "i", "c" }),
['<C-y>'] = cmp.mapping(cmp.mapping.confirm({ select = false }), { 'i', 'c' }), ["<C-y>"] = cmp.mapping(cmp.mapping.confirm({ select = false }), { "i", "c" }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
elseif luasnip.expand_or_locally_jumpable() then elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()
elseif has_words_before() then elseif has_words_before() then
cmp.complete() cmp.complete()
else else
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.jumpable(-1) then elseif luasnip.jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
else else
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
}, },
sources = cmp.config.sources({ sources = cmp.config.sources({
{ {
name = 'buffer', name = "buffer",
priority = 1, priority = 1,
},
}, {
{ name = "luasnip",
name = 'luasnip', priority = 4,
priority = 4, },
}, {
{ name = "tmux",
name = 'tmux', priority = 2,
priority = 2, option = {
option = { all_panes = true,
all_panes = true, trigger_characters = {},
trigger_characters = {}, },
} },
}, {
{ name = "nvim_lsp",
name = 'nvim_lsp', priority = 3,
priority = 3, },
}, {
}) name = "nvim_lsp_signature_help",
priority = 4,
},
}),
}) })