summaryrefslogtreecommitdiffstats
path: root/indent/go.vim
diff options
context:
space:
mode:
Diffstat (limited to 'indent/go.vim')
-rw-r--r--indent/go.vim80
1 files changed, 40 insertions, 40 deletions
diff --git a/indent/go.vim b/indent/go.vim
index 102d3495..fd973e45 100644
--- a/indent/go.vim
+++ b/indent/go.vim
@@ -11,7 +11,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'go') == -1
" - general line splits (line ends in an operator)
if exists("b:did_indent")
- finish
+ finish
endif
let b:did_indent = 1
@@ -23,60 +23,60 @@ setlocal indentexpr=GoIndent(v:lnum)
setlocal indentkeys+=<:>,0=},0=)
if exists("*GoIndent")
- finish
+ finish
endif
" use shiftwidth function only if it's available
if exists('*shiftwidth')
- func s:sw()
- return shiftwidth()
- endfunc
+ func s:sw()
+ return shiftwidth()
+ endfunc
else
- func s:sw()
- return &sw
- endfunc
+ func s:sw()
+ return &sw
+ endfunc
endif
function! GoIndent(lnum)
- let prevlnum = prevnonblank(a:lnum-1)
- if prevlnum == 0
- " top of file
- return 0
- endif
+ let prevlnum = prevnonblank(a:lnum-1)
+ if prevlnum == 0
+ " top of file
+ return 0
+ endif
- " grab the previous and current line, stripping comments.
- let prevl = substitute(getline(prevlnum), '//.*$', '', '')
- let thisl = substitute(getline(a:lnum), '//.*$', '', '')
- let previ = indent(prevlnum)
+ " grab the previous and current line, stripping comments.
+ let prevl = substitute(getline(prevlnum), '//.*$', '', '')
+ let thisl = substitute(getline(a:lnum), '//.*$', '', '')
+ let previ = indent(prevlnum)
- let ind = previ
+ let ind = previ
- if prevl =~ '[({]\s*$'
- " previous line opened a block
- let ind += s:sw()
- endif
- if prevl =~# '^\s*\(case .*\|default\):$'
- " previous line is part of a switch statement
- let ind += s:sw()
- endif
- " TODO: handle if the previous line is a label.
+ if prevl =~ '[({]\s*$'
+ " previous line opened a block
+ let ind += s:sw()
+ endif
+ if prevl =~# '^\s*\(case .*\|default\):$'
+ " previous line is part of a switch statement
+ let ind += s:sw()
+ endif
+ " TODO: handle if the previous line is a label.
- if thisl =~ '^\s*[)}]'
- " this line closed a block
- let ind -= s:sw()
- endif
+ if thisl =~ '^\s*[)}]'
+ " this line closed a block
+ let ind -= s:sw()
+ 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 -= s:sw()
- 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 -= s:sw()
+ endif
- return ind
+ return ind
endfunction
-" vim:ts=4:sw=4:et
+" vim: sw=2 ts=2 et
endif