From 7c5ff99e8a0ef7c345596df8a0c2eec80afd16b4 Mon Sep 17 00:00:00 2001 From: Tom Ampuero Date: Fri, 8 Aug 2025 16:31:57 +0100 Subject: refactor(spell): migrate to Lua, drop netrw dependency Problem: Spell file downloads relied on Vimscript and netrw (:Nread). If netrw is disabled, downloads fail. Solution: Port the logic to Lua as `nvim.spellfile` and wire it via a Lua plugin that handles `SpellFileMissing`. Use `vim.net.request()` with a timeout for HTTP, prompt via `vim.fn.input` and report via `vim.notify`. Closes #7189 --- runtime/plugin/nvim/spellfile.lua | 15 +++++++++++++++ runtime/plugin/spellfile.vim | 8 -------- 2 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 runtime/plugin/nvim/spellfile.lua delete mode 100644 runtime/plugin/spellfile.vim (limited to 'runtime/plugin') diff --git a/runtime/plugin/nvim/spellfile.lua b/runtime/plugin/nvim/spellfile.lua new file mode 100644 index 0000000000..cafa914163 --- /dev/null +++ b/runtime/plugin/nvim/spellfile.lua @@ -0,0 +1,15 @@ +vim.g.loaded_spellfile_plugin = true + +--- Callback for SpellFileMissing: download missing .spl +--- @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 = '*', + desc = 'Download missing spell files when setting spelllang', + callback = on_spellfile_missing, +}) diff --git a/runtime/plugin/spellfile.vim b/runtime/plugin/spellfile.vim deleted file mode 100644 index e03659d6d6..0000000000 --- a/runtime/plugin/spellfile.vim +++ /dev/null @@ -1,8 +0,0 @@ -" Vim plugin for downloading spell files - -if exists("loaded_spellfile_plugin") || &cp || exists("#SpellFileMissing") - finish -endif -let loaded_spellfile_plugin = 1 - -autocmd SpellFileMissing * call spellfile#LoadFile(expand('')) -- cgit