diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2023-04-03 17:24:51 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2023-04-06 15:47:01 +1200 |
commit | f14965af391b2f89ce26369eec3e333c98fbcdde (patch) | |
tree | b520a20e21938d9c8ea539bd4cd9187b1210dd6d | |
parent | Add a version guard (diff) | |
download | vim-spellfile-local-f14965af391b2f89ce26369eec3e333c98fbcdde.tar.gz vim-spellfile-local-f14965af391b2f89ce26369eec3e333c98fbcdde.zip |
If OptionSet is available, trigger on 'spelllang'
We have to switch from <afile> to simply expanding % here, because
<afile> doesn't expand to the buffer's filename when OptionSet fires.
-rw-r--r-- | autoload/spellfile_local.vim | 2 | ||||
-rw-r--r-- | plugin/spellfile_local.vim | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/autoload/spellfile_local.vim b/autoload/spellfile_local.vim index 177503f..7573c45 100644 --- a/autoload/spellfile_local.vim +++ b/autoload/spellfile_local.vim @@ -23,7 +23,7 @@ function! spellfile_local#() abort " filetype.lang.encoding.add. " let basenames = [s:Filename([lang, encoding, 'add'])] - let path = expand('<afile>:p') + let path = expand('%:p') call add( \ basenames, \ s:Filename(['path', path, lang, encoding, 'add']) diff --git a/plugin/spellfile_local.vim b/plugin/spellfile_local.vim index 623b148..5e348c0 100644 --- a/plugin/spellfile_local.vim +++ b/plugin/spellfile_local.vim @@ -17,4 +17,8 @@ let loaded_spellfile_local = 1 augroup spellfile_local autocmd BufFilePost,BufNewFile,BufRead,EncodingChanged,FileType * \ call spellfile_local#() + if has('##OptionSet') + autocmd OptionSet spelllang + \ call spellfile_local#() + endif augroup END |