From b10cb0296ae299e4f97335c201ccbf8da753b2a6 Mon Sep 17 00:00:00 2001 From: Yochem van Rosmalen Date: Fri, 4 Apr 2025 14:21:57 +0200 Subject: 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 Co-authored-by: Justin M. Keyes --- test/functional/core/spellfile_spec.lua | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'test/functional/core') diff --git a/test/functional/core/spellfile_spec.lua b/test/functional/core/spellfile_spec.lua index e2ccb038e7..96841f030e 100644 --- a/test/functional/core/spellfile_spec.lua +++ b/test/functional/core/spellfile_spec.lua @@ -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) -- cgit