From 77cdf208765ad351e48724ed5ad57e55703eca61 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Tue, 5 Oct 2021 08:46:35 +0200 Subject: Add major update to LSP from lunarvim --- .config/nvim/lua/core/cmp.lua | 51 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 8 deletions(-) (limited to '.config/nvim/lua/core/cmp.lua') diff --git a/.config/nvim/lua/core/cmp.lua b/.config/nvim/lua/core/cmp.lua index 50f7058..f9f2d01 100644 --- a/.config/nvim/lua/core/cmp.lua +++ b/.config/nvim/lua/core/cmp.lua @@ -30,10 +30,40 @@ M.config = function() return end options.builtin.cmp = { + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, formatting = { + kind_icons = { + Class = " ", + Color = " ", + Constant = "ﲀ ", + Constructor = " ", + Enum = "練", + EnumMember = " ", + Event = " ", + Field = " ", + File = "", + Folder = " ", + Function = " ", + Interface = "ﰮ ", + Keyword = " ", + Method = " ", + Module = " ", + Operator = "", + Property = " ", + Reference = " ", + Snippet = " ", + Struct = " ", + Text = " ", + TypeParameter = " ", + Unit = "塞", + Value = " ", + Variable = " ", + }, format = function(entry, vim_item) - local icons = require("lsp.kind").icons - vim_item.kind = icons[vim_item.kind] + vim_item.kind = options.builtin.cmp.formatting.kind_icons[vim_item.kind] vim_item.menu = ({ nvim_lsp = "(LSP)", emoji = "(Emoji)", @@ -78,7 +108,7 @@ M.config = function() -- TODO: potentially fix emmet nonsense [""] = cmp.mapping(function() if vim.fn.pumvisible() == 1 then - vim.fn.feedkeys(T "", "n") + vim.fn.feedkeys(T "", "n") elseif luasnip.expand_or_jumpable() then vim.fn.feedkeys(T "luasnip-expand-or-jump", "") elseif check_backspace() then @@ -94,7 +124,7 @@ M.config = function() }), [""] = cmp.mapping(function(fallback) if vim.fn.pumvisible() == 1 then - vim.fn.feedkeys(T "", "n") + vim.fn.feedkeys(T "", "n") elseif luasnip.jumpable(-1) then vim.fn.feedkeys(T "luasnip-jump-prev", "") else @@ -107,10 +137,15 @@ M.config = function() [""] = cmp.mapping.complete(), [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, + [""] = cmp.mapping(function(fallback) + if not require("cmp").confirm(options.builtin.cmp.confirm_opts) then + if luasnip.jumpable() then + vim.fn.feedkeys(T "luasnip-jump-next", "") + else + fallback() + end + end + end), }, } end -- cgit v1.2.3-70-g09d2