mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[nvim] fix some bugs with indentation detection yet again.
This commit is contained in:
parent
c62a48504f
commit
f06382d651
2 changed files with 13 additions and 4 deletions
|
@ -63,8 +63,17 @@ if exists(':Sleuth')
|
||||||
" shiftwidth to the unreasonable value picked above, which vim-sleuth
|
" shiftwidth to the unreasonable value picked above, which vim-sleuth
|
||||||
" internally compares with its local `s:default_shiftwidth`, sees that both
|
" internally compares with its local `s:default_shiftwidth`, sees that both
|
||||||
" are the same, and proceeds to execute the indent detection algorithm.
|
" are the same, and proceeds to execute the indent detection algorithm.
|
||||||
" Boom, my work here is done.
|
" ALSO Note how I'm not using `BufEnter` as vim-sleuth does because
|
||||||
autocmd BufEnter * let &l:shiftwidth = s:fake_default_shiftwidth | Sleuth
|
" 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
|
augroup END
|
||||||
|
|
||||||
" HACK: In case you are wondering why I'm using Polyglot's bundled vim-sleuth
|
" HACK: In case you are wondering why I'm using Polyglot's bundled vim-sleuth
|
||||||
|
|
|
@ -15,8 +15,8 @@ set commentstring=//%s
|
||||||
function SetIndent(expandtab, shiftwidth)
|
function SetIndent(expandtab, shiftwidth)
|
||||||
let &l:expandtab = a:expandtab
|
let &l:expandtab = a:expandtab
|
||||||
let &l:shiftwidth = str2nr(a:shiftwidth)
|
let &l:shiftwidth = str2nr(a:shiftwidth)
|
||||||
let &l:tabstop = &shiftwidth
|
let &l:tabstop = &l:shiftwidth
|
||||||
let &l:softtabstop = &shiftwidth
|
let &l:softtabstop = &l:shiftwidth
|
||||||
endfunction
|
endfunction
|
||||||
command -nargs=1 Indent call SetIndent(1, <q-args>)
|
command -nargs=1 Indent call SetIndent(1, <q-args>)
|
||||||
command -nargs=1 IndentTabs call SetIndent(0, <q-args>)
|
command -nargs=1 IndentTabs call SetIndent(0, <q-args>)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue