From 1bbd7f5e6c3e074f689c46b535e48d13a173fc5b Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Wed, 7 Aug 2024 11:15:50 -0700 Subject: [PATCH 1/2] dressing.nvim --- dot_vimrc | 1 + 1 file changed, 1 insertion(+) diff --git a/dot_vimrc b/dot_vimrc index 3930f20..349fa6e 100644 --- a/dot_vimrc +++ b/dot_vimrc @@ -275,6 +275,7 @@ Plug 'Shougo/echodoc.vim' "Plug 'python-rope/ropevim' Plug 'windwp/nvim-autopairs' Plug 'danymat/neogen' +Plug 'stevearc/dressing.nvim' " Unclear "Plug 'ncm2/float-preview.nvim' From 9165e6dad80f0d2caaa68b2e0fa6a834d7632fea Mon Sep 17 00:00:00 2001 From: Barak Michener Date: Wed, 7 Aug 2024 15:37:47 -0700 Subject: [PATCH 2/2] cmp supporting newline --- dot_vim/lua/cmp_setup.lua | 133 ++++++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 63 deletions(-) diff --git a/dot_vim/lua/cmp_setup.lua b/dot_vim/lua/cmp_setup.lua index 951bbd6..bbc30f0 100644 --- a/dot_vim/lua/cmp_setup.lua +++ b/dot_vim/lua/cmp_setup.lua @@ -43,68 +43,75 @@ local lspkind = require('lspkind') cmp.setup({ - snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - require('snippy').expand_snippet(args.body) -- For `snippy` users. - -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) - end, - }, - formatting = { - format = lspkind.cmp_format({ - mode = 'symbol_text', -- show only symbol annotations - maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) - -- can also be a function to dynamically calculate max width such as - -- maxwidth = function() return math.floor(0.45 * vim.o.columns) end, - ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) - show_labelDetails = true, -- show labelDetails in menu. Disabled by default + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require('snippy').expand_snippet(args.body) -- For `snippy` users. + -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) + end, + }, + formatting = { + format = lspkind.cmp_format({ + mode = 'symbol_text', -- show only symbol annotations + maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + -- can also be a function to dynamically calculate max width such as + -- maxwidth = function() return math.floor(0.45 * vim.o.columns) end, + ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) + show_labelDetails = true, -- show labelDetails in menu. Disabled by default - -- The function below will be called before any actual modifications from lspkind - -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) - before = function(entry, vim_item) - return vim_item - end - }) - }, - window = { - -- completion = cmp.config.window.bordered(), - -- documentation = cmp.config.window.bordered(), - }, - preselect = cmp.PreselectMode.None, - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete {}, - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - --elseif luasnip.expand_or_jumpable() then - --luasnip.expand_or_jump() - 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 = 'nvim_lsp' }, - -- { name = 'vsnip' }, -- For vsnip users. - -- { name = 'luasnip' }, -- For luasnip users. - -- { name = 'ultisnips' }, -- For ultisnips users. - { name = 'snippy' }, -- For snippy users. - --}, { - { name = 'buffer' }, - }) + -- The function below will be called before any actual modifications from lspkind + -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) + before = function(entry, vim_item) + return vim_item + end + }) + }, + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + preselect = cmp.PreselectMode.None, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete {}, + [""] = cmp.mapping({ + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) + else + fallback() + end + end, + s = cmp.mapping.confirm({ select = true }), + c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), + }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + --elseif luasnip.expand_or_jumpable() then + --luasnip.expand_or_jump() + 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 = 'nvim_lsp' }, + -- { name = 'vsnip' }, -- For vsnip users. + -- { name = 'luasnip' }, -- For luasnip users. + -- { name = 'ultisnips' }, -- For ultisnips users. + { name = 'snippy' }, -- For snippy users. + --}, { + { name = 'buffer' }, + }) })