Skip to content

Commit

Permalink
docs: add example of how to receive arguments in a plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Feb 2, 2024
1 parent 300ff4a commit 5f9236a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion docs/plugins/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,21 @@ You can bind a `plugin` command to a specific key in your `keymap.toml` with:
| `--sync` | Run the plugin in a sync context. |
| `--args=[args]` | Shell-style arguments passed to the plugin. |

For example, `plugin test --sync --args="foo bar"` will run the `test` plugin with the arguments `foo` and `bar` in a sync context.
For example, `plugin test --sync --args='foo bar'` will run the `test` plugin with the arguments `foo` and `bar` in a sync context.

To receive the arguments in the plugin, use `{ ... }`:

```lua
-- ~/.config/yazi/plugins/test.yazi/init.lua
local args = { ... }

return {
entry = function()
ya.err(args[1]) -- "foo"
ya.err(args[2]) -- "bar"
end,
}
```

## Sync vs Async

Expand Down

0 comments on commit 5f9236a

Please sign in to comment.