Skip to content

Commit

Permalink
docs: reword the example in the plugin overview
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Feb 19, 2024
1 parent fecd9bb commit c665c74
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/plugins/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ 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='hello world'` will run the `test` plugin with the arguments `hello` and `world` in a sync context.

To receive the arguments in the plugin, use `args`:

```lua
-- ~/.config/yazi/plugins/test.yazi/init.lua
return {
entry = function(self, args)
ya.err(args[1]) -- "foo"
ya.err(args[2]) -- "bar"
ya.err(args[1]) -- "hello"
ya.err(args[2]) -- "world"
end,
}
```
Expand All @@ -77,8 +77,8 @@ This is because `init.lua` is commonly used to initialize plugin configurations,
-- Initialize the bar plugin
-- Which needs `~/.config/yazi/plugins/bar.yazi/init.lua` to export a `setup` function
require("bar").setup {
key1 = "hello",
key2 = "world",
key1 = "value1",
key2 = "value2",
-- ...
}
```
Expand Down

0 comments on commit c665c74

Please sign in to comment.