Warning
skeletony007/qwiki.nvim is migrating to Codeberg!
https://codeberg.org/skeletony007/qwiki.nvim
Update your plugin config to receive future updates.
Pronounced "quickie". Quickly search wiki pages.
Using lazy.nvim
return {
"skeletony007/qwiki.nvim",
}Providers are available as Lua classes under the qwiki module:
local qwiki = require("qwiki")New instances should added like qwiki.<provider-name>:new(<instance-name>).
For example:
qwiki.wikikedia:new("My Wikipedia")There can be many instances of each provider, each having a unique name.
Simple set up:
qwiki.wikimedia:new("Wikipedia", {
endpoint = "https://en.wikipedia.org/w/rest.php",
})Or with API Portal Authentication:
qwiki.wikimedia:new("My Wikipedia", {
endpoint = "https://en.wikipedia.org/w/rest.php",
client_id_command = "pass wikimedia.org/MyAccount | awk -F': *' '/^API key Client ID:/ {print $2}'",
client_secret_command = "pass wikimedia.org/MyAccount | awk -F': *' '/^API key Client secret:/ {print $2}'",
})Simple set up:
qwiki.wikimedia:new("ArchWiki", {
endpoint = "https://wiki.archlinux.org/rest.php",
})local filetype = require("qwiki.filetype")Filetype modules are defined at filetype.<filetype>. Filetype callbacks are
defined on every filetype, but these can be overridden.
Module
filetype.mediawikiImplements
filetype.mediawiki.follow_wikilink_under_cursor(ref)filetype.mediawiki.get_wikilink_under_cursor()filetype.mediawiki.callback = function(args)
local buf, ref = args.buf, args.ref
vim.keymap.set(
"n",
"<C-]>",
function() filetype.mediawiki.follow_wikilink_under_cursor(ref) end,
{ buffer = buf, silent = true }
)
endTip
You might want to fallback to vim.cmd.tag({ vim.fn.expand("<cword>") }) or
:normal! <C-]> on error using pcall.
This plugin includes a telescope.nvim extension qwiki with
search_providers picker:
local telescope = require("telescope")
telescope.load_extension("qwiki")
telescope.extensions.qwiki.search_providers()The search flow is as follows:
- Select profider(s) using telescope.nvim. If there is a single provider, then this stage is skipped
- Enter starting search query, which is processed seperately by the each provider
- Select provider result(s) using telescope.nvim
- Select a single provider for any results from more than one provider
This extension supports multi-selection.
Loosely inspired by Python Requests, module qwiki.requests is a wrapper for
curl. This makes it simpler to maintain and add new providers.
local requests = require("qwiki.requests")Runs asynchronously:
local response = requests.request(
"https://api.wikimedia.org/core/v1/wikipedia/en/search/title",
"GET",
nil,
{["q"] = "Lua", ["limit"] = 20},
nil,
function(response)
print(string.format("Body:\n%s", response.body))
print(string.format("HTTP code: %d", response.code))
end
)Runs synchronously:
local response = requests.request(
"https://api.wikimedia.org/core/v1/wikipedia/en/search/title",
"GET",
nil,
{["q"] = "Lua", ["limit"] = 20}
):wait()
print(string.format("Body:\n%s", response.body))
print(string.format("HTTP code: %d", response.code))