summaryrefslogtreecommitdiff
path: root/runtime/indent/go.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-06-13 18:12:01 +0200
committerBram Moolenaar <Bram@vim.org>2017-06-13 18:12:01 +0200
commit3ec574f2b549f456f664f689d6da36dc5719aeb9 (patch)
tree8aa7d766ebc0eb3919fdc678e6f48dd0a2b36673 /runtime/indent/go.vim
parent2102035488e80ef6fd5038ed15d21672712ba0f6 (diff)
downloadvim-git-3ec574f2b549f456f664f689d6da36dc5719aeb9.tar.gz
Update runtime files.
Includes changing &sw to shiftwidth() for all indent scripts.
Diffstat (limited to 'runtime/indent/go.vim')
-rw-r--r--runtime/indent/go.vim22
1 files changed, 5 insertions, 17 deletions
diff --git a/runtime/indent/go.vim b/runtime/indent/go.vim
index 412ac871c..bf9ff75e6 100644
--- a/runtime/indent/go.vim
+++ b/runtime/indent/go.vim
@@ -1,7 +1,7 @@
" Vim indent file
" Language: Go
" Maintainer: David Barnett (https://github.com/google/vim-ft-go)
-" Last Change: 2014 Aug 16
+" Last Change: 2017 Jun 13
"
" TODO:
" - function invocations split across lines
@@ -23,18 +23,6 @@ if exists('*GoIndent')
finish
endif
-" The shiftwidth() function is relatively new.
-" Don't require it to exist.
-if exists('*shiftwidth')
- function s:sw() abort
- return shiftwidth()
- endfunction
-else
- function s:sw() abort
- return &shiftwidth
- endfunction
-endif
-
function! GoIndent(lnum)
let l:prevlnum = prevnonblank(a:lnum-1)
if l:prevlnum == 0
@@ -51,17 +39,17 @@ function! GoIndent(lnum)
if l:prevl =~ '[({]\s*$'
" previous line opened a block
- let l:ind += s:sw()
+ let l:ind += shiftwidth()
endif
if l:prevl =~# '^\s*\(case .*\|default\):$'
" previous line is part of a switch statement
- let l:ind += s:sw()
+ let l:ind += shiftwidth()
endif
" TODO: handle if the previous line is a label.
if l:thisl =~ '^\s*[)}]'
" this line closed a block
- let l:ind -= s:sw()
+ let l:ind -= shiftwidth()
endif
" Colons are tricky.
@@ -69,7 +57,7 @@ function! GoIndent(lnum)
" 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 l:thisl =~# '^\s*\(case .*\|default\):$'
- let l:ind -= s:sw()
+ let l:ind -= shiftwidth()
endif
return l:ind