mirror of
https://github.com/nix-community/nixvim.git
synced 2025-11-09 03:56:05 +01:00
Merge 941a9f7946 into d4b798a469
This commit is contained in:
commit
302afacaac
68 changed files with 77 additions and 48 deletions
|
|
@ -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)
|
||||
|
||||
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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue