Compare commits

..

2 commits

Author SHA1 Message Date
raf
4e647505d6
Merge 5c950f5f8c into 42c5228dc1 2024-10-28 17:05:08 +00:00
5c950f5f8c
docs: update release notes 2024-10-28 20:05:01 +03:00
2 changed files with 31 additions and 46 deletions

View file

@ -64,11 +64,6 @@ in {
=> $out/spell/en-utf-8.add.spl
```
:::
Note that while adding a new language, you will still need to add the name of
the language (e.g. "en") to the {option}`vim.spellcheck.languages` list by name
in order to enable spellchecking for the language. By default only `"en"` is in
the list.
'';
};
@ -86,45 +81,47 @@ in {
'';
};
/*
# FIXME: This needs to be revisited. It tries to install
# the spellfile to an user directory, but it cannot do so
# as we sanitize runtime paths.
programmingWordlist.enable = mkEnableOption ''
vim-dirtytalk, a wordlist for programmers containing
common programming terms.
::: {.note}
Enabling this option will unconditionally set
{option}`vim.spellcheck.enable` to true as vim-dirtytalk
depends on spellchecking having been set up.
:::
Setting this value as `true` has the same effect
as setting {option}`vim.spellCheck.enable`
'';
*/
};
config = mkIf cfg.enable {
vim = {
additionalRuntimePaths = let
spellfilesJoined = pkgs.symlinkJoin {
name = "nvf-spellfiles-joined";
paths = mapAttrsToList (name: value: pkgs.writeTextDir "spell/${name}.add" (concatLines value)) cfg.extraSpellWords;
postBuild = ''
echo "Spellfiles joined"
'';
};
compileJoinedSpellfiles =
pkgs.runCommandLocal "nvf-compile-spellfiles" {
# Use the same version of Neovim as the user's configuration
nativeBuildInputs = [config.vim.package];
spellfilesJoined = pkgs.symlinkJoin {
name = "nvf-spellfiles-joined";
paths = mapAttrsToList (name: value: pkgs.writeTextDir "spell/${name}.add" (concatLines value)) cfg.extraSpellWords;
postBuild = "echo Spellfiles joined";
};
} ''
# Fail on unset variables and non-zero exit codes
# this might be the only way to trace when `nvim --headless`
# fails in batch mode
set -eu
mkdir -p "$out/spell"
for spellfile in "$spellfilesJoined"/spell/*.add; do
name="$(basename "$spellfile" ".add")"
echo "Compiling spellfile: $spellfile"
nvim --headless --clean \
--cmd "mkspell $out/spell/$name.add.spl $spellfile" -Es -n
done
spellfilesJoined=$(find -L "${spellfilesJoined}/spell" -type f)
for spellfile in $spellfilesJoined; do
# Hacky way to ensure that the mangled extensions are omitted from the
# joined spellfiles. E.g.
local name=$(basename "$spellfile" ".add")
echo "Compiling spellfile: $spellfile"
nvim --headless --clean \
--cmd "mkspell $out/spell/$name.add.spl $spellfile" -Es -n
done
'';
in
mkIf (cfg.extraSpellWords != {}) [
@ -139,9 +136,7 @@ in {
-- Disable spellchecking for certain filetypes
-- as configured by `vim.spellcheck.ignoredFiletypes`
vim.api.nvim_create_augroup("nvf_autocmds", {clear = false})
vim.api.nvim_create_autocmd({ "FileType" }, {
group = "nvf_autocmds",
pattern = ${listToLuaTable cfg.ignoredFiletypes},
callback = function()
vim.opt_local.spell = false

View file

@ -7,26 +7,16 @@
inherit (lib.nvim.dag) entryAfter;
cfg = config.vim.spellcheck;
in {
config = mkIf cfg.programmingWordlist.enable {
config = mkIf (cfg.enable && cfg.programmingWordlist.enable) {
vim = {
startPlugins = ["vim-dirtytalk"];
spellcheck.enable = true;
# vim-dirtytalk doesn't have any setup but we would
# like to append programming to spelllangs as soon as
# possible while the plugin is enabled and the state
# directory can be found.
pluginRC.vim-dirtytalk = entryAfter ["spellcheck"] ''
-- If Neovim can find (or access) the state directory
-- then append "programming" wordlist from vim-dirtytalk
-- to spelllang table. If path cannot be found, display
-- an error and avoid appending the programming words
if vim.fn.isdirectory(vim.fn.stdpath('state')) == 1 then
vim.opt.spelllang:append("programming")
else
vim.notify("State path does not exist: " .. state_path, vim.log.levels.ERROR)
end
# vim-dirtytalk doesn't have any setup
# but we would like to append programming to spelllang
# as soon as possible while the plugin is enabled
pluginRC.vim-dirtytalk = entryAfter ["basic"] ''
-- append programming to spelllang
vim.opt.spelllang:append("programming")
'';
};
};