From f14965af391b2f89ce26369eec3e333c98fbcdde Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 3 Apr 2023 17:24:51 +1200 Subject: If OptionSet is available, trigger on 'spelllang' We have to switch from to simply expanding % here, because doesn't expand to the buffer's filename when OptionSet fires. --- autoload/spellfile_local.vim | 2 +- plugin/spellfile_local.vim | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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(':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 -- cgit v1.2.3