mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Updated plugins
This commit is contained in:
@ -1,10 +1,15 @@
|
||||
## 1.8 (unplanned)
|
||||
|
||||
FEATURES:
|
||||
|
||||
* If you open a new buffer with a Go filename it get automatically populated based on the directory. If there are no Go files a simple main package is created, otherwise the file will include the package declaration line based on the package in the current directory. Checkout the demo to see it in action: https://twitter.com/fatih/status/748333086643994624. This is enabled by default. Can be disabled with `let g:go_template_autocreate = 0`. You can use your own template with `let g:go_template_file = "foo.go"` and putting the file under the `templates/` folder. [gh-918]
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
||||
* `:GoDoc` accepts arguments now which are passed directly to `godoc`. So usages like `:GoDoc flag` works again (it was changed in previous versions [gh-894]
|
||||
* `:GoDef` works now for modified files as well [gh-910]
|
||||
* Internal: fix indentations on all files to **2-spaces/no tabs**. This is now the default vim-go style across all VimL files [gh-915]
|
||||
* Syntax: improved syntax highglighting performance for methods, fields, structs and interface type declarations [gh-917]
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
@ -13,6 +18,12 @@ BUG FIXES:
|
||||
* Fix `:GoCoverage` not running for Neovim [gh-899]
|
||||
* Fix `:GoFmt` not picking up `-srcdir` if the command was set to use `goimports` [gh-904]
|
||||
* Fix `:GoTestCompile` to not leave behind artifacts if the cwd and the test files's directory do not match [gh-909]
|
||||
* Fix `:GoDocBrowser` to not fail if godoc doesn't exist [gh-920]
|
||||
|
||||
BACKWARDS INCOMPATIBILITIES:
|
||||
|
||||
* `g:go_highlight_structs` and `g:go_highlight_interface` are removed in favor of `g:go_highlight_types` [gh-917]
|
||||
|
||||
|
||||
## 1.7.1 (June 7, 2016)
|
||||
|
||||
|
@ -181,8 +181,7 @@ To change it:
|
||||
let g:go_highlight_functions = 1
|
||||
let g:go_highlight_methods = 1
|
||||
let g:go_highlight_fields = 1
|
||||
let g:go_highlight_structs = 1
|
||||
let g:go_highlight_interfaces = 1
|
||||
let g:go_highlight_types = 1
|
||||
let g:go_highlight_operators = 1
|
||||
let g:go_highlight_build_constraints = 1
|
||||
```
|
||||
|
@ -19,7 +19,7 @@ function! s:godocWord(args)
|
||||
if !executable('godoc')
|
||||
let msg = "godoc command not found."
|
||||
let msg .= " install with: go get golang.org/x/tools/cmd/godoc"
|
||||
call go#util#echoWarning(msg)
|
||||
call go#util#EchoWarning(msg)
|
||||
return []
|
||||
endif
|
||||
|
||||
|
31
sources_non_forked/vim-go/autoload/go/template.vim
Normal file
31
sources_non_forked/vim-go/autoload/go/template.vim
Normal file
@ -0,0 +1,31 @@
|
||||
let s:current_file = expand("<sfile>")
|
||||
|
||||
function! go#template#create()
|
||||
let l:root_dir = fnamemodify(s:current_file, ':h:h:h')
|
||||
|
||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
|
||||
let dir = getcwd()
|
||||
execute cd . fnameescape(expand("%:p:h"))
|
||||
|
||||
let l:package_name = go#tool#PackageName()
|
||||
|
||||
" if we can't figure out any package name(no Go files or non Go package
|
||||
" files) from the directory create the template
|
||||
if l:package_name == -1
|
||||
let l:template_file = get(g:, 'go_template_file', "hello_world.go")
|
||||
let l:template_path = go#util#Join(l:root_dir, "templates", l:template_file)
|
||||
exe '0r ' . l:template_path
|
||||
$delete _
|
||||
else
|
||||
let l:content = printf("package %s", l:package_name)
|
||||
call append(0, l:content)
|
||||
$delete _
|
||||
endif
|
||||
|
||||
" Remove the '... [New File]' message line from the command line
|
||||
echon
|
||||
|
||||
execute cd . fnameescape(dir)
|
||||
endfunction
|
||||
|
||||
" vim: sw=2 ts=2 et
|
@ -43,6 +43,16 @@ function! go#tool#Imports()
|
||||
return imports
|
||||
endfunction
|
||||
|
||||
function! go#tool#PackageName()
|
||||
let command = "go list -f '{{.Name}}'"
|
||||
let out = go#tool#ExecuteInDir(command)
|
||||
if go#util#ShellError() != 0
|
||||
return -1
|
||||
endif
|
||||
|
||||
return split(out, '\n')[0]
|
||||
endfunction
|
||||
|
||||
function! go#tool#ParseErrors(lines)
|
||||
let errors = []
|
||||
|
||||
|
@ -25,6 +25,12 @@ function! go#util#LineEnding()
|
||||
return "\n"
|
||||
endfunction
|
||||
|
||||
" Join joins any number of path elements into a single path, adding a
|
||||
" Separator if necessary and returns the result
|
||||
function! go#util#Join(...)
|
||||
return join(a:000, go#util#PathSep())
|
||||
endfunction
|
||||
|
||||
" IsWin returns 1 if current OS is Windows or 0 otherwise
|
||||
function! go#util#IsWin()
|
||||
let win = ['win16', 'win32', 'win64', 'win95']
|
||||
|
@ -1118,23 +1118,17 @@ Highlights method names. By default it's disabled. >
|
||||
|
||||
let g:go_highlight_methods = 0
|
||||
<
|
||||
*'g:go_highlight_structs'*
|
||||
*'g:go_highlight_types'*
|
||||
|
||||
Highlights struct names. By default it's disabled. >
|
||||
Highlights struct and interface names. By default it's disabled. >
|
||||
|
||||
let g:go_highlight_structs = 0
|
||||
let g:go_highlight_types = 0
|
||||
<
|
||||
*'g:go_highlight_fields'*
|
||||
|
||||
Highlights field names. By default it's disabled. >
|
||||
|
||||
let g:go_highlight_fields = 0
|
||||
<
|
||||
*'g:go_highlight_interfaces'*
|
||||
|
||||
Highlights interface names. By default it's disabled. >
|
||||
|
||||
let g:go_highlight_interfaces = 0
|
||||
<
|
||||
*'g:go_highlight_build_constraints'*
|
||||
|
||||
@ -1291,8 +1285,30 @@ Specifies whether `gocode` should add built-in types, functions and constants
|
||||
to an autocompletion proposals. By default it is enabled.
|
||||
>
|
||||
let g:go_gocode_propose_builtins = 1
|
||||
<
|
||||
*g:go_template_autocreate*
|
||||
|
||||
When a new Go file is created, vim-go automatically fills the buffer content
|
||||
with a Go code template. By default the template under
|
||||
`templates/hello_world.go` is used. This can be changed with the
|
||||
|g:go_template_file| setting.
|
||||
|
||||
If the new file is created in an already prepopulated package (with other Go
|
||||
files), in this case a Go code template with only the Go package declaration
|
||||
(which is automatically determined according to the current package) is added.
|
||||
|
||||
By default it is enabled.
|
||||
>
|
||||
let g:go_template_autocreate = 1
|
||||
<
|
||||
*g:go_template_file*
|
||||
|
||||
Specifies the file under the `templates` folder that is used if a new Go file
|
||||
is created. Checkout |g:go_template_autocreate| for more info. By default the
|
||||
`hello_world.go` file is used.
|
||||
>
|
||||
let g:go_template_file = "hello_world.go"
|
||||
<
|
||||
===============================================================================
|
||||
TROUBLESHOOTING *go-troubleshooting*
|
||||
|
||||
|
@ -171,6 +171,11 @@ augroup vim-go
|
||||
if get(g:, "go_metalinter_autosave", 0)
|
||||
autocmd BufWritePost *.go call go#lint#Gometa(1)
|
||||
endif
|
||||
|
||||
" create new template from scratch
|
||||
if get(g:, "go_template_autocreate", 1)
|
||||
autocmd BufNewFile *.go call go#template#create()
|
||||
endif
|
||||
augroup END
|
||||
|
||||
" vim: sw=2 ts=2 et
|
||||
|
@ -71,12 +71,8 @@ if !exists("g:go_highlight_fields")
|
||||
let g:go_highlight_fields = 0
|
||||
endif
|
||||
|
||||
if !exists("g:go_highlight_structs")
|
||||
let g:go_highlight_structs = 0
|
||||
endif
|
||||
|
||||
if !exists("g:go_highlight_interfaces")
|
||||
let g:go_highlight_interfaces = 0
|
||||
if !exists("g:go_highlight_types")
|
||||
let g:go_highlight_types = 0
|
||||
endif
|
||||
|
||||
if !exists("g:go_highlight_build_constraints")
|
||||
@ -98,12 +94,10 @@ endif
|
||||
syn case match
|
||||
|
||||
syn keyword goDirective package import
|
||||
syn keyword goDeclaration var const type
|
||||
syn keyword goDeclType struct interface
|
||||
syn keyword goDeclaration var const
|
||||
|
||||
hi def link goDirective Statement
|
||||
hi def link goDeclaration Keyword
|
||||
hi def link goDeclType Keyword
|
||||
|
||||
" Keywords within functions
|
||||
syn keyword goStatement defer go goto return break continue fallthrough
|
||||
@ -129,10 +123,6 @@ hi def link goUnsignedInts Type
|
||||
hi def link goFloats Type
|
||||
hi def link goComplexes Type
|
||||
|
||||
" Treat func specially: it's a declaration at the start of a line, but a type
|
||||
" elsewhere. Order matters here.
|
||||
syn match goDeclaration /\<func\>/
|
||||
|
||||
|
||||
" Predefined functions and values
|
||||
syn match goBuiltins /\<\v(append|cap|close|complex|copy|delete|imag|len)\ze\(/
|
||||
@ -301,38 +291,43 @@ hi def link goOperator Operator
|
||||
|
||||
" Functions;
|
||||
if g:go_highlight_functions != 0
|
||||
syn match goFunction /\(func\s\+\)\@<=\w\+\((\)\@=/
|
||||
syn match goFunction /\()\s\+\)\@<=\w\+\((\)\@=/
|
||||
syn match goDeclaration /\<func\>/ nextgroup=goReceiver,goFunction skipwhite skipnl
|
||||
syn match goReceiver /([^),]\+)/ contained nextgroup=goFunction contains=goReceiverType skipwhite skipnl
|
||||
syn match goReceiverType /\(\s\|*\)\w\+)/hs=s+1,he=e-1 contained
|
||||
syn match goFunction /\w\+/ contained
|
||||
else
|
||||
syn keyword goDeclaration func
|
||||
endif
|
||||
hi def link goReceiverType Type
|
||||
hi def link goFunction Function
|
||||
|
||||
" Methods;
|
||||
if g:go_highlight_methods != 0
|
||||
syn match goMethod /\(\.\)\@<=\w\+\((\)\@=/
|
||||
syn match goMethod /\.\w\+(/hs=s+1,he=e-1
|
||||
endif
|
||||
hi def link goMethod Type
|
||||
|
||||
" Fields;
|
||||
if g:go_highlight_fields != 0
|
||||
syn match goField /\(\.\)\@<=\a\+\([\ \n\r\:\)]\)\@=/
|
||||
syn match goVarArgs /\.\.\.\w\+\>/
|
||||
syn match goField /\.\a\+\([\ \n\r\:\)\[]\)\@=/hs=s+1
|
||||
endif
|
||||
hi def link goField Type
|
||||
hi def link goField Identifier
|
||||
|
||||
" Structs;
|
||||
if g:go_highlight_structs != 0
|
||||
syn match goStruct /\(.\)\@<=\w\+\({\)\@=/
|
||||
syn match goStructDef /\(type\s\+\)\@<=\w\+\(\s\+struct\s\+{\)\@=/
|
||||
" Structs & Interfaces;
|
||||
if g:go_highlight_types != 0
|
||||
syn match goTypeConstructor /\<\w\+{/he=e-1
|
||||
syn match goTypeDecl /\<type\>/ nextgroup=goTypeName skipwhite skipnl
|
||||
syn match goTypeName /\w\+/ contained nextgroup=goDeclType skipwhite skipnl
|
||||
syn match goDeclType /\<interface\|struct\>/ contained skipwhite skipnl
|
||||
else
|
||||
syn keyword goDeclType struct interface
|
||||
syn keyword goDeclaration type
|
||||
endif
|
||||
hi def link goStruct Function
|
||||
hi def link goStructDef Function
|
||||
|
||||
" Interfaces;
|
||||
if g:go_highlight_interfaces != 0
|
||||
syn match goInterface /\(.\)\@<=\w\+\({\)\@=/
|
||||
syn match goInterfaceDef /\(type\s\+\)\@<=\w\+\(\s\+interface\s\+{\)\@=/
|
||||
endif
|
||||
hi def link goInterface Function
|
||||
hi def link goInterfaceDef Function
|
||||
hi def link goTypeConstructor Type
|
||||
hi def link goTypeName Type
|
||||
hi def link goTypeDecl Keyword
|
||||
hi def link goDeclType Keyword
|
||||
|
||||
" Build Constraints
|
||||
if g:go_highlight_build_constraints != 0
|
||||
|
7
sources_non_forked/vim-go/templates/hello_world.go
Normal file
7
sources_non_forked/vim-go/templates/hello_world.go
Normal file
@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("vim-go")
|
||||
}
|
Reference in New Issue
Block a user