treewide: make lib calls explicit

This commit is contained in:
Frothy 2024-03-23 20:14:39 -04:00
commit 974bfcc78e
56 changed files with 589 additions and 496 deletions

View file

@ -3,7 +3,7 @@
lib,
...
}: let
inherit (lib) mkEnableOption;
inherit (lib.options) mkEnableOption;
in {
options.vim.binds.cheatsheet = {
enable = mkEnableOption "cheatsheet-nvim: searchable cheatsheet for nvim using telescope";

View file

@ -3,14 +3,15 @@
lib,
...
}: let
inherit (lib) mkIf nvim;
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.binds.cheatsheet;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = ["cheatsheet-nvim"];
vim.luaConfigRC.cheaetsheet-nvim = nvim.dag.entryAnywhere ''
vim.luaConfigRC.cheaetsheet-nvim = entryAnywhere ''
require('cheatsheet').setup({})
'';
};

View file

@ -1,5 +1,6 @@
{lib, ...}: let
inherit (lib) mkEnableOption mkMappingOption;
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in {
options.vim.utility.ccc = {
enable = mkEnableOption "ccc color picker for neovim";

View file

@ -3,20 +3,17 @@
lib,
...
}: let
inherit (lib) addDescriptionsToMappings mkIf nvim;
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.ccc;
self = import ./ccc.nix {inherit lib;};
mappingDefinitions = self.options.vim.utility.ccc.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = [
"ccc"
];
vim.luaConfigRC.ccc = nvim.dag.entryAnywhere ''
vim.luaConfigRC.ccc = entryAnywhere ''
local ccc = require("ccc")
ccc.setup {
highlighter = {

View file

@ -3,7 +3,7 @@
lib,
...
}: let
inherit (lib) mkIf nvim;
inherit (lib.modules) mkIf;
cfg = config.vim.utility.diffview-nvim;
in {
@ -12,9 +12,5 @@ in {
"diffview-nvim"
"plenary-nvim"
];
vim.luaConfigRC.diffview-nvim =
nvim.dag.entryAnywhere ''
'';
};
}

View file

@ -1,5 +1,5 @@
{lib, ...}: let
inherit (lib) mkEnableOption;
inherit (lib.options) mkEnableOption;
in {
options.vim.utility.diffview-nvim = {
enable = mkEnableOption "diffview-nvim: cycle through diffs for all modified files for any git rev";

View file

@ -3,7 +3,9 @@
lib,
...
}: let
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetLuaBinding nvim;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.gestures.gesture-nvim;
@ -23,7 +25,7 @@ in {
})
];
vim.luaConfigRC.gesture-nvim = nvim.dag.entryAnywhere ''
vim.luaConfigRC.gesture-nvim = entryAnywhere ''
vim.opt.mouse = "a"
local gesture = require("gesture")

View file

