mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-09 14:45:58 +01:00
treewide: cleanup (#324)
* statix, deadnix, alejandra * _file * _module.args * concatStringsSep "\n" -> concatLines concatStringsSep "\n" map -> concatMapStringsSep "\n" * mkShell nativeBuildInputs -> packages
This commit is contained in:
parent
f1849c0ce5
commit
8d5f23035d
29 changed files with 46 additions and 82 deletions
17
flake.nix
17
flake.nix
|
@ -10,16 +10,15 @@
|
|||
# provide overridable systems
|
||||
# https://github.com/nix-systems/nix-systems
|
||||
systems = import inputs.systems;
|
||||
|
||||
imports = [
|
||||
# add lib to module args
|
||||
{_module.args = {inherit (nixpkgs) lib;};}
|
||||
./flake/apps.nix
|
||||
./flake/legacyPackages.nix
|
||||
./flake/overlays.nix
|
||||
./flake/packages.nix
|
||||
];
|
||||
|
||||
_module.args = {inherit (nixpkgs) lib;};
|
||||
|
||||
flake = {
|
||||
lib = {
|
||||
inherit (import ./lib/stdlib-extended.nix nixpkgs.lib inputs) nvim;
|
||||
|
@ -34,9 +33,7 @@
|
|||
''
|
||||
self.homeManagerModules.nvf;
|
||||
|
||||
nvf = {
|
||||
imports = [(import ./flake/modules/home-manager.nix self.packages inputs)];
|
||||
};
|
||||
nvf = import ./flake/modules/home-manager.nix self.packages inputs;
|
||||
|
||||
default = self.homeManagerModules.nvf;
|
||||
};
|
||||
|
@ -49,9 +46,7 @@
|
|||
''
|
||||
self.nixosModules.nvf;
|
||||
|
||||
nvf = {
|
||||
imports = [(import ./flake/modules/nixos.nix self.packages inputs)];
|
||||
};
|
||||
nvf = import ./flake/modules/nixos.nix self.packages inputs;
|
||||
|
||||
default = self.nixosModules.nvf;
|
||||
};
|
||||
|
@ -66,9 +61,9 @@
|
|||
formatter = pkgs.alejandra;
|
||||
devShells = {
|
||||
default = self'.devShells.lsp;
|
||||
nvim-nix = pkgs.mkShell {nativeBuildInputs = [config.packages.nix];};
|
||||
nvim-nix = pkgs.mkShell {packages = [config.packages.nix];};
|
||||
lsp = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [nil statix deadnix alejandra];
|
||||
packages = with pkgs; [nil statix deadnix alejandra];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -88,4 +88,5 @@ in {
|
|||
++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
|
||||
};
|
||||
};
|
||||
_file = ./home-manager.nix;
|
||||
}
|
||||
|
|
|
@ -88,4 +88,5 @@ in {
|
|||
++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
|
||||
};
|
||||
};
|
||||
_file = ./nixos.nix;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{inputs, ...}: {
|
||||
perSystem = {
|
||||
system,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
mkSetLuaBinding = binding: action:
|
||||
mkLuaBinding binding.value action binding.description;
|
||||
|
||||
pushDownDefault = attr: mapAttrs (_: value: mkDefault value) attr;
|
||||
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
||||
};
|
||||
in
|
||||
binds
|
||||
|
|
|
@ -84,7 +84,7 @@ in {
|
|||
normalizedDag =
|
||||
mapAttrs (n: v: {
|
||||
name = n;
|
||||
data = v.data;
|
||||
inherit (v) data;
|
||||
after = v.after ++ dagBefore dag n;
|
||||
})
|
||||
dag;
|
||||
|
@ -117,7 +117,6 @@ in {
|
|||
entriesBetween = tag: let
|
||||
go = i: before: after: entries: let
|
||||
name = "${tag}-${toString i}";
|
||||
i' = i + 1;
|
||||
in
|
||||
if entries == []
|
||||
then empty
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{lib}: let
|
||||
inherit (builtins) hasAttr head throw typeOf isList isAttrs isBool isInt isString isPath isFloat toJSON;
|
||||
inherit (lib.attrsets) mapAttrsToList filterAttrs;
|
||||
inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters;
|
||||
inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters concatLines;
|
||||
inherit (lib.trivial) boolToString warn;
|
||||
in rec {
|
||||
wrapLuaConfig = {
|
||||
|
@ -11,7 +11,7 @@ in rec {
|
|||
luaAfter ? "",
|
||||
}: ''
|
||||
lua << EOF
|
||||
${concatStringsSep "\n" [luaBefore luaConfig luaAfter]}
|
||||
${concatLines [luaBefore luaConfig luaAfter]}
|
||||
EOF
|
||||
'';
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
}: let
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
|
||||
inherit (lib.strings) hasPrefix removePrefix isString;
|
||||
inherit (lib.strings) hasPrefix removePrefix;
|
||||
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.
|
||||
|
|
|
@ -30,14 +30,14 @@ in {
|
|||
"copilot-lua"
|
||||
# cfg.copilotNodePackage
|
||||
]
|
||||
++ optionals (cfg.cmp.enable) [
|
||||
++ optionals cfg.cmp.enable [
|
||||
"copilot-cmp"
|
||||
];
|
||||
|
||||
vim.luaConfigRC.copilot = entryAnywhere ''
|
||||
require("copilot").setup(${toLuaObject cfg.setupOpts})
|
||||
|
||||
${lib.optionalString (cfg.cmp.enable) ''
|
||||
${lib.optionalString cfg.cmp.enable ''
|
||||
require("copilot_cmp").setup()
|
||||
''}
|
||||
'';
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) listOf attrs bool enum str oneOf int;
|
||||
in {
|
||||
|
|
|
@ -103,11 +103,11 @@ in {
|
|||
end
|
||||
end
|
||||
|
||||
${optionalString (config.vim.ui.breadcrumbs.enable) ''local navic = require("nvim-navic")''}
|
||||
${optionalString config.vim.ui.breadcrumbs.enable ''local navic = require("nvim-navic")''}
|
||||
default_on_attach = function(client, bufnr)
|
||||
attach_keymaps(client, bufnr)
|
||||
format_callback(client, bufnr)
|
||||
${optionalString (config.vim.ui.breadcrumbs.enable) ''
|
||||
${optionalString config.vim.ui.breadcrumbs.enable ''
|
||||
-- let navic attach to buffers
|
||||
if client.server_capabilities.documentSymbolProvider then
|
||||
navic.attach(client, bufnr)
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.modules) mkRenamedOptionModule;
|
||||
inherit (lib.types) bool listOf str enum;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
in {
|
||||
config = mkMerge [
|
||||
# TODO: move into nvim-tree file
|
||||
(mkIf (config.vim.filetree.nvimTree.enable) {
|
||||
(mkIf config.vim.filetree.nvimTree.enable {
|
||||
vim.statusline.lualine.setupOpts = {
|
||||
extensions = ["nvim-tree"];
|
||||
};
|
||||
|
@ -44,11 +44,11 @@ in {
|
|||
statusline.lualine.setupOpts = {
|
||||
options = {
|
||||
icons_enabled = cfg.icons.enable;
|
||||
theme = cfg.theme;
|
||||
inherit (cfg) theme;
|
||||
component_separators = [cfg.componentSeparator.left cfg.componentSeparator.right];
|
||||
section_separators = [cfg.sectionSeparator.left cfg.sectionSeparator.right];
|
||||
globalstatus = cfg.globalStatus;
|
||||
refresh = cfg.refresh;
|
||||
inherit (cfg) refresh;
|
||||
};
|
||||
|
||||
sections = {
|
||||
|
|
|
@ -6,10 +6,7 @@
|
|||
inherit (lib.trivial) boolToString warnIf;
|
||||
in {
|
||||
onedark = {
|
||||
setup = {
|
||||
style ? "dark",
|
||||
transparent,
|
||||
}: ''
|
||||
setup = {style ? "dark"}: ''
|
||||
-- OneDark theme
|
||||
require('onedark').setup {
|
||||
style = "${style}"
|
||||
|
@ -33,10 +30,7 @@ in {
|
|||
};
|
||||
|
||||
dracula = {
|
||||
setup = {
|
||||
style ? null,
|
||||
transparent,
|
||||
}: ''
|
||||
setup = {transparent}: ''
|
||||
require('dracula').setup({
|
||||
transparent_bg = ${boolToString transparent},
|
||||
});
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) attrsOf enum nullOr submodule bool str;
|
||||
inherit (lib.modules) mkRenamedOptionModule;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||
inherit (lib.types) nullOr int str attrsOf either listOf;
|
||||
inherit (lib.types) nullOr str attrsOf either listOf;
|
||||
inherit (lib.modules) mkRenamedOptionModule;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
in {
|
||||
options.vim.binds.cheatsheet = {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
cfg = config.vim.binds.cheatsheet;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["cheatsheet-nvim"];
|
||||
|
||||
vim.luaConfigRC.cheaetsheet-nvim = entryAnywhere ''
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
cfg = config.vim.binds.whichKey;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["which-key"];
|
||||
|
||||
vim.luaConfigRC.whichkey = entryAnywhere ''
|
||||
|
@ -23,7 +23,7 @@ in {
|
|||
["<tab>"] = "TAB",
|
||||
},
|
||||
|
||||
${optionalString (config.vim.ui.borders.plugins.which-key.enable) ''
|
||||
${optionalString config.vim.ui.borders.plugins.which-key.enable ''
|
||||
window = {
|
||||
border = "${config.vim.ui.borders.plugins.which-key.style}",
|
||||
},
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) attrsOf nullOr str;
|
||||
in {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
cfg = config.vim.utility.ccc;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"ccc"
|
||||
];
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
cfg = config.vim.utility.diffview-nvim;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"diffview-nvim"
|
||||
"plenary-nvim"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
cfg = config.vim.utility.icon-picker;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"icon-picker-nvim"
|
||||
"dressing-nvim"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
|
||||
inherit (lib.types) enum listOf str nullOr int;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
self = import ./glow.nix {
|
||||
inherit lib config pkgs;
|
||||
};
|
||||
mappings = self.options.vim.utility.preview.glow.mappings;
|
||||
inherit (self.options.vim.utility.preview.glow) mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["glow-nvim"];
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"telescope"
|
||||
"plenary-nvim"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
cfg = config.vim.utility.vim-wakatime;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
pkgs.vimPlugins.vim-wakatime
|
||||
];
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
inherit (builtins) map mapAttrs toJSON filter;
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.attrsets) filterAttrs getAttrs attrValues attrNames;
|
||||
inherit (lib.strings) isString concatStringsSep;
|
||||
inherit (lib.strings) isString concatLines concatMapStringsSep;
|
||||
inherit (lib.misc) mapAttrsFlatten;
|
||||
inherit (lib.trivial) showWarnings;
|
||||
inherit (lib.types) str nullOr;
|
||||
|
@ -126,7 +126,7 @@ in {
|
|||
in {
|
||||
vim = {
|
||||
configRC = {
|
||||
globalsScript = entryAnywhere (concatStringsSep "\n" globalsScript);
|
||||
globalsScript = entryAnywhere (concatLines globalsScript);
|
||||
|
||||
# Call additional lua files with :luafile in Vimscript
|
||||
# section of the configuration, only after
|
||||
|
@ -134,14 +134,14 @@ in {
|
|||
extraLuaFiles = let
|
||||
callLuaFiles = map (file: "luafile ${file}") cfg.extraLuaFiles;
|
||||
in
|
||||
entryAfter ["globalScript"] (concatStringsSep "\n" callLuaFiles);
|
||||
entryAfter ["globalScript"] (concatLines callLuaFiles);
|
||||
|
||||
# wrap the lua config in a lua block
|
||||
# using the wrapLuaConfic function from the lib
|
||||
luaScript = let
|
||||
mapResult = result: (wrapLuaConfig {
|
||||
luaBefore = "${cfg.luaConfigPre}";
|
||||
luaConfig = concatStringsSep "\n" (map mkLuarcSection result);
|
||||
luaConfig = concatLines (map mkLuarcSection result);
|
||||
luaAfter = "${cfg.luaConfigPost}";
|
||||
});
|
||||
|
||||
|
@ -155,7 +155,7 @@ in {
|
|||
|
||||
extraPluginConfigs = let
|
||||
mapResult = result: (wrapLuaConfig {
|
||||
luaConfig = concatStringsSep "\n" (map mkLuarcSection result);
|
||||
luaConfig = concatLines (map mkLuarcSection result);
|
||||
});
|
||||
|
||||
extraPluginsDag = mapAttrs (_: {
|
||||
|
@ -189,7 +189,7 @@ in {
|
|||
icmap
|
||||
allmap
|
||||
];
|
||||
mapConfig = wrapLuaConfig {luaConfig = concatStringsSep "\n" (map (v: concatStringsSep "\n" v) maps);};
|
||||
mapConfig = wrapLuaConfig {luaConfig = concatLines (map concatLines maps);};
|
||||
in
|
||||
entryAfter ["globalsScript"] mapConfig;
|
||||
};
|
||||
|
@ -200,10 +200,10 @@ in {
|
|||
failedAssertions = map (x: x.message) (filter (x: !x.assertion) config.assertions);
|
||||
baseSystemAssertWarn =
|
||||
if failedAssertions != []
|
||||
then throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}"
|
||||
then throw "\nFailed assertions:\n${concatMapStringsSep "\n" (x: "- ${x}") failedAssertions}"
|
||||
else showWarnings config.warnings;
|
||||
|
||||
mapResult = result: (concatStringsSep "\n" (map mkVimrcSection result));
|
||||
mapResult = result: concatMapStringsSep "\n" mkVimrcSection result;
|
||||
vimConfig = resolveDag {
|
||||
name = "vim config script";
|
||||
dag = cfg.configRC;
|
||||
|
|
Loading…
Reference in a new issue