aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2020-05-15 00:31:16 +1200
committerTom Ryder <tom@sanctum.geek.nz>2020-05-15 00:31:16 +1200
commit24ae63acd51f67023f899dcf7e645cf781e4dfd8 (patch)
tree34c9777783f6961d89881cf605e1f98bf7b11cbe
parentMerge branch 'release/v0.3.0' (diff)
parentBump VERSION (diff)
downloadvim-spellfile-local-24ae63acd51f67023f899dcf7e645cf781e4dfd8.tar.gz
vim-spellfile-local-24ae63acd51f67023f899dcf7e645cf781e4dfd8.zip
Merge branch 'hotfix/v0.3.1'v0.3.1
* hotfix/v0.3.1: Factor out error when no custom dirs set
-rw-r--r--VERSION2
-rw-r--r--autoload/spellfile_local.vim36
2 files changed, 20 insertions, 18 deletions
diff --git a/VERSION b/VERSION
index 0d91a54..9e11b32 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.3.0
+0.3.1
diff --git a/autoload/spellfile_local.vim b/autoload/spellfile_local.vim
index 618a354..9734988 100644
--- a/autoload/spellfile_local.vim
+++ b/autoload/spellfile_local.vim
@@ -36,34 +36,36 @@ function! spellfile_local#() abort
let dirnames = []
" If we have a list of directories to use as the base for 'spellfile' /spell
- " subdirectories, we'll add all of them to the list, and *attempt* to create
- " the first one if it doesn't exist--but it's not fatal if we can't; this is
- " intended to be suitable for passing in XDG basedirs
+ " subdirectories, we'll add all of them to the list with /spell suffixed,
+ " regardless of whether Vim can write to them.
"
if exists('g:spellfile_local_dirs') && !empty(g:spellfile_local_dirs)
for path in g:spellfile_local_dirs
- call add(dirnames, path.'/spell')
+ call add(dirnames, join([path, 'spell'], '/'))
endfor
- if (!isdirectory(dirnames[0]))
- call mkdir(dirnames[0], 'p', 0700)
- endif
" Failing that, do what Vim does by default: use the first *writeable* entry
- " in 'runtimepath', attempting to-create the /spell subdirectory within. If
- " none of them are writable, we raise an exception.
+ " in 'runtimepath'. If none of them are writable, we raise an exception.
"
else
for path in s:OptionSplit(&runtimepath)
- if filewritable(path)
- let spelldir = path.'/spell'
- if isdirectory(spelldir)
- \ || mkdir(spelldir, 'p', 0700)
- call add(dirnames, spelldir)
- break
- endif
+ if filewritable(path) != 2
+ continue
endif
+ call add(dirnames, join([path, 'spell'], '/'))
+ break
endfor
- throw 'No writable runtime dirs for ''spellfile'''
+ if empty(dirnames)
+ echoerr 'No writable runtime dirs for ''spellfile'''
+ return
+ endif
+ endif
+
+ " Attempt to create the first directory in the list if it doesn't exist
+ " already. Just let the error happen if it does.
+ "
+ if !isdirectory(dirnames[0])
+ call mkdir(dirnames[0], 'p', 0700)
endif
" Now we'll actually combine those two together to make a long list of