diff --git a/plugins/colorschemes/ayu.nix b/colorschemes/ayu/default.nix similarity index 100% rename from plugins/colorschemes/ayu.nix rename to colorschemes/ayu/default.nix diff --git a/plugins/colorschemes/bamboo.nix b/colorschemes/bamboo/default.nix similarity index 100% rename from plugins/colorschemes/bamboo.nix rename to colorschemes/bamboo/default.nix diff --git a/plugins/colorschemes/base16/default.nix b/colorschemes/base16/default.nix similarity index 100% rename from plugins/colorschemes/base16/default.nix rename to colorschemes/base16/default.nix diff --git a/plugins/colorschemes/base16/theme-list.nix b/colorschemes/base16/theme-list.nix similarity index 100% rename from plugins/colorschemes/base16/theme-list.nix rename to colorschemes/base16/theme-list.nix diff --git a/plugins/colorschemes/catppuccin.nix b/colorschemes/catppuccin/default.nix similarity index 100% rename from plugins/colorschemes/catppuccin.nix rename to colorschemes/catppuccin/default.nix diff --git a/plugins/colorschemes/cyberdream.nix b/colorschemes/cyberdream/default.nix similarity index 100% rename from plugins/colorschemes/cyberdream.nix rename to colorschemes/cyberdream/default.nix diff --git a/plugins/colorschemes/dracula-nvim.nix b/colorschemes/dracula-nvim/default.nix similarity index 100% rename from plugins/colorschemes/dracula-nvim.nix rename to colorschemes/dracula-nvim/default.nix diff --git a/plugins/colorschemes/dracula.nix b/colorschemes/dracula/default.nix similarity index 100% rename from plugins/colorschemes/dracula.nix rename to colorschemes/dracula/default.nix diff --git a/plugins/colorschemes/everforest.nix b/colorschemes/everforest/default.nix similarity index 100% rename from plugins/colorschemes/everforest.nix rename to colorschemes/everforest/default.nix diff --git a/plugins/colorschemes/github-theme.nix b/colorschemes/github-theme/default.nix similarity index 100% rename from plugins/colorschemes/github-theme.nix rename to colorschemes/github-theme/default.nix diff --git a/plugins/colorschemes/gruvbox-baby.nix b/colorschemes/gruvbox-baby/default.nix similarity index 100% rename from plugins/colorschemes/gruvbox-baby.nix rename to colorschemes/gruvbox-baby/default.nix diff --git a/plugins/colorschemes/gruvbox-material-nvim.nix b/colorschemes/gruvbox-material-nvim/default.nix similarity index 100% rename from plugins/colorschemes/gruvbox-material-nvim.nix rename to colorschemes/gruvbox-material-nvim/default.nix diff --git a/plugins/colorschemes/gruvbox-material.nix b/colorschemes/gruvbox-material/default.nix similarity index 100% rename from plugins/colorschemes/gruvbox-material.nix rename to colorschemes/gruvbox-material/default.nix diff --git a/plugins/colorschemes/gruvbox.nix b/colorschemes/gruvbox/default.nix similarity index 100% rename from plugins/colorschemes/gruvbox.nix rename to colorschemes/gruvbox/default.nix diff --git a/plugins/colorschemes/kanagawa-paper.nix b/colorschemes/kanagawa-paper/default.nix similarity index 100% rename from plugins/colorschemes/kanagawa-paper.nix rename to colorschemes/kanagawa-paper/default.nix diff --git a/plugins/colorschemes/kanagawa.nix b/colorschemes/kanagawa/default.nix similarity index 100% rename from plugins/colorschemes/kanagawa.nix rename to colorschemes/kanagawa/default.nix diff --git a/plugins/colorschemes/melange.nix b/colorschemes/melange/default.nix similarity index 100% rename from plugins/colorschemes/melange.nix rename to colorschemes/melange/default.nix diff --git a/plugins/colorschemes/mini-base16.nix b/colorschemes/mini-base16/default.nix similarity index 100% rename from plugins/colorschemes/mini-base16.nix rename to colorschemes/mini-base16/default.nix diff --git a/plugins/colorschemes/mini-hues.nix b/colorschemes/mini-hues/default.nix similarity index 100% rename from plugins/colorschemes/mini-hues.nix rename to colorschemes/mini-hues/default.nix diff --git a/plugins/colorschemes/modus.nix b/colorschemes/modus/default.nix similarity index 100% rename from plugins/colorschemes/modus.nix rename to colorschemes/modus/default.nix diff --git a/plugins/colorschemes/monokai-pro.nix b/colorschemes/monokai-pro/default.nix similarity index 100% rename from plugins/colorschemes/monokai-pro.nix rename to colorschemes/monokai-pro/default.nix diff --git a/plugins/colorschemes/moonfly.nix b/colorschemes/moonfly/default.nix similarity index 100% rename from plugins/colorschemes/moonfly.nix rename to colorschemes/moonfly/default.nix diff --git a/plugins/colorschemes/nightfox.nix b/colorschemes/nightfox/default.nix similarity index 100% rename from plugins/colorschemes/nightfox.nix rename to colorschemes/nightfox/default.nix diff --git a/plugins/colorschemes/nord.nix b/colorschemes/nord/default.nix similarity index 100% rename from plugins/colorschemes/nord.nix rename to colorschemes/nord/default.nix diff --git a/plugins/colorschemes/one.nix b/colorschemes/one/default.nix similarity index 100% rename from plugins/colorschemes/one.nix rename to colorschemes/one/default.nix diff --git a/plugins/colorschemes/onedark.nix b/colorschemes/onedark/default.nix similarity index 100% rename from plugins/colorschemes/onedark.nix rename to colorschemes/onedark/default.nix diff --git a/plugins/colorschemes/oxocarbon.nix b/colorschemes/oxocarbon/default.nix similarity index 100% rename from plugins/colorschemes/oxocarbon.nix rename to colorschemes/oxocarbon/default.nix diff --git a/plugins/colorschemes/palette.nix b/colorschemes/palette/default.nix similarity index 100% rename from plugins/colorschemes/palette.nix rename to colorschemes/palette/default.nix diff --git a/plugins/colorschemes/poimandres.nix b/colorschemes/poimandres/default.nix similarity index 100% rename from plugins/colorschemes/poimandres.nix rename to colorschemes/poimandres/default.nix diff --git a/plugins/colorschemes/rose-pine.nix b/colorschemes/rose-pine/default.nix similarity index 100% rename from plugins/colorschemes/rose-pine.nix rename to colorschemes/rose-pine/default.nix diff --git a/plugins/colorschemes/solarized-osaka.nix b/colorschemes/solarized-osaka/default.nix similarity index 100% rename from plugins/colorschemes/solarized-osaka.nix rename to colorschemes/solarized-osaka/default.nix diff --git a/plugins/colorschemes/tokyonight.nix b/colorschemes/tokyonight/default.nix similarity index 100% rename from plugins/colorschemes/tokyonight.nix rename to colorschemes/tokyonight/default.nix diff --git a/plugins/colorschemes/vscode.nix b/colorschemes/vscode/default.nix similarity index 100% rename from plugins/colorschemes/vscode.nix rename to colorschemes/vscode/default.nix diff --git a/flake/dev/new-plugin.py b/flake/dev/new-plugin.py index a88de0bd..7513a092 100755 --- a/flake/dev/new-plugin.py +++ b/flake/dev/new-plugin.py @@ -5,7 +5,7 @@ import os import re from argparse import ArgumentParser -# Template for default.nix +# Template for default.nix (plugin) # TODO: conditionally include parts of the template based on args default_nix_template = """{{ lib, ... }}: lib.nixvim.plugins.mkNeovimPlugin {{ @@ -24,7 +24,28 @@ lib.nixvim.plugins.mkNeovimPlugin {{ }} """ -# Template for test file +# Template for default.nix (colorscheme) +colorscheme_nix_template = """{{ lib, ... }}: +lib.nixvim.plugins.mkNeovimPlugin {{ + name = "{name}"; + moduleName = "LUA_MODULE_NAME"; # TODO replace (or remove entirely if it is the same as `name`) + package = "{package}"; + + isColorscheme = true; + colorscheme = "COLORSCHEME_NAME"; # TODO replace (or set to null if it has multiple colorschemes or doesn't need to set colorscheme, or remove completely if same as name) + + {maintainer_todo}maintainers = [ lib.maintainers.{maintainer} ]; + + # TODO provide an example for the `settings` option (or remove entirely if there is no useful example) + # NOTE you can use `lib.literalExpression` or `lib.literalMD` if needed + settingsExample = {{ + foo = 42; + bar.__raw = "function() print('hello') end"; + }}; +}} +""" + +# Template for test file (plugin) test_nix_template = """{{ empty = {{ plugins.{name}.enable = true; @@ -42,6 +63,27 @@ test_nix_template = """{{ }} """ +# Template for test file (colorscheme) +colorscheme_test_nix_template = """{{ + empty = {{ + colorscheme = "COLORSCHEME_NAME"; # TODO replace (or remove completely if doesn't need to set colorscheme) + colorschemes.{name}.enable = true; + }}; + + defaults = {{ + colorscheme = "COLORSCHEME_NAME"; # TODO replace (or remove completely if doesn't need to set colorscheme) + + colorschemes.{name} = {{ + enable = true; + settings = {{ + foo = 42; + bar.__raw = "function() print('hello') end"; + }}; + }}; + }}; +}} +""" + def to_kebab_case(input_string): """ @@ -163,15 +205,15 @@ def find_project_root(root_identifier): # TODO: support interactive unmanaged args def main(): """ - Main function to generate default.nix and test files for a new plugin. + Main function to generate default.nix and test files for a new plugin or colorscheme. """ DEFAULT_MAINTAINER = "YOUR_NAME" parser = ArgumentParser( - description="Generate default.nix and test files for a new plugin" + description="Generate default.nix and test files for a new plugin or colorscheme" ) parser.add_argument( - "originalName", type=str, help="Original name of the new plugin" + "originalName", type=str, help="Original name of the new plugin or colorscheme" ) parser.add_argument( "--package", @@ -186,6 +228,12 @@ def main(): help="Maintainer name (from lib.maintainers)", default=DEFAULT_MAINTAINER, ) + parser.add_argument( + "--colorscheme", + "-c", + action="store_true", + help="Create a colorscheme instead of a plugin", + ) parser.add_argument( "--dry-run", "-d", @@ -207,13 +255,21 @@ def main(): root_identifier = "flake.nix" root_dir = find_project_root(root_identifier) - plugin_path = f"{root_dir}/plugins/by-name/{name}/default.nix" - test_path = f"{root_dir}/tests/test-sources/plugins/by-name/{name}/default.nix" + if args.colorscheme: + plugin_template = colorscheme_nix_template + test_template = colorscheme_test_nix_template + plugin_path = f"{root_dir}/colorschemes/{name}/default.nix" + test_path = f"{root_dir}/tests/test-sources/colorschemes/{name}/default.nix" + else: + plugin_template = default_nix_template + test_template = test_nix_template + plugin_path = f"{root_dir}/plugins/by-name/{name}/default.nix" + test_path = f"{root_dir}/tests/test-sources/plugins/by-name/{name}/default.nix" # Create files create_nix_file( plugin_path, - default_nix_template, + plugin_template, name, args.originalName, package, @@ -223,7 +279,7 @@ def main(): ) create_test_file( test_path, - test_nix_template, + test_template, name, args.dry_run, ) diff --git a/modules/plugins.nix b/modules/plugins.nix index f2f5228c..9eb2f576 100644 --- a/modules/plugins.nix +++ b/modules/plugins.nix @@ -2,15 +2,21 @@ let inherit (builtins) readDir; inherit (lib.attrsets) foldlAttrs; - inherit (lib.lists) optional; - by-name = ../plugins/by-name; + inherit (lib.lists) optional concatMap; + + mkByName = + dir: + foldlAttrs ( + prev: name: type: + prev ++ optional (type == "directory") (dir + "/${name}") + ) [ ] (readDir dir); in { imports = [ ../plugins ] - ++ foldlAttrs ( - prev: name: type: - prev ++ optional (type == "directory") (by-name + "/${name}") - ) [ ] (readDir by-name); + ++ concatMap mkByName [ + ../colorschemes + ../plugins/by-name + ]; } diff --git a/plugins/default.nix b/plugins/default.nix index 856cb764..998879ee 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -2,39 +2,6 @@ imports = [ ./cmp - ./colorschemes/ayu.nix - ./colorschemes/bamboo.nix - ./colorschemes/base16 - ./colorschemes/catppuccin.nix - ./colorschemes/cyberdream.nix - ./colorschemes/dracula-nvim.nix - ./colorschemes/dracula.nix - ./colorschemes/everforest.nix - ./colorschemes/github-theme.nix - ./colorschemes/gruvbox.nix - ./colorschemes/gruvbox-baby.nix - ./colorschemes/gruvbox-material.nix - ./colorschemes/gruvbox-material-nvim.nix - ./colorschemes/kanagawa.nix - ./colorschemes/kanagawa-paper.nix - ./colorschemes/melange.nix - ./colorschemes/mini-base16.nix - ./colorschemes/mini-hues.nix - ./colorschemes/modus.nix - ./colorschemes/monokai-pro.nix - ./colorschemes/moonfly.nix - ./colorschemes/nightfox.nix - ./colorschemes/nord.nix - ./colorschemes/one.nix - ./colorschemes/onedark.nix - ./colorschemes/oxocarbon.nix - ./colorschemes/palette.nix - ./colorschemes/poimandres.nix - ./colorschemes/rose-pine.nix - ./colorschemes/solarized-osaka.nix - ./colorschemes/tokyonight.nix - ./colorschemes/vscode.nix - ./lsp ./pluginmanagers/lazy.nix diff --git a/tests/test-sources/plugins/colorschemes/ayu.nix b/tests/test-sources/colorschemes/ayu/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/ayu.nix rename to tests/test-sources/colorschemes/ayu/default.nix diff --git a/tests/test-sources/plugins/colorschemes/bamboo.nix b/tests/test-sources/colorschemes/bamboo/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/bamboo.nix rename to tests/test-sources/colorschemes/bamboo/default.nix diff --git a/tests/test-sources/plugins/colorschemes/base16.nix b/tests/test-sources/colorschemes/base16/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/base16.nix rename to tests/test-sources/colorschemes/base16/default.nix diff --git a/tests/test-sources/plugins/colorschemes/catppuccin.nix b/tests/test-sources/colorschemes/catppuccin/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/catppuccin.nix rename to tests/test-sources/colorschemes/catppuccin/default.nix diff --git a/tests/test-sources/plugins/colorschemes/cyberdream.nix b/tests/test-sources/colorschemes/cyberdream/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/cyberdream.nix rename to tests/test-sources/colorschemes/cyberdream/default.nix diff --git a/tests/test-sources/plugins/colorschemes/dracula-nvim.nix b/tests/test-sources/colorschemes/dracula-nvim/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/dracula-nvim.nix rename to tests/test-sources/colorschemes/dracula-nvim/default.nix diff --git a/tests/test-sources/plugins/colorschemes/dracula.nix b/tests/test-sources/colorschemes/dracula/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/dracula.nix rename to tests/test-sources/colorschemes/dracula/default.nix diff --git a/tests/test-sources/plugins/colorschemes/everforest.nix b/tests/test-sources/colorschemes/everforest/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/everforest.nix rename to tests/test-sources/colorschemes/everforest/default.nix diff --git a/tests/test-sources/plugins/colorschemes/github-theme.nix b/tests/test-sources/colorschemes/github-theme/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/github-theme.nix rename to tests/test-sources/colorschemes/github-theme/default.nix diff --git a/tests/test-sources/plugins/colorschemes/gruvbox-baby.nix b/tests/test-sources/colorschemes/gruvbox-baby/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/gruvbox-baby.nix rename to tests/test-sources/colorschemes/gruvbox-baby/default.nix diff --git a/tests/test-sources/plugins/colorschemes/gruvbox-material-nvim.nix b/tests/test-sources/colorschemes/gruvbox-material-nvim/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/gruvbox-material-nvim.nix rename to tests/test-sources/colorschemes/gruvbox-material-nvim/default.nix diff --git a/tests/test-sources/plugins/colorschemes/gruvbox-material.nix b/tests/test-sources/colorschemes/gruvbox-material/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/gruvbox-material.nix rename to tests/test-sources/colorschemes/gruvbox-material/default.nix diff --git a/tests/test-sources/plugins/colorschemes/gruvbox.nix b/tests/test-sources/colorschemes/gruvbox/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/gruvbox.nix rename to tests/test-sources/colorschemes/gruvbox/default.nix diff --git a/tests/test-sources/plugins/colorschemes/kanagawa-paper.nix b/tests/test-sources/colorschemes/kanagawa-paper/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/kanagawa-paper.nix rename to tests/test-sources/colorschemes/kanagawa-paper/default.nix diff --git a/tests/test-sources/plugins/colorschemes/kanagawa.nix b/tests/test-sources/colorschemes/kanagawa/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/kanagawa.nix rename to tests/test-sources/colorschemes/kanagawa/default.nix diff --git a/tests/test-sources/plugins/colorschemes/melange.nix b/tests/test-sources/colorschemes/melange/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/melange.nix rename to tests/test-sources/colorschemes/melange/default.nix diff --git a/tests/test-sources/plugins/colorschemes/mini-base16.nix b/tests/test-sources/colorschemes/mini-base16/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/mini-base16.nix rename to tests/test-sources/colorschemes/mini-base16/default.nix diff --git a/tests/test-sources/plugins/colorschemes/mini-hues.nix b/tests/test-sources/colorschemes/mini-hues/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/mini-hues.nix rename to tests/test-sources/colorschemes/mini-hues/default.nix diff --git a/tests/test-sources/plugins/colorschemes/modus.nix b/tests/test-sources/colorschemes/modus/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/modus.nix rename to tests/test-sources/colorschemes/modus/default.nix diff --git a/tests/test-sources/plugins/colorschemes/monokai-pro.nix b/tests/test-sources/colorschemes/monokai-pro/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/monokai-pro.nix rename to tests/test-sources/colorschemes/monokai-pro/default.nix diff --git a/tests/test-sources/plugins/colorschemes/moonfly.nix b/tests/test-sources/colorschemes/moonfly/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/moonfly.nix rename to tests/test-sources/colorschemes/moonfly/default.nix diff --git a/tests/test-sources/plugins/colorschemes/nightfox.nix b/tests/test-sources/colorschemes/nightfox/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/nightfox.nix rename to tests/test-sources/colorschemes/nightfox/default.nix diff --git a/tests/test-sources/plugins/colorschemes/nord.nix b/tests/test-sources/colorschemes/nord/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/nord.nix rename to tests/test-sources/colorschemes/nord/default.nix diff --git a/tests/test-sources/plugins/colorschemes/one.nix b/tests/test-sources/colorschemes/one/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/one.nix rename to tests/test-sources/colorschemes/one/default.nix diff --git a/tests/test-sources/plugins/colorschemes/onedark.nix b/tests/test-sources/colorschemes/onedark/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/onedark.nix rename to tests/test-sources/colorschemes/onedark/default.nix diff --git a/tests/test-sources/plugins/colorschemes/oxocarbon.nix b/tests/test-sources/colorschemes/oxocarbon/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/oxocarbon.nix rename to tests/test-sources/colorschemes/oxocarbon/default.nix diff --git a/tests/test-sources/plugins/colorschemes/palette.nix b/tests/test-sources/colorschemes/palette/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/palette.nix rename to tests/test-sources/colorschemes/palette/default.nix diff --git a/tests/test-sources/plugins/colorschemes/poimandres.nix b/tests/test-sources/colorschemes/poimandres/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/poimandres.nix rename to tests/test-sources/colorschemes/poimandres/default.nix diff --git a/tests/test-sources/plugins/colorschemes/rose-pine.nix b/tests/test-sources/colorschemes/rose-pine/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/rose-pine.nix rename to tests/test-sources/colorschemes/rose-pine/default.nix diff --git a/tests/test-sources/plugins/colorschemes/solazized-osaka.nix b/tests/test-sources/colorschemes/solarized-osaka/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/solazized-osaka.nix rename to tests/test-sources/colorschemes/solarized-osaka/default.nix diff --git a/tests/test-sources/plugins/colorschemes/tokyonight.nix b/tests/test-sources/colorschemes/tokyonight/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/tokyonight.nix rename to tests/test-sources/colorschemes/tokyonight/default.nix diff --git a/tests/test-sources/plugins/colorschemes/vscode.nix b/tests/test-sources/colorschemes/vscode/default.nix similarity index 100% rename from tests/test-sources/plugins/colorschemes/vscode.nix rename to tests/test-sources/colorschemes/vscode/default.nix