From 079f45a54aa7edbbc3326f5715f468e03d2e5e37 Mon Sep 17 00:00:00 2001 From: Daniel Lundin Date: Wed, 30 Nov 2022 12:57:01 +0100 Subject: [PATCH] deprecate lsp_signature for cmp --- .config/nvim/lua/plugins.lua | 2 +- .config/nvim/lua/plugins/lsp-config.lua | 25 ---- .config/nvim/lua/plugins/nvim-cmp.lua | 179 ++++++++++++------------ 3 files changed, 92 insertions(+), 114 deletions(-) diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 1eb5316..e86f6a4 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -3,7 +3,6 @@ return require("packer").startup(function() use("pierreglaser/folding-nvim") use("tjdevries/colorbuddy.vim") use("wbthomason/packer.nvim") - use("ray-x/lsp_signature.nvim") use("jose-elias-alvarez/nvim-lsp-ts-utils") use("rafamadriz/friendly-snippets") use({ "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap" } }) @@ -64,6 +63,7 @@ return require("packer").startup(function() "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-nvim-lsp-signature-help", "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip", }, diff --git a/.config/nvim/lua/plugins/lsp-config.lua b/.config/nvim/lua/plugins/lsp-config.lua index 176acd9..b797ad3 100644 --- a/.config/nvim/lua/plugins/lsp-config.lua +++ b/.config/nvim/lua/plugins/lsp-config.lua @@ -41,7 +41,6 @@ end local on_attach = function() require("folding").on_attach() - require("lsp_signature").on_attach() -- Note: add in lsp client on-attach end -- simple setups -- @@ -190,30 +189,6 @@ require("lspconfig").tsserver.setup({}) -- client.resolved_capabilities.document_formatting = false -- 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") -- ts_utils.setup({ diff --git a/.config/nvim/lua/plugins/nvim-cmp.lua b/.config/nvim/lua/plugins/nvim-cmp.lua index cb86e19..a9b5855 100644 --- a/.config/nvim/lua/plugins/nvim-cmp.lua +++ b/.config/nvim/lua/plugins/nvim-cmp.lua @@ -1,98 +1,101 @@ -local cmp = require'cmp' -local luasnip = require'luasnip' +local cmp = require("cmp") +local luasnip = require("luasnip") local has_words_before = function() - 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 + 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 end cmp.setup({ - formatting = { - format = require('lspkind').cmp_format({ - with_text = true, - menu = { - buffer = "[Buffer]", - tmux = "[Tmux]", - luasnip = "[LuaSnip]", - nvim_lsp = "[LSP]", - nvim_lua = "[Lua]", - path = "[Path]", - }, - }), - }, + formatting = { + format = require("lspkind").cmp_format({ + with_text = true, + menu = { + buffer = "[Buffer]", + tmux = "[Tmux]", + luasnip = "[LuaSnip]", + nvim_lsp = "[LSP]", + nvim_lua = "[Lua]", + path = "[Path]", + }, + }), + }, - window = { - completion = cmp.config.window.bordered({ - winhighlight = 'Normal:PMenu,FloatBorder:PMenuBorder,CursorLine:PMenuSel,Search:None', - }), - documentation = cmp.config.window.bordered({ - winhighlight = 'Normal:PMenu,FloatBorder:PMenu,CursorLine:PMenuSel,Search:None', - }), - }, + window = { + completion = cmp.config.window.bordered({ + winhighlight = "Normal:PMenu,FloatBorder:PMenuBorder,CursorLine:PMenuSel,Search:None", + }), + documentation = cmp.config.window.bordered({ + winhighlight = "Normal:PMenu,FloatBorder:PMenu,CursorLine:PMenuSel,Search:None", + }), + }, - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, - mapping = { - [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - [''] = cmp.mapping(cmp.mapping.confirm({ select = false }), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.confirm({ select = false }), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }, + mapping = { + [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [""] = cmp.mapping(cmp.mapping.confirm({ select = false }), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.confirm({ select = false }), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }, - sources = cmp.config.sources({ - { - name = 'buffer', - priority = 1, - - }, - { - name = 'luasnip', - priority = 4, - }, - { - name = 'tmux', - priority = 2, - option = { - all_panes = true, - trigger_characters = {}, - } - }, - { - name = 'nvim_lsp', - priority = 3, - }, - }) + sources = cmp.config.sources({ + { + name = "buffer", + priority = 1, + }, + { + name = "luasnip", + priority = 4, + }, + { + name = "tmux", + priority = 2, + option = { + all_panes = true, + trigger_characters = {}, + }, + }, + { + name = "nvim_lsp", + priority = 3, + }, + { + name = "nvim_lsp_signature_help", + priority = 4, + }, + }), })