Skip to content

Commit

Permalink
chore(build): auto-generate vimdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
astronvimbot committed Sep 19, 2024
1 parent e7d7a35 commit 97de158
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
28 changes: 28 additions & 0 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,34 @@ function astrocore.on_load(plugins: string|string[], load_op: string|fun()|strin

*param* `load_op` — the function to execute when the plugin is loaded, a plugin name to load, or a list of plugin names to load

### patch_func


```lua
function astrocore.patch_func(orig?: function, override: fun(orig: function, ...any):...unknown)
-> the: function
```

Monkey patch into an existing function

Example from `:h vim.paste()`
```lua
local patch_func = require("astrocore").patch_func
vim.paste = patch_func(vim.paste, function(orig, lines, phase)
for i, line in ipairs(lines) do
-- Scrub ANSI color codes from paste input.
lines[i] = line:gsub('\27%[[0-9;mK]+', '')
end
return orig(lines, phase)
end)
```

*param* `orig` — the original function to override, if `nil` is provided then an empty function is passed

*param* `override` — the override function

*return* `the` — new function with the patch applied

### plugin_opts


Expand Down
23 changes: 23 additions & 0 deletions doc/astrocore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,29 @@ _param_ `load_op` — the function to execute when the plugin is loaded, a
plugin name to load, or a list of plugin names to load


PATCH_FUNC ~

>lua
function astrocore.patch_func(orig?: function, override: fun(orig: function, ...any):...unknown)
-> the: function
<

Monkey patch into an existing function

Example from |vim.paste()| `lua local patch_func =
require("astrocore").patch_func vim.paste = patch_func(vim.paste,
function(orig, lines, phase) for i, line in ipairs(lines) do -- Scrub ANSI
color codes from paste input. lines[i] = line:gsub('\27%[[0-9;mK]+', '') end
return orig(lines, phase) end)`

_param_ `orig` — the original function to override, if `nil` is provided then
an empty function is passed

_param_ `override` — the override function

_return_ `the` — new function with the patch applied


PLUGIN_OPTS ~

>lua
Expand Down

0 comments on commit 97de158

Please sign in to comment.