Update go plugins
git-svn-id: http://photonzero.com/dotfiles/trunk@116 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
parent
dd6a5dac7f
commit
20ed6c412c
15 changed files with 761 additions and 470 deletions
49
.vim/bundle/go-official/autoload/go/complete.vim
Normal file
49
.vim/bundle/go-official/autoload/go/complete.vim
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
" Copyright 2011 The Go Authors. All rights reserved.
|
||||||
|
" Use of this source code is governed by a BSD-style
|
||||||
|
" license that can be found in the LICENSE file.
|
||||||
|
"
|
||||||
|
" This file provides a utility function that performs auto-completion of
|
||||||
|
" package names, for use by other commands.
|
||||||
|
|
||||||
|
let s:goos = $GOOS
|
||||||
|
let s:goarch = $GOARCH
|
||||||
|
|
||||||
|
if len(s:goos) == 0
|
||||||
|
if exists('g:golang_goos')
|
||||||
|
let s:goos = g:golang_goos
|
||||||
|
elseif has('win32') || has('win64')
|
||||||
|
let s:goos = 'windows'
|
||||||
|
elseif has('macunix')
|
||||||
|
let s:goos = 'darwin'
|
||||||
|
else
|
||||||
|
let s:goos = '*'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
if len(s:goarch) == 0
|
||||||
|
if exists('g:golang_goarch')
|
||||||
|
let s:goarch = g:golang_goarch
|
||||||
|
else
|
||||||
|
let s:goarch = '*'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
function! go#complete#Package(ArgLead, CmdLine, CursorPos)
|
||||||
|
let goroot = $GOROOT
|
||||||
|
if len(goroot) == 0
|
||||||
|
" should not occur.
|
||||||
|
return []
|
||||||
|
endif
|
||||||
|
let ret = {}
|
||||||
|
let root = expand(goroot.'/pkg/'.s:goos.'_'.s:goarch)
|
||||||
|
for i in split(globpath(root, a:ArgLead.'*'), "\n")
|
||||||
|
if isdirectory(i)
|
||||||
|
let i .= '/'
|
||||||
|
elseif i !~ '\.a$'
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
let i = substitute(substitute(i[len(root)+1:], '[\\]', '/', 'g'), '\.a$', '', 'g')
|
||||||
|
let ret[i] = i
|
||||||
|
endfor
|
||||||
|
return sort(keys(ret))
|
||||||
|
endfunction
|
||||||
1
.vim/bundle/go-official/ftdetect/gofiletype.vim
Normal file
1
.vim/bundle/go-official/ftdetect/gofiletype.vim
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
au BufReadPre,BufNewFile *.go set filetype=go fileencoding=utf-8 fileencodings=utf-8
|
||||||
44
.vim/bundle/go-official/ftplugin/go/fmt.vim
Normal file
44
.vim/bundle/go-official/ftplugin/go/fmt.vim
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
" Copyright 2011 The Go Authors. All rights reserved.
|
||||||
|
" Use of this source code is governed by a BSD-style
|
||||||
|
" license that can be found in the LICENSE file.
|
||||||
|
"
|
||||||
|
" fmt.vim: Vim command to format Go files with gofmt.
|
||||||
|
"
|
||||||
|
" This filetype plugin add a new commands for go buffers:
|
||||||
|
"
|
||||||
|
" :Fmt
|
||||||
|
"
|
||||||
|
" Filter the current Go buffer through gofmt.
|
||||||
|
" It tries to preserve cursor position and avoids
|
||||||
|
" replacing the buffer with stderr output.
|
||||||
|
"
|
||||||
|
|
||||||
|
command! -buffer Fmt call s:GoFormat()
|
||||||
|
|
||||||
|
function! s:GoFormat()
|
||||||
|
let view = winsaveview()
|
||||||
|
silent %!gofmt
|
||||||
|
if v:shell_error
|
||||||
|
let errors = []
|
||||||
|
for line in getline(1, line('$'))
|
||||||
|
let tokens = matchlist(line, '^\(.\{-}\):\(\d\+\):\(\d\+\)\s*\(.*\)')
|
||||||
|
if !empty(tokens)
|
||||||
|
call add(errors, {"filename": @%,
|
||||||
|
\"lnum": tokens[2],
|
||||||
|
\"col": tokens[3],
|
||||||
|
\"text": tokens[4]})
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
if empty(errors)
|
||||||
|
% | " Couldn't detect gofmt error format, output errors
|
||||||
|
endif
|
||||||
|
undo
|
||||||
|
if !empty(errors)
|
||||||
|
call setloclist(0, errors, 'r')
|
||||||
|
endif
|
||||||
|
echohl Error | echomsg "Gofmt returned error" | echohl None
|
||||||
|
endif
|
||||||
|
call winrestview(view)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" vim:ts=4:sw=4:et
|
||||||
13
.vim/bundle/go-official/ftplugin/go/godoc.vim
Normal file
13
.vim/bundle/go-official/ftplugin/go/godoc.vim
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
" Copyright 2011 The Go Authors. All rights reserved.
|
||||||
|
" Use of this source code is governed by a BSD-style
|
||||||
|
" license that can be found in the LICENSE file.
|
||||||
|
"
|
||||||
|
" godoc.vim: Vim command to see godoc.
|
||||||
|
|
||||||
|
if exists("b:did_ftplugin")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
silent! nmap <buffer> <silent> K <Plug>(godoc-keyword)
|
||||||
|
|
||||||
|
" vim:ts=4:sw=4:et
|
||||||
|
|
@ -36,9 +36,9 @@ if exists("b:did_ftplugin")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
command! -buffer -nargs=? Drop call s:SwitchImport(0, '', <f-args>)
|
command! -buffer -nargs=? -complete=customlist,go#complete#Package Drop call s:SwitchImport(0, '', <f-args>)
|
||||||
command! -buffer -nargs=1 Import call s:SwitchImport(1, '', <f-args>)
|
command! -buffer -nargs=1 -complete=customlist,go#complete#Package Import call s:SwitchImport(1, '', <f-args>)
|
||||||
command! -buffer -nargs=* ImportAs call s:SwitchImport(1, <f-args>)
|
command! -buffer -nargs=* -complete=customlist,go#complete#Package ImportAs call s:SwitchImport(1, <f-args>)
|
||||||
map <buffer> <LocalLeader>f :Import fmt<CR>
|
map <buffer> <LocalLeader>f :Import fmt<CR>
|
||||||
map <buffer> <LocalLeader>F :Drop fmt<CR>
|
map <buffer> <LocalLeader>F :Drop fmt<CR>
|
||||||
|
|
||||||
65
.vim/bundle/go-official/indent/go.vim
Normal file
65
.vim/bundle/go-official/indent/go.vim
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
" Copyright 2011 The Go Authors. All rights reserved.
|
||||||
|
" Use of this source code is governed by a BSD-style
|
||||||
|
" license that can be found in the LICENSE file.
|
||||||
|
"
|
||||||
|
" indent/go.vim: Vim indent file for Go.
|
||||||
|
"
|
||||||
|
" TODO:
|
||||||
|
" - function invocations split across lines
|
||||||
|
" - general line splits (line ends in an operator)
|
||||||
|
|
||||||
|
if exists("b:did_indent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_indent = 1
|
||||||
|
|
||||||
|
" C indentation is too far off useful, mainly due to Go's := operator.
|
||||||
|
" Let's just define our own.
|
||||||
|
setlocal nolisp
|
||||||
|
setlocal autoindent
|
||||||
|
setlocal indentexpr=GoIndent(v:lnum)
|
||||||
|
setlocal indentkeys+=<:>,0=},0=)
|
||||||
|
|
||||||
|
if exists("*GoIndent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
function! GoIndent(lnum)
|
||||||
|
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)
|
||||||
|
|
||||||
|
let ind = previ
|
||||||
|
|
||||||
|
if prevl =~ '[({]\s*$'
|
||||||
|
" previous line opened a block
|
||||||
|
let ind += &sw
|
||||||
|
endif
|
||||||
|
if prevl =~# '^\s*\(case .*\|default\):$'
|
||||||
|
" previous line is part of a switch statement
|
||||||
|
let ind += &sw
|
||||||
|
endif
|
||||||
|
" TODO: handle if the previous line is a label.
|
||||||
|
|
||||||
|
if thisl =~ '^\s*[)}]'
|
||||||
|
" this line closed a block
|
||||||
|
let ind -= &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 -= &sw
|
||||||
|
endif
|
||||||
|
|
||||||
|
return ind
|
||||||
|
endfunction
|
||||||
85
.vim/bundle/go-official/plugin/godoc.vim
Normal file
85
.vim/bundle/go-official/plugin/godoc.vim
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
" Copyright 2011 The Go Authors. All rights reserved.
|
||||||
|
" Use of this source code is governed by a BSD-style
|
||||||
|
" license that can be found in the LICENSE file.
|
||||||
|
"
|
||||||
|
" godoc.vim: Vim command to see godoc.
|
||||||
|
|
||||||
|
if exists("g:loaded_godoc")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let g:loaded_godoc = 1
|
||||||
|
|
||||||
|
let s:buf_nr = -1
|
||||||
|
let s:last_word = ''
|
||||||
|
|
||||||
|
function! s:GodocView()
|
||||||
|
if !bufexists(s:buf_nr)
|
||||||
|
leftabove new
|
||||||
|
file `="[Godoc]"`
|
||||||
|
let s:buf_nr = bufnr('%')
|
||||||
|
elseif bufwinnr(s:buf_nr) == -1
|
||||||
|
leftabove split
|
||||||
|
execute s:buf_nr . 'buffer'
|
||||||
|
delete _
|
||||||
|
elseif bufwinnr(s:buf_nr) != bufwinnr('%')
|
||||||
|
execute bufwinnr(s:buf_nr) . 'wincmd w'
|
||||||
|
endif
|
||||||
|
|
||||||
|
setlocal filetype=godoc
|
||||||
|
setlocal bufhidden=delete
|
||||||
|
setlocal buftype=nofile
|
||||||
|
setlocal noswapfile
|
||||||
|
setlocal nobuflisted
|
||||||
|
setlocal modifiable
|
||||||
|
setlocal nocursorline
|
||||||
|
setlocal nocursorcolumn
|
||||||
|
setlocal iskeyword+=:
|
||||||
|
setlocal iskeyword-=-
|
||||||
|
|
||||||
|
nnoremap <buffer> <silent> K :Godoc<cr>
|
||||||
|
|
||||||
|
au BufHidden <buffer> call let <SID>buf_nr = -1
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:GodocWord(word)
|
||||||
|
let word = a:word
|
||||||
|
silent! let content = system('godoc ' . word)
|
||||||
|
if v:shell_error || !len(content)
|
||||||
|
if len(s:last_word)
|
||||||
|
silent! let content = system('godoc ' . s:last_word.'/'.word)
|
||||||
|
if v:shell_error || !len(content)
|
||||||
|
echo 'No documentation found for "' . word . '".'
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let word = s:last_word.'/'.word
|
||||||
|
else
|
||||||
|
echo 'No documentation found for "' . word . '".'
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
let s:last_word = word
|
||||||
|
silent! call s:GodocView()
|
||||||
|
setlocal modifiable
|
||||||
|
silent! %d _
|
||||||
|
silent! put! =content
|
||||||
|
silent! normal gg
|
||||||
|
setlocal nomodifiable
|
||||||
|
setfiletype godoc
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:Godoc(...)
|
||||||
|
let word = join(a:000, ' ')
|
||||||
|
if !len(word)
|
||||||
|
let word = expand('<cword>')
|
||||||
|
endif
|
||||||
|
let word = substitute(word, '[^a-zA-Z0-9\/]', '', 'g')
|
||||||
|
if !len(word)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
call s:GodocWord(word)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
command! -nargs=* -range -complete=customlist,go#complete#Package Godoc :call s:Godoc(<q-args>)
|
||||||
|
nnoremap <silent> <Plug>(godoc-keyword) :<C-u>call <SID>Godoc('')<CR>
|
||||||
|
|
||||||
|
" vim:ts=4:sw=4:et
|
||||||
76
.vim/bundle/go-official/readme.txt
Normal file
76
.vim/bundle/go-official/readme.txt
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
Vim plugins for Go (http://golang.org)
|
||||||
|
======================================
|
||||||
|
|
||||||
|
To use all the Vim plugins, add these lines to your vimrc.
|
||||||
|
|
||||||
|
set rtp+=$GOROOT/misc/vim
|
||||||
|
filetype plugin indent on
|
||||||
|
syntax on
|
||||||
|
|
||||||
|
If you want to select fewer plugins, use the instructions in the rest of
|
||||||
|
this file.
|
||||||
|
|
||||||
|
Vim syntax highlighting
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
To install automatic syntax highlighting for GO programs:
|
||||||
|
|
||||||
|
1. Copy or link the filetype detection script to the ftdetect directory
|
||||||
|
underneath your vim runtime directory (normally $HOME/.vim/ftdetect)
|
||||||
|
2. Copy or link syntax/go.vim to the syntax directory underneath your vim
|
||||||
|
runtime directory (normally $HOME/.vim/syntax). Linking this file rather
|
||||||
|
than just copying it will ensure any changes are automatically reflected
|
||||||
|
in your syntax highlighting.
|
||||||
|
3. Add the following line to your .vimrc file (normally $HOME/.vimrc):
|
||||||
|
|
||||||
|
syntax on
|
||||||
|
|
||||||
|
In a typical unix environment you might accomplish this using the following
|
||||||
|
commands:
|
||||||
|
|
||||||
|
mkdir -p $HOME/.vim/ftdetect
|
||||||
|
mkdir -p $HOME/.vim/syntax
|
||||||
|
mkdir -p $HOME/.vim/autoload/go
|
||||||
|
ln -s $GOROOT/misc/vim/ftdetect/gofiletype.vim $HOME/.vim/ftdetect/
|
||||||
|
ln -s $GOROOT/misc/vim/syntax/go.vim $HOME/.vim/syntax
|
||||||
|
ln -s $GOROOT/misc/vim/autoload/go/complete.vim $HOME/.vim/autoload/go
|
||||||
|
echo "syntax on" >> $HOME/.vimrc
|
||||||
|
|
||||||
|
|
||||||
|
Vim filetype plugins
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
To install one of the available filetype plugins:
|
||||||
|
|
||||||
|
1. Same as 1 above.
|
||||||
|
2. Copy or link one or more plugins from ftplugin/go/*.vim to the
|
||||||
|
Go-specific ftplugin directory underneath your vim runtime directory
|
||||||
|
(normally $HOME/.vim/ftplugin/go/*.vim).
|
||||||
|
3. Add the following line to your .vimrc file (normally $HOME/.vimrc):
|
||||||
|
|
||||||
|
filetype plugin on
|
||||||
|
|
||||||
|
|
||||||
|
Vim indentation plugin
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
To install automatic indentation:
|
||||||
|
|
||||||
|
1. Same as 1 above.
|
||||||
|
2. Copy or link indent/go.vim to the indent directory underneath your vim
|
||||||
|
runtime directory (normally $HOME/.vim/indent).
|
||||||
|
3. Add the following line to your .vimrc file (normally $HOME/.vimrc):
|
||||||
|
|
||||||
|
filetype indent on
|
||||||
|
|
||||||
|
|
||||||
|
Godoc plugin
|
||||||
|
------------
|
||||||
|
|
||||||
|
To install godoc plugin:
|
||||||
|
|
||||||
|
1. Same as 1 above.
|
||||||
|
2. Copy or link plugin/godoc.vim to $HOME/.vim/plugin/godoc,
|
||||||
|
syntax/godoc.vim to $HOME/.vim/syntax/godoc.vim,
|
||||||
|
ftplugin/go/godoc.vim to $HOME/.vim/ftplugin/go/godoc.vim.
|
||||||
|
and autoload/go/complete.vim to $HOME/.vim/autoload/go/complete.vim.
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
" Highlights white space around the communications operator that don't follow
|
" Highlights white space around the communications operator that don't follow
|
||||||
" the standard style.
|
" the standard style.
|
||||||
" - go_highlight_extra_types
|
" - go_highlight_extra_types
|
||||||
" Highlights commonly used library types (os.Error, etc.).
|
" Highlights commonly used library types (io.Reader, etc.).
|
||||||
" - go_highlight_space_tab_error
|
" - go_highlight_space_tab_error
|
||||||
" Highlights instances of tabs following spaces.
|
" Highlights instances of tabs following spaces.
|
||||||
" - go_highlight_trailing_whitespace_error
|
" - go_highlight_trailing_whitespace_error
|
||||||
|
|
@ -67,8 +67,8 @@ hi def link goLabel Label
|
||||||
hi def link goRepeat Repeat
|
hi def link goRepeat Repeat
|
||||||
|
|
||||||
" Predefined types
|
" Predefined types
|
||||||
syn keyword goType chan map bool string
|
syn keyword goType chan map bool string error
|
||||||
syn keyword goSignedInts int int8 int16 int32 int64
|
syn keyword goSignedInts int int8 int16 int32 int64 rune
|
||||||
syn keyword goUnsignedInts byte uint uint8 uint16 uint32 uint64 uintptr
|
syn keyword goUnsignedInts byte uint uint8 uint16 uint32 uint64 uintptr
|
||||||
syn keyword goFloats float32 float64
|
syn keyword goFloats float32 float64
|
||||||
syn keyword goComplexes complex64 complex128
|
syn keyword goComplexes complex64 complex128
|
||||||
|
|
@ -85,7 +85,7 @@ syn match goType /\<func\>/
|
||||||
syn match goDeclaration /^func\>/
|
syn match goDeclaration /^func\>/
|
||||||
|
|
||||||
" Predefined functions and values
|
" Predefined functions and values
|
||||||
syn keyword goBuiltins append cap close complex copy imag len
|
syn keyword goBuiltins append cap close complex copy delete imag len
|
||||||
syn keyword goBuiltins make new panic print println real recover
|
syn keyword goBuiltins make new panic print println real recover
|
||||||
syn keyword goConstants iota true false nil
|
syn keyword goConstants iota true false nil
|
||||||
|
|
||||||
|
|
@ -180,7 +180,6 @@ endif
|
||||||
if go_highlight_extra_types != 0
|
if go_highlight_extra_types != 0
|
||||||
syn match goExtraType /\<bytes\.\(Buffer\)\>/
|
syn match goExtraType /\<bytes\.\(Buffer\)\>/
|
||||||
syn match goExtraType /\<io\.\(Reader\|Writer\|ReadWriter\|ReadWriteCloser\)\>/
|
syn match goExtraType /\<io\.\(Reader\|Writer\|ReadWriter\|ReadWriteCloser\)\>/
|
||||||
syn match goExtraType /\<\(os\.Error\)\>/
|
|
||||||
syn match goExtraType /\<reflect\.\(Kind\|Type\|Value\)\>/
|
syn match goExtraType /\<reflect\.\(Kind\|Type\|Value\)\>/
|
||||||
syn match goExtraType /\<unsafe\.Pointer\>/
|
syn match goExtraType /\<unsafe\.Pointer\>/
|
||||||
endif
|
endif
|
||||||
20
.vim/bundle/go-official/syntax/godoc.vim
Normal file
20
.vim/bundle/go-official/syntax/godoc.vim
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
" Copyright 2011 The Go Authors. All rights reserved.
|
||||||
|
" Use of this source code is governed by a BSD-style
|
||||||
|
" license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
syn case match
|
||||||
|
syn match godocTitle "^\([A-Z]*\)$"
|
||||||
|
|
||||||
|
command -nargs=+ HiLink hi def link <args>
|
||||||
|
|
||||||
|
HiLink godocTitle Title
|
||||||
|
|
||||||
|
delcommand HiLink
|
||||||
|
|
||||||
|
let b:current_syntax = "godoc"
|
||||||
|
|
||||||
|
" vim:ts=4 sts=2 sw=2:
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
au BufRead,BufNewFile *.go set filetype=go
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
" Copyright 2011 The Go Authors. All rights reserved.
|
|
||||||
" Use of this source code is governed by a BSD-style
|
|
||||||
" license that can be found in the LICENSE file.
|
|
||||||
"
|
|
||||||
" fmt.vim: Vim command to format Go files with gofmt.
|
|
||||||
"
|
|
||||||
" This filetype plugin add a new commands for go buffers:
|
|
||||||
"
|
|
||||||
" :Fmt
|
|
||||||
"
|
|
||||||
" Filter the current Go buffer through gofmt.
|
|
||||||
" It tries to preserve cursor position and avoids
|
|
||||||
" replacing the buffer with stderr output.
|
|
||||||
"
|
|
||||||
|
|
||||||
command! Fmt call s:GoFormat()
|
|
||||||
|
|
||||||
function! s:GoFormat()
|
|
||||||
let view = winsaveview()
|
|
||||||
%!gofmt
|
|
||||||
if v:shell_error
|
|
||||||
%| " output errors returned by gofmt
|
|
||||||
" TODO(dchest): perhaps, errors should go to quickfix
|
|
||||||
undo
|
|
||||||
echohl Error | echomsg "Gofmt returned error" | echohl None
|
|
||||||
endif
|
|
||||||
call winrestview(view)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" vim:ts=4:sw=4:et
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
" Copyright 2011 The Go Authors. All rights reserved.
|
|
||||||
" Use of this source code is governed by a BSD-style
|
|
||||||
" license that can be found in the LICENSE file.
|
|
||||||
"
|
|
||||||
" indent/go.vim: Vim indent file for Go.
|
|
||||||
"
|
|
||||||
|
|
||||||
if exists("b:did_indent")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let b:did_indent = 1
|
|
||||||
|
|
||||||
" C indentation is mostly correct
|
|
||||||
setlocal cindent
|
|
||||||
|
|
||||||
" Options set:
|
|
||||||
" +0 -- Don't indent continuation lines (because Go doesn't use semicolons
|
|
||||||
" much)
|
|
||||||
" L0 -- Don't move jump labels (NOTE: this isn't correct when working with
|
|
||||||
" gofmt, but it does keep struct literals properly indented.)
|
|
||||||
" :0 -- Align case labels with switch statement
|
|
||||||
" l1 -- Always align case body relative to case labels
|
|
||||||
" J1 -- Indent JSON-style objects (properly indents struct-literals)
|
|
||||||
" (0, Ws -- Indent lines inside of unclosed parentheses by one shiftwidth
|
|
||||||
" m1 -- Align closing parenthesis line with first non-blank of matching
|
|
||||||
" parenthesis line
|
|
||||||
"
|
|
||||||
" Known issue: Trying to do a multi-line struct literal in a short variable
|
|
||||||
" declaration will not indent properly.
|
|
||||||
setlocal cinoptions+=+0,L0,:0,l1,J1,(0,Ws,m1
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue