diff options
| author | Senghan Bright <senghan.bright@deltaprojects.com> | 2020-09-25 06:16:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-25 00:16:48 -0400 |
| commit | c3f9b25606cea94bc4af55dbddf7d7d863be4517 (patch) | |
| tree | f7640ee93bb11f191ee1388aa737128b0142b062 /lua/telescope/builtin.lua | |
| parent | a38bb06e7da233a975cbf27b897a22001c4fd206 (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/builtin.lua')
| -rw-r--r-- | lua/telescope/builtin.lua | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lua/telescope/builtin.lua b/lua/telescope/builtin.lua index 5264ca3..fced93c 100644 --- a/lua/telescope/builtin.lua +++ b/lua/telescope/builtin.lua @@ -402,6 +402,45 @@ builtin.command_history = function(opts) }):find() 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() + + pickers.new(opts, { + prompt = 'Help', + finder = finders.new_table { + results = tags, + entry_maker = make_entry.gen_from_tagfile(opts), + }, + -- TODO: previewer for Vim help + previewer = previewers.help.new(opts), + sorter = sorters.get_generic_fuzzy_sorter(), + attach_mappings = function(prompt_bufnr, map) + local view_help = function() + local selection = actions.get_selected_entry(prompt_bufnr) + + actions.close(prompt_bufnr) + vim.cmd("help " .. selection.value) + end + + map('i', '<CR>', view_help) + map('n', '<CR>', view_help) + + return true + end + }):find() +end + -- TODO: What the heck should we do for accepting this. -- vim.fn.setreg("+", "nnoremap $TODO :lua require('telescope.builtin').<whatever>()<CR>") -- TODO: Can we just do the names instead? |
