diff --git a/nvim/init.vim b/nvim/init.vim index a1911ba..fbbb72a 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -63,8 +63,17 @@ if exists(':Sleuth') " shiftwidth to the unreasonable value picked above, which vim-sleuth " internally compares with its local `s:default_shiftwidth`, sees that both " are the same, and proceeds to execute the indent detection algorithm. - " Boom, my work here is done. - autocmd BufEnter * let &l:shiftwidth = s:fake_default_shiftwidth | Sleuth + " ALSO Note how I'm not using `BufEnter` as vim-sleuth does because + " apparently `BufWinEnter` leads to better compatibility with the + " indentLine plugin and potentially less useless invocations (see the note + " about window splits in the docs for this event). Oh, one last thing: + " vim-sleuth forgets to assign the tabstop options, which I have to do as + " well. But anyway, boom, my work here is done. + autocmd BufWinEnter * + \ let &l:shiftwidth = s:fake_default_shiftwidth + \| Sleuth + \| let &l:tabstop = &l:shiftwidth + \| let &l:softtabstop = &l:shiftwidth augroup END " HACK: In case you are wondering why I'm using Polyglot's bundled vim-sleuth diff --git a/nvim/plugin/editing.vim b/nvim/plugin/editing.vim index 70ba62e..5a81cec 100644 --- a/nvim/plugin/editing.vim +++ b/nvim/plugin/editing.vim @@ -15,8 +15,8 @@ set commentstring=//%s function SetIndent(expandtab, shiftwidth) let &l:expandtab = a:expandtab let &l:shiftwidth = str2nr(a:shiftwidth) - let &l:tabstop = &shiftwidth - let &l:softtabstop = &shiftwidth + let &l:tabstop = &l:shiftwidth + let &l:softtabstop = &l:shiftwidth endfunction command -nargs=1 Indent call SetIndent(1, ) command -nargs=1 IndentTabs call SetIndent(0, )