diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2018-12-26 10:41:57 +0100 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2018-12-26 10:41:57 +0100 |
commit | d43b70d93987c94d15a352cf0026fb93d3317cc8 (patch) | |
tree | 74470b6cc30ddb4ef8ceb2ec557bc32ccccb5ebb /indent/go.vim | |
parent | ec1c94306953b678bb36572897bd218fe6c76506 (diff) | |
download | vim-polyglot-d43b70d93987c94d15a352cf0026fb93d3317cc8.tar.gz vim-polyglot-d43b70d93987c94d15a352cf0026fb93d3317cc8.zip |
Update
Diffstat (limited to '')
-rw-r--r-- | indent/go.vim | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/indent/go.vim b/indent/go.vim index 887fb587..d31a6a1d 100644 --- a/indent/go.vim +++ b/indent/go.vim @@ -26,7 +26,11 @@ if exists("*GoIndent") finish endif -function! GoIndent(lnum) +" don't spam the user when Vim is started in Vi compatibility mode +let s:cpo_save = &cpo +set cpo&vim + +function! GoIndent(lnum) abort let prevlnum = prevnonblank(a:lnum-1) if prevlnum == 0 " top of file @@ -40,10 +44,17 @@ function! GoIndent(lnum) let ind = previ - if prevl =~ ' = `[^`]*$' - " previous line started a multi-line raw string - return 0 - endif + for synid in synstack(a:lnum, 1) + if synIDattr(synid, 'name') == 'goRawString' + if prevl =~ '\%(\%(:\?=\)\|(\|,\)\s*`[^`]*$' + " previous line started a multi-line raw string + return 0 + endif + " return -1 to keep the current indent. + return -1 + endif + endfor + if prevl =~ '[({]\s*$' " previous line opened a block let ind += shiftwidth() @@ -70,6 +81,10 @@ function! GoIndent(lnum) return ind endfunction +" restore Vi compatibility settings +let &cpo = s:cpo_save +unlet s:cpo_save + " vim: sw=2 ts=2 et endif |