mirror of
				https://github.com/amix/vimrc
				synced 2025-10-31 14:43:35 +08:00 
			
		
		
		
	Updated plugins
This commit is contained in:
		| @ -191,12 +191,14 @@ function! go#cmd#Test(bang, compile, ...) | ||||
|     " don't run the test, only compile it. Useful to capture and fix errors or | ||||
|     " to create a test binary. | ||||
|     if a:compile | ||||
|         call add(args, "-c") | ||||
|         let compile_file = "vim-go-test-compile" | ||||
|         call extend(args, ["-c", "-o", compile_file]) | ||||
|     endif | ||||
|  | ||||
|     if a:0 | ||||
|         " expand all wildcards(i.e: '%' to the current file name) | ||||
|         let goargs = map(copy(a:000), "expand(v:val)") | ||||
|         let goargs = go#util#Shelllist(goargs, 1) | ||||
|  | ||||
|         call extend(args, goargs, 1) | ||||
|     else | ||||
| @ -217,6 +219,11 @@ function! go#cmd#Test(bang, compile, ...) | ||||
|         else | ||||
|             let id = go#jobcontrol#Spawn(a:bang, "test", args) | ||||
|         endif | ||||
|  | ||||
|         if a:compile | ||||
|             call go#jobcontrol#AddHandler(function('s:test_compile_handler')) | ||||
|             let s:test_compile_handlers[id] = compile_file | ||||
|         endif | ||||
|         return id | ||||
|     endif | ||||
|  | ||||
| @ -229,6 +236,10 @@ function! go#cmd#Test(bang, compile, ...) | ||||
|  | ||||
|     let l:listtype = "quickfix" | ||||
|  | ||||
|     if a:compile | ||||
|         call delete(compile_file) | ||||
|     endif | ||||
|  | ||||
|     if go#util#ShellError() != 0 | ||||
|         let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' | ||||
|         let dir = getcwd() | ||||
| @ -332,4 +343,19 @@ function! go#cmd#Generate(bang, ...) | ||||
|     let $GOPATH = old_gopath | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| " ----------------------- | ||||
| " | Neovim job handlers | | ||||
| " ----------------------- | ||||
| let s:test_compile_handlers = {} | ||||
|  | ||||
| function! s:test_compile_handler(job, exit_status, data) | ||||
|     if !has_key(s:test_compile_handlers, a:job.id) | ||||
|         return | ||||
|     endif | ||||
|     let l:compile_file = s:test_compile_handlers[a:job.id] | ||||
|     call delete(l:compile_file) | ||||
|     unlet s:test_compile_handlers[a:job.id] | ||||
| endfunction | ||||
|  | ||||
| " vim:ts=4:sw=4:et | ||||
|  | ||||
| @ -1,9 +1,4 @@ | ||||
| if !exists("g:go_gocode_bin") | ||||
|     let g:go_gocode_bin = "gocode" | ||||
| endif | ||||
|  | ||||
|  | ||||
| fu! s:gocodeCurrentBuffer() | ||||
| function! s:gocodeCurrentBuffer() | ||||
|     let buf = getline(1, '$') | ||||
|     if &encoding != 'utf-8' | ||||
|         let buf = map(buf, 'iconv(v:val, &encoding, "utf-8")') | ||||
| @ -17,9 +12,9 @@ fu! s:gocodeCurrentBuffer() | ||||
|     call writefile(buf, file) | ||||
|  | ||||
|     return file | ||||
| endf | ||||
| endfunction | ||||
|  | ||||
| fu! s:gocodeCommand(cmd, preargs, args) | ||||
| function! s:gocodeCommand(cmd, preargs, args) | ||||
|     for i in range(0, len(a:args) - 1) | ||||
|         let a:args[i] = go#util#Shellescape(a:args[i]) | ||||
|     endfor | ||||
| @ -27,7 +22,7 @@ fu! s:gocodeCommand(cmd, preargs, args) | ||||
|         let a:preargs[i] = go#util#Shellescape(a:preargs[i]) | ||||
|     endfor | ||||
|  | ||||
|     let bin_path = go#path#CheckBinPath(g:go_gocode_bin) | ||||
|     let bin_path = go#path#CheckBinPath("gocode") | ||||
|     if empty(bin_path) | ||||
|         return | ||||
|     endif | ||||
| @ -49,20 +44,43 @@ fu! s:gocodeCommand(cmd, preargs, args) | ||||
|         endif | ||||
|         return result | ||||
|     endif | ||||
| endf | ||||
| endfunction | ||||
|  | ||||
| fu! s:gocodeCurrentBufferOpt(filename) | ||||
| function! s:gocodeCurrentBufferOpt(filename) | ||||
|     return '-in=' . a:filename | ||||
| endf | ||||
| endfunction | ||||
|  | ||||
| let s:optionsEnabled = 0 | ||||
| function! s:gocodeEnableOptions() | ||||
|     if s:optionsEnabled  | ||||
|         return | ||||
|     endif | ||||
|  | ||||
|     let bin_path = go#path#CheckBinPath("gocode") | ||||
|     if empty(bin_path) | ||||
|         return | ||||
|     endif | ||||
|  | ||||
|     let s:optionsEnabled = 1 | ||||
|  | ||||
|     call go#util#System(printf('%s set propose-builtins %s', go#util#Shellescape(bin_path), s:toBool(get(g:, 'go_gocode_propose_builtins', 1)))) | ||||
|     call go#util#System(printf('%s set autobuild %s', go#util#Shellescape(bin_path), s:toBool(get(g:, 'go_gocode_autobuild', 1)))) | ||||
| endfunction | ||||
|  | ||||
| function! s:toBool(val) | ||||
|     if a:val | return 'true ' | else | return 'false' | endif | ||||
| endfunction | ||||
|  | ||||
| function! s:gocodeAutocomplete() | ||||
|     call s:gocodeEnableOptions() | ||||
|  | ||||
| fu! s:gocodeAutocomplete() | ||||
|     let filename = s:gocodeCurrentBuffer() | ||||
|     let result = s:gocodeCommand('autocomplete', | ||||
|                 \ [s:gocodeCurrentBufferOpt(filename), '-f=vim'], | ||||
|                 \ [expand('%:p'), go#util#OffsetCursor()]) | ||||
|     call delete(filename) | ||||
|     return result | ||||
| endf | ||||
| endfunction | ||||
|  | ||||
| function! go#complete#GetInfo() | ||||
|     let offset = go#util#OffsetCursor()+1 | ||||
| @ -120,7 +138,7 @@ function! s:trim_bracket(val) | ||||
|     return a:val | ||||
| endfunction | ||||
|  | ||||
| fu! go#complete#Complete(findstart, base) | ||||
| function! go#complete#Complete(findstart, base) | ||||
|     "findstart = 1 when we need to get the text length | ||||
|     if a:findstart == 1 | ||||
|         execute "silent let g:gocomplete_completions = " . s:gocodeAutocomplete() | ||||
|  | ||||
| @ -28,6 +28,19 @@ function! go#coverage#Buffer(bang, ...) | ||||
|         return -1 | ||||
|     endif | ||||
|  | ||||
|     " check if there is any test file, if not we just return | ||||
|     let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' | ||||
|     let dir = getcwd() | ||||
|     try | ||||
|         execute cd . fnameescape(expand("%:p:h")) | ||||
|         if empty(glob("*_test.go")) | ||||
|             call go#util#EchoError("no tests files available") | ||||
|             return | ||||
|         endif | ||||
|     finally | ||||
|         execute cd . fnameescape(dir) | ||||
|     endtry | ||||
|  | ||||
|     let s:toggle = 1 | ||||
|     let l:tmpname = tempname() | ||||
|     let args = [a:bang, 0, "-coverprofile", l:tmpname] | ||||
| @ -221,9 +234,9 @@ function! go#coverage#overlay(file) | ||||
|     endfor | ||||
|  | ||||
|     syntax manual | ||||
|     highlight normaltext term=bold ctermfg=59 guifg=#75715E | ||||
|     highlight covered term=bold ctermfg=118 guifg=#A6E22E | ||||
|     highlight uncover term=bold ctermfg=197 guifg=#F92672 | ||||
|     highlight normaltext term=bold ctermfg=darkgrey guifg=#75715E | ||||
|     highlight covered term=bold ctermfg=green guifg=#A6E22E | ||||
|     highlight uncover term=bold ctermfg=red guifg=#F92672 | ||||
|  | ||||
|     " clear the matches if we leave the buffer | ||||
|     autocmd BufWinLeave <buffer> call go#coverage#Clear() | ||||
|  | ||||
| @ -2,201 +2,227 @@ let s:go_stack = [] | ||||
| let s:go_stack_level = 0 | ||||
|  | ||||
| function! go#def#Jump(mode) | ||||
| 	let bin_path = go#path#CheckBinPath("guru") | ||||
| 	if empty(bin_path) | ||||
| 		return | ||||
| 	endif | ||||
|     let old_gopath = $GOPATH | ||||
|     let $GOPATH = go#path#Detect() | ||||
|  | ||||
| 	let old_gopath = $GOPATH | ||||
| 	let $GOPATH = go#path#Detect() | ||||
|     let fname = fnamemodify(expand("%"), ':p:gs?\\?/?') | ||||
|  | ||||
| 	let flags = "" | ||||
| 	if exists('g:go_guru_tags') | ||||
| 		let tags = get(g:, 'go_guru_tags') | ||||
| 		let flags = printf(" -tags %s", tags) | ||||
| 	endif | ||||
|     " so guru right now is slow for some people. previously we were using | ||||
|     " godef which also has it's own quirks. But this issue come up so many | ||||
|     " times I've decided to support both. By default we still use guru as it | ||||
|     " covers all edge cases, but now anyone can switch to godef if they wish | ||||
|     let bin_name = get(g:, 'go_def_mode', 'guru') | ||||
|     if bin_name == 'godef' | ||||
|         let bin_path = go#path#CheckBinPath("godef") | ||||
|         if empty(bin_path) | ||||
|             let $GOPATH = old_gopath | ||||
|             return | ||||
|         endif | ||||
|         let command = printf("%s -f=%s -o=%s -t", bin_path, fname, go#util#OffsetCursor()) | ||||
|         let out = go#util#System(command) | ||||
|  | ||||
| 	let fname = fnamemodify(expand("%"), ':p:gs?\\?/?') | ||||
| 	let command = printf("%s %s definition %s:#%s", bin_path, flags, shellescape(fname), go#util#OffsetCursor()) | ||||
|         " append the type information to the same line so our | ||||
|         " jump_to_declaration() function can parse it. This makes it | ||||
|         " compatible with guru definition as well too | ||||
|         let out = join(split(out, '\n'), ':') | ||||
|     elseif bin_name == 'guru' | ||||
|         let bin_path = go#path#CheckBinPath("guru") | ||||
|         if empty(bin_path) | ||||
|             let $GOPATH = old_gopath | ||||
|             return | ||||
|         endif | ||||
|  | ||||
| 	let out = go#util#System(command) | ||||
| 	if go#util#ShellError() != 0 | ||||
| 		call go#util#EchoError(out) | ||||
| 		return | ||||
| 	endif | ||||
|         let flags = "" | ||||
|         if exists('g:go_guru_tags') | ||||
|             let tags = get(g:, 'go_guru_tags') | ||||
|             let flags = printf(" -tags %s", tags) | ||||
|         endif | ||||
|  | ||||
| 	call s:jump_to_declaration(out, a:mode) | ||||
| 	let $GOPATH = old_gopath | ||||
|         let fname = shellescape(fname.':#'.go#util#OffsetCursor()) | ||||
|         let command = printf("%s %s definition %s", bin_path, flags, fname) | ||||
|         let out = go#util#System(command) | ||||
|     else | ||||
|         call go#util#EchoError('go_def_mode value: '. bin_name .' is not valid. Valid values are: [godef, guru]') | ||||
|         return | ||||
|     endif | ||||
|  | ||||
|     if go#util#ShellError() != 0 | ||||
|         call go#util#EchoError(out) | ||||
|         return | ||||
|     endif | ||||
|  | ||||
|     call s:jump_to_declaration(out, a:mode) | ||||
|     let $GOPATH = old_gopath | ||||
| endfunction | ||||
|  | ||||
| function! s:jump_to_declaration(out, mode) | ||||
| 	" strip line ending | ||||
| 	let out = split(a:out, go#util#LineEnding())[0] | ||||
| 	if go#util#IsWin() | ||||
| 		let parts = split(out, '\(^[a-zA-Z]\)\@<!:') | ||||
| 	else | ||||
| 		let parts = split(out, ':') | ||||
| 	endif | ||||
|     " strip line ending | ||||
|     let out = split(a:out, go#util#LineEnding())[0] | ||||
|     if go#util#IsWin() | ||||
|         let parts = split(out, '\(^[a-zA-Z]\)\@<!:') | ||||
|     else | ||||
|         let parts = split(out, ':') | ||||
|     endif | ||||
|  | ||||
| 	let filename = parts[0] | ||||
| 	let line = parts[1] | ||||
| 	let col = parts[2] | ||||
| 	let ident = parts[3] | ||||
|     let filename = parts[0] | ||||
|     let line = parts[1] | ||||
|     let col = parts[2] | ||||
|     let ident = parts[3] | ||||
|  | ||||
| 	" Remove anything newer than the current position, just like basic | ||||
| 	" vim tag support | ||||
| 	if s:go_stack_level == 0 | ||||
| 		let s:go_stack = [] | ||||
| 	else | ||||
| 		let s:go_stack = s:go_stack[0:s:go_stack_level-1] | ||||
| 	endif | ||||
|     " Remove anything newer than the current position, just like basic | ||||
|     " vim tag support | ||||
|     if s:go_stack_level == 0 | ||||
|         let s:go_stack = [] | ||||
|     else | ||||
|         let s:go_stack = s:go_stack[0:s:go_stack_level-1] | ||||
|     endif | ||||
|  | ||||
| 	" increment the stack counter | ||||
| 	let s:go_stack_level += 1 | ||||
|     " increment the stack counter | ||||
|     let s:go_stack_level += 1 | ||||
|  | ||||
| 	" push it on to the jumpstack | ||||
| 	let stack_entry = {'line': line("."), 'col': col("."), 'file': expand('%:p'), 'ident': ident} | ||||
| 	call add(s:go_stack, stack_entry) | ||||
|     " push it on to the jumpstack | ||||
|     let stack_entry = {'line': line("."), 'col': col("."), 'file': expand('%:p'), 'ident': ident} | ||||
|     call add(s:go_stack, stack_entry) | ||||
|  | ||||
| 	" needed for restoring back user setting this is because there are two | ||||
| 	" modes of switchbuf which we need based on the split mode | ||||
| 	let old_switchbuf = &switchbuf | ||||
|     " needed for restoring back user setting this is because there are two | ||||
|     " modes of switchbuf which we need based on the split mode | ||||
|     let old_switchbuf = &switchbuf | ||||
|  | ||||
| 	" jump to existing buffer if, 1. we have enabled it, 2. the buffer is loaded | ||||
| 	" and 3. there is buffer window number we switch to | ||||
| 	if get(g:, 'go_def_reuse_buffer', 0) && bufloaded(filename) != 0 && bufwinnr(filename) != -1 | ||||
| 		" jumpt to existing buffer if it exists | ||||
| 		execute bufwinnr(filename) . 'wincmd w' | ||||
| 	elseif a:mode == "tab" | ||||
| 		let &switchbuf = "usetab" | ||||
| 		if bufloaded(filename) == 0 | ||||
| 			tab split | ||||
| 		endif | ||||
| 	elseif a:mode == "split" | ||||
| 		split | ||||
| 	elseif a:mode == "vsplit" | ||||
| 		vsplit | ||||
| 	endif | ||||
|     " jump to existing buffer if, 1. we have enabled it, 2. the buffer is loaded | ||||
|     " and 3. there is buffer window number we switch to | ||||
|     if get(g:, 'go_def_reuse_buffer', 0) && bufloaded(filename) != 0 && bufwinnr(filename) != -1 | ||||
|         " jumpt to existing buffer if it exists | ||||
|         execute bufwinnr(filename) . 'wincmd w' | ||||
|     elseif a:mode == "tab" | ||||
|         let &switchbuf = "usetab" | ||||
|         if bufloaded(filename) == 0 | ||||
|             tab split | ||||
|         endif | ||||
|     elseif a:mode == "split" | ||||
|         split | ||||
|     elseif a:mode == "vsplit" | ||||
|         vsplit | ||||
|     endif | ||||
|  | ||||
| 	" open the file and jump to line and column | ||||
| 	exec 'edit '.filename | ||||
| 	call cursor(line, col) | ||||
|     " open the file and jump to line and column | ||||
|     exec 'edit '.filename | ||||
|     call cursor(line, col) | ||||
|  | ||||
| 	" also align the line to middle of the view | ||||
| 	normal! zz | ||||
|     " also align the line to middle of the view | ||||
|     normal! zz | ||||
|  | ||||
| 	let &switchbuf = old_switchbuf | ||||
|     let &switchbuf = old_switchbuf | ||||
| endfunction | ||||
|  | ||||
| function! go#def#SelectStackEntry() | ||||
| 	let target_window = go#ui#GetReturnWindow() | ||||
| 	if empty(target_window) | ||||
| 		let target_window = winnr() | ||||
| 	endif | ||||
|     let target_window = go#ui#GetReturnWindow() | ||||
|     if empty(target_window) | ||||
|         let target_window = winnr() | ||||
|     endif | ||||
|  | ||||
| 	let highlighted_stack_entry = matchstr(getline("."), '^..\zs\(\d\+\)') | ||||
| 	if !empty(highlighted_stack_entry) | ||||
| 		execute target_window . "wincmd w" | ||||
| 		call go#def#Stack(str2nr(highlighted_stack_entry)) | ||||
| 	endif | ||||
|     let highlighted_stack_entry = matchstr(getline("."), '^..\zs\(\d\+\)') | ||||
|     if !empty(highlighted_stack_entry) | ||||
|         execute target_window . "wincmd w" | ||||
|         call go#def#Stack(str2nr(highlighted_stack_entry)) | ||||
|     endif | ||||
|  | ||||
| 	call go#ui#CloseWindow() | ||||
|     call go#ui#CloseWindow() | ||||
| endfunction | ||||
|  | ||||
| function! go#def#StackUI() | ||||
| 	if len(s:go_stack) == 0 | ||||
| 		call go#util#EchoError("godef stack empty") | ||||
| 		return | ||||
| 	endif | ||||
|     if len(s:go_stack) == 0 | ||||
|         call go#util#EchoError("godef stack empty") | ||||
|         return | ||||
|     endif | ||||
|  | ||||
| 	let stackOut = ['" <Up>,<Down>:navigate <Enter>:jump <Esc>,q:exit'] | ||||
|     let stackOut = ['" <Up>,<Down>:navigate <Enter>:jump <Esc>,q:exit'] | ||||
|  | ||||
| 	let i = 0 | ||||
| 	while i < len(s:go_stack) | ||||
| 		let entry = s:go_stack[i] | ||||
| 		let prefix = "" | ||||
|     let i = 0 | ||||
|     while i < len(s:go_stack) | ||||
|         let entry = s:go_stack[i] | ||||
|         let prefix = "" | ||||
|  | ||||
| 		if i == s:go_stack_level | ||||
| 			let prefix = ">" | ||||
| 		else | ||||
| 			let prefix = " " | ||||
| 		endif | ||||
|         if i == s:go_stack_level | ||||
|             let prefix = ">" | ||||
|         else | ||||
|             let prefix = " " | ||||
|         endif | ||||
|  | ||||
| 		call add(stackOut, printf("%s %d %s|%d col %d|%s",  | ||||
| 					\ prefix, i+1, entry["file"], entry["line"], entry["col"], entry["ident"])) | ||||
| 		let i += 1 | ||||
| 	endwhile | ||||
|         call add(stackOut, printf("%s %d %s|%d col %d|%s",  | ||||
|                     \ prefix, i+1, entry["file"], entry["line"], entry["col"], entry["ident"])) | ||||
|         let i += 1 | ||||
|     endwhile | ||||
|  | ||||
| 	if s:go_stack_level == i | ||||
| 		call add(stackOut, "> ") | ||||
| 	endif | ||||
|     if s:go_stack_level == i | ||||
|         call add(stackOut, "> ") | ||||
|     endif | ||||
|  | ||||
| 	call go#ui#OpenWindow("GoDef Stack", stackOut, "godefstack") | ||||
|     call go#ui#OpenWindow("GoDef Stack", stackOut, "godefstack") | ||||
|  | ||||
| 	noremap <buffer> <silent> <CR>  :<C-U>call go#def#SelectStackEntry()<CR> | ||||
| 	noremap <buffer> <silent> <Esc> :<C-U>call go#ui#CloseWindow()<CR> | ||||
| 	noremap <buffer> <silent> q     :<C-U>call go#ui#CloseWindow()<CR> | ||||
|     noremap <buffer> <silent> <CR>  :<C-U>call go#def#SelectStackEntry()<CR> | ||||
|     noremap <buffer> <silent> <Esc> :<C-U>call go#ui#CloseWindow()<CR> | ||||
|     noremap <buffer> <silent> q     :<C-U>call go#ui#CloseWindow()<CR> | ||||
| endfunction | ||||
|  | ||||
| function! go#def#StackClear(...) | ||||
| 	let s:go_stack = [] | ||||
| 	let s:go_stack_level = 0 | ||||
|     let s:go_stack = [] | ||||
|     let s:go_stack_level = 0 | ||||
| endfunction | ||||
|  | ||||
| function! go#def#StackPop(...) | ||||
| 	if len(s:go_stack) == 0 | ||||
| 		call go#util#EchoError("godef stack empty") | ||||
| 		return | ||||
| 	endif | ||||
|     if len(s:go_stack) == 0 | ||||
|         call go#util#EchoError("godef stack empty") | ||||
|         return | ||||
|     endif | ||||
|  | ||||
| 	if s:go_stack_level == 0 | ||||
| 		call go#util#EchoError("at bottom of the godef stack") | ||||
| 		return | ||||
| 	endif | ||||
|     if s:go_stack_level == 0 | ||||
|         call go#util#EchoError("at bottom of the godef stack") | ||||
|         return | ||||
|     endif | ||||
|  | ||||
| 	if !len(a:000) | ||||
| 		let numPop = 1 | ||||
| 	else | ||||
| 		let numPop = a:1 | ||||
| 	endif | ||||
|     if !len(a:000) | ||||
|         let numPop = 1 | ||||
|     else | ||||
|         let numPop = a:1 | ||||
|     endif | ||||
|  | ||||
| 	let newLevel = str2nr(s:go_stack_level) - str2nr(numPop) | ||||
| 	call go#def#Stack(newLevel + 1) | ||||
|     let newLevel = str2nr(s:go_stack_level) - str2nr(numPop) | ||||
|     call go#def#Stack(newLevel + 1) | ||||
| endfunction | ||||
|  | ||||
| function! go#def#Stack(...) | ||||
| 	if len(s:go_stack) == 0 | ||||
| 		call go#util#EchoError("godef stack empty") | ||||
| 		return | ||||
| 	endif | ||||
|     if len(s:go_stack) == 0 | ||||
|         call go#util#EchoError("godef stack empty") | ||||
|         return | ||||
|     endif | ||||
|  | ||||
| 	if !len(a:000) | ||||
| 		" Display interactive stack | ||||
| 		call go#def#StackUI() | ||||
| 		return | ||||
| 	else | ||||
| 		let jumpTarget = a:1 | ||||
| 	endif | ||||
|     if !len(a:000) | ||||
|         " Display interactive stack | ||||
|         call go#def#StackUI() | ||||
|         return | ||||
|     else | ||||
|         let jumpTarget = a:1 | ||||
|     endif | ||||
|  | ||||
| 	if jumpTarget !~ '^\d\+$' | ||||
| 		if jumpTarget !~ '^\s*$' | ||||
| 			call go#util#EchoError("location must be a number") | ||||
| 		endif | ||||
| 		return | ||||
| 	endif | ||||
|     if jumpTarget !~ '^\d\+$' | ||||
|         if jumpTarget !~ '^\s*$' | ||||
|             call go#util#EchoError("location must be a number") | ||||
|         endif | ||||
|         return | ||||
|     endif | ||||
|  | ||||
| 	let jumpTarget = str2nr(jumpTarget) - 1 | ||||
|     let jumpTarget = str2nr(jumpTarget) - 1 | ||||
|  | ||||
| 	if jumpTarget >= 0 && jumpTarget < len(s:go_stack) | ||||
| 		let s:go_stack_level = jumpTarget | ||||
| 		let target = s:go_stack[s:go_stack_level] | ||||
|     if jumpTarget >= 0 && jumpTarget < len(s:go_stack) | ||||
|         let s:go_stack_level = jumpTarget | ||||
|         let target = s:go_stack[s:go_stack_level] | ||||
|  | ||||
| 		" jump | ||||
| 		exec 'edit '.target["file"] | ||||
| 		call cursor(target["line"], target["col"]) | ||||
| 		normal! zz | ||||
| 	else | ||||
| 		call go#util#EchoError("invalid location. Try :GoDefStack to see the list of valid entries") | ||||
| 	endif | ||||
|         " jump | ||||
|         exec 'edit '.target["file"] | ||||
|         call cursor(target["line"], target["col"]) | ||||
|         normal! zz | ||||
|     else | ||||
|         call go#util#EchoError("invalid location. Try :GoDefStack to see the list of valid entries") | ||||
|     endif | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| @ -77,17 +77,28 @@ function! go#doc#OpenBrowser(...) | ||||
| endfunction | ||||
|  | ||||
| function! go#doc#Open(newmode, mode, ...) | ||||
|     " check if we have 'gogetdoc' and use it automatically | ||||
|     let bin_path = go#path#CheckBinPath('gogetdoc') | ||||
|     if empty(bin_path) | ||||
|         return | ||||
|     if len(a:000) | ||||
|         " check if we have 'godoc' and use it automatically | ||||
|         let bin_path = go#path#CheckBinPath('godoc') | ||||
|         if empty(bin_path) | ||||
|             return | ||||
|         endif | ||||
|  | ||||
|         let command = printf("%s %s", bin_path, join(a:000, ' ')) | ||||
|     else | ||||
|         " check if we have 'gogetdoc' and use it automatically | ||||
|         let bin_path = go#path#CheckBinPath('gogetdoc') | ||||
|         if empty(bin_path) | ||||
|             return | ||||
|         endif | ||||
|  | ||||
|         let offset = go#util#OffsetCursor() | ||||
|         let fname = expand("%:p:gs!\\!/!") | ||||
|         let pos = shellescape(fname.':#'.offset) | ||||
|  | ||||
|         let command = printf("%s -pos %s", bin_path, pos) | ||||
|     endif | ||||
|  | ||||
|     let offset = go#util#OffsetCursor() | ||||
|     let fname = expand("%:p") | ||||
|  | ||||
|     let command = printf("%s -pos %s:#%s", bin_path, fname, offset) | ||||
|  | ||||
|     let out = go#util#System(command) | ||||
|     if go#util#ShellError() != 0 | ||||
|         call go#util#EchoError(out) | ||||
| @ -134,6 +145,7 @@ function! s:GodocView(newposition, position, content) | ||||
|     call append(0, split(a:content, "\n")) | ||||
|     sil $delete _ | ||||
|     setlocal nomodifiable | ||||
|     sil normal! gg | ||||
|  | ||||
|     " close easily with <esc> or enter | ||||
|     noremap <buffer> <silent> <CR> :<C-U>close<CR> | ||||
|  | ||||
| @ -87,7 +87,7 @@ function! go#fmt#Format(withGoimport) | ||||
|  | ||||
|     " get the command first so we can test it | ||||
|     let fmt_command = g:go_fmt_command | ||||
|     if a:withGoimport  == 1  | ||||
|     if a:withGoimport  == 1 | ||||
|         let fmt_command  = g:go_goimports_bin | ||||
|     endif | ||||
|  | ||||
| @ -109,18 +109,15 @@ function! go#fmt#Format(withGoimport) | ||||
|  | ||||
|     " populate the final command with user based fmt options | ||||
|     let command = fmt_command . ' -w ' | ||||
|     if a:withGoimport  != 1  | ||||
|     if a:withGoimport  != 1 | ||||
|         let command  = command . g:go_fmt_options | ||||
|     endif | ||||
|  | ||||
|     if fmt_command == "goimports" | ||||
|         if !exists('b:goimports_vendor_compatible') | ||||
|             let out = go#util#System("goimports --help") | ||||
|             let out = go#util#System(bin_path . " --help") | ||||
|             if out !~ "-srcdir" | ||||
|                 echohl WarningMsg | ||||
|                 echomsg "vim-go: goimports does not support srcdir." | ||||
|                 echomsg "  update with: :GoUpdateBinaries" | ||||
|                 echohl None | ||||
|                 call go#util#EchoWarning("vim-go: goimports does not support srcdir. update with: :GoUpdateBinaries") | ||||
|             else | ||||
|                let b:goimports_vendor_compatible = 1 | ||||
|             endif | ||||
|  | ||||
| @ -74,7 +74,8 @@ func! s:RunGuru(mode, format, selected, needs_scope) range abort | ||||
|     endif | ||||
|  | ||||
|     " this is our final command | ||||
|     let command .= printf(' %s %s:%s', a:mode, shellescape(filename), pos) | ||||
|     let filename .= ':'.pos | ||||
|     let command .= printf(' %s %s', a:mode, shellescape(filename)) | ||||
|  | ||||
|     let old_gopath = $GOPATH | ||||
|     let $GOPATH = go#path#Detect() | ||||
|  | ||||
| @ -24,7 +24,7 @@ endif | ||||
|  | ||||
| function! go#lint#Gometa(autosave, ...) abort | ||||
|     if a:0 == 0 | ||||
|         let goargs = expand('%:p:h') | ||||
|         let goargs = shellescape(expand('%:p:h')) | ||||
|     else | ||||
|         let goargs = go#util#Shelljoin(a:000) | ||||
|     endif | ||||
|  | ||||
| @ -46,7 +46,7 @@ function! go#package#Paths() | ||||
|         let dirs += [s:goroot] | ||||
|     endif | ||||
|  | ||||
|     let workspaces = split($GOPATH, go#util#PathListSep()) | ||||
|     let workspaces = split(go#path#Detect(), go#util#PathListSep()) | ||||
|     if workspaces != [] | ||||
|         let dirs += workspaces | ||||
|     endif | ||||
|  | ||||
| @ -151,6 +151,9 @@ function! go#path#CheckBinPath(binpath) | ||||
|  | ||||
|     " if it's in PATH just return it | ||||
|     if executable(binpath) | ||||
|         if v:version == 704 && has('patch235') | ||||
|             let binpath = exepath(binpath) | ||||
|         endif | ||||
|         let $PATH = old_path | ||||
|         return binpath | ||||
|     endif | ||||
|  | ||||
| @ -36,6 +36,15 @@ function! go#rename#Rename(bang, ...) | ||||
|  | ||||
|     let out = go#tool#ExecuteInDir(cmd) | ||||
|  | ||||
|     " reload all files to reflect the new changes. We explicitly call | ||||
|     " checktime to trigger a reload of all files. See | ||||
|     " http://www.mail-archive.com/vim@vim.org/msg05900.html for more info | ||||
|     " about the autoread bug | ||||
|     let current_autoread = &autoread | ||||
|     set autoread | ||||
|     silent! checktime | ||||
|     let &autoread = current_autoread | ||||
|  | ||||
|     " strip out newline on the end that gorename puts. If we don't remove, it | ||||
|     " will trigger the 'Hit ENTER to continue' prompt | ||||
|     let clean = split(out, '\n') | ||||
|  | ||||
| @ -16,7 +16,7 @@ endif | ||||
| function! go#textobj#Function(mode) | ||||
|   let offset = go#util#OffsetCursor() | ||||
|  | ||||
|   let fname = expand("%:p") | ||||
|   let fname = shellescape(expand("%:p")) | ||||
|   if &modified | ||||
|     " Write current unsaved buffer to a temp file and use the modified content | ||||
|     let l:tmpname = tempname() | ||||
| @ -103,7 +103,7 @@ function! go#textobj#FunctionJump(mode, direction) | ||||
|  | ||||
|   let offset = go#util#OffsetCursor() | ||||
|  | ||||
|   let fname = expand("%:p") | ||||
|   let fname = shellescape(expand("%:p")) | ||||
|   if &modified | ||||
|     " Write current unsaved buffer to a temp file and use the modified content | ||||
|     let l:tmpname = tempname() | ||||
|  | ||||
| @ -1,19 +1,21 @@ | ||||
| function! go#tool#Files() | ||||
|     if go#util#IsWin() | ||||
|         let command = 'go list -f "{{range $f := .GoFiles}}{{$.Dir}}\{{$f}}{{printf \"\n\"}}{{end}}{{range $f := .CgoFiles}}{{$.Dir}}\{{$f}}{{printf \"\n\"}}{{end}}"' | ||||
|         let format = '{{range $f := .GoFiles}}{{$.Dir}}\{{$f}}{{printf \"\n\"}}{{end}}{{range $f := .CgoFiles}}{{$.Dir}}\{{$f}}{{printf \"\n\"}}{{end}}' | ||||
|     else | ||||
|         let command = "go list -f '{{range $f := .GoFiles}}{{$.Dir}}/{{$f}}{{printf \"\\n\"}}{{end}}{{range $f := .CgoFiles}}{{$.Dir}}/{{$f}}{{printf \"\\n\"}}{{end}}'" | ||||
|         let format = "{{range $f := .GoFiles}}{{$.Dir}}/{{$f}}{{printf \"\\n\"}}{{end}}{{range $f := .CgoFiles}}{{$.Dir}}/{{$f}}{{printf \"\\n\"}}{{end}}" | ||||
|     endif | ||||
|     let command = 'go list -f '.shellescape(format) | ||||
|     let out = go#tool#ExecuteInDir(command) | ||||
|     return split(out, '\n') | ||||
| endfunction | ||||
|  | ||||
| function! go#tool#Deps() | ||||
|     if go#util#IsWin() | ||||
|         let command = 'go list -f "{{range $f := .Deps}}{{$f}}{{printf \"\n\"}}{{end}}"' | ||||
|         let format = '{{range $f := .Deps}}{{$f}}{{printf \"\n\"}}{{end}}' | ||||
|     else | ||||
|         let command = "go list -f $'{{range $f := .Deps}}{{$f}}\n{{end}}'" | ||||
|         let format = "{{range $f := .Deps}}{{$f}}\n{{end}}" | ||||
|     endif | ||||
|     let command = 'go list -f '.shellescape(format) | ||||
|     let out = go#tool#ExecuteInDir(command) | ||||
|     return split(out, '\n') | ||||
| endfunction | ||||
| @ -21,10 +23,11 @@ endfunction | ||||
| function! go#tool#Imports() | ||||
|     let imports = {} | ||||
|     if go#util#IsWin() | ||||
|         let command = 'go list -f "{{range $f := .Imports}}{{$f}}{{printf \"\n\"}}{{end}}"' | ||||
|         let format = '{{range $f := .Imports}}{{$f}}{{printf \"\n\"}}{{end}}' | ||||
|     else | ||||
|         let command = "go list -f $'{{range $f := .Imports}}{{$f}}\n{{end}}'" | ||||
|         let format = "{{range $f := .Imports}}{{$f}}{{printf \"\\n\"}}{{end}}" | ||||
|     endif | ||||
|     let command = 'go list -f '.shellescape(format) | ||||
|     let out = go#tool#ExecuteInDir(command) | ||||
|     if go#util#ShellError() != 0 | ||||
|         echo out | ||||
| @ -32,7 +35,7 @@ function! go#tool#Imports() | ||||
|     endif | ||||
|  | ||||
|     for package_path in split(out, '\n') | ||||
|         let cmd = "go list -f {{.Name}} " . package_path | ||||
|         let cmd = "go list -f '{{.Name}}' " . shellescape(package_path) | ||||
|         let package_name = substitute(go#tool#ExecuteInDir(cmd), '\n$', '', '') | ||||
|         let imports[package_name] = package_path | ||||
|     endfor | ||||
| @ -168,10 +171,10 @@ function! go#tool#OpenBrowser(url) | ||||
|         return | ||||
|     endif | ||||
|     if cmd =~ '^!' | ||||
|         let cmd = substitute(cmd, '%URL%', '\=shellescape(a:url)', 'g') | ||||
|         let cmd = substitute(cmd, '%URL%', '\=escape(shellescape(a:url),"#")', 'g') | ||||
|         silent! exec cmd | ||||
|     elseif cmd =~ '^:[A-Z]' | ||||
|         let cmd = substitute(cmd, '%URL%', '\=a:url', 'g') | ||||
|         let cmd = substitute(cmd, '%URL%', '\=escape(a:url,"#")', 'g') | ||||
|         exec cmd | ||||
|     else | ||||
|         let cmd = substitute(cmd, '%URL%', '\=shellescape(a:url)', 'g') | ||||
|  | ||||
| @ -87,7 +87,7 @@ function! go#ui#OpenDefinition(filter) | ||||
|  | ||||
|     " don't touch our first line or any blank line | ||||
|     if curline =~ a:filter || curline =~ "^$" | ||||
|         " supress information about calling this function | ||||
|         " suppress information about calling this function | ||||
|         echo "" | ||||
|         return | ||||
|     endif | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 amix
					amix