From 75bca38fb1edab8623cc899215cd19d2937af653 Mon Sep 17 00:00:00 2001 From: LeMarsu Date: Thu, 30 May 2024 02:15:37 +0200 Subject: [PATCH] feat: add `Sloth load` subcommand The command allows you to load plugins --- README.md | 28 ++++++++++++++++++---------- lua/sloth-flake/init.lua | 10 ++++++++++ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e16ceae..54fc845 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ A [neovim] plugin and configuration management plugin, highly inspired by [lazy] - [Using your own `init.lua`](#using-your-own-initlua) - [`:Sloth` command](#sloth-command) - [`list` subcommand](#list-subcommand) + - [`load` subcommand](#load-subcommand) - [API](#api) @@ -45,6 +46,7 @@ A [neovim] plugin and configuration management plugin, highly inspired by [lazy] - [ ] on event - [ ] on keybinding - [X] load plugins in order (via plugin `dependencies` property) +- [X] Have a `:Sloth` command to load or query your plugins - [ ] Generate spell files on build (maybe) ## SemVer @@ -205,23 +207,29 @@ sloth_flake.setup { #### `:Sloth` command `sloth-flake` give a `Sloth` command that you can call to gather some -informations about your plugins. +informations about or load your plugins. -```vim -Sloth [command] [args...] -``` +Usage: `Sloth [command] [args...]` If no arguments are given, the `Sloth` command will call the `list` subcommand. ##### `list` subcommand -```vim -Sloth list [filter] -``` +Summary: List plugins. + +Usage: `Sloth list [filter]` + - `filter`: filter the list of plugins. - - `"all"`: list all declared plugins. Same as if no filter is given. - - `"loaded"`: list only loaded plugins. - - `"notloaded"`: list only not loaded plugins. + - `all`: list all declared plugins. Same as if no filter is given. + - `loaded`: list only loaded plugins. + - `notloaded`: list only not loaded plugins. + +##### `load` subcommand + +Summary: Load lazy plugins. + +Usage: `Sloth load [plugin [...]]` +- `plugin`: a plugin to load #### API diff --git a/lua/sloth-flake/init.lua b/lua/sloth-flake/init.lua index f25540f..45a196e 100644 --- a/lua/sloth-flake/init.lua +++ b/lua/sloth-flake/init.lua @@ -221,6 +221,16 @@ local commands = { print(string.format("- %s", dep)) end end, + + load = function(plugins) + if #plugins == 0 then + vim_error("You should at least give a plugin to load!") + return + end + for _, plugin in ipairs(plugins) do + M.load(plugin) + end + end } function sloth_cmd(param)