Skip to content

Commit

Permalink
docs: add example of installing a flavor from a subdirectory (#318)
Browse files Browse the repository at this point in the history
For a real life example, see
mikavilpas/dotfiles@abbf921
  • Loading branch information
mikavilpas authored Aug 4, 2024
1 parent 962b6af commit b2f8d4b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions documentation/plugin-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ return {
require("yazi.plugin").build_flavor(plugin)
end,
},
{
-- example: include a flavor from a subdirectory. There are lots of flavors
-- available in https://github.com/yazi-rs/flavors
"yazi-rs/flavors",
name = "yazi-flavor-catppuccino-macchiato",
lazy = true,
build = function(spec)
require("yazi.plugin").build_flavor(spec, {
sub_dir = "catppuccin-macchiato.yazi",
})
end,
},
}
```

Expand Down
20 changes: 20 additions & 0 deletions lua/yazi/plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ function M.build_plugin(plugin, options)
return M.symlink(plugin, to)
end

--- Helper utility for compatibility with
--- [lazy.nvim](https://github.com/folke/lazy.nvim).
---
--- Example: installing a flavor from the
--- [yazi-rs/flavors](https://github.com/yazi-rs/flavors) repository:
---
--- ```lua
--- ---@type LazyPlugin
--- {
--- "yazi-rs/flavors",
--- name = "yazi-flavor-catppuccino-macchiato",
--- lazy = true,
--- build = function(spec)
--- require("yazi.plugin").build_flavor(spec, {
--- sub_dir = "catppuccin-macchiato.yazi",
--- })
--- end,
--- },
--- ```
---
---@param flavor YaziLazyNvimSpec
---@param options? { yazi_dir: string, sub_dir?: string }
function M.build_flavor(flavor, options)
Expand Down

0 comments on commit b2f8d4b

Please sign in to comment.