summaryrefslogtreecommitdiff
path: root/lua/telescope/make_entry.lua
diff options
context:
space:
mode:
authorSenghan Bright <senghan.bright@deltaprojects.com>2020-09-25 06:16:48 +0200
committerGitHub <noreply@github.com>2020-09-25 00:16:48 -0400
commitc3f9b25606cea94bc4af55dbddf7d7d863be4517 (patch)
treef7640ee93bb11f191ee1388aa737128b0142b062 /lua/telescope/make_entry.lua
parenta38bb06e7da233a975cbf27b897a22001c4fd206 (diff)
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 <devries.timothyj@gmail.com>
Diffstat (limited to 'lua/telescope/make_entry.lua')
-rw-r--r--lua/telescope/make_entry.lua49
1 files changed, 49 insertions, 0 deletions
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