feat(vim): style the completion better
This also keeps it a consistent width so it does not keep jumping arround. We are also using nice nerd font icons without using `lspkind`
This commit is contained in:
parent
4274d31d39
commit
0dd4a191a1
1 changed files with 50 additions and 0 deletions
|
|
@ -1,6 +1,33 @@
|
||||||
local cmp = require'cmp'
|
local cmp = require'cmp'
|
||||||
local luasnip = require'luasnip'
|
local luasnip = require'luasnip'
|
||||||
|
|
||||||
|
local icons = {
|
||||||
|
Text = "",
|
||||||
|
Method = "",
|
||||||
|
Function = "",
|
||||||
|
Constructor = "",
|
||||||
|
Field = "ﰠ",
|
||||||
|
Variable = "",
|
||||||
|
Class = "ﴯ",
|
||||||
|
Interface = "",
|
||||||
|
Module = "",
|
||||||
|
Property = "ﰠ",
|
||||||
|
Unit = "塞",
|
||||||
|
Value = "",
|
||||||
|
Enum = "",
|
||||||
|
Keyword = "",
|
||||||
|
Snippet = "",
|
||||||
|
Color = "",
|
||||||
|
File = "",
|
||||||
|
Reference = "",
|
||||||
|
Folder = "",
|
||||||
|
EnumMember = "",
|
||||||
|
Constant = "",
|
||||||
|
Struct = "פּ",
|
||||||
|
Event = "",
|
||||||
|
Operator = "",
|
||||||
|
}
|
||||||
|
|
||||||
local has_words_before = function()
|
local has_words_before = function()
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
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
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||||
|
|
@ -52,5 +79,28 @@ cmp.setup({
|
||||||
luasnip.lsp_expand(args.body)
|
luasnip.lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
window = {
|
||||||
|
completion = cmp.config.window.bordered(),
|
||||||
|
documentation = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
|
formatting = {
|
||||||
|
fields = { 'menu', 'abbr', 'kind' },
|
||||||
|
format = function(entry, vim_item)
|
||||||
|
-- Give the completion menu a consistent size to stop it jumping arround
|
||||||
|
local width = 34
|
||||||
|
if #vim_item.abbr > width then
|
||||||
|
vim_item.abbr = string.sub(vim_item.abbr, 1, width)
|
||||||
|
else
|
||||||
|
vim_item.abbr = vim_item.abbr .. string.rep(" ", width - #vim_item.abbr)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim_item.menu = icons[vim_item.kind] or " "
|
||||||
|
vim_item.kind = "(" .. vim_item.kind .. ")"
|
||||||
|
return vim_item
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
experimental = {
|
||||||
|
ghost_text = false,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue