Skip to content

Commit bf94a57

Browse files
committed
Merge pull request #308 from fd0/fix-indent
Use shiftwidth() instead of '&shiftwidth'
2 parents 6fa7bdb + 229130c commit bf94a57

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

indent/go.vim

+5-4
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,29 @@ function! GoIndent(lnum)
3737
let previ = indent(prevlnum)
3838

3939
let ind = previ
40+
let s:shiftwidth = shiftwidth()
4041

4142
if prevl =~ '[({]\s*$'
4243
" previous line opened a block
43-
let ind += &sw
44+
let ind += s:shiftwidth
4445
endif
4546
if prevl =~# '^\s*\(case .*\|default\):$'
4647
" previous line is part of a switch statement
47-
let ind += &sw
48+
let ind += s:shiftwidth
4849
endif
4950
" TODO: handle if the previous line is a label.
5051

5152
if thisl =~ '^\s*[)}]'
5253
" this line closed a block
53-
let ind -= &sw
54+
let ind -= s:shiftwidth
5455
endif
5556

5657
" Colons are tricky.
5758
" We want to outdent if it's part of a switch ("case foo:" or "default:").
5859
" We ignore trying to deal with jump labels because (a) they're rare, and
5960
" (b) they're hard to disambiguate from a composite literal key.
6061
if thisl =~# '^\s*\(case .*\|default\):$'
61-
let ind -= &sw
62+
let ind -= s:shiftwidth
6263
endif
6364

6465
return ind

0 commit comments

Comments
 (0)