summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/core/cmp.lua
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-10-05 08:46:35 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-10-05 08:46:35 +0200
commit77cdf208765ad351e48724ed5ad57e55703eca61 (patch)
tree7f19757b255ab66895d9240a5aca77a35cef8aac /.config/nvim/lua/core/cmp.lua
parent4fd170aa9d55b7bcd1f0a9445c9e136b560e3220 (diff)
Add major update to LSP from lunarvim
Diffstat (limited to '.config/nvim/lua/core/cmp.lua')
-rw-r--r--.config/nvim/lua/core/cmp.lua51
1 files changed, 43 insertions, 8 deletions
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
["<Tab>"] = cmp.mapping(function()
if vim.fn.pumvisible() == 1 then
- vim.fn.feedkeys(T "<C-n>", "n")
+ vim.fn.feedkeys(T "<down>", "n")
elseif luasnip.expand_or_jumpable() then
vim.fn.feedkeys(T "<Plug>luasnip-expand-or-jump", "")
elseif check_backspace() then
@@ -94,7 +124,7 @@ M.config = function()
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if vim.fn.pumvisible() == 1 then
- vim.fn.feedkeys(T "<C-p>", "n")
+ vim.fn.feedkeys(T "<up>", "n")
elseif luasnip.jumpable(-1) then
vim.fn.feedkeys(T "<Plug>luasnip-jump-prev", "")
else
@@ -107,10 +137,15 @@ M.config = function()
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
- ["<CR>"] = cmp.mapping.confirm {
- behavior = cmp.ConfirmBehavior.Replace,
- select = true,
- },
+ ["<CR>"] = cmp.mapping(function(fallback)
+ if not require("cmp").confirm(options.builtin.cmp.confirm_opts) then
+ if luasnip.jumpable() then
+ vim.fn.feedkeys(T "<Plug>luasnip-jump-next", "")
+ else
+ fallback()
+ end
+ end
+ end),
},
}
end