Rename and simplify make_entry function

This commit is contained in:
Nolan Prochnau
2020-11-09 22:18:36 -05:00
parent 6667fd36b1
commit 1678d7cb13
2 changed files with 7 additions and 15 deletions

View File

@@ -499,7 +499,7 @@ builtin.help_tags = function(opts)
prompt_title = 'Help', prompt_title = 'Help',
finder = finders.new_table { finder = finders.new_table {
results = tags, results = tags,
entry_maker = make_entry.gen_from_tagfile(opts), entry_maker = make_entry.gen_from_taglist(opts),
}, },
-- TODO: previewer for Vim help -- TODO: previewer for Vim help
previewer = previewers.help.new(opts), previewer = previewers.help.new(opts),

View File

@@ -365,24 +365,16 @@ function make_entry.gen_from_treesitter(opts)
end end
end end
function make_entry.gen_from_tagfile(_) function make_entry.gen_from_taglist(_)
local delim = string.char(9) local delim = string.char(9)
local make_display = function(line)
local help_entry = (line..delim):match("(.-)" .. delim)
return {
display = help_entry,
value = help_entry
}
end
return function(line) return function(line)
local entry = {} local entry = {}
local d = make_display(line) local tag = (line..delim):match("(.-)" .. delim)
entry.valid = next(d) ~= nil entry.valid = tag ~= ""
entry.display = d.display entry.display = tag
entry.value = d.value entry.value = tag
entry.ordinal = d.value entry.ordinal = tag
return entry return entry
end end