cmp sorting woot

This commit is contained in:
Christian Nieves
2023-11-23 15:30:58 -06:00
parent b63ef26e3b
commit 70b43e497b
5 changed files with 16 additions and 12 deletions

View File

@ -3,4 +3,4 @@ set nowrap
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set noexpandtab

View File

@ -6,3 +6,4 @@ createApkDescriptor
setInstance
collsion_body
shake_decay
index

View File

@ -88,29 +88,31 @@ return {
cmp.setup({
preselect = cmp.PreselectMode.None,
sources = cmp.config.sources(require("utils").TableConcat({
{ name = "luasnip", priority = 8 },
{ name = "nvim_lsp", priority = 7 },
{ name = "async_path" },
{ name = "treesitter" },
{ name = "buffer" },
{ name = "calc" },
{ name = "crates" },
{ name = "emoji" },
{ name = "luasnip", priority = 8 },
{ name = "nvim_lsp", priority = 7 },
{ name = "spell" },
{ name = "treesitter" },
{ name = "buffer" },
}, conditionalSources)),
sorting = {
comparators = {
-- compare.score_offset, -- not good at all
compare.locality,
compare.recently_used,
compare.score, -- based on : score = score + ((#sources - (source_index - 1)) * sorting.priority_weight)
compare.offset,
--compare.order,
--compare.sort_text,
compare.order,
-- compare.scopes, -- what?
-- compare.sort_text,
-- compare.exact,
-- compare.kind,
-- compare.length,
-- compare.length, -- useless
},
},
formatting = {
format = lspkind.cmp_format({
menu = {
@ -148,8 +150,8 @@ return {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
-- elseif has_words_before() then
-- cmp.complete()
-- elseif has_words_before() then
-- cmp.complete()
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end

View File

@ -13,6 +13,7 @@ return {
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = false,
indent = { enable = true },
-- List of parsers to ignore installing (or "all")
-- ignore_install = { "" },