mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-30 00:26:45 +00:00
get rid of after/
This commit is contained in:
parent
62292777f1
commit
53207d2dcb
1 changed files with 21 additions and 21 deletions
|
@ -6,7 +6,7 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf mkRenamedOptionModule;
|
inherit (lib.modules) mkIf mkRenamedOptionModule;
|
||||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||||
inherit (lib.strings) concatStringsSep;
|
inherit (lib.strings) concatLines;
|
||||||
inherit (lib.attrsets) mapAttrsToList;
|
inherit (lib.attrsets) mapAttrsToList;
|
||||||
inherit (lib.types) listOf str attrsOf;
|
inherit (lib.types) listOf str attrsOf;
|
||||||
inherit (lib.nvim.lua) listToLuaTable;
|
inherit (lib.nvim.lua) listToLuaTable;
|
||||||
|
@ -33,9 +33,9 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
extraSpellFiles = mkOption {
|
extraSpellWords = mkOption {
|
||||||
type = attrsOf (listOf str);
|
type = attrsOf (listOf str);
|
||||||
default = {"en.utf-8" = ["nvf" "word_you_want_to_add"];};
|
default = {};
|
||||||
example = literalExpression ''{"en.utf-8" = ["nvf" "word_you_want_to_add"];}'';
|
example = literalExpression ''{"en.utf-8" = ["nvf" "word_you_want_to_add"];}'';
|
||||||
description = ''
|
description = ''
|
||||||
Additional words to be used for spellchecking. The names of each key will be
|
Additional words to be used for spellchecking. The names of each key will be
|
||||||
|
@ -46,15 +46,13 @@ in {
|
||||||
```
|
```
|
||||||
|
|
||||||
will result in `en.utf-8.add.spl` being added to Neovim's runtime in the
|
will result in `en.utf-8.add.spl` being added to Neovim's runtime in the
|
||||||
`after/spell` <directory. Spellwords added in `after/spell` will be loaded
|
{file}`spell` directory.
|
||||||
after all spell directories provided by plugins and those placed in
|
|
||||||
{file}`$XDG_CONFIG_HOME/nvf/spell`.
|
|
||||||
|
|
||||||
::: {.warning}
|
::: {.warning}
|
||||||
The attribute keys must be in `"<name>.<encoding>"` format for Neovim to
|
The attribute keys must be in `"<name>.<encoding>"` format for Neovim to
|
||||||
compile your spellfiles without mangling the resulting file names. Please
|
compile your spellfiles without mangling the resulting file names. Please
|
||||||
make sure that you enter the correct value, as nvf does not do any kind of
|
make sure that you enter the correct value, as nvf does not do any kind of
|
||||||
internal checking. Please see `:help mkspell` for more details.
|
internal checking. Please see {command}`:help mkspell` for more details.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -63,7 +61,7 @@ in {
|
||||||
# will be enough, however, you may change it to any encoding format Neovim
|
# will be enough, however, you may change it to any encoding format Neovim
|
||||||
# accepts, e.g., utf-16.
|
# accepts, e.g., utf-16.
|
||||||
"en.utf-8" = ["nvf" "word_you_want_to_add"];
|
"en.utf-8" = ["nvf" "word_you_want_to_add"];
|
||||||
=> $out/after/spell/en-utf-8.add.spl
|
=> $out/spell/en-utf-8.add.spl
|
||||||
```
|
```
|
||||||
:::
|
:::
|
||||||
'';
|
'';
|
||||||
|
@ -76,8 +74,10 @@ in {
|
||||||
description = ''
|
description = ''
|
||||||
A list of filetypes for which spellchecking will be disabled.
|
A list of filetypes for which spellchecking will be disabled.
|
||||||
|
|
||||||
|
::: {.tip}
|
||||||
You may use {command}`:echo &filetype` in Neovim to find out the
|
You may use {command}`:echo &filetype` in Neovim to find out the
|
||||||
filetype for a specific buffer.
|
filetype for a specific buffer.
|
||||||
|
:::
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ in {
|
||||||
additionalRuntimePaths = let
|
additionalRuntimePaths = let
|
||||||
spellfilesJoined = pkgs.symlinkJoin {
|
spellfilesJoined = pkgs.symlinkJoin {
|
||||||
name = "nvf-spellfiles-joined";
|
name = "nvf-spellfiles-joined";
|
||||||
paths = mapAttrsToList (name: value: pkgs.writeTextDir "spell/${name}.add" (concatStringsSep "\n" value)) cfg.extraSpellFiles;
|
paths = mapAttrsToList (name: value: pkgs.writeTextDir "spell/${name}.add" (concatLines value)) cfg.extraSpellWords;
|
||||||
postBuild = ''
|
postBuild = ''
|
||||||
echo "Spellfiles joined"
|
echo "Spellfiles joined"
|
||||||
'';
|
'';
|
||||||
|
@ -108,25 +108,25 @@ in {
|
||||||
|
|
||||||
compileJoinedSpellfiles =
|
compileJoinedSpellfiles =
|
||||||
pkgs.runCommandLocal "nvf-compile-spellfiles" {
|
pkgs.runCommandLocal "nvf-compile-spellfiles" {
|
||||||
|
# Use the same version of Neovim as the user's configuration
|
||||||
nativeBuildInputs = [config.vim.package];
|
nativeBuildInputs = [config.vim.package];
|
||||||
} ''
|
} ''
|
||||||
mkdir -p $out/after/spell
|
mkdir -p "$out/spell"
|
||||||
|
|
||||||
spellfilesJoined=$(find -L ${spellfilesJoined}/spell -type f)
|
spellfilesJoined=$(find -L "${spellfilesJoined}/spell" -type f)
|
||||||
for spellfile in $spellfilesJoined; do
|
for spellfile in $spellfilesJoined; do
|
||||||
# Hacky way to ensure that the mangled extensions are omitted from the
|
# Hacky way to ensure that the mangled extensions are omitted from the
|
||||||
# joined spellfiles. E.g.
|
# joined spellfiles. E.g.
|
||||||
local extension=".add"
|
local name=$(basename "$spellfile" ".add")
|
||||||
local name=$(basename $spellfile "$extension")
|
|
||||||
echo "Compiling spellfile: $spellfile"
|
echo "Compiling spellfile: $spellfile"
|
||||||
nvim --headless --clean \
|
nvim --headless --clean \
|
||||||
--cmd "mkspell $out/after/spell/"$name".add.spl $spellfile" -Es -n
|
--cmd "mkspell $out/spell/$name.add.spl $spellfile" -Es -n
|
||||||
|
|
||||||
ls -lah $out/after/spell
|
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
mkIf (cfg.extraSpellFiles != {}) [
|
mkIf (cfg.extraSpellWords != {}) [
|
||||||
|
# If .outPath is missing, additionalRuntimePaths receives the *function*
|
||||||
|
# instead of a path, causing errors.
|
||||||
compileJoinedSpellfiles.outPath
|
compileJoinedSpellfiles.outPath
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue