nvim_runtime_lua

vim._core.help

Methods3

function M.escape_subject(word: string) -> pattern string

Transform a help tag query into a search pattern for find_tags().

This function converts user input from :help {subject} into a regex pattern that balances literal matching with wildcard support. Vim help tags can contain characters that have special meaning in regex (like *, ?, |), but we also want to support wildcard searches.

Examples: '' --> 'star' (literal match for the command help tag) 'buffer' --> 'buffer.' (wildcard: find all buffer-related tags) 'CTRL-W' --> stays as 'CTRL-W' (already in tag format) '^A' --> 'CTRL-A' (caret notation converted to tag format)

Parameters
wordstring

The help subject as entered by the user

Returns
patternstring

The escaped regex pattern to search for in tag files

function M.resolve_tag() -> resolved nil | string

For ":help!" (bang, no args): DWIM resolve a help tag from the cursor context. Gets <cWORD> at cursor, tries it first, then trims punctuation and dots until a valid help tag is found. Falls back to <cword> (keyword at cursor) before dot-trimming.

Returns
resolvednil | string

The resolved help tag, or nil if no match found

function M.local_additions() -> nil

Populates the |local-additions| section of a help buffer with references to locally-installed help files. These are help files outside of $VIMRUNTIME (typically from plugins) whose first line contains a tag (e.g. plugin-name.txt) and a short description.

For each help file found in 'runtimepath', the first line is extracted and added to the buffer as a reference (converting 'tag' to '|tag|'). If a translated version of a help file exists in the same language as the current buffer (e.g. 'plugin.nlx' alongside 'plugin.txt'), the translated version is preferred over the '.txt' file.