mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-01 11:01:15 +00:00
neovim/spellcheck: add autogroup to spellcheck fts autocmd; fix vim-dirtytalk
This commit is contained in:
parent
2e1779fbae
commit
b836b39941
2 changed files with 23 additions and 13 deletions
|
@ -81,18 +81,16 @@ 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 ''
|
programmingWordlist.enable = mkEnableOption ''
|
||||||
vim-dirtytalk, a wordlist for programmers containing
|
vim-dirtytalk, a wordlist for programmers containing
|
||||||
common programming terms.
|
common programming terms.
|
||||||
|
|
||||||
Setting this value as `true` has the same effect
|
::: {.note}
|
||||||
as setting {option}`vim.spellCheck.enable`
|
Enabling this option will unconditionally set
|
||||||
|
{option}`vim.spellcheck.enable` to true as vim-dirtytalk
|
||||||
|
depends on spellchecking having been set up.
|
||||||
|
:::
|
||||||
'';
|
'';
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -136,7 +134,9 @@ in {
|
||||||
|
|
||||||
-- Disable spellchecking for certain filetypes
|
-- Disable spellchecking for certain filetypes
|
||||||
-- as configured by `vim.spellcheck.ignoredFiletypes`
|
-- as configured by `vim.spellcheck.ignoredFiletypes`
|
||||||
|
vim.api.nvim_create_augroup("nvf_autocmds", {clear = false})
|
||||||
vim.api.nvim_create_autocmd({ "FileType" }, {
|
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||||
|
group = "nvf_autocmds",
|
||||||
pattern = ${listToLuaTable cfg.ignoredFiletypes},
|
pattern = ${listToLuaTable cfg.ignoredFiletypes},
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.opt_local.spell = false
|
vim.opt_local.spell = false
|
||||||
|
|
|
@ -7,16 +7,26 @@
|
||||||
inherit (lib.nvim.dag) entryAfter;
|
inherit (lib.nvim.dag) entryAfter;
|
||||||
cfg = config.vim.spellcheck;
|
cfg = config.vim.spellcheck;
|
||||||
in {
|
in {
|
||||||
config = mkIf (cfg.enable && cfg.programmingWordlist.enable) {
|
config = mkIf cfg.programmingWordlist.enable {
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = ["vim-dirtytalk"];
|
startPlugins = ["vim-dirtytalk"];
|
||||||
|
|
||||||
# vim-dirtytalk doesn't have any setup
|
spellcheck.enable = true;
|
||||||
# but we would like to append programming to spelllang
|
|
||||||
# as soon as possible while the plugin is enabled
|
# 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 ["basic"] ''
|
pluginRC.vim-dirtytalk = entryAfter ["basic"] ''
|
||||||
-- append programming to spelllang
|
-- If Neovim can find (or access) the state directory
|
||||||
vim.opt.spelllang:append("programming")
|
-- 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
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue