Compare commits

...

12 commits

Author SHA1 Message Date
Ching Pei Yang
189967c8bd
Merge b59689dbd9 into da86e554a6 2024-10-28 02:15:25 +00:00
Ching Pei Yang
b59689dbd9
trouble: remove redundant import 2024-10-28 03:14:36 +01:00
Ching Pei Yang
536feac331
docs: update dag-entries 2024-10-28 03:14:36 +01:00
Ching Pei Yang
192340494b
refactor: re-order plugin and lz.n configs
lazy: make lzn-auto-require togglable
2024-10-28 03:14:36 +01:00
Ching Pei Yang
eb95f77e75
nvim-dap-ui: add setupOpts 2024-10-28 03:04:59 +01:00
Ching Pei Yang
12ed05bcfb
lazy: refactor common var 2024-10-28 03:04:58 +01:00
Ching Pei Yang
aac776f7a4
Update docs/manual/hacking/additional-plugins.md
Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com>
2024-10-28 02:31:47 +01:00
Ching Pei Yang
eff15d27b4
cmp: install sourcess via cmp.sourcePlugins 2024-10-26 01:51:58 +02:00
Soliprem
da86e554a6
Fix typo in otter setupOpts (#424)
* Revert "leap: changed default binds"

This reverts commit 92a7bfc4b8.

* Reapply "leap: changed default binds"

This reverts commit ede1d4437e2d8d1a6ff31b4dc855676c6e16df36.

* otter: fixed stupid typo

* otter: added changelog entry
2024-10-23 14:51:43 +00:00
Anthony
71e2ae1db4
languages/nix: change nixpkgs-fmt to nixfmt (rfc-style) (#383) 2024-10-22 21:44:18 +00:00
Anthony
e80520ddf3
languages: add biome support for formatting (#423) 2024-10-22 22:15:07 +02:00
Ching Pei Yang
0397d0722f
lazy: allow key mode of str type 2024-10-22 15:46:04 +02:00
21 changed files with 194 additions and 112 deletions

View file

@ -15,9 +15,11 @@ entries in nvf:
5. `theme` (this is simply placed before `pluginConfigs`, meaning that 5. `theme` (this is simply placed before `pluginConfigs`, meaning that
surrounding entries don't depend on it) - used to set up the theme, which has surrounding entries don't depend on it) - used to set up the theme, which has
to be done before other plugins to be done before other plugins
6. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option, 6. `lazyConfigs` - `lz.n` and `lzn-auto-require` configs. If `vim.lazy.enable`
is false, this will contain each plugin's config instead.
7. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option,
see the [Custom Plugins](/index.xhtml#ch-custom-plugins) page for adding your see the [Custom Plugins](/index.xhtml#ch-custom-plugins) page for adding your
own plugins) DAG, used to set up internal plugins own plugins) DAG, used to set up internal plugins
7. `extraPluginConfigs` - the result of `vim.extraPlugins`, which is not a 8. `extraPluginConfigs` - the result of `vim.extraPlugins`, which is not a
direct DAG, but is converted to, and resolved as one internally direct DAG, but is converted to, and resolved as one internally
8. `mappings` - the result of `vim.maps` 9. `mappings` - the result of `vim.maps`

View file

@ -162,7 +162,7 @@ in {
} }
``` ```
This results in the lua code: This results in the following lua code:
```lua ```lua
require('lz.n').load({ require('lz.n').load({
{ {

View file

@ -68,9 +68,19 @@ everyone.
As part of the autocompletion rewrite, modules that used to use a `type` option As part of the autocompletion rewrite, modules that used to use a `type` option
have been replaced by per-plugin modules instead. Since both modules only had have been replaced by per-plugin modules instead. Since both modules only had
one type, you can simply change one type, you can simply change
- `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*` - `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*`
- `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable` - `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable`
### `nixpkgs-fmt` removed in favor of `nixfmt` {#sec-nixpkgs-fmt-deprecation}
`nixpkgs-fmt` has been archived for a while, and it's finally being removed in
favor of nixfmt (more information can be found
[here](https://github.com/nix-community/nixpkgs-fmt?tab=readme-ov-file#nixpkgs-fmt---nix-code-formatter-for-nixpkgs).
To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
`nixfmt`.
## Changelog {#sec-release-0.7-changelog} ## Changelog {#sec-release-0.7-changelog}
[ItsSorae](https://github.com/ItsSorae): [ItsSorae](https://github.com/ItsSorae):
@ -224,8 +234,7 @@ one type, you can simply change
`vim.languages.ts.extensions.ts-error-translator` to aid with Typescript `vim.languages.ts.extensions.ts-error-translator` to aid with Typescript
development. development.
- Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available - Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available under `vim.filetree.neo-tree`, similar to nvimtree.
under `vim.filetree.neo-tree`, similar to nvimtree.
- Add `nvf-print-config` & `nvf-print-config-path` helper scripts to Neovim - Add `nvf-print-config` & `nvf-print-config-path` helper scripts to Neovim
closure. Both of those scripts have been automatically added to your PATH upon closure. Both of those scripts have been automatically added to your PATH upon
@ -274,6 +283,7 @@ one type, you can simply change
- Add LSP and Treesitter support for R under `vim.languages.R`. - Add LSP and Treesitter support for R under `vim.languages.R`.
- Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with - Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with
ccc ccc
- Fixed typo in Otter's setupOpts
- Add Neorg support under `vim.notes.neorg` - Add Neorg support under `vim.notes.neorg`
- Add LSP, diagnostics, formatter and Treesitter support for Kotlin under - Add LSP, diagnostics, formatter and Treesitter support for Kotlin under
`vim.languages.kotlin` `vim.languages.kotlin`
@ -290,3 +300,7 @@ one type, you can simply change
- Add LSP support for Scala via - Add LSP support for Scala via
[nvim-metals](https://github.com/scalameta/nvim-metals) [nvim-metals](https://github.com/scalameta/nvim-metals)
[nezia1](https://github.com/nezia1):
- Add [biome](https://github.com/biomejs/biome) support for Typescript, CSS and Svelte. Enable them via [](#opt-vim.languages.ts.format.type), [](#opt-vim.languages.css.format.type) and [](#opt-vim.languages.svelte.format.type) respectively.
- Replace [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) with [nixfmt](https://github.com/NixOS/nixfmt) (nixfmt-rfc-style).

View file

@ -56,22 +56,13 @@ in {
(mkLuaKeymap ["i"] cfg.mappings.suggestion.prev "function() require('copilot.suggestion').prev() end" "[copilot] previous suggestion" {}) (mkLuaKeymap ["i"] cfg.mappings.suggestion.prev "function() require('copilot.suggestion').prev() end" "[copilot] previous suggestion" {})
]; ];
}; };
copilot-cmp = mkIf cfg.cmp.enable {
package = "copilot-cmp";
lazy = true;
after = optionalString config.vim.lazy.enable ''
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/copilot-cmp')
require("rtp_nvim").source_after_plugin_dir(path)
require("lz.n").trigger_load("copilot-lua")
'';
}; };
nvim-cmp.after = mkIf cfg.cmp.enable "require('lz.n').trigger_load('copilot-cmp')"; autocomplete.nvim-cmp = {
sources = {copilot = "[Copilot]";};
sourcePlugins = ["copilot-cmp"];
}; };
autocomplete.nvim-cmp.sources = {copilot = "[Copilot]";};
# Disable plugin handled keymaps. # Disable plugin handled keymaps.
# Setting it here so that it doesn't show up in user docs # Setting it here so that it doesn't show up in user docs
assistant.copilot.setupOpts = { assistant.copilot.setupOpts = {

View file

@ -3,38 +3,40 @@
config, config,
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf mkMerge;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
inherit (builtins) attrNames; inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (builtins) attrNames typeOf tryEval concatStringsSep;
cfg = config.vim.autocomplete.nvim-cmp; cfg = config.vim.autocomplete.nvim-cmp;
luasnipEnable = config.vim.snippets.luasnip.enable; luasnipEnable = config.vim.snippets.luasnip.enable;
getPluginName = plugin:
if typeOf plugin == "string"
then plugin
else if (plugin ? pname && (tryEval plugin.pname).success)
then plugin.pname
else plugin.name;
inherit (cfg) mappings; inherit (cfg) mappings;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
startPlugins = ["rtp-nvim"]; startPlugins = ["rtp-nvim"];
lazy.plugins = { lazy.plugins = mkMerge [
# cmp sources are loaded via lzn-auto-require as long as it is defined (mapListToAttrs (package: {
# in cmp sources name = getPluginName package;
cmp-buffer = { value = {
package = "cmp-buffer"; inherit package;
lazy = true; lazy = true;
after = '' after = ''
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/cmp-buffer') local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/${getPluginName package}')
require("rtp_nvim").source_after_plugin_dir(path)
'';
};
cmp-path = {
package = "cmp-path";
lazy = true;
after = ''
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/cmp-path')
require("rtp_nvim").source_after_plugin_dir(path) require("rtp_nvim").source_after_plugin_dir(path)
''; '';
}; };
})
cfg.sourcePlugins)
{
nvim-cmp = { nvim-cmp = {
package = "nvim-cmp"; package = "nvim-cmp";
after = '' after = ''
@ -43,16 +45,15 @@ in {
local cmp = require("cmp") local cmp = require("cmp")
cmp.setup(${toLuaObject cfg.setupOpts}) cmp.setup(${toLuaObject cfg.setupOpts})
${ ${concatStringsSep "\n" (map
optionalString config.vim.lazy.enable '' (package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
require("lz.n").trigger_load("cmp-buffer") cfg.sourcePlugins)}
''
}
''; '';
event = ["InsertEnter" "CmdlineEnter"]; event = ["InsertEnter" "CmdlineEnter"];
}; };
}; }
];
autocomplete.nvim-cmp = { autocomplete.nvim-cmp = {
sources = { sources = {
@ -61,6 +62,8 @@ in {
path = "[Path]"; path = "[Path]";
}; };
sourcePlugins = ["cmp-buffer" "cmp-path"];
setupOpts = { setupOpts = {
sources = map (s: {name = s;}) (attrNames cfg.sources); sources = map (s: {name = s;}) (attrNames cfg.sources);

View file

@ -4,10 +4,10 @@
... ...
}: let }: let
inherit (lib.options) mkEnableOption mkOption literalExpression literalMD; inherit (lib.options) mkEnableOption mkOption literalExpression literalMD;
inherit (lib.types) str attrsOf nullOr either; inherit (lib.types) str attrsOf nullOr either listOf;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf; inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf pluginType;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
inherit (builtins) isString; inherit (builtins) isString;
@ -99,5 +99,11 @@ in {
} }
''; '';
}; };
sourcePlugins = mkOption {
type = listOf pluginType;
default = [];
description = "List of source plugins used by nvim-cmp.";
};
}; };
} }

View file

@ -57,7 +57,7 @@ in {
lazy.plugins.nvim-dap-ui = { lazy.plugins.nvim-dap-ui = {
package = "nvim-dap-ui"; package = "nvim-dap-ui";
setupModule = "dapui"; setupModule = "dapui";
setupOpts = {}; inherit (cfg.ui) setupOpts;
keys = [ keys = [
(mkSetLuaLznBinding mappings.toggleDapUI "function() require('dapui').toggle() end") (mkSetLuaLznBinding mappings.toggleDapUI "function() require('dapui').toggle() end")

View file

@ -2,12 +2,16 @@
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) bool attrsOf str; inherit (lib.types) bool attrsOf str;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
options.vim.debugger.nvim-dap = { options.vim.debugger.nvim-dap = {
enable = mkEnableOption "debugging via nvim-dap"; enable = mkEnableOption "debugging via nvim-dap";
ui = { ui = {
enable = mkEnableOption "UI extension for nvim-dap"; enable = mkEnableOption "UI extension for nvim-dap";
setupOpts = mkPluginSetupOption "nvim-dap-ui" {};
autoStart = mkOption { autoStart = mkOption {
type = bool; type = bool;
default = true; default = true;

View file

@ -63,6 +63,18 @@
) )
''; '';
}; };
biome = {
package = pkgs.biome;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.biome.with({
command = "${cfg.format.package}/bin/biome",
})
)
'';
};
}; };
in { in {
options.vim.languages.css = { options.vim.languages.css = {

View file

@ -5,6 +5,7 @@
... ...
}: let }: let
inherit (builtins) attrNames; inherit (builtins) attrNames;
inherit (lib) concatStringsSep;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList; inherit (lib.lists) isList;
@ -62,10 +63,10 @@
command = {"${cfg.format.package}/bin/alejandra", "--quiet"}, command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
}, },
''} ''}
${optionalString (cfg.format.type == "nixpkgs-fmt") ${optionalString (cfg.format.type == "nixfmt")
'' ''
formatting = { formatting = {
command = {"${cfg.format.package}/bin/nixpkgs-fmt"}, command = {"${cfg.format.package}/bin/nixfmt"},
}, },
''} ''}
}, },
@ -90,10 +91,19 @@
''; '';
}; };
nixpkgs-fmt = { nixfmt = {
package = pkgs.nixpkgs-fmt; package = pkgs.nixfmt-rfc-style;
# Never need to use null-ls for nixpkgs-fmt nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.nixfmt.with({
command = "${cfg.format.package}/bin/nixfmt"
})
)
'';
}; };
nixpkgs-fmt = null; # removed
}; };
defaultDiagnosticsProvider = ["statix" "deadnix"]; defaultDiagnosticsProvider = ["statix" "deadnix"];
@ -175,6 +185,12 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
{ {
assertions = [
{
assertion = cfg.format.type != "nixpkgs-fmt";
message = "nixpkgs-fmt has been archived upstream. Please use one of the following instead: ${concatStringsSep ", " (attrNames formats)}";
}
];
vim.pluginRC.nix = '' vim.pluginRC.nix = ''
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = "nix", pattern = "nix",

View file

@ -48,6 +48,18 @@
) )
''; '';
}; };
biome = {
package = pkgs.biome;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.biome.with({
command = "${cfg.format.package}/bin/biome",
})
)
'';
};
}; };
# TODO: specify packages # TODO: specify packages

