feat(defaults): store spellfile in stdpath('data') #33048

Problem:
First rtp directory is unpredictable and not in line with XDG
base spec.

Solution:
Use stdpath('data')/spell as directory if 'spellfile' is not set.

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
This commit is contained in:
Yochem van Rosmalen
2025-04-04 14:21:57 +02:00
committed by GitHub
parent 4983fa45fc
commit b10cb0296a
8 changed files with 76 additions and 59 deletions

View File

@@ -14,7 +14,7 @@ local testdir = 'Xtest-functional-spell-spellfile.d'
describe('spellfile', function()
before_each(function()
clear()
clear({ env = { XDG_DATA_HOME = testdir .. '/xdg_data' } })
rmdir(testdir)
mkdir(testdir)
mkdir(testdir .. '/spell')
@@ -117,4 +117,29 @@ describe('spellfile', function()
local fname = fn.fnamemodify(testdir .. '/spell/spell.add', ':p')
api.nvim_set_option_value('spellfile', fname, {})
end)
describe('default location', function()
it("is stdpath('data')/spell/en.utf-8.add", function()
n.command('set spell')
n.insert('abc')
n.feed('zg')
eq(
t.fix_slashes(fn.stdpath('data') .. '/spell/en.utf-8.add'),
t.fix_slashes(api.nvim_get_option_value('spellfile', {}))
)
end)
it("is not set if stdpath('data') is not writable", function()
n.command('set spell')
fn.writefile({ '' }, testdir .. '/xdg_data')
n.insert('abc')
eq("Vim(normal):E764: Option 'spellfile' is not set", exc_exec('normal! zg'))
end)
it("is not set if 'spelllang' is not set", function()
n.command('set spell spelllang=')
n.insert('abc')
eq("Vim(normal):E764: Option 'spellfile' is not set", exc_exec('normal! zg'))
end)
end)
end)