Skip to content
This repository was archived by the owner on May 16, 2024. It is now read-only.

Commit 242a14a

Browse files
feat: ability to search in installed apidocs
1 parent 6685d79 commit 242a14a

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Available commands:
107107
- `DevdocsOpenFloat`: Open documentation in a floating window, 0 or 1 arg.
108108
- `DevdocsOpenCurrent`: Open documentation for the current filetype in a normal buffer.
109109
- `DevdocsOpenCurrentFloat`: Open documentation for the current filetype in a floating window.
110+
- `DevdocsSearch`: Search in the installed apidocs.
110111
- `DevdocsUpdate`: Update documentation, 0-n args.
111112
- `DevdocsUpdateAll`: Update all documentations.
112113

lua/nvim-devdocs/init.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ M.keywordprg = function(args)
7272
end
7373
end
7474

75+
M.search = function(args)
76+
if vim.tbl_isempty(args.fargs) then
77+
pickers.open_picker_search("")
78+
else
79+
local alias = args.fargs[1]
80+
pickers.open_picker_search(alias)
81+
end
82+
end
83+
7584
M.setup = function(opts)
7685
config.setup(opts)
7786

@@ -86,6 +95,7 @@ M.setup = function(opts)
8695
cmd("DevdocsUninstall", M.uninstall_doc, { nargs = "*", complete = completion.get_installed })
8796
cmd("DevdocsOpen", M.open_doc, { nargs = "?", complete = completion.get_installed })
8897
cmd("DevdocsOpenFloat", M.open_doc_float, { nargs = "?", complete = completion.get_installed })
98+
cmd("DevdocsSearch", M.search, { nargs = "?", complete = completion.get_installed })
8999
cmd("DevdocsOpenCurrent", function() M.open_doc_current_file() end, {})
90100
cmd("DevdocsOpenCurrentFloat", function() M.open_doc_current_file(true) end, {})
91101
cmd("DevdocsKeywordprg", M.keywordprg, { nargs = "?" })

lua/nvim-devdocs/pickers.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ M.open_picker = function(entries, float)
176176
picker:find()
177177
end
178178

179+
M.open_picker_search = function(subfolder)
180+
require('telescope.builtin').live_grep({cwd=DOCS_DIR:joinpath(subfolder).filename})
181+
end
182+
179183
---@param alias string
180184
---@param float? boolean
181185
M.open_picker_alias = function(alias, float)

0 commit comments

Comments
 (0)