View file

@ -95,6 +95,18 @@
) )
''; '';
}; };
biome = {
package = pkgs.biome;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.biome.with({
command = "${cfg.format.package}/bin/biome",
})
)
'';
};
}; };
# TODO: specify packages # TODO: specify packages

View file

@ -5,7 +5,6 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.lists) optional;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString; inherit (lib.trivial) boolToString;
inherit (lib.nvim.binds) addDescriptionsToMappings; inherit (lib.nvim.binds) addDescriptionsToMappings;
@ -23,19 +22,10 @@
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
lazy.plugins = { autocomplete.nvim-cmp = {
cmp-nvim-lsp = { sources = {nvim_lsp = "[LSP]";};
package = "cmp-nvim-lsp"; sourcePlugins = ["cmp-nvim-lsp"];
lazy = true;
after = ''
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/cmp-treesitter')
require("rtp_nvim").source_after_plugin_dir(path)
'';
}; };
nvim-cmp.after = mkIf usingNvimCmp "require('lz.n').trigger_load('cmp-nvim-lsp')";
};
autocomplete.nvim-cmp.sources = {nvim_lsp = "[LSP]";};
pluginRC.lsp-setup = '' pluginRC.lsp-setup = ''
vim.g.formatsave = ${boolToString cfg.formatOnSave}; vim.g.formatsave = ${boolToString cfg.formatOnSave};
@ -126,7 +116,7 @@ in {
end end
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
${optionalString usingNvimCmp "capabilities = require('cmp_nvim_lsp').default_capabilities()"} -- ${optionalString usingNvimCmp "capabilities = require('cmp_nvim_lsp').default_capabilities()"}
''; '';
}; };
}; };

