treewide: change modules to use 'inherit (builtins) ...

This commit is contained in:
Frothy 2023-11-14 00:18:32 -07:00
parent c77b007a26
commit 4dc7576176
19 changed files with 59 additions and 42 deletions

View file

@ -4,6 +4,7 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) toJSON;
inherit (lib) mkIf nvim mkLuaBinding mkMerge; inherit (lib) mkIf nvim mkLuaBinding mkMerge;
cfg = config.vim.assistant.copilot; cfg = config.vim.assistant.copilot;
@ -13,7 +14,7 @@
local s, _ = pcall(${luaFunction}) local s, _ = pcall(${luaFunction})
if not s then if not s then
local termcode = vim.api.nvim_replace_termcodes(${builtins.toJSON key}, true, false, true) local termcode = vim.api.nvim_replace_termcodes(${toJSON key}, true, false, true)
vim.fn.feedkeys(termcode, 'n') vim.fn.feedkeys(termcode, 'n')
end end

View file

@ -3,6 +3,7 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) toJSON;
inherit (lib) mkIf mkMerge mkExprBinding boolToString nvim; inherit (lib) mkIf mkMerge mkExprBinding boolToString nvim;
cfg = config.vim.assistant.tabnine; cfg = config.vim.assistant.tabnine;
@ -17,7 +18,7 @@ in {
local completion = require("tabnine.completion") local completion = require("tabnine.completion")
if not state.completions_cache then if not state.completions_cache then
return "${builtins.toJSON cfg.mappings.accept}" return "${toJSON cfg.mappings.accept}"
end end
vim.schedule(completion.accept) vim.schedule(completion.accept)
@ -29,7 +30,7 @@ in {
local completion = require("tabnine.completion") local completion = require("tabnine.completion")
if not state.completions_cache then if not state.completions_cache then
return "${builtins.toJSON cfg.mappings.dismiss}" return "${toJSON cfg.mappings.dismiss}"
end end
vim.schedule(function() vim.schedule(function()

View file

@ -3,6 +3,7 @@
config, config,
... ...
}: let }: let
inherit (builtins) concatStringsSep;
inherit (lib) optionalString mkIf nvim; inherit (lib) optionalString mkIf nvim;
cfg = config.vim; cfg = config.vim;
@ -141,7 +142,7 @@ in {
''} ''}
${optionalString cfg.spellChecking.enable '' ${optionalString cfg.spellChecking.enable ''
set spell set spell
set spelllang=${builtins.concatStringsSep "," cfg.spellChecking.languages}${optionalString cfg.spellChecking.enableProgrammingWordList ",programming"} set spelllang=${concatStringsSep "," cfg.spellChecking.languages}${optionalString cfg.spellChecking.enableProgrammingWordList ",programming"}
''} ''}
${optionalString (cfg.leaderKey != null) '' ${optionalString (cfg.leaderKey != null) ''
let mapleader = "${toString cfg.leaderKey}" let mapleader = "${toString cfg.leaderKey}"

View file

@ -3,7 +3,9 @@
config, config,
... ...
}: let }: let
inherit (lib) addDescriptionsToMappings concatMapStringsSep attrNames concatStringsSep mapAttrsToList nvim mkIf mkSetLuaBinding mkMerge optionalString; inherit (builtins) toJSON;
inherit (lib) addDescriptionsToMappings concatMapStringsSep attrNames concatStringsSep mapAttrsToList mkIf mkSetLuaBinding mkMerge optionalString;
inherit (lib.nvim) dag;
cfg = config.vim.autocomplete; cfg = config.vim.autocomplete;
lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable; lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable;
@ -31,8 +33,8 @@
dagPlacement = dagPlacement =
if lspkindEnabled if lspkindEnabled
then nvim.dag.entryAfter ["lspkind"] then dag.entryAfter ["lspkind"]
else nvim.dag.entryAnywhere; else dag.entryAnywhere;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = [ vim.startPlugins = [
@ -59,7 +61,7 @@ in {
(mkSetLuaBinding mappings.confirm '' (mkSetLuaBinding mappings.confirm ''
function() function()
if not require('cmp').confirm({ select = true }) then if not require('cmp').confirm({ select = true }) then
local termcode = vim.api.nvim_replace_termcodes(${builtins.toJSON mappings.confirm.value}, true, false, true) local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.confirm.value}, true, false, true)
vim.fn.feedkeys(termcode, 'n') vim.fn.feedkeys(termcode, 'n')
end end
@ -85,7 +87,7 @@ in {
elseif has_words_before() then elseif has_words_before() then
cmp.complete() cmp.complete()
else else
local termcode = vim.api.nvim_replace_termcodes(${builtins.toJSON mappings.next.value}, true, false, true) local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.next.value}, true, false, true)
vim.fn.feedkeys(termcode, 'n') vim.fn.feedkeys(termcode, 'n')
end end
@ -152,7 +154,7 @@ in {
elseif has_words_before() then elseif has_words_before() then
cmp.complete() cmp.complete()
else else
local termcode = vim.api.nvim_replace_termcodes(${builtins.toJSON mappings.next.value}, true, false, true) local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.next.value}, true, false, true)
vim.fn.feedkeys(termcode, 'n') vim.fn.feedkeys(termcode, 'n')
end end

View file

@ -2,8 +2,8 @@
config, config,
lib, lib,
... ...
}: }: let
with builtins; let inherit (builtins) attrValues attrNames map mapAttrs toJSON isString concatStringsSep filter;
inherit (lib) mkOption types mapAttrsFlatten filterAttrs optionalString getAttrs literalExpression; inherit (lib) mkOption types mapAttrsFlatten filterAttrs optionalString getAttrs literalExpression;
inherit (lib) nvim; inherit (lib) nvim;
inherit (nvim.lua) toLuaObject; inherit (nvim.lua) toLuaObject;
@ -84,7 +84,7 @@ with builtins; let
else action.action; else action.action;
}; };
in in
builtins.attrValues (builtins.mapAttrs attrValues (mapAttrs
(key: action: let (key: action: let
normalizedAction = normalizeAction action; normalizedAction = normalizeAction action;
in { in {
@ -258,7 +258,7 @@ in {
(filterNonNull cfg.globals); (filterNonNull cfg.globals);
toLuaBindings = mode: maps: toLuaBindings = mode: maps:
builtins.map (value: '' map (value: ''
vim.keymap.set(${toLuaObject mode}, ${toLuaObject value.key}, ${toLuaObject value.action}, ${toLuaObject value.config}) vim.keymap.set(${toLuaObject mode}, ${toLuaObject value.key}, ${toLuaObject value.action}, ${toLuaObject value.config})
'') (genMaps mode maps); '') (genMaps mode maps);
@ -282,7 +282,7 @@ in {
}: let }: let
# When the value is a string, default it to dag.entryAnywhere # When the value is a string, default it to dag.entryAnywhere
finalDag = lib.mapAttrs (_: value: finalDag = lib.mapAttrs (_: value:
if builtins.isString value if isString value
then nvim.dag.entryAnywhere value then nvim.dag.entryAnywhere value
else value) else value)
dag; dag;
@ -290,7 +290,7 @@ in {
result = result =
if sortedDag ? result if sortedDag ? result
then mapResult sortedDag.result then mapResult sortedDag.result
else abort ("Dependency cycle in ${name}: " + toJSON sortedConfig); else abort ("Dependency cycle in ${name}: " + toJSON sortedDag);
in in
result; result;
in { in {

View file

@ -5,8 +5,8 @@ inputs: {
check ? true, check ? true,
extraSpecialArgs ? {}, extraSpecialArgs ? {},
}: let }: let
inherit (pkgs) wrapNeovim vimPlugins;
inherit (builtins) map filter isString toString getAttr; inherit (builtins) map filter isString toString getAttr;
inherit (pkgs) wrapNeovim vimPlugins;
inherit (pkgs.vimUtils) buildVimPlugin; inherit (pkgs.vimUtils) buildVimPlugin;
extendedLib = import ../lib/stdlib-extended.nix lib; extendedLib = import ../lib/stdlib-extended.nix lib;

View file

@ -3,7 +3,9 @@
lib, lib,
... ...
}: let }: let
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetExprBinding toJSON mkSetLuaBinding nvim; inherit (builtins) toJSON;
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetExprBinding mkSetLuaBinding nvim;
cfg = config.vim.git; cfg = config.vim.git;
self = import ./git.nix {inherit lib;}; self = import ./git.nix {inherit lib;};
@ -19,7 +21,7 @@ in {
vim.maps.normal = mkMerge [ vim.maps.normal = mkMerge [
(mkSetExprBinding gsMappings.nextHunk '' (mkSetExprBinding gsMappings.nextHunk ''
function() function()
if vim.wo.diff then return ${builtins.toJSON gsMappings.nextHunk.value} end if vim.wo.diff then return ${toJSON gsMappings.nextHunk.value} end
vim.schedule(function() package.loaded.gitsigns.next_hunk() end) vim.schedule(function() package.loaded.gitsigns.next_hunk() end)
@ -28,7 +30,7 @@ in {
'') '')
(mkSetExprBinding gsMappings.previousHunk '' (mkSetExprBinding gsMappings.previousHunk ''
function() function()
if vim.wo.diff then return ${builtins.toJSON gsMappings.previousHunk.value} end if vim.wo.diff then return ${toJSON gsMappings.previousHunk.value} end
vim.schedule(function() package.loaded.gitsigns.prev_hunk() end) vim.schedule(function() package.loaded.gitsigns.prev_hunk() end)
@ -69,7 +71,7 @@ in {
vim.lsp.null-ls.sources.gitsigns-ca = '' vim.lsp.null-ls.sources.gitsigns-ca = ''
table.insert( table.insert(
ls_sources, ls_sources,
null_ls.builtins.code_actions.gitsigns null_ls.gcode_actions.gitsigns
) )
''; '';
}) })

View file

@ -4,6 +4,7 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) attrNames;
inherit (lib) mkOption mkEnableOption types isList nvim; inherit (lib) mkOption mkEnableOption types isList nvim;
cfg = config.vim.languages.bash; cfg = config.vim.languages.bash;
@ -69,7 +70,7 @@ in {
server = mkOption { server = mkOption {
description = "Bash LSP server to use"; description = "Bash LSP server to use";
type = with types; enum (builtins.attrNames servers); type = with types; enum (attrNames servers);
default = defaultServer; default = defaultServer;
}; };
@ -89,7 +90,7 @@ in {
}; };
type = mkOption { type = mkOption {
description = "Bash formatter to use"; description = "Bash formatter to use";
type = with types; enum (builtins.attrNames formats); type = with types; enum (attrNames formats);
default = defaultFormat; default = defaultFormat;
}; };

View file

@ -4,6 +4,7 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) attrNames;
inherit (lib) isList nvim optionalString mkEnableOption mkOption types mkIf mkMerge; inherit (lib) isList nvim optionalString mkEnableOption mkOption types mkIf mkMerge;
cfg = config.vim.languages.clang; cfg = config.vim.languages.clang;
@ -93,7 +94,7 @@ in {
server = mkOption { server = mkOption {
description = "The clang LSP server to use"; description = "The clang LSP server to use";
type = with types; enum (builtins.attrNames servers); type = with types; enum (attrNames servers);
default = defaultServer; default = defaultServer;
}; };
@ -119,7 +120,7 @@ in {
}; };
debugger = mkOption { debugger = mkOption {
description = "clang debugger to use"; description = "clang debugger to use";
type = with types; enum (builtins.attrNames debuggers); type = with types; enum (attrNames debuggers);
default = defaultDebugger; default = defaultDebugger;
}; };
package = mkOption { package = mkOption {

View file

@ -4,6 +4,7 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (builtins) attrNames;
inherit (lib) isList nvim mkEnableOption mkOption types optionalString; inherit (lib) isList nvim mkEnableOption mkOption types optionalString;
cfg = config.vim.languages.dart; cfg = config.vim.languages.dart;
@ -38,7 +39,7 @@ in {
enable = mkEnableOption "Dart LSP support"; enable = mkEnableOption "Dart LSP support";
server = mkOption { server = mkOption {
description = "The Dart LSP server to use"; description = "The Dart LSP server to use";
type = with types; enum (builtins.attrNames servers); type = with types; enum (attrNames servers);
default = defaultServer; default = defaultServer;
}; };
package = mkOption { package = mkOption {

View file

@ -4,6 +4,7 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) attrNames;
inherit (lib) isList nvim getExe mkEnableOption mkOption types mkMerge mkIf; inherit (lib) isList nvim getExe mkEnableOption mkOption types mkMerge mkIf;
cfg = config.vim.languages.go; cfg = config.vim.languages.go;
@ -80,7 +81,7 @@ in {
server = mkOption { server = mkOption {
description = "Go LSP server to use"; description = "Go LSP server to use";
type = with types; enum (builtins.attrNames servers); type = with types; enum (attrNames servers);
default = defaultServer; default = defaultServer;
}; };
@ -100,7 +101,7 @@ in {
}; };
debugger = mkOption { debugger = mkOption {
description = "Go debugger to use"; description = "Go debugger to use";
type = with types; enum (builtins.attrNames debuggers); type = with types; enum (attrNames debuggers);
default = defaultDebugger; default = defaultDebugger;
}; };
package = mkOption { package = mkOption {

View file

@ -4,6 +4,7 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) attrNames;
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge optionalString; inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge optionalString;
cfg = config.vim.languages.nix; cfg = config.vim.languages.nix;
@ -146,7 +147,7 @@ in {
type = mkOption { type = mkOption {
description = "Nix formatter to use"; description = "Nix formatter to use";
type = with types; enum (builtins.attrNames formats); type = with types; enum (attrNames formats);
default = defaultFormat; default = defaultFormat;
}; };
package = mkOption { package = mkOption {

View file

@ -4,6 +4,7 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) attrNames;
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge getExe; inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge getExe;
cfg = config.vim.languages.php; cfg = config.vim.languages.php;
@ -72,7 +73,7 @@ in {
server = mkOption { server = mkOption {
description = "PHP LSP server to use"; description = "PHP LSP server to use";
type = with types; enum (builtins.attrNames servers); type = with types; enum (attrNames servers);
default = defaultServer; default = defaultServer;
}; };

View file

@ -4,6 +4,7 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) attrNames;
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge getExe literalExpression; inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge getExe literalExpression;
cfg = config.vim.languages.python; cfg = config.vim.languages.python;
@ -149,7 +150,7 @@ in {
server = mkOption { server = mkOption {
description = "Python LSP server to use"; description = "Python LSP server to use";
type = with types; enum (builtins.attrNames servers); type = with types; enum (attrNames servers);
default = defaultServer; default = defaultServer;
}; };
@ -166,7 +167,7 @@ in {
type = mkOption { type = mkOption {
description = "Python formatter to use"; description = "Python formatter to use";
type = with types; enum (builtins.attrNames formats); type = with types; enum (attrNames formats);
default = defaultFormat; default = defaultFormat;
}; };
@ -186,7 +187,7 @@ in {
}; };
debugger = mkOption { debugger = mkOption {
description = "Python debugger to use"; description = "Python debugger to use";
type = with types; enum (builtins.attrNames debuggers); type = with types; enum (attrNames debuggers);
default = defaultDebugger; default = defaultDebugger;
}; };
package = mkOption { package = mkOption {

View file

@ -4,6 +4,7 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) attrNames;
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge; inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge;
cfg = config.vim.languages.sql; cfg = config.vim.languages.sql;
@ -86,7 +87,7 @@ in {
server = mkOption { server = mkOption {
description = "SQL LSP server to use"; description = "SQL LSP server to use";
type = with types; enum (builtins.attrNames servers); type = with types; enum (attrNames servers);
default = defaultServer; default = defaultServer;
}; };
@ -103,7 +104,7 @@ in {
type = mkOption { type = mkOption {
description = "SQL formatter to use"; description = "SQL formatter to use";
type = with types; enum (builtins.attrNames formats); type = with types; enum (attrNames formats);
default = defaultFormat; default = defaultFormat;
}; };

View file

@ -4,6 +4,7 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) attrNames;
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge; inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge;
cfg = config.vim.languages.svelte; cfg = config.vim.languages.svelte;
@ -72,7 +73,7 @@ in {
server = mkOption { server = mkOption {
description = "Svelte LSP server to use"; description = "Svelte LSP server to use";
type = with types; enum (builtins.attrNames servers); type = with types; enum (attrNames servers);
default = defaultServer; default = defaultServer;
}; };
@ -89,7 +90,7 @@ in {
type = mkOption { type = mkOption {
description = "Svelte formatter to use"; description = "Svelte formatter to use";
type = with types; enum (builtins.attrNames formats); type = with types; enum (attrNames formats);
default = defaultFormat; default = defaultFormat;
}; };

View file

@ -4,6 +4,7 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) attrNames;
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge; inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge;
cfg = config.vim.languages.ts; cfg = config.vim.languages.ts;
@ -98,7 +99,7 @@ in {
server = mkOption { server = mkOption {
description = "Typescript/Javascript LSP server to use"; description = "Typescript/Javascript LSP server to use";
type = with types; enum (builtins.attrNames servers); type = with types; enum (attrNames servers);
default = defaultServer; default = defaultServer;
}; };
@ -115,7 +116,7 @@ in {
type = mkOption { type = mkOption {
description = "Typescript/Javascript formatter to use"; description = "Typescript/Javascript formatter to use";
type = with types; enum (builtins.attrNames formats); type = with types; enum (attrNames formats);
default = defaultFormat; default = defaultFormat;
}; };

View file

@ -3,6 +3,7 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) toJSON;
inherit (lib) mkMerge mkIf mkBinding nvim getExe; inherit (lib) mkMerge mkIf mkBinding nvim getExe;
cfg = config.vim.terminal.toggleterm; cfg = config.vim.terminal.toggleterm;
@ -59,7 +60,7 @@ in {
end end
}) })
vim.keymap.set('n', ${builtins.toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = 'Open lazygit [toggleterm]'}) vim.keymap.set('n', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = 'Open lazygit [toggleterm]'})
''; '';
} }
) )

View file

@ -2,8 +2,7 @@
config, config,
lib, lib,
... ...
}: }: let
with builtins; let
inherit (lib) optionalString boolToString mkIf optionals; inherit (lib) optionalString boolToString mkIf optionals;
inherit (lib.nvim.lua) nullString; inherit (lib.nvim.lua) nullString;