summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authortami5 <65782666+tami5@users.noreply.github.com>2020-11-15 09:53:03 +0300
committerGitHub <noreply@github.com>2020-11-15 09:53:03 +0300
commit3c4a88efe499456452fbeea397db62b2efb35bbb (patch)
tree84e43becccec9d7659c1ee87c2879137ff736661 /lua
parent3c2dea3ea5c03496a1a74e86decc22009a8a12a2 (diff)
parent522c2faca189e25081499df274c7f795ce523189 (diff)
Merge pull request #230 from parmort/rework-helptags
Rework helptags builtin, including helps tags from installed plugins
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/builtin.lua18
-rw-r--r--lua/telescope/make_entry.lua45
2 files changed, 15 insertions, 48 deletions
diff --git a/lua/telescope/builtin.lua b/lua/telescope/builtin.lua
index 684afa8..30b8c90 100644
--- a/lua/telescope/builtin.lua
+++ b/lua/telescope/builtin.lua
@@ -486,22 +486,20 @@ end
builtin.help_tags = function(opts)
opts = opts or {}
- local sourced_file = require('plenary.debug_utils').sourced_filepath()
- local base_directory = vim.fn.fnamemodify(sourced_file, ":h:h:h")
- local file = base_directory .. "/data/help/tags"
-
local tags = {}
- local f = assert(io.open(file, "rb"))
- for line in f:lines() do
- table.insert(tags, line)
- end
- f:close()
+ for _, file in pairs(vim.fn.findfile('doc/tags', vim.o.runtimepath, -1)) do
+ local f = assert(io.open(file, "rb"))
+ for line in f:lines() do
+ table.insert(tags, line)
+ end
+ f:close()
+ end
pickers.new(opts, {
prompt_title = 'Help',
finder = finders.new_table {
results = tags,
- entry_maker = make_entry.gen_from_tagfile(opts),
+ entry_maker = make_entry.gen_from_taglist(opts),
},
-- TODO: previewer for Vim help
previewer = previewers.help.new(opts),
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua
index 7707122..5e7d493 100644
--- a/lua/telescope/make_entry.lua
+++ b/lua/telescope/make_entry.lua
@@ -365,47 +365,16 @@ 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
+function make_entry.gen_from_taglist(_)
+ local delim = string.char(9)
return function(line)
local entry = {}
- local d = make_display(line)
- entry.valid = next(d) ~= nil
- entry.display = d.display
- entry.value = d.value
- entry.ordinal = d.value
+ local tag = (line..delim):match("(.-)" .. delim)
+ entry.valid = tag ~= ""
+ entry.display = tag
+ entry.value = tag
+ entry.ordinal = tag
return entry
end