mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Updated plugins
This commit is contained in:
9
sources_non_forked/vim-go/.github/CONTRIBUTING.md
vendored
Normal file
9
sources_non_forked/vim-go/.github/CONTRIBUTING.md
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
Thanks for improving vim-go! Before you dive in please read the following:
|
||||
|
||||
1. Please read our
|
||||
[FAQ](https://github.com/fatih/vim-go/wiki/FAQ-Troubleshooting), it might
|
||||
have answers for your problem
|
||||
2. If you add a new feature please don't forget to update the documentation:
|
||||
[doc/vim-go.txt](doc/vim-go.txt)
|
||||
3. If it's a breaking change or exceed +100 lines please open an issue first
|
||||
and describe the changes you want to make.
|
30
sources_non_forked/vim-go/.github/ISSUE_TEMPLATE.md
vendored
Normal file
30
sources_non_forked/vim-go/.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
### Expected behavior
|
||||
|
||||
Write here what you're expecting ...
|
||||
|
||||
### Actual behavior
|
||||
|
||||
Write here what happens instead ...
|
||||
|
||||
### Steps to reproduce:
|
||||
|
||||
Please create a reproducible case of your problem. Re produce it
|
||||
with a minimal `vimrc` with all plugins disabled and only `vim-go`
|
||||
enabled:
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
### Configuration
|
||||
|
||||
#### `vimrc` you used to reproduce:
|
||||
|
||||
#### vim version:
|
||||
|
||||
#### vim-go version:
|
||||
|
||||
#### go version:
|
||||
|
||||
|
||||
|
@ -5,26 +5,26 @@ endif
|
||||
|
||||
" Test alternates between the implementation of code and the test code.
|
||||
function! go#alternate#Switch(bang, cmd)
|
||||
let l:file = go#alternate#Filename(fnameescape(expand("%")))
|
||||
if !filereadable(l:file) && !bufexists(l:file) && !a:bang
|
||||
redraws! | echon "vim-go: " | echohl ErrorMsg | echon "couldn't find ".file | echohl None
|
||||
let file = expand('%')
|
||||
if empty(file)
|
||||
call go#util#EchoError("no buffer name")
|
||||
return
|
||||
elseif file =~# '^\f\+_test\.go$'
|
||||
let l:root = split(file, '_test.go$')[0]
|
||||
let l:alt_file = l:root . ".go"
|
||||
elseif file =~# '^\f\+\.go$'
|
||||
let l:root = split(file, ".go$")[0]
|
||||
let l:alt_file = l:root . '_test.go'
|
||||
else
|
||||
call go#util#EchoError("not a go file")
|
||||
return
|
||||
endif
|
||||
if !filereadable(alt_file) && !bufexists(alt_file) && !a:bang
|
||||
call go#util#EchoError("couldn't find ".alt_file)
|
||||
return
|
||||
elseif empty(a:cmd)
|
||||
execute ":" . g:go_alternate_mode . " " . file
|
||||
execute ":" . g:go_alternate_mode . " " . alt_file
|
||||
else
|
||||
execute ":" . a:cmd . " " . file
|
||||
execute ":" . a:cmd . " " . alt_file
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Filename returns the name of the test file or implementation file
|
||||
" depending on the arguments
|
||||
function! go#alternate#Filename(path)
|
||||
if empty(matchstr(a:path, "_test"))
|
||||
let l:root = split(a:path, ".go$")[0]
|
||||
let l:file = l:root . "_test.go"
|
||||
else
|
||||
let l:root = split(a:path, "_test.go$")[0]
|
||||
let l:file = l:root . ".go"
|
||||
endif
|
||||
return l:file
|
||||
endfunction
|
||||
|
@ -74,8 +74,12 @@ endfunction
|
||||
|
||||
|
||||
" Run runs the current file (and their dependencies if any) in a new terminal.
|
||||
function! go#cmd#RunTerm(bang, mode)
|
||||
let cmd = "go run ". go#util#Shelljoin(go#tool#Files())
|
||||
function! go#cmd#RunTerm(bang, mode, files)
|
||||
if empty(a:files)
|
||||
let cmd = "go run ". go#util#Shelljoin(go#tool#Files())
|
||||
else
|
||||
let cmd = "go run ". go#util#Shelljoin(map(copy(a:files), "expand(v:val)"), 1)
|
||||
endif
|
||||
call go#term#newmode(a:bang, cmd, a:mode)
|
||||
endfunction
|
||||
|
||||
@ -85,7 +89,7 @@ endfunction
|
||||
" calling long running apps will block the whole UI.
|
||||
function! go#cmd#Run(bang, ...)
|
||||
if has('nvim')
|
||||
call go#cmd#RunTerm(a:bang, '')
|
||||
call go#cmd#RunTerm(a:bang, '', a:000)
|
||||
return
|
||||
endif
|
||||
|
||||
@ -117,9 +121,9 @@ function! go#cmd#Run(bang, ...)
|
||||
if g:go_dispatch_enabled && exists(':Make') == 2
|
||||
silent! exe 'Make'
|
||||
elseif l:listtype == "locationlist"
|
||||
silent! exe 'lmake!'
|
||||
exe 'lmake!'
|
||||
else
|
||||
silent! exe 'make!'
|
||||
exe 'make!'
|
||||
endif
|
||||
|
||||
let items = go#list#Get(l:listtype)
|
||||
|
@ -149,13 +149,16 @@ function! go#complete#GetInfoFromOffset(offset)
|
||||
endfunction
|
||||
|
||||
function! go#complete#GetInfo()
|
||||
let offset = go#complete#gocodeCursor()
|
||||
let offset = go#complete#gocodeCursor()+1
|
||||
return go#complete#GetInfoFromOffset(offset)
|
||||
endfunction
|
||||
|
||||
function! go#complete#Info()
|
||||
function! go#complete#Info(auto)
|
||||
" auto is true if we were called by g:go_auto_type_info's autocmd
|
||||
let result = go#complete#GetInfo()
|
||||
if !empty(result)
|
||||
" if auto, and the result is a PANIC by gocode, hide it
|
||||
if a:auto && result ==# 'PANIC PANIC PANIC' | return | endif
|
||||
echo "vim-go: " | echohl Function | echon result | echohl None
|
||||
endif
|
||||
endfunction
|
||||
|
@ -116,7 +116,7 @@ function! s:godefJump(out, mode)
|
||||
|
||||
" jump to file now
|
||||
sil ll 1
|
||||
normal zz
|
||||
normal! zz
|
||||
|
||||
let &switchbuf = old_switchbuf
|
||||
end
|
||||
|
@ -113,28 +113,28 @@ function! go#doc#Open(newmode, mode, ...)
|
||||
call s:GodocView(a:newmode, a:mode, content)
|
||||
|
||||
if exported_name == ''
|
||||
silent! normal gg
|
||||
silent! normal! gg
|
||||
return -1
|
||||
endif
|
||||
|
||||
" jump to the specified name
|
||||
if search('^func ' . exported_name . '(')
|
||||
silent! normal zt
|
||||
silent! normal! zt
|
||||
return -1
|
||||
endif
|
||||
|
||||
if search('^type ' . exported_name)
|
||||
silent! normal zt
|
||||
silent! normal! zt
|
||||
return -1
|
||||
endif
|
||||
|
||||
if search('^\%(const\|var\|type\|\s\+\) ' . pkg . '\s\+=\s')
|
||||
silent! normal zt
|
||||
silent! normal! zt
|
||||
return -1
|
||||
endif
|
||||
|
||||
" nothing found, jump to top
|
||||
silent! normal gg
|
||||
silent! normal! gg
|
||||
endfunction
|
||||
|
||||
function! s:GodocView(newposition, position, content)
|
||||
|
@ -52,13 +52,25 @@ endif
|
||||
" this and have VimL experience, please look at the function for
|
||||
" improvements, patches are welcome :)
|
||||
function! go#fmt#Format(withGoimport)
|
||||
" save cursor position, folds and many other things
|
||||
let l:curw = {}
|
||||
try
|
||||
mkview!
|
||||
catch
|
||||
if g:go_fmt_experimental == 1
|
||||
" Using winsaveview to save/restore cursor state has the problem of
|
||||
" closing folds on save:
|
||||
" https://github.com/fatih/vim-go/issues/502
|
||||
" One fix is to use mkview instead. Unfortunately, this sometimes causes
|
||||
" other bad side effects:
|
||||
" https://github.com/fatih/vim-go/issues/728
|
||||
" and still closes all folds if foldlevel>0:
|
||||
" https://github.com/fatih/vim-go/issues/732
|
||||
let l:curw = {}
|
||||
try
|
||||
mkview!
|
||||
catch
|
||||
let l:curw=winsaveview()
|
||||
endtry
|
||||
else
|
||||
" Save cursor position and many other things.
|
||||
let l:curw=winsaveview()
|
||||
endtry
|
||||
endif
|
||||
|
||||
" Write current unsaved buffer to a temp file
|
||||
let l:tmpname = tempname()
|
||||
@ -101,6 +113,24 @@ function! go#fmt#Format(withGoimport)
|
||||
let command = command . g:go_fmt_options
|
||||
endif
|
||||
|
||||
if fmt_command == "goimports"
|
||||
if !exists('b:goimports_vendor_compatible')
|
||||
let out = system("goimports --help")
|
||||
if out !~ "-srcdir"
|
||||
echohl WarningMsg
|
||||
echomsg "vim-go: goimports does not support srcdir."
|
||||
echomsg " update with: :GoUpdateBinaries"
|
||||
echohl None
|
||||
else
|
||||
let b:goimports_vendor_compatible = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
if exists('b:goimports_vendor_compatible') && b:goimports_vendor_compatible
|
||||
let command = command . '-srcdir ' . fnameescape(expand("%:p:h"))
|
||||
endif
|
||||
endif
|
||||
|
||||
" execute our command...
|
||||
let out = system(command . " " . l:tmpname)
|
||||
|
||||
@ -163,10 +193,15 @@ function! go#fmt#Format(withGoimport)
|
||||
call delete(tmpundofile)
|
||||
endif
|
||||
|
||||
" restore our cursor/windows positions, folds, etc..
|
||||
if empty(l:curw)
|
||||
silent! loadview
|
||||
if g:go_fmt_experimental == 1
|
||||
" Restore our cursor/windows positions, folds, etc.
|
||||
if empty(l:curw)
|
||||
silent! loadview
|
||||
else
|
||||
call winrestview(l:curw)
|
||||
endif
|
||||
else
|
||||
" Restore our cursor/windows positions.
|
||||
call winrestview(l:curw)
|
||||
endif
|
||||
endfunction
|
||||
|
@ -165,7 +165,7 @@ function! go#import#SwitchImport(enabled, localname, path, bang)
|
||||
call append(appendline, appendstr)
|
||||
execute appendline + 1
|
||||
if indentstr
|
||||
execute 'normal >>'
|
||||
execute 'normal! >>'
|
||||
endif
|
||||
let linesdelta += 1
|
||||
endif
|
||||
|
@ -114,6 +114,10 @@ func! s:RunOracle(mode, selected, needs_package) range abort
|
||||
\ shellescape(fname), pos, tags, a:mode)
|
||||
endif
|
||||
|
||||
" strip trailing slashes for each path in scoped. bug:
|
||||
" https://github.com/golang/go/issues/14584
|
||||
let scopes = go#util#StripTrailingSlash(scopes)
|
||||
|
||||
" now append each scope to the end as Oracle's scope parameter. It can be
|
||||
" a packages or go files, dependent on the User's own choice. For more
|
||||
" info check Oracle's User Manual section about scopes:
|
||||
|
@ -48,6 +48,12 @@ function! go#util#StripPathSep(path)
|
||||
return a:path
|
||||
endfunction
|
||||
|
||||
" StripTrailingSlash strips the trailing slash from the given path list.
|
||||
" example: ['/foo/bar/'] -> ['/foo/bar']
|
||||
function! go#util#StripTrailingSlash(paths)
|
||||
return map(copy(a:paths), 'go#util#StripPathSep(v:val)')
|
||||
endfunction
|
||||
|
||||
" Shelljoin returns a shell-safe string representation of arglist. The
|
||||
" {special} argument of shellescape() may optionally be passed.
|
||||
function! go#util#Shelljoin(arglist, ...)
|
||||
|
@ -16,12 +16,12 @@ command! -nargs=? GoOracleTags call go#oracle#Tags(<f-args>)
|
||||
" tool
|
||||
command! -nargs=0 GoFiles echo go#tool#Files()
|
||||
command! -nargs=0 GoDeps echo go#tool#Deps()
|
||||
command! -nargs=* GoInfo call go#complete#Info()
|
||||
command! -nargs=* GoInfo call go#complete#Info(0)
|
||||
|
||||
" cmd
|
||||
command! -nargs=* -bang GoBuild call go#cmd#Build(<bang>0,<f-args>)
|
||||
command! -nargs=* -bang GoGenerate call go#cmd#Generate(<bang>0,<f-args>)
|
||||
command! -nargs=* -bang GoRun call go#cmd#Run(<bang>0,<f-args>)
|
||||
command! -nargs=* -bang -complete=file GoRun call go#cmd#Run(<bang>0,<f-args>)
|
||||
command! -nargs=* -bang GoInstall call go#cmd#Install(<bang>0, <f-args>)
|
||||
command! -nargs=* -bang GoTest call go#cmd#Test(<bang>0, 0, <f-args>)
|
||||
command! -nargs=* -bang GoTestFunc call go#cmd#TestFunc(<bang>0, <f-args>)
|
||||
|
@ -12,9 +12,9 @@ endif
|
||||
nnoremap <silent> <Plug>(go-run) :<C-u>call go#cmd#Run(!g:go_jump_to_error)<CR>
|
||||
|
||||
if has("nvim")
|
||||
nnoremap <silent> <Plug>(go-run-vertical) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'vsplit')<CR>
|
||||
nnoremap <silent> <Plug>(go-run-split) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'split')<CR>
|
||||
nnoremap <silent> <Plug>(go-run-tab) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'tabe')<CR>
|
||||
nnoremap <silent> <Plug>(go-run-vertical) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'vsplit', [])<CR>
|
||||
nnoremap <silent> <Plug>(go-run-split) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'split', [])<CR>
|
||||
nnoremap <silent> <Plug>(go-run-tab) :<C-u>call go#cmd#RunTerm(!g:go_jump_to_error, 'tabe', [])<CR>
|
||||
endif
|
||||
|
||||
nnoremap <silent> <Plug>(go-build) :<C-u>call go#cmd#Build(!g:go_jump_to_error)<CR>
|
||||
@ -27,7 +27,7 @@ nnoremap <silent> <Plug>(go-coverage) :<C-u>call go#cmd#Coverage(!g:go_jump_to_e
|
||||
|
||||
nnoremap <silent> <Plug>(go-files) :<C-u>call go#tool#Files()<CR>
|
||||
nnoremap <silent> <Plug>(go-deps) :<C-u>call go#tool#Deps()<CR>
|
||||
nnoremap <silent> <Plug>(go-info) :<C-u>call go#complete#Info()<CR>
|
||||
nnoremap <silent> <Plug>(go-info) :<C-u>call go#complete#Info(0)<CR>
|
||||
nnoremap <silent> <Plug>(go-import) :<C-u>call go#import#SwitchImport(1, '', expand('<cword>'), '')<CR>
|
||||
|
||||
nnoremap <silent> <Plug>(go-implements) :<C-u>call go#oracle#Implements(-1)<CR>
|
||||
|
@ -143,7 +143,7 @@ augroup vim-go
|
||||
|
||||
" GoInfo automatic update
|
||||
if get(g:, "go_auto_type_info", 0)
|
||||
autocmd CursorHold *.go nested call go#complete#Info()
|
||||
autocmd CursorHold *.go nested call go#complete#Info(1)
|
||||
endif
|
||||
|
||||
" Echo the identifier information when completion is done. Useful to see
|
||||
|
@ -179,30 +179,31 @@ syn region goBlock start="{" end="}" transparent fold
|
||||
syn region goParen start='(' end=')' transparent
|
||||
|
||||
" Integers
|
||||
syn match goDecimalInt "\<\d\+\([Ee]\d\+\)\?\>"
|
||||
syn match goHexadecimalInt "\<0x\x\+\>"
|
||||
syn match goOctalInt "\<0\o\+\>"
|
||||
syn match goOctalError "\<0\o*[89]\d*\>"
|
||||
syn match goDecimalInt "\<-\=\d\+\%([Ee][-+]\=\d\+\)\=\>"
|
||||
syn match goHexadecimalInt "\<-\=0[xX]\x\+\>"
|
||||
syn match goOctalInt "\<-\=0\o\+\>"
|
||||
syn match goOctalError "\<-\=0\o*[89]\d*\>"
|
||||
|
||||
hi def link goDecimalInt Integer
|
||||
hi def link goHexadecimalInt Integer
|
||||
hi def link goOctalInt Integer
|
||||
hi def link goOctalError Error
|
||||
hi def link Integer Number
|
||||
|
||||
" Floating point
|
||||
syn match goFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>"
|
||||
syn match goFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>"
|
||||
syn match goFloat "\<\d\+[Ee][-+]\d\+\>"
|
||||
syn match goFloat "\<-\=\d\+\.\d*\%([Ee][-+]\=\d\+\)\=\>"
|
||||
syn match goFloat "\<-\=\.\d\+\%([Ee][-+]\=\d\+\)\=\>"
|
||||
|
||||
hi def link goFloat Float
|
||||
|
||||
" Imaginary literals
|
||||
syn match goImaginary "\<\d\+i\>"
|
||||
syn match goImaginary "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>"
|
||||
syn match goImaginary "\<\.\d\+\([Ee][-+]\d\+\)\?i\>"
|
||||
syn match goImaginary "\<\d\+[Ee][-+]\d\+i\>"
|
||||
syn match goImaginary "\<-\=\d\+i\>"
|
||||
syn match goImaginary "\<-\=\d\+[Ee][-+]\=\d\+i\>"
|
||||
syn match goImaginaryFloat "\<-\=\d\+\.\d*\%([Ee][-+]\=\d\+\)\=i\>"
|
||||
syn match goImaginaryFloat "\<-\=\.\d\+\%([Ee][-+]\=\d\+\)\=i\>"
|
||||
|
||||
hi def link goImaginary Number
|
||||
hi def link goImaginaryFloat Float
|
||||
|
||||
" Spaces after "[]"
|
||||
if g:go_highlight_array_whitespace_error != 0
|
||||
|
Reference in New Issue
Block a user