Skip to content

Commit

Permalink
Merge pull request #308 from fd0/fix-indent
Browse files Browse the repository at this point in the history
Use shiftwidth() instead of '&shiftwidth'
  • Loading branch information
fatih committed Feb 8, 2015
2 parents 6fa7bdb + 229130c commit bf94a57
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions indent/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,29 @@ function! GoIndent(lnum)
let previ = indent(prevlnum)

let ind = previ
let s:shiftwidth = shiftwidth()

if prevl =~ '[({]\s*$'
" previous line opened a block
let ind += &sw
let ind += s:shiftwidth
endif
if prevl =~# '^\s*\(case .*\|default\):$'
" previous line is part of a switch statement
let ind += &sw
let ind += s:shiftwidth
endif
" TODO: handle if the previous line is a label.

if thisl =~ '^\s*[)}]'
" this line closed a block
let ind -= &sw
let ind -= s:shiftwidth
endif

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

return ind
Expand Down

0 comments on commit bf94a57

Please sign in to comment.