mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-07 14:55:59 +01:00
Compare commits
7 commits
fad8b00a0a
...
275f78f683
Author | SHA1 | Date | |
---|---|---|---|
|
275f78f683 | ||
|
f43d3835f1 | ||
|
664d7154b4 | ||
|
42c60df933 | ||
|
b437242689 | ||
|
c6071b7da4 | ||
|
4d51981179 |
4 changed files with 32 additions and 19 deletions
|
@ -67,6 +67,10 @@
|
|||
mkLuaBinding binding.value action binding.description;
|
||||
|
||||
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
||||
|
||||
mkLznBinding = mode: lhs: rhs: desc: {
|
||||
inherit mode lhs rhs desc;
|
||||
};
|
||||
};
|
||||
in
|
||||
binds
|
||||
|
|
|
@ -138,14 +138,14 @@
|
|||
# lz.n options
|
||||
|
||||
before = mkOption {
|
||||
type = nullOr luaInline;
|
||||
description = "Code to run before plugin is loaded";
|
||||
type = nullOr str;
|
||||
description = "Lua code to run before plugin is loaded. This will be wrapped in a function.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
after = mkOption {
|
||||
type = nullOr luaInline;
|
||||
description = "Code to run after plugin is loaded";
|
||||
type = nullOr str;
|
||||
description = "Lua code to run after plugin is loaded. This will be wrapped in a function.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
|
@ -186,7 +186,12 @@
|
|||
keys = mkOption {
|
||||
description = "Lazy-load on key mapping";
|
||||
default = null;
|
||||
type = nullOr (oneOf [str (listOf lznKeysSpec) (listOf str)]); # TODO: support lz.n.KeysSpec
|
||||
type = nullOr (oneOf [str (listOf lznKeysSpec) (listOf str)]);
|
||||
example = ''
|
||||
keys = [
|
||||
{lhs = "<leader>s"; rhs = ":NvimTreeToggle<cr>"; desc = "Toggle NvimTree"}
|
||||
]
|
||||
'';
|
||||
};
|
||||
|
||||
# TODO: enabled, beforeAll, colorscheme, priority, load
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) filter;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) mkBinding;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.binds) mkLznBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.binds) pushDownDefault;
|
||||
|
||||
cfg = config.vim.filetree.nvimTree;
|
||||
|
@ -16,13 +16,6 @@
|
|||
inherit (self.options.vim.filetree.nvimTree) mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkBinding cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
||||
(mkBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
||||
(mkBinding cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
||||
(mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
||||
];
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>t" = "+NvimTree";
|
||||
};
|
||||
|
@ -34,6 +27,13 @@ in {
|
|||
setupModule = "nvim-tree";
|
||||
inherit (cfg) setupOpts;
|
||||
cmd = ["NvimTreeClipboard" "NvimTreeClose" "NvimTreeCollapse" "NvimTreeCollapseKeepBuffers" "NvimTreeFindFile" "NvimTreeFindFileToggle" "NvimTreeFocus" "NvimTreeHiTest" "NvimTreeOpen" "NvimTreeRefresh" "NvimTreeResize" "NvimTreeToggle"];
|
||||
|
||||
keys = filter ({lhs, ...}: lhs != null) [
|
||||
(mkLznBinding ["n"] cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
||||
(mkLznBinding ["n"] cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
||||
(mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
||||
(mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -49,6 +49,7 @@ in {
|
|||
|
||||
${
|
||||
optionalString cfg.openOnSetup ''
|
||||
require('lz.n').trigger_load("nvim-tree-lua")
|
||||
-- autostart behaviour
|
||||
-- Open on startup has been deprecated
|
||||
-- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON;
|
||||
inherit (builtins) toJSON typeOf head length;
|
||||
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;
|
||||
inherit (lib.nvim.dag) entryBefore;
|
||||
cfg = config.vim.lazy;
|
||||
|
||||
toLuzLznKeySpec = {
|
||||
|
@ -40,7 +40,10 @@
|
|||
${optionalString (spec.after != null) spec.after}
|
||||
end
|
||||
'';
|
||||
keys = map toLuzLznKeySpec spec.keys;
|
||||
keys =
|
||||
if typeOf spec.keys == "list" && length spec.keys > 0 && typeOf (head spec.keys) == "set"
|
||||
then map toLuzLznKeySpec spec.keys
|
||||
else spec.keys;
|
||||
};
|
||||
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
|
||||
in {
|
||||
|
@ -49,7 +52,7 @@ in {
|
|||
|
||||
optPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins;
|
||||
|
||||
luaConfigRC.lzn-load = entryAnywhere ''
|
||||
luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] ''
|
||||
require('lz.n').load(${toLuaObject lznSpecs})
|
||||
'';
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue