mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-22 08:53:28 +02:00
modules/spellfiles: init
This commit is contained in:
parent
a3245848da
commit
420470dfde
7 changed files with 1015 additions and 0 deletions
|
@ -27,4 +27,5 @@ lib.fix (self: {
|
|||
none-ls-builtins = pkgs.callPackage ./none-ls.nix { };
|
||||
rust-analyzer-options = pkgs.callPackage ./rust-analyzer { };
|
||||
lspconfig-servers = pkgs.callPackage ./nvim-lspconfig { };
|
||||
fetch-spellfiles = pkgs.callPackage ./fetch-spellfiles.nix { };
|
||||
})
|
||||
|
|
44
update-scripts/fetch-spellfiles.nix
Normal file
44
update-scripts/fetch-spellfiles.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
writeShellApplication,
|
||||
curl,
|
||||
nix,
|
||||
...
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "fetch-spellfiles";
|
||||
|
||||
runtimeInputs = [
|
||||
curl
|
||||
nix
|
||||
];
|
||||
|
||||
text = ''
|
||||
echo "{"
|
||||
|
||||
BASE_URL="https://ftp.nluug.nl/pub/vim/runtime/spell/"
|
||||
|
||||
html=$(curl -s "$BASE_URL")
|
||||
|
||||
# Extract only .spl and .sug file links
|
||||
readarray -t filenames < <(echo "$html" | grep -oP '(?<=href=")[^"]+\.(spl|sug)' | sort -u)
|
||||
|
||||
for filename in "''${filenames[@]}"; do
|
||||
|
||||
url="$BASE_URL$filename"
|
||||
|
||||
# Special characters (like '%40', standing for `@`) are invalid for nix store paths
|
||||
# -> We replace all non-alphanumeric characters with '_' and used this sanitized filename for
|
||||
# the derivation name
|
||||
sanitized_filename="''${filename//[^a-zA-Z0-9]/_}"
|
||||
sha256=$(nix-prefetch-url "$url" --name "$sanitized_filename")
|
||||
|
||||
hash=$(nix hash convert --to sri --hash-algo sha256 "$sha256")
|
||||
|
||||
# Ugly hardcoding of the `%40` -> `@` substitution
|
||||
filename="''${filename//%40/@}"
|
||||
echo -e " \"$filename\": { url: \"$url\", hash: \"$hash\" },"
|
||||
done
|
||||
|
||||
echo "}"
|
||||
'';
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
{
|
||||
lib,
|
||||
writeShellApplication,
|
||||
rust-analyzer-options,
|
||||
efmls-configs-sources,
|
||||
none-ls-builtins,
|
||||
lspconfig-servers,
|
||||
fetch-spellfiles,
|
||||
nixfmt-rfc-style,
|
||||
nodePackages,
|
||||
}:
|
||||
|
@ -49,6 +51,12 @@ writeShellApplication {
|
|||
echo "lspconfig servers"
|
||||
prettier --parser=json "${lspconfig-servers}" >"$generated_dir/lspconfig-servers.json"
|
||||
|
||||
echo "fetching spellfiles"
|
||||
${lib.getExe fetch-spellfiles} > "$generated_dir/spellfiles.json"
|
||||
prettier --parser=json --write "$generated_dir/spellfiles.json"
|
||||
|
||||
################################################################
|
||||
|
||||
if [ -n "$commit" ]; then
|
||||
cd "$generated_dir"
|
||||
git add .
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue