mirror of
				https://github.com/amix/vimrc
				synced 2025-10-31 06:33:35 +08:00 
			
		
		
		
	Updated plugins
This commit is contained in:
		| @ -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, ...) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 amix
					amix