Skip to content

Commit

Permalink
Thursday 2024-11-28 00:15:35
Browse files Browse the repository at this point in the history
  • Loading branch information
jackokring committed Nov 28, 2024
1 parent 540f3c2 commit f85846b
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions extras-backup/nvim/lua/config/complete.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit f85846b

Please sign in to comment.