@ -1,5 +1,6 @@
{lib, ...}: let
inherit (lib) mkEnableOption mkMappingOption;
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in {
options.vim.gestures.gesture-nvim = {
enable = mkEnableOption "gesture-nvim: mouse gestures";

View file

@ -3,7 +3,8 @@
lib,
...
}: let
inherit (lib) mkIf nvim;
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.icon-picker;
in {
@ -13,7 +14,7 @@ in {
"dressing-nvim"
];
vim.luaConfigRC.icon-picker = nvim.dag.entryAnywhere ''
vim.luaConfigRC.icon-picker = entryAnywhere ''
require("icon-picker").setup({
disable_legacy_commands = true
})

View file

@ -1,5 +1,5 @@
{lib, ...}: let
inherit (lib) mkEnableOption;
inherit (lib.options) mkEnableOption;
in {
options.vim.utility.icon-picker = {
enable = mkEnableOption "nerdfonts icon picker for nvim";

View file

@ -3,7 +3,9 @@
lib,
...
}: let
inherit (lib) addDescriptionsToMappings mkIf mkSetBinding nvim;
inherit (lib.modules) mkIf;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.motion.hop;
@ -17,7 +19,7 @@ in {
vim.maps.normal = mkSetBinding mappings.hop "<cmd> HopPattern<CR>";
vim.luaConfigRC.hop-nvim = nvim.dag.entryAnywhere ''
vim.luaConfigRC.hop-nvim = entryAnywhere ''
require('hop').setup()
'';
};

View file

@ -1,5 +1,6 @@
{lib, ...}: let
inherit (lib) mkMappingOption mkEnableOption;
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in {
options.vim.utility.motion.hop = {
mappings = {

View file

@ -3,7 +3,9 @@
lib,
...
}: let
inherit (lib) mkIf mkMerge mkBinding nvim;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.motion.leap;
in {
@ -35,7 +37,7 @@ in {
(mkBinding cfg.mappings.leapFromWindow "<Plug>(leap-from-window)" "Leap from window")
];
vim.luaConfigRC.leap-nvim = nvim.dag.entryAnywhere ''
vim.luaConfigRC.leap-nvim = entryAnywhere ''
require('leap').opts = {
max_phase_one_targets = nil,
highlight_unlabeled_phase_one_targets = false,

View file

@ -1,32 +1,33 @@
{lib, ...}: let
inherit (lib) mkEnableOption mkOption types;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) nullOr str;
in {
options.vim.utility.motion.leap = {
enable = mkEnableOption "leap.nvim plugin (easy motion)";
mappings = {
leapForwardTo = mkOption {
type = types.nullOr types.str;
type = nullOr str;
description = "Leap forward to";
default = "s";
};
leapBackwardTo = mkOption {
type = types.nullOr types.str;
type = nullOr str;
description = "Leap backward to";
default = "S";
};
leapForwardTill = mkOption {
type = types.nullOr types.str;
type = nullOr str;
description = "Leap forward till";
default = "x";
};
leapBackwardTill = mkOption {
type = types.nullOr types.str;
type = nullOr str;
description = "Leap backward till";
default = "X";
};
leapFromWindow = mkOption {
type = types.nullOr types.str;
type = nullOr str;
description = "Leap from window";
default = "gs";
};

View file

@ -4,7 +4,11 @@
lib,
...
}: let
inherit (lib) nvim mkIf mkMerge mkBinding pushDownDefault;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere;
# TODO: move this to its own module
inherit (lib) pushDownDefault;
cfg = config.vim.utility.preview.glow;
self = import ./glow.nix {
@ -23,7 +27,7 @@ in {
"<leader>pm" = "+Preview Markdown";
};
vim.luaConfigRC.glow = nvim.dag.entryAnywhere ''
vim.luaConfigRC.glow = entryAnywhere ''
require('glow').setup({
glow_path = "${pkgs.glow}/bin/glow"
});

View file

@ -1,5 +1,7 @@
{lib, ...}: let
inherit (lib) mkEnableOption mkMappingOption mkRenamedOptionModule;
inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in {
imports = [
(mkRenamedOptionModule ["vim" "languages" "markdown" "glow" "enable"] ["vim" "utility" "preview" "glow" "enable"])

View file

@ -4,15 +4,17 @@
lib,
...
}: let
inherit (lib) nvim mkIf concatMapStringsSep optionalString stringLength;
inherit (nvim.vim) mkVimBool;
inherit (lib.strings) optionalString stringLength concatMapStringsSep;
inherit (lib.modules) mkIf;
inherit (lib.nvim.vim) mkVimBool;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.preview.markdownPreview;
in {
config = mkIf cfg.enable {
vim.startPlugins = [pkgs.vimPlugins.markdown-preview-nvim];
vim.configRC.markdown-preview = nvim.dag.entryAnywhere ''
vim.configRC.markdown-preview = entryAnywhere ''
let g:mkdp_auto_start = ${mkVimBool cfg.autoStart}
let g:mkdp_auto_close = ${mkVimBool cfg.autoClose}
let g:mkdp_refresh_slow = ${mkVimBool cfg.lazyRefresh}

View file

@ -1,54 +1,55 @@
{lib, ...}: let
inherit (lib) types mkEnableOption mkOption;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) bool str listOf;
in {
options.vim.utility.preview = {
markdownPreview = {
enable = mkEnableOption "Markdown preview in neovim with markdown-preview.nvim";
autoStart = mkOption {
type = types.bool;
type = bool;
default = false;
description = "Automatically open the preview window after entering a Markdown buffer";
};
autoClose = mkOption {
type = types.bool;
type = bool;
default = true;
description = "Automatically close the preview window after leaving a Markdown buffer";
};
lazyRefresh = mkOption {
type = types.bool;
type = bool;
default = false;
description = "Only update preview when saving or leaving insert mode";
};
filetypes = mkOption {
type = with types; listOf str;
type = listOf str;
default = ["markdown"];
description = "Allowed filetypes";
};
alwaysAllowPreview = mkOption {
type = types.bool;
type = bool;
default = false;
description = "Allow preview on all filetypes";
};
broadcastServer = mkOption {
type = types.bool;
type = bool;
default = false;
description = "Allow for outside and network wide connections";
};
customIP = mkOption {
type = types.str;
type = str;
default = "";
description = "IP-address to use";
};
customPort = mkOption {
type = types.str;
type = str;
default = "";
description = "Port to use";
};

View file

@ -3,7 +3,9 @@
lib,
...
}: let
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.surround;
self = import ./surround.nix {inherit lib config;};
@ -16,7 +18,7 @@ in {
"nvim-surround"
];
luaConfigRC.surround = nvim.dag.entryAnywhere ''
luaConfigRC.surround = entryAnywhere ''
require('nvim-surround').setup()
'';

View file

@ -3,67 +3,69 @@
config,
...
}: let
inherit (lib) mkOption types mkIf mkDefault;
inherit (lib.modules) mkIf mkDefault;
inherit (lib.options) mkOption;
inherit (lib.types) bool nullOr str;
in {
options.vim.utility.surround = {
enable = mkOption {
type = types.bool;
type = bool;
default = false;
description = "nvim-surround: add/change/delete surrounding delimiter pairs with ease. Note that the default mappings deviate from upstreeam to avoid conflicts with nvim-leap.";
};
useVendoredKeybindings = mkOption {
type = types.bool;
type = bool;
default = true;
description = "Use alternative set of keybindings that avoids conflicts with other popular plugins, e.g. nvim-leap";
};
mappings = {
insert = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "<C-g>z";
description = "Add surround character around the cursor";
};
insertLine = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "<C-g>Z";
description = "Add surround character around the cursor on new lines";
};
normal = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "gz";
description = "Surround motion with character";
};
normalCur = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "gZ";
description = "Surround motion with character on new lines";
};
normalLine = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "gzz";
description = "Surround line with character";
};
normalCurLine = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "gZZ";
description = "Surround line with character on new lines";
};
visual = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "gz";
description = "Surround selection with character";
};
visualLine = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "gZ";
description = "Surround selection with character on new lines";
};
delete = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "gzd";
description = "Delete surrounding character";
};
change = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "gzr";
description = "Change surrounding character";
};

View file

@ -4,7 +4,11 @@
lib,
...
}: let
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim pushDownDefault;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
inherit (lib.nvim.dag) entryAnywhere;
# TODO: move this to its own module
inherit (lib) pushDownDefault;
cfg = config.vim.telescope;
self = import ./telescope.nix {inherit lib;};
@ -60,7 +64,7 @@ in {
"<leader>fvc" = "Commits";
};
vim.luaConfigRC.telescope = nvim.dag.entryAnywhere ''
vim.luaConfigRC.telescope = entryAnywhere ''
local telescope = require('telescope')
telescope.setup {
defaults = {

View file

@ -1,5 +1,6 @@
{lib, ...}: let
inherit (lib) mkMappingOption mkEnableOption;
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in {
options.vim.telescope = {
mappings = {

View file

@ -4,7 +4,8 @@
pkgs,
...
}: let
inherit (lib) mkIf nvim;
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.vim-wakatime;
in {
@ -13,7 +14,7 @@ in {
pkgs.vimPlugins.vim-wakatime
];
vim.configRC.vim-wakatime = nvim.dag.entryAnywhere ''
vim.configRC.vim-wakatime = entryAnywhere ''
${
if cfg.cli-package == null
then ""

View file

@ -3,13 +3,14 @@
pkgs,
...
}: let
inherit (lib) mkEnableOption mkOption types;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) nullOr package;
in {
options.vim.utility.vim-wakatime = {
enable = mkEnableOption "vim-wakatime: live code statistics";
cli-package = mkOption {
type = with types; nullOr package;
type = nullOr package;
default = pkgs.wakatime;
description = "The package that should be used for wakatime-cli. Set as null to use the default path in `$XDG_DATA_HOME`";
};