refactor(spellfile): config() interface, docs #36481

Problem:
- Exposing the raw config as table is a pattern not seen anywhere else
  in the Nvim codebase.
- Old spellfile.vim docs still available, no new documentation

Solution:
- Exposing a `config()` function that both acts as "getter" and "setter"
  is a much more common idiom (e.g. vim.lsp, vim.diagnostic).
- Add new documentation and link old docs to |spellfile.lua| instead of
  |spellfile.vim|.
This commit is contained in:
Yochem van Rosmalen
2025-11-10 06:51:39 +01:00
committed by GitHub
parent cf347110c1
commit 9bdb011a50
11 changed files with 160 additions and 93 deletions

View File

@@ -1,16 +1,12 @@
if vim.g.loaded_spellfile_plugin ~= nil then
return
end
vim.g.loaded_spellfile_plugin = true
--- Downloads missing .spl file.
---
--- @param args { bufnr: integer, match: string }
local function on_spellfile_missing(args)
local spellfile = require('nvim.spellfile')
spellfile.load_file(args.match)
end
vim.api.nvim_create_autocmd('SpellFileMissing', {
group = vim.api.nvim_create_augroup('nvim_spellfile', { clear = true }),
pattern = '*',
group = vim.api.nvim_create_augroup('nvim.spellfile', {}),
desc = 'Download missing spell files when setting spelllang',
callback = on_spellfile_missing,
callback = function(args)
require('nvim.spellfile').get(args.match)
end,
})