group -> group_index
This commit is contained in:
@@ -237,7 +237,7 @@ The source specific keyword_length for override.
|
|||||||
|
|
||||||
The source specific maximum item count.
|
The source specific maximum item count.
|
||||||
|
|
||||||
#### sources[number].group (type: number)
|
#### sources[number].group_index (type: number)
|
||||||
|
|
||||||
The source group index.
|
The source group index.
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ return function(...)
|
|||||||
local sources = {}
|
local sources = {}
|
||||||
for i, group in ipairs({ ... }) do
|
for i, group in ipairs({ ... }) do
|
||||||
for _, source in ipairs(group) do
|
for _, source in ipairs(group) do
|
||||||
source.group = i
|
source.group_index = i
|
||||||
table.insert(sources, source)
|
table.insert(sources, source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -50,17 +50,17 @@ view.open = function(self, ctx, sources)
|
|||||||
while true do
|
while true do
|
||||||
group_index = group_index + 1
|
group_index = group_index + 1
|
||||||
|
|
||||||
local group = vim.tbl_filter(function(s)
|
local source_group = vim.tbl_filter(function(s)
|
||||||
return (s:get_config().group or 1) == group_index
|
return (s:get_config().group_index or 1) == group_index
|
||||||
end, sources)
|
end, sources)
|
||||||
|
|
||||||
if #group == 0 then
|
if #source_group == 0 then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check the source triggered by character
|
-- check the source triggered by character
|
||||||
local has_triggered_by_symbol_source = false
|
local has_triggered_by_symbol_source = false
|
||||||
for _, s in ipairs(group) do
|
for _, s in ipairs(source_group) do
|
||||||
if #s:get_entries(ctx) > 0 then
|
if #s:get_entries(ctx) > 0 then
|
||||||
if s.is_triggered_by_symbol then
|
if s.is_triggered_by_symbol then
|
||||||
has_triggered_by_symbol_source = true
|
has_triggered_by_symbol_source = true
|
||||||
@@ -71,11 +71,11 @@ view.open = function(self, ctx, sources)
|
|||||||
|
|
||||||
-- create filtered entries.
|
-- create filtered entries.
|
||||||
local offset = ctx.cursor.col
|
local offset = ctx.cursor.col
|
||||||
for i, s in ipairs(group) do
|
for i, s in ipairs(source_group) do
|
||||||
if s.offset <= offset then
|
if s.offset <= offset then
|
||||||
if not has_triggered_by_symbol_source or s.is_triggered_by_symbol then
|
if not has_triggered_by_symbol_source or s.is_triggered_by_symbol then
|
||||||
-- source order priority bonus.
|
-- source order priority bonus.
|
||||||
local priority = s:get_config().priority or ((#group - (i - 1)) * config.get().sorting.priority_weight)
|
local priority = s:get_config().priority or ((#source_group - (i - 1)) * config.get().sorting.priority_weight)
|
||||||
|
|
||||||
for _, e in ipairs(s:get_entries(ctx)) do
|
for _, e in ipairs(s:get_entries(ctx)) do
|
||||||
e.score = e.score + priority
|
e.score = e.score + priority
|
||||||
|
|||||||
Reference in New Issue
Block a user