Compare commits

..

54 commits

Author SHA1 Message Date
Pei Yang Ching
db76167e95 lazy: move type definition out of lib 2024-08-24 16:00:11 +02:00
Pei Yang Ching
236f3e84a6 flake: update lz.n and lzn-auto-require 2024-08-24 15:16:53 +02:00
Pei Yang Ching
299639065c lazy: use listOf plugins instead of attr 2024-08-24 15:15:31 +02:00
Pei Yang Ching
cb99286189 lib.binds: update lzn util functions 2024-08-24 15:03:34 +02:00
Pei Yang Ching
945b9e6500 lazy: use similar API to nvf keymaps 2024-08-24 15:03:34 +02:00
Ching Pei Yang
05156b4e1b flake: update lzn-auto-require 2024-08-24 15:03:34 +02:00
Ching Pei Yang
c992135d11 lz.n: add missing PluginSpec options 2024-08-24 15:03:34 +02:00
Ching Pei Yang
d64b4b827a add TODO 2024-08-24 15:03:34 +02:00
Ching Pei Yang
9c1c2056f2 lib: allow luaInline in lz.n map action 2024-08-24 15:03:34 +02:00
Ching Pei Yang
5f4dfb44e2 flake: update lzn-auto-require 2024-08-24 15:03:34 +02:00
Ching Pei Yang
7c8221a6d5 fixup! wrapper: use lzn-auto-require loader 2024-08-24 15:03:34 +02:00
Ching Pei Yang
608f8e6536 lib: add mkSetLuaBinding 2024-08-24 15:03:34 +02:00
Ching Pei Yang
99b1ce252c wrapper: use lzn-auto-require loader 2024-08-24 15:03:34 +02:00
Ching Pei Yang
0d17a40ae9 flake: add plugin lzn-auto-require 2024-08-24 15:03:34 +02:00
Ching Pei Yang
118f33f1fc lz.n: generate less code 2024-08-24 15:03:34 +02:00
Ching Pei Yang
5002e25c1d lz.n: wrap lua code in function 2024-08-24 15:03:34 +02:00
Ching Pei Yang
7c28651f51 lib: add mkLznBinding 2024-08-24 15:03:34 +02:00
Ching Pei Yang
c7bd41fe94 nvim-tree: load nvim-tree if openOnSetup 2024-08-24 15:03:34 +02:00
Ching Pei Yang
a8b0e8e073 nvim-tree: move to lz.n keymaps 2024-08-24 15:03:34 +02:00
Ching Pei Yang
eef3e773bc lib: add mkLznBinding 2024-08-24 15:00:56 +02:00
Ching Pei Yang
a46502b939 lib: change lz.n spec "inlineLua" types to str 2024-08-24 15:00:56 +02:00
Ching Pei Yang
0dae5a0ffe lz.n: missing type check 2024-08-24 15:00:56 +02:00
Ching Pei Yang
1226269143 lib: add lznKeySpec example 2024-08-24 15:00:56 +02:00
Ching Pei Yang
99bbdad2e1 lz.n: process key maps 2024-08-24 15:00:56 +02:00
Ching Pei Yang
0e3cc7f53c remove unused 2024-08-24 15:00:56 +02:00
Pei Yang Ching
024732e8b2 lib: fix lz.n map type 2024-08-24 15:00:56 +02:00
Ching Pei Yang
96244e0a2c lib: add lz.n KeySpec 2024-08-24 15:00:56 +02:00
Pei Yang Ching
8bbb9ff1b0 nvim-tree: use lazy 2024-08-24 15:00:56 +02:00
Pei Yang Ching
f68472a78b lazy: add setupOpts support 2024-08-24 15:00:56 +02:00
Pei Yang Ching
c0750e74c5 fix: broken optPlugins 2024-08-24 15:00:56 +02:00
Pei Yang Ching
d6c1424d12 switch to other hacky array-table syntax 2024-08-24 15:00:56 +02:00
Pei Yang Ching
e062e93d2f wrap lazy init code in function 2024-08-24 15:00:56 +02:00
Ching Pei Yang
35bb2157cf flake: update lz.n 2024-08-24 15:00:56 +02:00
Ching Pei Yang
bb49f63e71 lib: add lznPluginTableType 2024-08-24 15:00:56 +02:00
Ching Pei Yang
9817e31e10 lib: export lznPluginType 2024-08-24 15:00:56 +02:00
Ching Pei Yang
bdc1c83826 lz.n: load lz.n 2024-08-24 15:00:56 +02:00
Ching Pei Yang
d3c4eaa693 lz.n: add basic lazy.plugins option 2024-08-24 15:00:56 +02:00
Pei Yang Ching
d70951305d lib: add basic lz.n plugin spec type 2024-08-24 15:00:56 +02:00
Pei Yang Ching
caff0029a2 add lazy module skeleton 2024-08-24 15:00:56 +02:00
Pei Yang Ching
0ece3311c2 flake: add lz.n plugin 2024-08-24 15:00:56 +02:00
Pei Yang Ching
0f17254bb6 maps: fix missing description 2024-08-24 15:00:56 +02:00
Ching Pei Yang
6a5f8f68ab remove unused 2024-08-24 15:00:56 +02:00
Pei Yang Ching
12a01936cd cleanup unused import 2024-08-24 15:00:56 +02:00
Pei Yang Ching
e5a2c58f26 remove unneeded pipe 2024-08-24 15:00:56 +02:00
Pei Yang Ching
a6cfdb10fb keymaps: update example 2024-08-24 15:00:56 +02:00
Pei Yang Ching
afc7092d63 keymaps: use listOf mapOption instead 2024-08-24 15:00:56 +02:00
Pei Yang Ching
93c6f6e7f4 maps: fix bad mode names 2024-08-24 15:00:56 +02:00
Pei Yang Ching
cce4195148 maps: allow same key on multiple mode 2024-08-24 15:00:56 +02:00
Ching Pei Yang
84c2a32054 fix: map descriptions (#358)
* remove unused

* maps: fix missing description
2024-08-24 15:00:56 +02:00
Ching Pei Yang
3db8b47027 Re-add old maps API (#356)
* wrapper: fix wrong import source

* wrapper: fix typo

* Revert "lib/binds: improve code, adjust functions to new api"

This reverts commit 6cb57e1d26.

* mappings: re-add legacy vim.maps API

* mappings: fix wrong submodule syntax

* docs: fix missing section id
2024-08-24 15:00:56 +02:00
diniamo
2dd1be0b45 vim.maps rewrite (#352)
* feat: rewrite vim.maps

* modules/mappings: enable silent by default

* docs: add entry for vim.maps rewrite

* lib/binds: improve code, adjust functions to new api
2024-08-24 14:35:50 +02:00
Gerg-L
fc2e5998e7
flake.lock: Update (#363)
Flake lock file updates:

• Updated input 'mnw':
    'github:Gerg-L/mnw/e06b48c51291cc1df08adcd34a8796f86d5b235e?narHash=sha256-qimVBdes%2B2gNRRcyFoIUA1RyOKV0Ee40hUaVVf7ZsNs%3D' (2024-08-22)
  → 'github:Gerg-L/mnw/c261925dbbf02f523af0e8add844df64fddf0359?narHash=sha256-SMgnviF6ofBPbyV3%2BrljPGcX0Hn9HBOhgXE10Cyjaic%3D' (2024-08-23)
2024-08-24 10:47:26 +00:00
Gerg-L
25fe1c4625
flake.lock: Update (#362)
Some checks failed
Set up binary cache / cachix (default) (push) Has been cancelled
Set up binary cache / cachix (maximal) (push) Has been cancelled
Set up binary cache / cachix (nix) (push) Has been cancelled
Validate flake & check formatting / Validate Flake (push) Has been cancelled
Validate flake & check formatting / Formatting via Alejandra (push) Has been cancelled
Flake lock file updates:

• Updated input 'mnw':
    'github:Gerg-L/mnw/c7b289f3f5a31b6e744be37d83fc231816621231?narHash=sha256-YF//iMALbrd2Ni9aju7w8NniH16Qz6RFTRD6md5UkDc%3D' (2024-07-28)
  → 'github:Gerg-L/mnw/e06b48c51291cc1df08adcd34a8796f86d5b235e?narHash=sha256-qimVBdes%2B2gNRRcyFoIUA1RyOKV0Ee40hUaVVf7ZsNs%3D' (2024-08-22)
2024-08-22 23:42:51 +00:00
fd90cf7fd5
flake: revert 37dbdbb06d4d99297ee94adf6733893242b979c7
Some checks failed
Set up binary cache / cachix (default) (push) Has been cancelled
Set up binary cache / cachix (maximal) (push) Has been cancelled
Set up binary cache / cachix (nix) (push) Has been cancelled
Validate flake & check formatting / Validate Flake (push) Has been cancelled
Validate flake & check formatting / Formatting via Alejandra (push) Has been cancelled
The bald frog balded again...
2024-08-12 19:26:09 +03:00
15 changed files with 116 additions and 496 deletions

View file

@ -69,11 +69,11 @@
},
"mnw": {
"locked": {
"lastModified": 1723419050,
"narHash": "sha256-Eb8jBUgHwpte+bGsqeXNbKMBfZaDB7RiPQwyb1vzJK8=",
"lastModified": 1724456641,
"narHash": "sha256-SMgnviF6ofBPbyV3+rljPGcX0Hn9HBOhgXE10Cyjaic=",
"owner": "Gerg-L",
"repo": "mnw",
"rev": "e625f5965567f16102bc52897c7600dcde53c6c3",
"rev": "c261925dbbf02f523af0e8add844df64fddf0359",
"type": "github"
},
"original": {
@ -843,38 +843,6 @@
"type": "github"
}
},
"plugin-lz-n": {
"flake": false,
"locked": {
"lastModified": 1719989949,
"narHash": "sha256-oHwmlLgdJJDz5+gs1KLAa2MHQAadM/JYmHGfep9yl28=",
"owner": "nvim-neorocks",
"repo": "lz.n",
"rev": "4c790ba2c3789f580aa019712bbe3112f85e73a0",
"type": "github"
},
"original": {
"owner": "nvim-neorocks",
"repo": "lz.n",
"type": "github"
}
},
"plugin-lzn-auto-require": {
"flake": false,
"locked": {
"lastModified": 1723928740,
"narHash": "sha256-CMWy+btqUaXUWSO4jZYDfBcNiYMFyRb8jtIdi072WP8=",
"owner": "horriblename",
"repo": "lzn-auto-require",
"rev": "1b9f6527e32bf196ce239f7a8b9a54d342605511",
"type": "github"
},
"original": {
"owner": "horriblename",
"repo": "lzn-auto-require",
"type": "github"
}
},
"plugin-mind-nvim": {
"flake": false,
"locked": {
@ -1904,8 +1872,6 @@
"plugin-lspkind": "plugin-lspkind",
"plugin-lspsaga": "plugin-lspsaga",
"plugin-lualine": "plugin-lualine",
"plugin-lz-n": "plugin-lz-n",
"plugin-lzn-auto-require": "plugin-lzn-auto-require",
"plugin-mind-nvim": "plugin-mind-nvim",
"plugin-minimap-vim": "plugin-minimap-vim",
"plugin-modes-nvim": "plugin-modes-nvim",

View file

@ -102,17 +102,6 @@
};
## Plugins
# Lazy loading
plugin-lz-n = {
url = "github:nvim-neorocks/lz.n";
flake = false;
};
plugin-lzn-auto-require = {
url = "github:horriblename/lzn-auto-require";
flake = false;
};
# LSP plugins
plugin-nvim-lspconfig = {
url = "github:neovim/nvim-lspconfig";

View file

@ -3,7 +3,6 @@
inherit (lib.modules) mkIf mkDefault;
inherit (lib.types) nullOr str;
inherit (lib.attrsets) isAttrs mapAttrs;
inherit (lib.generators) mkLuaInline;
binds = rec {
mkLuaBinding = key: action: desc:
@ -68,22 +67,6 @@
mkLuaBinding binding.value action binding.description;
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
mkLznBinding = mode: lhs: rhs: desc: {
inherit mode lhs rhs desc;
};
mkSetLznBinding = binding: action: {
lhs = binding.value;
rhs = action;
desc = binding.description;
};
mkSetLuaLznBinding = binding: action: {
lhs = binding.value;
rhs = mkLuaInline "function() ${action} end";
desc = binding.description;
};
};
in
binds

View file

@ -9,7 +9,7 @@
typesCustom = import ./custom.nix {inherit lib;};
in {
inherit (typesDag) dagOf;
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType lznPluginType lznPluginTableType;
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType;
inherit (typesLanguage) diagnostics mkGrammarOption;
inherit (typesCustom) anythingConcatLists char;
}

View file

@ -6,7 +6,8 @@
inherit (lib.options) mkOption;
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
inherit (lib.strings) hasPrefix removePrefix;
inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr oneOf bool int;
inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr;
# Get the names of all flake inputs that start with the given prefix.
fromInputs = {
inputs,
@ -50,188 +51,8 @@
};
};
};
luaInline = lib.mkOptionType {
name = "luaInline";
check = x: lib.nvim.lua.isLuaInline x;
};
lznKeysSpec = submodule {
options = {
desc = mkOption {
description = "Description of the key map";
type = nullOr str;
default = null;
};
noremap = mkOption {
description = "TBD";
type = bool;
default = false;
};
expr = mkOption {
description = "TBD";
type = bool;
default = false;
};
nowait = mkOption {
description = "TBD";
type = bool;
default = false;
};
ft = mkOption {
description = "TBD";
type = nullOr (listOf str);
default = null;
};
lhs = mkOption {
type = str;
description = "Key to bind to";
};
rhs = mkOption {
type = nullOr (either str luaInline);
default = null;
# FIXME: use a separate flag to indicate lua instead of luaInline
description = "Action to trigger. luaInline code will be wrapped in a function.";
};
mode = mkOption {
description = "Modes to bind in";
type = listOf str;
default = ["n" "x" "s" "o"];
};
};
};
lznPluginTableType = attrsOf lznPluginType;
lznPluginType = submodule {
options = {
## Should probably infer from the actual plugin somehow
## In general this is the name passed to packadd, so the dir name of the plugin
# name = mkOption {
# 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
enabled = mkOption {
type = nullOr (either bool str);
description = "When false, or if the lua function returns false, this plugin will not be included in the spec";
default = null;
};
beforeAll = mkOption {
type = nullOr str;
description = "Lua code to run before any plugins are loaded. This will be wrapped in a function.";
default = null;
};
before = mkOption {
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 str;
description = "Lua code to run after plugin is loaded. This will be wrapped in a function.";
default = null;
};
event = mkOption {
description = "Lazy-load on event";
default = null;
type = let
event = submodule {
options = {
event = mkOption {
type = nullOr (either str (listOf str));
description = "Exact event name";
example = "BufEnter";
};
pattern = mkOption {
type = nullOr (either str (listOf str));
description = "Event pattern";
example = "BufEnter *.lua";
};
};
};
in
nullOr (oneOf [str (listOf str) event]);
};
cmd = mkOption {
description = "Lazy-load on command";
default = null;
type = nullOr (either str (listOf str));
};
ft = mkOption {
description = "Lazy-load on filetype";
default = null;
type = nullOr (either str (listOf str));
};
keys = mkOption {
description = "Lazy-load on key mapping";
default = null;
type = nullOr (oneOf [str (listOf lznKeysSpec) (listOf str)]);
example = ''
keys = [
{lhs = "<leader>s"; rhs = ":NvimTreeToggle<cr>"; desc = "Toggle NvimTree"}
]
'';
};
colorscheme = mkOption {
description = "Lazy-load on colorscheme.";
type = nullOr (either str (listOf str));
default = null;
};
priority = mkOption {
type = nullOr int;
description = "Only useful for stat plugins (not lazy-loaded) to force loading certain plugins first.";
default = null;
};
load = mkOption {
type = nullOr str;
default = null;
description = ''
Lua code to override the `vim.g.lz_n.load()` function for a single plugin.
This will be wrapped in a function
'';
};
};
};
in {
inherit extraPluginType fromInputs pluginType luaInline lznPluginType lznPluginTableType;
inherit extraPluginType fromInputs pluginType;
pluginsOpt = {
description,
@ -243,6 +64,11 @@ in {
type = pluginsType;
};
luaInline = lib.mkOptionType {
name = "luaInline";
check = x: lib.nvim.lua.isLuaInline x;
};
/*
opts is a attrset of options, example:
```

View file

@ -69,7 +69,10 @@ inputs: {
# built (or "normalized") plugins that are modified
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins);
builtOptPlugins = map (package: {
plugin = package;
optional = true;
}) (buildConfigPlugins vimOptions.optPlugins);
# additional Lua and Python3 packages, mapped to their respective functions
# to conform to the format mnw expects. end user should

View file

@ -50,7 +50,6 @@
wrapper = map (p: ./wrapper + "/${p}") [
"build"
"rc"
"lazy"
"warnings"
];

View file

@ -3,75 +3,32 @@
lib,
...
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.trivial) pipe;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.lists) flatten;
legacyMapModes = {
normal = ["n"];
insert = ["i"];
select = ["s"];
visual = ["v"];
terminal = ["t"];
normalVisualOp = ["n" "v" "o"];
visualOnly = ["n" "x"];
operator = ["o"];
insertCommand = ["i" "c"];
lang = ["l"];
command = ["c"];
};
inherit (lib.modules) mkIf;
cfg = config.vim;
in {
config = {
vim.keymaps = mkMerge [
(
mkIf cfg.disableArrows [
{
key = "<up>";
mode = ["n" "i"];
action = "<nop>";
noremap = false;
}
{
key = "<down>";
mode = ["n" "i"];
action = "<nop>";
noremap = false;
}
{
key = "<left>";
mode = ["n" "i"];
action = "<nop>";
noremap = false;
}
{
key = "<right>";
mode = ["n" "i"];
action = "<nop>";
noremap = false;
}
]
)
(
pipe cfg.maps
[
(mapAttrsToList (
oldMode: keybinds:
mapAttrsToList (
key: bind:
bind
// {
inherit key;
mode = legacyMapModes.${oldMode};
}
)
keybinds
))
flatten
]
)
];
vim.maps = mkIf cfg.disableArrows {
"<up>" = {
mode = ["n" "i"];
action = "<nop>";
noremap = false;
};
"<down>" = {
mode = ["n" "i"];
action = "<nop>";
noremap = false;
};
"<left>" = {
mode = ["n" "i"];
action = "<nop>";
noremap = false;
};
"<right>" = {
mode = ["n" "i"];
action = "<nop>";
noremap = false;
};
};
};
}

View file

@ -31,12 +31,6 @@
options =
mapConfigOptions
// {
key = mkOption {
type = str;
description = ''
Key that triggers this keybind.
'';
};
mode = mkOption {
type = either str (listOf str);
description = ''
@ -44,59 +38,52 @@
See `:help map-modes` for a list of modes.
'';
example = ''"nvc" for normal, visual and command mode'';
};
};
};
# legacy stuff
legacyMapOption = submodule {
mapOption = submodule {
options = mapConfigOptions;
};
mapOptions = mode:
mkOption {
description = "Mappings for ${mode} mode";
type = attrsOf legacyMapOption;
type = attrsOf mapOption;
default = {};
};
in {
options.vim = {
keymaps = mkOption {
type = listOf mapType;
maps = mkOption {
type = submodule {
freeformType = attrsOf mapType;
options = {
normal = mapOptions "normal";
insert = mapOptions "insert";
select = mapOptions "select";
visual = mapOptions "visual and select";
terminal = mapOptions "terminal";
normalVisualOp = mapOptions "normal, visual, select and operator-pending (same as plain 'map')";
visualOnly = mapOptions "visual only";
operator = mapOptions "operator-pending";
insertCommand = mapOptions "insert and command-line";
lang = mapOptions "insert, command-line and lang-arg";
command = mapOptions "command-line";
};
};
default = {};
description = "Custom keybindings.";
example = ''
vim.keymaps = [
{
key = "<leader>m";
maps = {
"<leader>m" = {
mode = "n";
silent = true;
action = ":make<CR>";
}
{
key = "<leader>l";
mode = ["n" "x"];
silent = true;
action = "<cmd>cnext<CR>";
}
];
action = "<cmd>make<CR>";
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
};
'';
default = {};
};
maps = {
normal = mapOptions "normal";
insert = mapOptions "insert";
select = mapOptions "select";
visual = mapOptions "visual and select";
terminal = mapOptions "terminal";
normalVisualOp = mapOptions "normal, visual, select and operator-pending (same as plain 'map')";
visualOnly = mapOptions "visual only";
operator = mapOptions "operator-pending";
insertCommand = mapOptions "insert and command-line";
lang = mapOptions "insert, command-line and lang-arg";
command = mapOptions "command-line";
};
};
}

View file

@ -4,11 +4,11 @@
pkgs,
...
}: let
inherit (builtins) filter;
inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf;
inherit (lib.nvim.binds) mkLznBinding;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.binds) pushDownDefault;
cfg = config.vim.filetree.nvimTree;
@ -16,28 +16,19 @@
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)
(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";
};
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"];
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)
];
};
};
};
vim.pluginRC.nvimtreelua = entryAnywhere ''
${
optionalString cfg.setupOpts.disable_netrw ''
@ -47,9 +38,10 @@ in {
''
}
require'nvim-tree'.setup(${toLuaObject cfg.setupOpts})
${
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

View file

@ -6,7 +6,7 @@
inherit (lib.trivial) boolToString warnIf;
in {
onedark = {
setup = {style ? "dark"}: ''
setup = {style ? "dark", ...}: ''
-- OneDark theme
require('onedark').setup {
style = "${style}"
@ -30,7 +30,7 @@ in {
};
dracula = {
setup = {transparent}: ''
setup = {transparent, ...}: ''
require('dracula').setup({
transparent_bg = ${boolToString transparent},
});

View file

@ -1,74 +0,0 @@
{
lib,
config,
...
}: let
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) entryBefore;
cfg = config.vim.lazy;
toLuzLznKeySpec = {
desc,
noremap,
expr,
nowait,
ft,
lhs,
rhs,
mode,
}: {
"@1" = lhs;
"@2" = rhs;
inherit desc noremap expr nowait ft mode;
};
toLuaLznSpec = name: spec:
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
// {
"@1" = name;
before =
if spec.before != null
then
mkLuaInline ''
function()
${spec.before}
end
''
else null;
after =
if spec.setupModule == null && spec.after == null
then null
else
mkLuaInline ''
function()
${
optionalString (spec.setupModule != null)
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"
}
${optionalString (spec.after != null) spec.after}
end
'';
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 {
config.vim = mkIf cfg.enable {
startPlugins = ["lz-n" "lzn-auto-require"];
optPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins;
luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] ''
require('lz.n').load(${toLuaObject lznSpecs})
'';
};
}

View file

@ -1,6 +0,0 @@
_: {
imports = [
./lazy.nix
./config.nix
];
}

View file

@ -1,29 +0,0 @@
{lib, ...}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) enum;
inherit (lib.nvim.types) lznPluginTableType;
in {
options.vim.lazy = {
enable = mkEnableOption "plugin lazy-loading" // {default = true;};
loader = mkOption {
description = "Lazy loader to use";
type = enum ["lz.n"];
default = "lz.n";
};
plugins = mkOption {
default = {};
type = lznPluginTableType;
description = "list of plugins to lazy load";
example = ''
{
toggleterm-nvim = {
package = "toggleterm-nvim";
after = lib.generators.mkLuaInline "function() require('toggleterm').setup{} end";
cmd = ["ToggleTerm"];
};
}
'';
};
};
}

View file

@ -3,9 +3,9 @@
lib,
...
}: let
inherit (builtins) map mapAttrs filter;
inherit (lib.attrsets) mapAttrsToList filterAttrs;
inherit (lib.strings) concatLines concatMapStringsSep optionalString;
inherit (builtins) map mapAttrs filter removeAttrs attrNames;
inherit (lib.attrsets) mapAttrsToList filterAttrs attrsToList;
inherit (lib.strings) concatLines concatMapStringsSep;
inherit (lib.trivial) showWarnings;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere;
@ -40,11 +40,40 @@ in {
inherit (keymap) desc silent nowait script expr unique noremap;
};
toLuaKeymap = bind: "vim.keymap.set(${toLuaObject bind.mode}, ${toLuaObject bind.key}, ${toLuaObject (getAction bind)}, ${toLuaObject (getOpts bind)})";
toLuaKeymap = {
name,
value,
}: "vim.keymap.set(${toLuaObject value.mode}, ${toLuaObject name}, ${toLuaObject (getAction value)}, ${toLuaObject (getOpts value)})";
maps = concatLines (map toLuaKeymap cfg.keymaps);
namedModes = {
"normal" = ["n"];
"insert" = ["i"];
"select" = ["s"];
"visual" = ["v"];
"terminal" = ["t"];
"normalVisualOp" = ["n" "v" "o"];
"visualOnly" = ["n" "x"];
"operator" = ["o"];
"insertCommand" = ["i" "c"];
"lang" = ["l"];
"command" = ["c"];
};
keymaps = maps;
maps =
removeAttrs cfg.maps (attrNames namedModes)
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.normal;}) cfg.maps.normal
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.insert;}) cfg.maps.insert
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.select;}) cfg.maps.select
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.visual;}) cfg.maps.visual
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.terminal;}) cfg.maps.terminal
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.normalVisualOp;}) cfg.maps.normalVisualOp
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.visualOnly;}) cfg.maps.visualOnly
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.operator;}) cfg.maps.operator
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.insertCommand;}) cfg.maps.insertCommand
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.lang;}) cfg.maps.lang
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.command;}) cfg.maps.command;
keymaps = concatLines (map toLuaKeymap (attrsToList (filterNonNull maps)));
in {
vim = {
luaConfigRC = {
@ -53,8 +82,6 @@ in {
pluginConfigs = entryAfter ["theme"] pluginConfigs;
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
mappings = entryAfter ["extraPluginConfigs"] keymaps;
# FIXME: put this somewhere less stupid
footer = entryAfter ["mappings"] (optionalString config.vim.lazy.enable "require('lzn-auto-require.loader').register_loader()");
};
builtLuaConfigRC = let