aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorYochem van Rosmalen <git@yochem.nl>2025-04-04 14:21:57 +0200
committerGitHub <noreply@github.com>2025-04-04 05:21:57 -0700
commitb10cb0296ae299e4f97335c201ccbf8da753b2a6 (patch)
treee2b14fc0fe3844dd448798faadfa904000d5478d /test
parent4983fa45fcfb420a38112e782b2a30baf9cc05d2 (diff)
downloadrneovim-b10cb0296ae299e4f97335c201ccbf8da753b2a6.tar.gz
rneovim-b10cb0296ae299e4f97335c201ccbf8da753b2a6.tar.bz2
rneovim-b10cb0296ae299e4f97335c201ccbf8da753b2a6.zip
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>
Diffstat (limited to 'test')
-rw-r--r--test/functional/core/spellfile_spec.lua27
-rw-r--r--test/old/testdir/test_spellfile.vim1
2 files changed, 27 insertions, 1 deletions
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)
diff --git a/test/old/testdir/test_spellfile.vim b/test/old/testdir/test_spellfile.vim
index f356b12370..351ffc9612 100644
--- a/test/old/testdir/test_spellfile.vim
+++ b/test/old/testdir/test_spellfile.vim
@@ -1123,6 +1123,7 @@ endfunc
" When 'spellfile' is not set, adding a new good word will automatically set
" the 'spellfile'
func Test_init_spellfile()
+ throw 'Skipped: Nvim defaults spellfile to stdpath("data")/spell/'
let save_rtp = &rtp
let save_encoding = &encoding
call mkdir('Xrtp/spell', 'pR')