diff --git a/docs/manual/configuring/custom-plugins.md b/docs/manual/configuring/custom-plugins.md index c58c497..76b32ea 100644 --- a/docs/manual/configuring/custom-plugins.md +++ b/docs/manual/configuring/custom-plugins.md @@ -20,6 +20,7 @@ custom plugins that you might have added to your configuration. ```{=include=} sections custom-plugins/configuring.md -custom-plugins/new-method.md -custom-plugins/old-method.md +custom-plugins/lazy-method.md +custom-plugins/non-lazy-method.md +custom-plugins/legacy-method.md ``` diff --git a/docs/manual/configuring/custom-plugins/configuring.md b/docs/manual/configuring/custom-plugins/configuring.md index 5e837ce..71ce9b8 100644 --- a/docs/manual/configuring/custom-plugins/configuring.md +++ b/docs/manual/configuring/custom-plugins/configuring.md @@ -1,12 +1,32 @@ # Configuring {#sec-configuring-plugins} -Just making the plugin to your Neovim configuration available might not always -be enough. In that case, you can write custom lua config using either -`config.vim.extraPlugins` (which has the `setup` field) or -`config.vim.luaConfigRC`. The first option uses an attribute set, which maps DAG -section names to a custom type, which has the fields `package`, `after`, -`setup`. They allow you to set the package of the plugin, the sections its setup -code should be after (note that the `extraPlugins` option has its own DAG +Just making the plugin to your Neovim configuration available might not always be enough. In that +case, you can write custom lua config using either `config.vim.lazy.plugins.*.setupOpts` +`config.vim.extraPlugins.*.setup` or `config.vim.luaConfigRC`. + +The first option uses an extended version of `lz.n`'s PluginSpec. `setupModule` and `setupOpt` can +be used if the plugin uses a `require('module').setup(...)` pattern. Otherwise, the `before` and +`after` hooks should do what you need. + +```nix +{ + config.vim.lazy.plugins = { + aerial-nvim = { + # ^^^^^^^^^ this name should match the package.pname or package.name + package = aerial-nvim; + + setupModule = "aerial"; + setupOpts = {option_name = false;}; + + after = "print('aerial loaded')"; + }; + }; +} +``` + +The second option uses an attribute set, which maps DAG section names to a custom type, which has +the fields `package`, `after`, `setup`. They allow you to set the package of the plugin, the +sections its setup code should be after (note that the `extraPlugins` option has its own DAG scope), and the its setup code respectively. For example: ```nix @@ -24,7 +44,7 @@ config.vim.extraPlugins = with pkgs.vimPlugins; { } ``` -The second option also uses an attribute set, but this one is resolved as a DAG +The third option also uses an attribute set, but this one is resolved as a DAG directly. The attribute names denote the section names, and the values lua code. For example: diff --git a/docs/manual/configuring/custom-plugins/lazy-method.md b/docs/manual/configuring/custom-plugins/lazy-method.md new file mode 100644 index 0000000..77b77d5 --- /dev/null +++ b/docs/manual/configuring/custom-plugins/lazy-method.md @@ -0,0 +1,40 @@ +# Lazy Method {#sec-lazy-method} + +As of version **0.7**, we exposed an API for configuring lazy-loaded plugins via +`lz.n` and `lzn-auto-require`. + +```nix +{ + config.vim.lazy.plugins = { + aerial = { + package = pkgs.vimPlugins.aerial-nvim; + setupModule = aerial; + setupOpts = { + option_name = true; + }; + after = '' + -- custom lua code to run after plugin is loaded + print('aerial loaded') + ''; + + # Explicitly mark plugin as lazy. You don't need this if you define one of + # the trigger "events" below + lazy = true; + + # load on command + cmd = ["AerialOpen"]; + + # load on event + event = ["BufEnter"]; + + # load on keymap + keys = [ + { + key = "a"; + action = ":AerialToggle"; + } + ]; + }; + }; +} +``` diff --git a/docs/manual/configuring/custom-plugins/old-method.md b/docs/manual/configuring/custom-plugins/legacy-method.md similarity index 96% rename from docs/manual/configuring/custom-plugins/old-method.md rename to docs/manual/configuring/custom-plugins/legacy-method.md index 3b9d090..0a6b377 100644 --- a/docs/manual/configuring/custom-plugins/old-method.md +++ b/docs/manual/configuring/custom-plugins/legacy-method.md @@ -1,4 +1,4 @@ -# Old Method {#sec-old-method} +# Legacy Method {#sec-legacy-method} Prior to version 0.5, the method of adding new plugins was adding the plugin package to `vim.startPlugins` and add its configuration as a DAG under one of diff --git a/docs/manual/configuring/custom-plugins/new-method.md b/docs/manual/configuring/custom-plugins/non-lazy-method.md similarity index 93% rename from docs/manual/configuring/custom-plugins/new-method.md rename to docs/manual/configuring/custom-plugins/non-lazy-method.md index 200ba5e..351af2e 100644 --- a/docs/manual/configuring/custom-plugins/new-method.md +++ b/docs/manual/configuring/custom-plugins/non-lazy-method.md @@ -1,4 +1,4 @@ -# New Method {#sec-new-method} +# Non-lazy Method {#sec-non-lazy-method} As of version **0.5**, we have a more extensive API for configuring plugins, under `vim.extraPlugins`. Instead of using DAGs exposed by the library, you may