dev: still trying to pass inputs

This commit is contained in:
NotAShelf 2023-07-30 22:25:23 +03:00
parent 8d9ca12b9d
commit 3d0c62f961
No known key found for this signature in database
GPG Key ID: 02D1DD3FA08B6B29
5 changed files with 81 additions and 162 deletions

View File

@ -25,7 +25,7 @@
flake = { flake = {
lib = { lib = {
inherit (import ./lib/stdlib-extended.nix input:s nixpkgs.lib) nvim; inherit (import ./lib/stdlib-extended.nix inputs nixpkgs.lib) nvim;
inherit (import ./configuration.nix inputs) neovimConfiguration; inherit (import ./configuration.nix inputs) neovimConfiguration;
}; };

66
lib/binds.nix Normal file
View File

@ -0,0 +1,66 @@
{lib}: rec {
mkLuaBinding = key: action: desc:
lib.mkIf (key != null) {
"${key}" = {
inherit action desc;
lua = true;
silent = true;
};
};
mkExprBinding = key: action: desc:
lib.mkIf (key != null) {
"${key}" = {
inherit action desc;
lua = true;
silent = true;
expr = true;
};
};
mkBinding = key: action: desc:
lib.mkIf (key != null) {
"${key}" = {
inherit action desc;
silent = true;
};
};
mkMappingOption = description: default:
lib.mkOption {
type = lib.types.nullOrlib.types.str;
inherit default description;
};
# Utility function that takes two attrsets:
# { someKey = "some_value" } and
# { someKey = { description = "Some Description"; }; }
# and merges them into
# { someKey = { value = "some_value"; description = "Some Description"; }; }
addDescriptionsToMappings = actualMappings: mappingDefinitions:
lib.attrsets.mapAttrs (name: value: let
isNested = lib.isAttrs value;
returnedValue =
if isNested
then addDescriptionsToMappings actualMappings."${name}" mappingDefinitions."${name}"
else {
value = value;
description = mappingDefinitions."${name}".description;
};
in
returnedValue)
actualMappings;
mkSetBinding = binding: action:
mkBinding binding.value action binding.description;
mkSetExprBinding = binding: action:
mkExprBinding binding.value action binding.description;
mkSetLuaBinding = binding: action:
mkLuaBinding binding.value action binding.description;
# For forward compatibility.
literalExpression = lib.literalExpression or lib.literalExample;
literalDocBook = lib.literalDocBook or lib.literalExample;
}

View File

@ -4,71 +4,6 @@
nixpkgsLib: let nixpkgsLib: let
mkNvimLib = import ./.; mkNvimLib = import ./.;
in in
nixpkgsLib.extend (self: super: rec { nixpkgsLib.extend (self: super: {
nvim = mkNvimLib {lib = self;}; nvim = mkNvimLib {lib = self;};
mkLuaBinding = key: action: desc:
self.mkIf (key != null) {
"${key}" = {
inherit action desc;
lua = true;
silent = true;
};
};
mkExprBinding = key: action: desc:
self.mkIf (key != null) {
"${key}" = {
inherit action desc;
lua = true;
silent = true;
expr = true;
};
};
mkBinding = key: action: desc:
self.mkIf (key != null) {
"${key}" = {
inherit action desc;
silent = true;
};
};
mkMappingOption = description: default:
self.mkOption {
type = self.types.nullOr self.types.str;
inherit default description;
};
# Utility function that takes two attrsets:
# { someKey = "some_value" } and
# { someKey = { description = "Some Description"; }; }
# and merges them into
# { someKey = { value = "some_value"; description = "Some Description"; }; }
addDescriptionsToMappings = actualMappings: mappingDefinitions:
self.attrsets.mapAttrs (name: value: let
isNested = self.isAttrs value;
returnedValue =
if isNested
then addDescriptionsToMappings actualMappings."${name}" mappingDefinitions."${name}"
else {
value = value;
description = mappingDefinitions."${name}".description;
};
in
returnedValue)
actualMappings;
mkSetBinding = binding: action:
mkBinding binding.value action binding.description;
mkSetExprBinding = binding: action:
mkExprBinding binding.value action binding.description;
mkSetLuaBinding = binding: action:
mkLuaBinding binding.value action binding.description;
# For forward compatibility.
literalExpression = super.literalExpression or super.literalExample;
literalDocBook = super.literalDocBook or super.literalExample;
}) })

View File

@ -1,6 +1,9 @@
{lib}: let {
inputs,
lib,
}: let
typesDag = import ./dag.nix {inherit lib;}; typesDag = import ./dag.nix {inherit lib;};
typesPlugin = import ./plugins.nix {inherit lib;}; typesPlugin = import ./plugins.nix {inherit inputs lib;};
typesLanguage = import ./languages.nix {inherit lib;}; typesLanguage = import ./languages.nix {inherit lib;};
in { in {
inherit (typesDag) dagOf; inherit (typesDag) dagOf;

View File

@ -1,102 +1,17 @@
{lib}: {lib}:
with lib; let with lib; let
# Plugin must be same as input name from flake.nix fromInputs = inputs: prefix:
availablePlugins = [ mapAttrs'
# TODO: sort by category (n: v: nameValuePair (removePrefix prefix n) {src = v;})
"nvim-treesitter-context" (filterAttrs (n: _: hasPrefix prefix n) inputs);
"gitsigns-nvim"
"plenary-nvim" rawPlugins = fromInputs inputs "plugin-";
"nvim-lspconfig"
"nvim-treesitter"
"lspsaga"
"lspkind"
"nvim-lightbulb"
"lsp-signature"
"nvim-tree-lua"
"nvim-bufferline-lua"
"lualine"
"nvim-compe"
"nvim-autopairs"
"nvim-ts-autotag"
"nvim-web-devicons"
"tokyonight"
"bufdelete-nvim"
"nvim-cmp"
"cmp-nvim-lsp"
"cmp-buffer"
"cmp-vsnip"
"cmp-path"
"cmp-treesitter"
"crates-nvim"
"vim-vsnip"
"nvim-code-action-menu"
"trouble"
"null-ls"
"which-key"
"indent-blankline"
"nvim-cursorline"
"sqls-nvim"
"glow-nvim"
"telescope"
"rust-tools"
"onedark"
"catppuccin"
"dracula"
"minimap-vim"
"dashboard-nvim"
"alpha-nvim"
"scrollbar-nvim"
"codewindow-nvim"
"nvim-notify"
"cinnamon-nvim"
"cheatsheet-nvim"
"ccc"
"cellular-automaton"
"presence-nvim"
"icon-picker-nvim"
"dressing-nvim"
"orgmode-nvim"
"obsidian-nvim"
"vim-markdown"
"tabular"
"toggleterm-nvim"
"noice-nvim"
"nui-nvim"
"copilot-lua"
"tabnine-nvim"
"nvim-session-manager"
"gesture-nvim"
"comment-nvim"
"kommentary"
"mind-nvim"
"fidget-nvim"
"diffview-nvim"
"todo-comments"
"flutter-tools"
"flutter-tools-patched"
"hop-nvim"
"leap-nvim"
"modes-nvim"
"vim-repeat"
"smartcolumn"
"project-nvim"
"elixir-ls"
"elixir-tools"
"nvim-colorizer-lua"
"vim-illuminate"
"nvim-surround"
"nvim-dap"
"nvim-dap-ui"
"nvim-navic"
"nvim-navbuddy"
"copilot-cmp"
];
# You can either use the name of the plugin or a package.
pluginType = with types; pluginType = with types;
nullOr ( nullOr (
either either
package package
(enum availablePlugins) (enum rawPlugins)
); );
pluginsType = types.listOf pluginType; pluginsType = types.listOf pluginType;