astronvim_config/plugins/cmp.lua
2022-10-29 23:16:55 +02:00

98 lines
2.4 KiB
Lua
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local kind_icons = {
NONE = "",
Array = "",
Boolean = "",
Class = "",
Constructor = "",
Key = "",
Namespace = "",
Null = "NULL",
Number = "#",
Object = "⦿",
Package = "",
Property = "",
Reference = "",
Snippet = "",
String = "𝓐",
TypeParameter = "",
Unit = "",
Text = "",
Method = "",
Function = "",
Field = "",
Variable = "",
Interface = "",
Module = "",
Value = "",
Enum = "",
Keyword = "",
Color = "",
File = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
Copilot = "",
}
local cmp = require("cmp")
-- local has_words_before = function()
-- if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then return false end
-- local line, col = unpack(vim.api.nvim_win_get_cursor(0))
-- return col ~= 0 and vim.api.nvim_buf_get_text(0, line - 1, 0, line - 1, col, {})[1]:match("^%s*$") == nil
-- end
return {
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(_, vim_item)
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
return vim_item
end,
},
-- completion = {
-- keyword_length = 0,
-- },
-- mapping = {
-- ["<Tab>"] = vim.schedule_wrap(function(fallback)
-- if cmp.visible() and has_words_before() then
-- cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
-- else
-- fallback()
-- end
-- end),
-- ['<Tab>'] = cmp.mapping(function(fallback)
-- if vim.fn['vsnip#jumpable'](1) == 1 then
-- feedkey('<Plug>(vsnip-jump-next)', '')
-- else
-- local copilot_keys = vim.fn['copilot#Accept']()
-- if copilot_keys ~= '' then
-- vim.api.nvim_feedkeys(copilot_keys, 'i', true)
-- else
-- fallback()
-- end
-- end
-- end, { 'i', 's' }),
-- },
}
-- local cmp = require "cmp"
-- local luasnip = require "luasnip"
-- return {
-- preselect = cmp.PreselectMode.None,
-- mapping = {
-- ["<CR>"] = cmp.mapping.confirm { select = false },
-- ["<Tab>"] = cmp.mapping(function(fallback)
-- if luasnip.expandable() then
-- luasnip.expand()
-- elseif luasnip.expand_or_jumpable() then
-- luasnip.expand_or_jump()
-- fallback()
-- end
-- end, {
-- "i",
-- "s",
-- }),
-- },
-- }