View file

@ -32,7 +32,7 @@ in {
pluginRC.otter-nvim = entryAnywhere '' pluginRC.otter-nvim = entryAnywhere ''
-- Enable otter diagnostics viewer -- Enable otter diagnostics viewer
require("otter").setup({${toLuaObject cfg.otter-nvim.setupOpts}}) require("otter").setup(${toLuaObject cfg.otter-nvim.setupOpts})
''; '';
}; };
}; };

View file

@ -1,6 +1,7 @@
{ {
config, config,
lib, lib,
options,
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
@ -8,8 +9,7 @@
cfg = config.vim.lsp; cfg = config.vim.lsp;
self = import ./trouble.nix {inherit lib;}; mappingDefinitions = options.vim.lsp.trouble.mappings;
mappingDefinitions = self.options.vim.lsp.trouble.mappings;
mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions; mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions;
in { in {
config = mkIf (cfg.enable && cfg.trouble.enable) { config = mkIf (cfg.enable && cfg.trouble.enable) {

View file

@ -4,7 +4,6 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString;
cfg = config.vim.snippets.luasnip; cfg = config.vim.snippets.luasnip;
in { in {
@ -16,20 +15,12 @@ in {
lazy = true; lazy = true;
after = cfg.loaders; after = cfg.loaders;
}; };
cmp-luasnip = mkIf config.vim.autocomplete.nvim-cmp.enable {
package = "cmp-luasnip";
lazy = true;
after = ''
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/cmp-luasnip')
require("rtp_nvim").source_after_plugin_dir(path)
'';
};
nvim-cmp.after = optionalString config.vim.lazy.enable ''
require("lz.n").trigger_load("cmp-luasnip")
'';
}; };
startPlugins = cfg.providers; startPlugins = cfg.providers;
autocomplete.nvim-cmp.sources = {luasnip = "[LuaSnip]";}; autocomplete.nvim-cmp = {
sources = {luasnip = "[LuaSnip]";};
sourcePlugins = ["cmp-luasnip"];
};
}; };
}; };
} }

