From c3f9b25606cea94bc4af55dbddf7d7d863be4517 Mon Sep 17 00:00:00 2001 From: Senghan Bright Date: Fri, 25 Sep 2020 06:16:48 +0200 Subject: feature: Vim help-tags picker (#117) * feature: Vim help-tags picker * fix: filtered results were wrong because of missing `entry.value` * fix: filtered (Vim only help) items are listed in results as empty entries. * fix: avoid search history pollution by replacing / in cmd returned by taglist() with search() * fix: improve search() formatting * fix: escape tilde in search() command * fix: improve help-preview * fix: improve search() * fix: search() string fixes. * fix: use no magic to do magic Co-authored-by: TJ DeVries --- lua/telescope/make_entry.lua | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'lua/telescope/make_entry.lua') diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 3ec663b..4db664e 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -284,4 +284,53 @@ function make_entry.gen_from_treesitter(opts) end end +function make_entry.gen_from_tagfile(opts) + local help_entry, version + local delim = string.char(7) + + local make_display = function(line) + help_entry = "" + display = "" + version = "" + + line = line .. delim + for section in line:gmatch("(.-)" .. delim) do + if section:find("^vim:") == nil then + local ver = section:match("^neovim:(.*)") + if ver == nil then + help_entry = section + else + version = ver:sub(1, -2) + end + end + end + + result = {} + if version ~= "" then -- some Vim only entries are unversioned + if opts.show_version then + result.display = string.format("%s [%s]", help_entry, version) + else + result.display = help_entry + end + result.value = help_entry + end + + return result + end + + return function(line) + local entry = { + entry_type = make_entry.types.GENERIC, + + } + local d = make_display(line) + entry.valid = next(d) ~= nil + entry.display = d.display + entry.value = d.value + entry.ordinal = d.value + + return entry + end +end + return make_entry -- cgit v1.2.3