summaryrefslogtreecommitdiffstats
path: root/.config/nvim/plugin/50-nvim-help.lua
blob: 926bb6808281425e71d5c471ea0b2da84bae1e15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-- `nvim-help://<tag>` — open Neovim help for <tag> in a scratch, read-only
-- buffer. Registered with the follow engine (see 50-follow.lua).

require("dotfiles.follow").register_scheme("nvim-help", {
	resolve = function(uri)
		local tagfiles = {}
		for _, path in pairs(vim.opt.runtimepath:get()) do
			tagfiles[#tagfiles + 1] = path .. "/doc/tags"
		end
		vim.opt_local.tags = tagfiles
		local matches = vim.fn.taglist(uri)
		if #matches == 0 then
			return nil, "No help page found for nvim-help://" .. uri
		end
		return matches[1].filename
	end,
	after = function()
		vim.opt_local.bufhidden = "wipe"
		vim.opt_local.buftype = "nofile"
		vim.opt_local.swapfile = false
		vim.opt_local.readonly = true
	end,
})