From 44f1dbee0da3c516541434774b44f74a627b8e3f Mon Sep 17 00:00:00 2001 From: "Au." Date: Fri, 18 Apr 2025 23:56:20 +0800 Subject: [PATCH] fix(spell): save spell files to stdpath('data')/site/spell #33528 --- runtime/doc/news.txt | 2 +- runtime/doc/options.txt | 2 +- runtime/doc/vim_diff.txt | 2 +- runtime/lua/vim/_meta/options.lua | 2 +- src/nvim/options.lua | 2 +- src/nvim/spellfile.c | 4 ++-- test/functional/core/spellfile_spec.lua | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 48162b9fa2..740036297b 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -186,7 +186,7 @@ CHANGED FEATURES *news-changed* These existing features changed their behavior. -• 'spellfile' location defaults to `stdpath("data").."/spell/"` instead of the +• 'spellfile' location defaults to `stdpath("data").."/site/spell/"` instead of the first writable directoy in 'runtimepath'. • |vim.version.range()| doesn't exclude `to` if it is equal to `from`. diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 4740b03c17..4b98f487d3 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5795,7 +5795,7 @@ A jump table for the options with a short description can be found at |Q_op|. |zg| and |zw| commands can be used to access each. This allows using a personal word list file and a project word list file. When a word is added while this option is empty Nvim will use - (and auto-create) `stdpath('data')/spell/`. For the file name the + (and auto-create) `stdpath('data')/site/spell/`. For the file name the first language name that appears in 'spelllang' is used, ignoring the region. The resulting ".spl" file will be used for spell checking, it does not diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index d475ef1f3d..7ffb505528 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -79,7 +79,7 @@ Defaults *defaults* *nvim-defaults* - 'showcmd' is enabled - 'sidescroll' defaults to 1 - 'smarttab' is enabled -- 'spellfile' defaults to `stdpath("data").."/spell/"` +- 'spellfile' defaults to `stdpath("data").."/site/spell/"` - 'startofline' is disabled - 'switchbuf' defaults to "uselast" - 'tabpagemax' defaults to 50 diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua index a73204c88b..956a22bd4b 100644 --- a/runtime/lua/vim/_meta/options.lua +++ b/runtime/lua/vim/_meta/options.lua @@ -6169,7 +6169,7 @@ vim.bo.spc = vim.bo.spellcapcheck --- `zg` and `zw` commands can be used to access each. This allows using --- a personal word list file and a project word list file. --- When a word is added while this option is empty Nvim will use ---- (and auto-create) `stdpath('data')/spell/`. For the file name the +--- (and auto-create) `stdpath('data')/site/spell/`. For the file name the --- first language name that appears in 'spelllang' is used, ignoring the --- region. --- The resulting ".spl" file will be used for spell checking, it does not diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 504e5defa1..d43a71e5e9 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -8216,7 +8216,7 @@ local options = { |zg| and |zw| commands can be used to access each. This allows using a personal word list file and a project word list file. When a word is added while this option is empty Nvim will use - (and auto-create) `stdpath('data')/spell/`. For the file name the + (and auto-create) `stdpath('data')/site/spell/`. For the file name the first language name that appears in 'spelllang' is used, ignoring the region. The resulting ".spl" file will be used for spell checking, it does not diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 44e084dd2a..743e7916d1 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -5550,7 +5550,7 @@ void spell_add_word(char *word, int len, SpellAddType what, int idx, bool undo) // Initialize 'spellfile' for the current buffer. // // If the location does not exist, create it. Defaults to -// stdpath("data") + "/spell/{spelllang}.{encoding}.add". +// stdpath("data") + "/site/spell/{spelllang}.{encoding}.add". static void init_spellfile(void) { char *lend; @@ -5579,7 +5579,7 @@ static void init_spellfile(void) xstrlcpy(buf, xdg_path, buf_len); xfree(xdg_path); - xstrlcat(buf, "/spell", buf_len); + xstrlcat(buf, "/site/spell", buf_len); char *failed_dir; if (os_mkdir_recurse(buf, 0755, &failed_dir, NULL) != 0) { diff --git a/test/functional/core/spellfile_spec.lua b/test/functional/core/spellfile_spec.lua index 96841f030e..90531de429 100644 --- a/test/functional/core/spellfile_spec.lua +++ b/test/functional/core/spellfile_spec.lua @@ -119,12 +119,12 @@ describe('spellfile', function() end) describe('default location', function() - it("is stdpath('data')/spell/en.utf-8.add", function() + it("is stdpath('data')/site/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(fn.stdpath('data') .. '/site/spell/en.utf-8.add'), t.fix_slashes(api.nvim_get_option_value('spellfile', {})) ) end)