+15
-8
lines changedFilter options
+15
-8
lines changed Original file line number Diff line number Diff line change
@@ -2629,11 +2629,6 @@ if !has_key(s:disabled_packages, 'autoindent')
2629
2629
" Code below re-implements sleuth for vim-polyglot
2630
2630
let g:loaded_sleuth = 1
2631
2631
2632
-
" Makes shiftwidth to be synchronized with tabstop by default
2633
-
if &shiftwidth == &tabstop
2634
-
let &shiftwidth = 0
2635
-
endif
2636
-
2637
2632
function! s:guess(lines) abort
2638
2633
let options = {}
2639
2634
let ccomment = 0
@@ -2718,11 +2713,12 @@ if !has_key(s:disabled_packages, 'autoindent')
2718
2713
if line[0] == "\t"
2719
2714
setlocal noexpandtab
2720
2715
let &l:shiftwidth=&tabstop
2716
+
let &l:tabstop=minindent
2721
2717
let b:sleuth_culprit .= ':' . i
2722
2718
return 1
2723
2719
elseif line[0] == " "
2724
2720
let indent = len(matchstr(line, '^ *'))
2725
-
if (indent % 2 == 0 || indent % 3 == 0) && indent < minindent
2721
+
if indent < minindent && index([2, 3, 4, 8], indent) >= 0
2726
2722
let minindent = indent
2727
2723
endif
2728
2724
endif
@@ -2731,6 +2727,7 @@ if !has_key(s:disabled_packages, 'autoindent')
2731
2727
if minindent < 10
2732
2728
setlocal expandtab
2733
2729
let &l:shiftwidth=minindent
2730
+
let &l:tabstop=minindent
2734
2731
let b:sleuth_culprit .= ':' . i
2735
2732
return 1
2736
2733
endif
@@ -2743,6 +2740,16 @@ if !has_key(s:disabled_packages, 'autoindent')
2743
2740
return
2744
2741
endif
2745
2742
2743
+
if &expandtab
2744
+
" Make tabstop to be synchronized with shiftwidth by default
2745
+
" Some plugins are using &shiftwidth directly or accessing &tabstop
2746
+
if &tabstop != 8 || &shiftwidth == 0
2747
+
let &shiftwidth = &tabstop
2748
+
else
2749
+
let &tabstop = &shiftwidth
2750
+
endif
2751
+
endif
2752
+
2746
2753
let b:sleuth_culprit = expand("<afile>:p")
2747
2754
if s:guess(getline(1, 32))
2748
2755
return
@@ -2784,7 +2791,7 @@ if !has_key(s:disabled_packages, 'autoindent')
2784
2791
unlet b:sleuth_culprit
2785
2792
endfunction
2786
2793
2787
-
setglobal smarttab
2794
+
set smarttab
2788
2795
2789
2796
function! SleuthIndicator() abort
2790
2797
let sw = &shiftwidth ? &shiftwidth : &tabstop
@@ -2799,7 +2806,7 @@ if !has_key(s:disabled_packages, 'autoindent')
2799
2806
2800
2807
augroup polyglot-sleuth
2801
2808
au!
2802
-
au FileType * call s:detect_indent()
2809
+
au BufEnter * call s:detect_indent()
2803
2810
au User Flags call Hoist('buffer', 5, 'SleuthIndicator')
2804
2811
augroup END
2805
2812
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4