Merge pull request #230 from parmort/rework-helptags

Rework helptags builtin, including helps tags from installed plugins
This commit is contained in:
tami5
2020-11-15 09:53:03 +03:00
committed by GitHub
4 changed files with 21 additions and 11906 deletions

View File

@@ -361,6 +361,12 @@ require'telescope.builtin'.buffers{
Search on vim buffers list. Search on vim buffers list.
```lua
require'telescope.builtin'.help_tags{}
```
Search on the helptags in each directory in the runtimepath
#### LSP #### LSP
```lua ```lua

File diff suppressed because it is too large Load Diff

View File

@@ -486,22 +486,20 @@ end
builtin.help_tags = function(opts) builtin.help_tags = function(opts)
opts = opts or {} 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 tags = {}
for _, file in pairs(vim.fn.findfile('doc/tags', vim.o.runtimepath, -1)) do
local f = assert(io.open(file, "rb")) local f = assert(io.open(file, "rb"))
for line in f:lines() do for line in f:lines() do
table.insert(tags, line) table.insert(tags, line)
end end
f:close() f:close()
end
pickers.new(opts, { pickers.new(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,47 +365,16 @@ function make_entry.gen_from_treesitter(opts)
end end
end end
function make_entry.gen_from_tagfile(opts) function make_entry.gen_from_taglist(_)
local help_entry, version local delim = string.char(9)
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) 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