View file

@ -5,7 +5,7 @@
... ...
}: let }: let
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) optional optionals; inherit (lib.lists) optionals;
inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings; inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.dag) entryBefore entryAfter; inherit (lib.nvim.dag) entryBefore entryAfter;
@ -32,7 +32,11 @@ in {
nvim-cmp.after = mkIf usingNvimCmp "require('lz.n').trigger_load('cmp-treesitter')"; nvim-cmp.after = mkIf usingNvimCmp "require('lz.n').trigger_load('cmp-treesitter')";
}; };
autocomplete.nvim-cmp.sources = {treesitter = "[Treesitter]";}; autocomplete.nvim-cmp = {
sources = {treesitter = "[Treesitter]";};
sourcePlugins = ["cmp-treesitter"];
};
treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars; treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars;
maps = { maps = {

View file

@ -1,6 +1,6 @@
{ {
options,
config, config,
pkgs,
lib, lib,
... ...
}: let }: let
@ -11,8 +11,7 @@
inherit (lib.nvim.binds) pushDownDefault mkSetLznBinding; inherit (lib.nvim.binds) pushDownDefault mkSetLznBinding;
cfg = config.vim.telescope; cfg = config.vim.telescope;
self = import ./telescope.nix {inherit pkgs lib;}; mappingDefinitions = options.vim.telescope.mappings;
mappingDefinitions = self.options.vim.telescope.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
in { in {

View file

@ -58,6 +58,8 @@
}; };
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins; lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
pluginPackages = mapAttrsToList (_: plugin: plugin.package) cfg.plugins;
specToNotLazyConfig = _: spec: '' specToNotLazyConfig = _: spec: ''
do do
${optionalString (spec.before != null) spec.before} ${optionalString (spec.before != null) spec.before}
@ -74,25 +76,32 @@
then [] then []
else [spec.keys]; else [spec.keys];
notLazyConfig = concatStringsSep "\n" (mapAttrsToList specToNotLazyConfig cfg.plugins); notLazyConfig =
concatStringsSep "\n"
(mapAttrsToList specToNotLazyConfig cfg.plugins);
beforeAllJoined =
concatStringsSep "\n"
(filter (x: x != null) (mapAttrsToList (_: spec: spec.beforeAll) cfg.plugins));
in { in {
config.vim = mkMerge [ config.vim = mkMerge [
(mkIf cfg.enable { (mkIf cfg.enable {
startPlugins = ["lz-n" "lzn-auto-require"]; startPlugins = ["lz-n" "lzn-auto-require"];
optPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins; optPlugins = pluginPackages;
luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] '' lazy.builtLazyConfig = ''
require('lz.n').load(${toLuaObject lznSpecs}) require('lz.n').load(${toLuaObject lznSpecs})
${optionalString cfg.enableLznAutoRequire "require('lzn-auto-require').enable()"}
''; '';
}) })
(mkIf (!cfg.enable) { (mkIf (!cfg.enable) {
startPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins; startPlugins = pluginPackages;
luaConfigPre = lazy.builtLazyConfig = ''
concatStringsSep "\n" ${beforeAllJoined}
(filter (x: x != null) (mapAttrsToList (_: spec: spec.beforeAll) cfg.plugins)); ${notLazyConfig}
luaConfigRC.unlazy = entryAfter ["pluginConfigs"] notLazyConfig; '';
keymaps = concatLists (mapAttrsToList specToKeymaps cfg.plugins); keymaps = concatLists (mapAttrsToList specToKeymaps cfg.plugins);
}) })
]; ];

View file

@ -35,7 +35,7 @@
mode = mkOption { mode = mkOption {
description = "Modes to bind in"; description = "Modes to bind in";
type = listOf str; type = either str (listOf str);
default = ["n" "x" "s" "o"]; default = ["n" "x" "s" "o"];
}; };
@ -181,7 +181,7 @@
}; };
in { in {
options.vim.lazy = { options.vim.lazy = {
enable = mkEnableOption "plugin lazy-loading" // {default = true;}; enable = mkEnableOption "plugin lazy-loading via lz.n and lzn-auto-require" // {default = true;};
loader = mkOption { loader = mkOption {
description = "Lazy loader to use"; description = "Lazy loader to use";
type = enum ["lz.n"]; type = enum ["lz.n"];
@ -215,5 +215,23 @@ in {
} }
''; '';
}; };
enableLznAutoRequire = mkOption {
description = ''
Enable lzn-auto-require. Since builtin plugins rely on this, only turn
off for debugging.
'';
type = bool;
default = true;
};
builtLazyConfig = mkOption {
internal = true;
type = lines;
description = ''
The built config for lz.n, or if `vim.lazy.enable` is false, the
individual plugin configs.
'';
};
}; };
} }

View file

@ -52,11 +52,10 @@ in {
optionsScript = entryAfter ["basic"] (concatLines optionsScript); optionsScript = entryAfter ["basic"] (concatLines optionsScript);
# Basic # Basic
pluginConfigs = entryAfter ["optionsScript"] pluginConfigs; lazyConfigs = entryAfter ["optionsScript"] cfg.lazy.builtLazyConfig;
pluginConfigs = entryAfter ["lazyConfigs"] pluginConfigs;
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs; extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
mappings = entryAfter ["extraPluginConfigs"] keymaps; mappings = entryAfter ["extraPluginConfigs"] keymaps;
# FIXME: put this somewhere less stupid
footer = entryAfter ["mappings"] (optionalString config.vim.lazy.enable "require('lzn-auto-require').enable()");
}; };
builtLuaConfigRC = let builtLuaConfigRC = let