aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2020-05-15 01:04:57 +1200
committerTom Ryder <tom@sanctum.geek.nz>2020-05-15 01:04:57 +1200
commitf82671a01f007fc2872650dc888c97eaa991dc4c (patch)
tree1a2d6aea6c7275ad0b9d032ee65fcf7dad3e9639
parentMerge branch 'hotfix/v0.3.1' into develop (diff)
downloadvim-spellfile-local-f82671a01f007fc2872650dc888c97eaa991dc4c.tar.gz
vim-spellfile-local-f82671a01f007fc2872650dc888c97eaa991dc4c.zip
Use period separators for types, not path
-rw-r--r--autoload/spellfile_local.vim25
-rw-r--r--doc/spellfile_local.txt4
2 files changed, 18 insertions, 11 deletions
diff --git a/autoload/spellfile_local.vim b/autoload/spellfile_local.vim
index 9734988..596d997 100644
--- a/autoload/spellfile_local.vim
+++ b/autoload/spellfile_local.vim
@@ -15,18 +15,25 @@ function! spellfile_local#() abort
return
endif
let lang = split(spelllangs[0], '_')[0]
+ let encoding = &encoding
" Make a list of all the spellfile names for which we want to search in
" every directory; the first is the normal lang.encoding.add, the second is
" filename.lang.encoding.add, and the third, if there's a filetype set, is
" filetype.lang.encoding.add.
"
- let basenames = [
- \ s:Filename([lang, &encoding, 'add']),
- \ s:Filename([expand('<afile>:p'), lang, &encoding, 'add']),
- \]
- if &filetype !=# ''
- call add(basenames, s:Filename([&filetype, lang, &encoding, 'add']))
+ let basenames = [s:Filename([lang, encoding, 'add'])]
+ let path = expand('<afile>:p')
+ call add(
+ \ basenames,
+ \ s:Filename(['path', path, lang, encoding, 'add'])
+ \)
+ let filetype = &filetype
+ if filetype !=# ''
+ call add(
+ \ basenames,
+ \ s:Filename(['filetype', filetype, lang, encoding, 'add'])
+ \)
endif
" Now make a list of all of the directories in which those files will be
@@ -41,7 +48,7 @@ function! spellfile_local#() abort
"
if exists('g:spellfile_local_dirs') && !empty(g:spellfile_local_dirs)
for path in g:spellfile_local_dirs
- call add(dirnames, join([path, 'spell'], '/'))
+ call add(dirnames, path.'/spell')
endfor
" Failing that, do what Vim does by default: use the first *writeable* entry
@@ -52,7 +59,7 @@ function! spellfile_local#() abort
if filewritable(path) != 2
continue
endif
- call add(dirnames, join([path, 'spell'], '/'))
+ call add(dirnames, path.'/spell')
break
endfor
if empty(dirnames)
@@ -62,7 +69,7 @@ function! spellfile_local#() abort
endif
" Attempt to create the first directory in the list if it doesn't exist
- " already. Just let the error happen if it does.
+ " already. Just let any error happen and reach the user.
"
if !isdirectory(dirnames[0])
call mkdir(dirnames[0], 'p', 0700)
diff --git a/doc/spellfile_local.txt b/doc/spellfile_local.txt
index 486da43..0bb0641 100644
--- a/doc/spellfile_local.txt
+++ b/doc/spellfile_local.txt
@@ -8,8 +8,8 @@ The 'spellfile' setting for a file named `test.vim` in one's home directory
while writing English in UTF-8 encoding might look like this:
>
spellfile=~/.vim/spell/en.utf-8.add
- ,~/.vim/spell/path/%home%user%test.vim.en.utf-8.add
- ,~/.vim/spell/filetype/vim.en.utf-8.add
+ ,~/.vim/spell/path.%home%user%test.vim.en.utf-8.add
+ ,~/.vim/spell/filetype.vim.en.utf-8.add
<
Words can then be added to the file's word list with `2zg`, or to the
filetype's list with `3zg`.