mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-09 14:45:58 +01:00
Compare commits
4 commits
e20034c86a
...
d50d6d0bd9
Author | SHA1 | Date | |
---|---|---|---|
|
d50d6d0bd9 | ||
|
5b8414a6a6 | ||
|
ca98d6d2c3 | ||
|
0638bcb60d |
4 changed files with 46 additions and 11 deletions
|
@ -65,10 +65,27 @@
|
|||
# type= str;
|
||||
# }
|
||||
|
||||
# Non-lz.n options
|
||||
|
||||
package = mkOption {
|
||||
type = pluginType;
|
||||
description = "Plugin package";
|
||||
};
|
||||
|
||||
setupModule = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Lua module to run setup function on.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
setupOpts = mkOption {
|
||||
type = submodule {freeformType = attrsOf anything;};
|
||||
description = "Options to pass to the setup function";
|
||||
default = {};
|
||||
};
|
||||
|
||||
# lz.n options
|
||||
|
||||
before = mkOption {
|
||||
type = nullOr luaInline;
|
||||
description = "Code to run before plugin is loaded";
|
||||
|
|
|
@ -88,10 +88,7 @@ inputs: {
|
|||
|
||||
# built (or "normalized") plugins that are modified
|
||||
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
||||
builtOptPlugins = map (package: {
|
||||
plugin = package;
|
||||
optional = true;
|
||||
}) (buildConfigPlugins vimOptions.optPlugins);
|
||||
builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins);
|
||||
|
||||
# additional Lua and Python3 packages, mapped to their respective functions
|
||||
# to conform to the format makeNeovimConfig expects. end user should
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
inherit (self.options.vim.filetree.nvimTree) mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["nvim-tree-lua"];
|
||||
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkBinding cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
||||
(mkBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
||||
|
@ -29,6 +27,17 @@ in {
|
|||
"<leader>t" = "+NvimTree";
|
||||
};
|
||||
|
||||
vim.lazy = {
|
||||
plugins = {
|
||||
nvim-tree-lua = {
|
||||
package = "nvim-tree-lua";
|
||||
setupModule = "nvim-tree";
|
||||
inherit (cfg) setupOpts;
|
||||
cmd = ["NvimTreeClipboard" "NvimTreeClose" "NvimTreeCollapse" "NvimTreeCollapseKeepBuffers" "NvimTreeFindFile" "NvimTreeFindFileToggle" "NvimTreeFocus" "NvimTreeHiTest" "NvimTreeOpen" "NvimTreeRefresh" "NvimTreeResize" "NvimTreeToggle"];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
vim.pluginRC.nvimtreelua = entryAnywhere ''
|
||||
${
|
||||
optionalString cfg.setupOpts.disable_netrw ''
|
||||
|
@ -38,8 +47,6 @@ in {
|
|||
''
|
||||
}
|
||||
|
||||
require'nvim-tree'.setup(${toLuaObject cfg.setupOpts})
|
||||
|
||||
${
|
||||
optionalString cfg.openOnSetup ''
|
||||
-- autostart behaviour
|
||||
|
|
|
@ -3,15 +3,29 @@
|
|||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
cfg = config.vim.lazy;
|
||||
|
||||
toLuaLznSpec = name: plugin:
|
||||
(removeAttrs plugin ["package"])
|
||||
// {"@1" = name;};
|
||||
toLuaLznSpec = name: spec:
|
||||
(removeAttrs spec ["package" "setupModule" "setupOpts"])
|
||||
// {
|
||||
"@1" = name;
|
||||
after = mkLuaInline ''
|
||||
function()
|
||||
${
|
||||
optionalString (spec.setupModule != null)
|
||||
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"
|
||||
}
|
||||
${optionalString (spec.after != null) spec.after}
|
||||
end
|
||||
'';
|
||||
};
|
||||
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
|
||||
in {
|
||||
config.vim = mkIf cfg.enable {
|
||||
|
|
Loading…
Reference in a new issue