Search and view offline C++ reference HTML (e.g. a cppreference HTML dump) inside Neovim.
-- lazy.nvim example (local plugin directory)
{
dir = vim.fn.stdpath("config") .. "/lua/CppDocs",
config = function()
require("cppdocs").setup({
docs_root = "D:/html_book_20190607/reference/en",
})
end,
}You need an offline copy of the C++ reference site in HTML form.
One convenient source is the cppreference HTML archive mirror:
https://github.com/stdman3/cppreference-archive-html
Download an archive from that repo, extract it somewhere, then point docs_root at the extracted reference/en directory (the folder that contains lots of *.html files).
Add this repo to your runtimepath (early in startup, before :CppSearch is used):
vim.opt.rtp:append(vim.fn.stdpath("config") .. "/lua/CppDocs")If you copy plugin/cppdocs.lua into ~/.config/nvim/plugin/, you must also copy lua/cppdocs/* into ~/.config/nvim/lua/cppdocs/ so require("cppdocs.*") can resolve.
:CppSearch {query}: fuzzy-search by HTML filename (without.html) and open the best match in a scratch split.:CppReindex: rebuild the in-memory index (useful after changingdocs_root).
- Indexing is done once per Neovim session (first
:CppSearchcall) by recursively scanningdocs_rootfor*.html. - Rendering extracts content starting at
#mw-content-textand converts HTML to a markdown-ish buffer for reading.