This commit is contained in:
Ching Pei Yang 2026-02-03 15:50:37 +01:00 committed by GitHub
commit 4e6319855a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 17 deletions

View file

@ -180,4 +180,8 @@ https://github.com/gorbit99/codewindow.nvim
- Add [codewindow.nvim] plugin in `vim.assistant.codewindow` with `enable` and - Add [codewindow.nvim] plugin in `vim.assistant.codewindow` with `enable` and
`setupOpts` `setupOpts`
[horriblename](https://github.com/horriblename):
- Ignore terminals by default in spell-checking
<!-- vim: set textwidth=80: --> <!-- vim: set textwidth=80: -->

View file

@ -4,13 +4,14 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) length;
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) concatLines concatStringsSep optionalString; inherit (lib.strings) concatLines concatStringsSep;
inherit (lib.attrsets) mapAttrsToList; inherit (lib.attrsets) mapAttrsToList;
inherit (lib.types) listOf str attrsOf; inherit (lib.types) listOf str attrsOf bool;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.lists) optional;
inherit (lib.nvim.dag) entryAfter; inherit (lib.generators) mkLuaInline;
cfg = config.vim.spellcheck; cfg = config.vim.spellcheck;
in { in {
@ -86,6 +87,12 @@ in {
''; '';
}; };
ignoreTerminal = mkOption {
type = bool;
default = true;
description = "Disable spell checking in terminal.";
};
programmingWordlist.enable = mkEnableOption '' programmingWordlist.enable = mkEnableOption ''
vim-dirtytalk, a wordlist for programmers containing vim-dirtytalk, a wordlist for programmers containing
common programming terms. common programming terms.
@ -144,20 +151,25 @@ in {
spelllang = concatStringsSep "," cfg.languages; spelllang = concatStringsSep "," cfg.languages;
}; };
# Register an autocommand to disable spellchecking in buffers with given filetypes. augroups = [{name = "nvf_spellcheck";}];
# If the list is empty, the autocommand does not need to be registered. autocmds =
luaConfigRC.spellcheck = entryAfter ["basic"] (optionalString (cfg.ignoredFiletypes != []) '' (optional cfg.ignoreTerminal {
-- Disable spellchecking for certain filetypes event = ["TermOpen"];
-- as configured by `vim.spellcheck.ignoredFiletypes` group = "nvf_spellcheck";
vim.api.nvim_create_augroup("nvf_autocmds", {clear = false}) callback = mkLuaInline ''
vim.api.nvim_create_autocmd({ "FileType" }, { function() vim.opt_local.spell = false end
group = "nvf_autocmds", '';
pattern = ${toLuaObject cfg.ignoredFiletypes},
callback = function()
vim.opt_local.spell = false
end,
}) })
''); ++ (optional (length cfg.ignoredFiletypes > 0) {
event = ["FileType"];
group = "nvf_spellcheck";
pattern = cfg.ignoredFiletypes;
callback = mkLuaInline ''
function()
vim.opt_local.spell = false
end
'';
});
}; };
}; };
} }