From f85846b5ef2edbd71da9499aa45524cc43c00613 Mon Sep 17 00:00:00 2001 From: jackokring Date: Thu, 28 Nov 2024 00:15:35 +0000 Subject: [PATCH] Thursday 2024-11-28 00:15:35 --- extras-backup/nvim/lua/config/complete.lua | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/extras-backup/nvim/lua/config/complete.lua b/extras-backup/nvim/lua/config/complete.lua index b3124db..8b9bd7c 100644 --- a/extras-backup/nvim/lua/config/complete.lua +++ b/extras-backup/nvim/lua/config/complete.lua @@ -66,10 +66,30 @@ end -- callback(completion_item) -- end -local function reg(name, src) +local function compare(item1, item2) + return nil +end + +local function reg(name, src, fn) local cmp = require("cmp") table.insert(cmp.get_config().sources, { name = name }) + local i + for k, v in ipairs(cmp.get_config().sorting.comparators) do + if v == cmp.config.compare.kind then + i = k + break + end + end + local c = cmp.get_config().sorting.comparators + table.insert(c, i or (#c + 1), function(entry1, entry2) + -- not from same source + if entry1.source.name ~= name or entry2.source.name ~= name then + return nil + end + -- TODO + return fn(entry1.completion_item, entry2.completion_item) + end) cmp.register_source(name, src) end -reg("autojump", source) +reg("autojump", source, compare)