Skip to content

pjinhispjs/wikiman.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wikiman.nvim

Read Wikipedia articles in NeoVim as if they were man pages.

Requires NeoVim 0.10+ and curl.

screenshot

Usage

:Wiki Python (programming language)

Tab-completion suggests article titles as you type. Inside an article buffer:

  • q closes the window
  • K on a highlighted link jumps to its exact target article; on plain text it looks up the word under the cursor
  • K in visual mode opens the article for the selection

Install

With lazy.nvim:

{ "pjinhispjs/wikiman.nvim" }

No setup() call is required. To change defaults:

require("wikiman").setup({
  lang = "en",     -- Wikipedia language subdomain
  open = "split",  -- "split" | "vsplit" | "tab"
  width = 78,      -- text width of the rendered article
})

How it works

Articles are fetched as rendered HTML from the MediaWiki API (action=parse) with curl via vim.system(), parsed by a small built-in HTML reader, and rendered into a read-only scratch buffer with man-page conventions: uppercased section headings, indented body text, and a NAME(WIKI) header. Title completion uses the opensearch API.

  • Tables render as box-drawing grids (colspan/rowspan included); infoboxes become key/value lists
  • Math formulas are converted from LaTeX into readable text (1/π, sqrt(163), Σ_(k=0)^∞)
  • Citations stay inline as [1] markers, and the references section keeps external URLs in <angle brackets>
  • Images render as [image: caption or alt text]
  • Inline code is highlighted, and <pre> blocks (source listings, pseudocode) keep their line structure instead of word-wrapping

Highlight groups, overridable with vim.api.nvim_set_hl:

Group Default link Used for
WikimanMath Special formulas
WikimanLink Underlined links to other articles
WikimanCode String inline code and pre blocks
WikimanCitation Comment citation markers, image placeholders
WikimanTableBorder Comment table borders

Tests

tests/run.sh

Runs headless-nvim E2E tests offline: a stub curl on $PATH serves JSON fixtures, and the tests drive :Wiki and assert on buffer contents, keymaps, error handling, and completion.

About

Read Wikipedia articles in NeoVim as if they were man pages.

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Contributors