Skip to content

Commit 78d34d1

Browse files
committed
Merge branch 'mixed-tabs-and-spaces' of https://github.com/graywh/vim-indent-guides into graywh-mixed-tabs-and-spaces
* 'mixed-tabs-and-spaces' of https://github.com/graywh/vim-indent-guides: Partial support for mixed tabs and spaces.
2 parents 0a14a15 + f7d5111 commit 78d34d1

File tree

8 files changed

+42
-13
lines changed

8 files changed

+42
-13
lines changed

autoload/indent_guides.vim

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function! indent_guides#enable()
4141
" will automagically figure out whether to use tabs or spaces
4242
for l:level in range(s:start_level, s:indent_levels)
4343
let l:group = 'IndentGuides' . ((l:level % 2 == 0) ? 'Even' : 'Odd')
44-
let l:pattern = '^\s\{' . (l:level * s:indent_size - s:indent_size) . '\}\zs'
45-
let l:pattern .= '\s\{' . s:guide_size . '\}'
44+
let l:pattern = '^\s*\%' . ((l:level - 1) * s:indent_size + 1) . 'v\zs'
45+
let l:pattern .= '\s*\%' . (((l:level - 1) * s:indent_size + 1) + s:guide_size) . 'v'
4646
let l:pattern .= '\ze'
4747

4848
" define the higlight pattern and add to list
@@ -207,12 +207,17 @@ endfunction
207207
"
208208
function! indent_guides#calculate_guide_size()
209209
let l:guide_size = g:indent_guides_guide_size
210-
let l:indent_size = indent_guides#get_indent_size()
211210

212-
if l:indent_size > 1 && l:guide_size >= 1
213-
let l:guide_size = (l:guide_size > s:indent_size) ? s:indent_size : l:guide_size
214-
else
211+
if &expandtab == 0 && &tabstop == s:indent_size
215212
let l:guide_size = s:indent_size
213+
else
214+
if s:indent_size > 1 && l:guide_size >= 1
215+
if l:guide_size > s:indent_size
216+
let l:guide_size = s:indent_size
217+
end
218+
else
219+
let l:guide_size = s:indent_size
220+
endif
216221
endif
217222

218223
return l:guide_size
@@ -223,7 +228,7 @@ endfunction
223228
" being used.
224229
"
225230
function! indent_guides#get_indent_size()
226-
return (&l:expandtab == 1) ? &l:shiftwidth : 1
231+
return &l:shiftwidth
227232
endfunction
228233

229234
"

test-files/test-ts2sw2et.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vim:tw=78:ts=2:sw=2:et
1+
vim:tw=78:ts=2:sw=2:et:nolist
22

33
test
44
test

test-files/test-ts2sw2noet.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vim:tw=78:ts=2:sw=2:noet
1+
vim:tw=78:ts=2:sw=2:noet:nolist
22

33
test
44
test

test-files/test-ts4sw4et.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vim:tw=78:ts=4:sw=4:et
1+
vim:tw=78:ts=4:sw=4:et:nolist
22

33
test
44
test

test-files/test-ts4sw4noet.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vim:tw=78:ts=4:sw=4:noet
1+
vim:tw=78:ts=4:sw=4:noet:nolist
22

33
test
44
test

test-files/test-ts8sw2noet.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
vim:tw=78:ts=8:sw=2:noet:nolist
2+
3+
test
4+
test
5+
test
6+
test
7+
test
8+
test
9+
test
10+
test
11+
test
12+
test
13+
test
14+
test
15+
test
16+
test
17+
test
18+
test
19+
test
20+
test
21+
test
22+
test
23+
test
24+
test

test-files/test-ts8sw8et.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vim:tw=78:ts=8:sw=8:et
1+
vim:tw=78:ts=8:sw=8:et:nolist
22

33
test
44
test

test-files/test-ts8sw8noet.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vim:tw=78:ts=8:sw=8:noet
1+
vim:tw=78:ts=8:sw=8:noet:nolist
22

33
test
44
test

0 commit comments

Comments
 (0)