mirror of
				https://github.com/amix/vimrc
				synced 2025-10-31 06:33:35 +08:00 
			
		
		
		
	Updated plugins
This commit is contained in:
		| @ -1,2 +1,5 @@ | ||||
| .local/ | ||||
| .cache/ | ||||
| .dlv/ | ||||
| .git/ | ||||
| .viminfo | ||||
|  | ||||
| @ -1,5 +1,9 @@ | ||||
| ## unplanned | ||||
|  | ||||
| BACKWARDS INCOMPATABILITIES: | ||||
| * g:go_highlight_fuction_arguments is renamed to g:go_highlight_function_parameters | ||||
|   [[GH-2117]](https://github.com/fatih/vim-go/pull/2117) | ||||
|  | ||||
| IMPROVEMENTS: | ||||
| * Disable `g:go_gocode_propose_source` by default. | ||||
|   [[GH-2050]](https://github.com/fatih/vim-go/pull/2050) | ||||
| @ -15,6 +19,10 @@ IMPROVEMENTS: | ||||
| * Do not require `'autowrite'` or `'autowriteall'` to be set when using | ||||
|   autocompletion in module mode. | ||||
|   [[GH-2091]](https://github.com/fatih/vim-go/pull/2091) | ||||
| * Fix use of g:go_metalinter_command _and_ apply it even when autosaving. | ||||
|   [[GH-2101]](https://github.com/fatih/vim-go/pull/2101) | ||||
| * Report errors in quickfix when Delve fails to start (e.g. compiler errors). | ||||
|   [[GH-2111]](https://github.com/fatih/vim-go/pull/2111) | ||||
|  | ||||
| BUG FIXES: | ||||
| * Fix opening of non-existent file from `:GoDeclsDir` when the current | ||||
| @ -28,6 +36,13 @@ BUG FIXES: | ||||
|   [[GH-2075]](https://github.com/fatih/vim-go/pull/2075) | ||||
| * Fix `:GoSameIdsToggle`. | ||||
|   [[GH-2086]](https://github.com/fatih/vim-go/pull/2086) | ||||
| * Do not set fileencoding or fileformat options or populate from template when | ||||
|   the buffer is not modifiable. | ||||
|   [[GH-2097]](https://github.com/fatih/vim-go/pull/2097) | ||||
| * Do not clear buffer-local autocmds of other buffers.  | ||||
|   [[GH-2109]](https://github.com/fatih/vim-go/pull/2109) | ||||
| * Highlight return parameter types when g:go_highlight_function_arguments is set. | ||||
|   [[GH-2116]](https://github.com/fatih/vim-go/pull/2116) | ||||
|  | ||||
| ## 1.19 - (November 4, 2018) | ||||
|  | ||||
|  | ||||
| @ -26,9 +26,7 @@ endfunction | ||||
| function! go#cmd#Build(bang, ...) abort | ||||
|   " Create our command arguments. go build discards any results when it | ||||
|   " compiles multiple packages. So we pass the `errors` package just as an | ||||
|   " placeholder with the current folder (indicated with '.'). We also pass -i | ||||
|   " that tries to install the dependencies, this has the side effect that it | ||||
|   " caches the build results, so every other build is faster. | ||||
|   " placeholder with the current folder (indicated with '.'). | ||||
|   let l:args = | ||||
|         \ ['build', '-tags', go#config#BuildTags()] + | ||||
|         \ map(copy(a:000), "expand(v:val)") + | ||||
| @ -63,6 +61,7 @@ function! go#cmd#Build(bang, ...) abort | ||||
|       redraw! | ||||
|     finally | ||||
|       execute cd . fnameescape(dir) | ||||
|       let &makeprg = default_makeprg | ||||
|     endtry | ||||
|  | ||||
|     let errors = go#list#Get(l:listtype) | ||||
| @ -72,8 +71,6 @@ function! go#cmd#Build(bang, ...) abort | ||||
|     else | ||||
|       call go#util#EchoSuccess("[build] SUCCESS") | ||||
|     endif | ||||
|  | ||||
|     let &makeprg = default_makeprg | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| @ -169,11 +166,15 @@ function! go#cmd#Run(bang, ...) abort | ||||
|  | ||||
|   let l:listtype = go#list#Type("GoRun") | ||||
|  | ||||
|   if l:listtype == "locationlist" | ||||
|     exe 'lmake!' | ||||
|   else | ||||
|     exe 'make!' | ||||
|   endif | ||||
|   try | ||||
|     if l:listtype == "locationlist" | ||||
|       exe 'lmake!' | ||||
|     else | ||||
|       exe 'make!' | ||||
|     endif | ||||
|   finally | ||||
|     let &makeprg = default_makeprg | ||||
|   endtry | ||||
|  | ||||
|   let items = go#list#Get(l:listtype) | ||||
|   let errors = go#tool#FilterValids(items) | ||||
| @ -184,7 +185,6 @@ function! go#cmd#Run(bang, ...) abort | ||||
|     call go#list#JumpToFirst(l:listtype) | ||||
|   endif | ||||
|  | ||||
|   let &makeprg = default_makeprg | ||||
| endfunction | ||||
|  | ||||
| " Install installs the package by simple calling 'go install'. If any argument | ||||
| @ -226,6 +226,7 @@ function! go#cmd#Install(bang, ...) abort | ||||
|     redraw! | ||||
|   finally | ||||
|     execute cd . fnameescape(dir) | ||||
|     let &makeprg = default_makeprg | ||||
|   endtry | ||||
|  | ||||
|   let errors = go#list#Get(l:listtype) | ||||
| @ -235,8 +236,6 @@ function! go#cmd#Install(bang, ...) abort | ||||
|   else | ||||
|     call go#util#EchoSuccess("installed to ". go#path#Default()) | ||||
|   endif | ||||
|  | ||||
|   let &makeprg = default_makeprg | ||||
| endfunction | ||||
|  | ||||
| " Generate runs 'go generate' in similar fashion to go#cmd#Build() | ||||
| @ -255,12 +254,17 @@ function! go#cmd#Generate(bang, ...) abort | ||||
|   let l:listtype = go#list#Type("GoGenerate") | ||||
|  | ||||
|   echon "vim-go: " | echohl Identifier | echon "generating ..."| echohl None | ||||
|   if l:listtype == "locationlist" | ||||
|     silent! exe 'lmake!' | ||||
|   else | ||||
|     silent! exe 'make!' | ||||
|   endif | ||||
|   redraw! | ||||
|  | ||||
|   try | ||||
|     if l:listtype == "locationlist" | ||||
|       silent! exe 'lmake!' | ||||
|     else | ||||
|       silent! exe 'make!' | ||||
|     endif | ||||
|   finally | ||||
|     redraw! | ||||
|     let &makeprg = default_makeprg | ||||
|   endtry | ||||
|  | ||||
|   let errors = go#list#Get(l:listtype) | ||||
|   call go#list#Window(l:listtype, len(errors)) | ||||
| @ -272,7 +276,6 @@ function! go#cmd#Generate(bang, ...) abort | ||||
|     redraws! | echon "vim-go: " | echohl Function | echon "[generate] SUCCESS"| echohl None | ||||
|   endif | ||||
|  | ||||
|   let &makeprg = default_makeprg | ||||
| endfunction | ||||
|  | ||||
| " --------------------- | ||||
|  | ||||
| @ -388,8 +388,9 @@ function! go#config#HighlightFunctions() abort | ||||
|   return get(g:, 'go_highlight_functions', 0) | ||||
| endfunction | ||||
|  | ||||
| function! go#config#HighlightFunctionArguments() abort | ||||
|   return get(g:, 'go_highlight_function_arguments', 0) | ||||
| function! go#config#HighlightFunctionParameters() abort | ||||
|   " fallback to highlight_function_arguments for backwards compatibility | ||||
|   return get(g:, 'go_highlight_function_parameters', get(g:, 'go_highlight_function_arguments', 0)) | ||||
| endfunction | ||||
|  | ||||
| function! go#config#HighlightFunctionCalls() abort | ||||
|  | ||||
| @ -85,7 +85,7 @@ function! go#coverage#Clear() abort | ||||
|  | ||||
|   " remove the autocmd we defined | ||||
|   augroup vim-go-coverage | ||||
|     autocmd! | ||||
|     autocmd! * <buffer> | ||||
|   augroup end | ||||
| endfunction | ||||
|  | ||||
| @ -242,7 +242,7 @@ function! go#coverage#overlay(file) abort | ||||
|  | ||||
|   " clear the matches if we leave the buffer | ||||
|   augroup vim-go-coverage | ||||
|     autocmd! | ||||
|     autocmd! * <buffer> | ||||
|     autocmd BufWinLeave <buffer> call go#coverage#Clear() | ||||
|   augroup end | ||||
|  | ||||
|  | ||||
| @ -30,6 +30,21 @@ function! s:groutineID() abort | ||||
| endfunction | ||||
|  | ||||
| function! s:complete(job, exit_status, data) abort | ||||
|   let l:gotready = get(s:state, 'ready', 0) | ||||
|   " copy messages to a:data _only_ when dlv exited non-zero and it was never | ||||
|   " detected as ready (e.g. there was a compiler error). | ||||
|   if a:exit_status > 0 && !l:gotready | ||||
|       " copy messages to data so that vim-go's usual handling of errors from | ||||
|       " async jobs will occur. | ||||
|       call extend(a:data, s:state['message']) | ||||
|   endif | ||||
|  | ||||
|   " return early instead of clearing any variables when the current job is not | ||||
|   " a:job | ||||
|   if has_key(s:state, 'job') && s:state['job'] != a:job | ||||
|     return | ||||
|   endif | ||||
|  | ||||
|   if has_key(s:state, 'job') | ||||
|     call remove(s:state, 'job') | ||||
|   endif | ||||
| @ -38,10 +53,11 @@ function! s:complete(job, exit_status, data) abort | ||||
|     call remove(s:state, 'ready') | ||||
|   endif | ||||
|  | ||||
|   call s:clearState() | ||||
|   if a:exit_status > 0 | ||||
|     call go#util#EchoError(s:state['message']) | ||||
|   if has_key(s:state, 'ch') | ||||
|     call remove(s:state, 'ch') | ||||
|   endif | ||||
|  | ||||
|   call s:clearState() | ||||
| endfunction | ||||
|  | ||||
| function! s:logger(prefix, ch, msg) abort | ||||
| @ -217,8 +233,8 @@ endfunction | ||||
| function! s:stop() abort | ||||
|   let l:res = s:call_jsonrpc('RPCServer.Detach', {'kill': v:true}) | ||||
|  | ||||
|   call s:clearState() | ||||
|   if has_key(s:state, 'job') | ||||
|     call go#job#Wait(s:state['job']) | ||||
|     call remove(s:state, 'job') | ||||
|   endif | ||||
|  | ||||
| @ -230,9 +246,7 @@ function! s:stop() abort | ||||
|     call remove(s:state, 'ch') | ||||
|   endif | ||||
|  | ||||
|   if has_key( s:state, 'data') | ||||
|     call remove(s:state, 'data') | ||||
|   endif | ||||
|   call s:clearState() | ||||
| endfunction | ||||
|  | ||||
| function! go#debug#Stop() abort | ||||
| @ -473,7 +487,7 @@ function! s:start_cb(res) abort | ||||
|   exe bufwinnr(oldbuf) 'wincmd w' | ||||
|  | ||||
|   augroup vim-go-debug | ||||
|     autocmd! | ||||
|     autocmd! * <buffer> | ||||
|     autocmd FileType go nmap <buffer> <F5>   <Plug>(go-debug-continue) | ||||
|     autocmd FileType go nmap <buffer> <F6>   <Plug>(go-debug-print) | ||||
|     autocmd FileType go nmap <buffer> <F9>   <Plug>(go-debug-breakpoint) | ||||
| @ -489,7 +503,6 @@ function! s:err_cb(ch, msg) abort | ||||
|     return | ||||
|   endif | ||||
|  | ||||
|   call go#util#EchoError(a:msg) | ||||
|   let s:state['message'] += [a:msg] | ||||
| endfunction | ||||
|  | ||||
| @ -499,7 +512,6 @@ function! s:out_cb(ch, msg) abort | ||||
|     return | ||||
|   endif | ||||
|  | ||||
|   call go#util#EchoProgress(a:msg) | ||||
|   let s:state['message'] += [a:msg] | ||||
|  | ||||
|   if stridx(a:msg, go#config#DebugAddress()) != -1 | ||||
| @ -572,7 +584,7 @@ function! go#debug#Start(is_test, ...) abort | ||||
|  | ||||
|   " It's already running. | ||||
|   if has_key(s:state, 'job') | ||||
|     return | ||||
|     return s:state['job'] | ||||
|   endif | ||||
|  | ||||
|   let s:start_args = a:000 | ||||
| @ -634,7 +646,7 @@ function! go#debug#Start(is_test, ...) abort | ||||
|  | ||||
|     let s:state['message'] = [] | ||||
|     let l:opts = { | ||||
|           \ 'for': '_', | ||||
|           \ 'for': 'GoDebug', | ||||
|           \ 'statustype': 'debug', | ||||
|           \ 'complete': function('s:complete'), | ||||
|           \ } | ||||
| @ -647,6 +659,8 @@ function! go#debug#Start(is_test, ...) abort | ||||
|   catch | ||||
|     call go#util#EchoError(v:exception) | ||||
|   endtry | ||||
|  | ||||
|   return s:state['job'] | ||||
| endfunction | ||||
|  | ||||
| " Translate a reflect kind constant to a human string. | ||||
| @ -872,7 +886,7 @@ function! go#debug#Restart() abort | ||||
|   call go#cmd#autowrite() | ||||
|  | ||||
|   try | ||||
|     call go#job#Stop(s:state['job']) | ||||
|     call s:stop() | ||||
|  | ||||
|     let l:breaks = s:state['breakpoint'] | ||||
|     let s:state = { | ||||
|  | ||||
| @ -7,11 +7,49 @@ function! Test_GoDebugStart_Empty() abort | ||||
| endfunction | ||||
|  | ||||
| function! Test_GoDebugStart_RelativePackage() abort | ||||
|   call s:debug('./debugmain') | ||||
|   call s:debug('./debug/debugmain') | ||||
| endfunction | ||||
|  | ||||
| function! Test_GoDebugStart_Package() abort | ||||
|   call s:debug('debugmain') | ||||
|   call s:debug('debug/debugmain') | ||||
| endfunction | ||||
|  | ||||
| function! Test_GoDebugStart_Errors() abort | ||||
|   if !go#util#has_job() | ||||
|     return | ||||
|   endif | ||||
|  | ||||
|   try | ||||
|     let l:expected = [ | ||||
|           \ {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': '# debug/compilerror'}, | ||||
|           \ {'lnum': 6, 'bufnr': 7, 'col': 22, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': ' syntax error: unexpected newline, expecting comma or )'}, | ||||
|           \ {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exit status 2'} | ||||
|           \] | ||||
|     call setqflist([], 'r') | ||||
|  | ||||
|     let l:tmp = gotest#load_fixture('debug/compilerror/main.go') | ||||
|     call assert_false(exists(':GoDebugStop')) | ||||
|  | ||||
|     let l:cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd' | ||||
|     execute l:cd . ' debug/compilerror' | ||||
|  | ||||
|     call go#debug#Start(0) | ||||
|  | ||||
|     let l:actual = getqflist() | ||||
|     let l:start = reltime() | ||||
|     while len(l:actual) == 0 && reltimefloat(reltime(l:start)) < 10 | ||||
|       sleep 100m | ||||
|       let l:actual = getqflist() | ||||
|     endwhile | ||||
|  | ||||
|     call gotest#assert_quickfix(l:actual, l:expected) | ||||
|     call assert_false(exists(':GoDebugStop')) | ||||
|  | ||||
|   finally | ||||
|     call delete(l:tmp, 'rf') | ||||
|     " clear the quickfix lists | ||||
|     call setqflist([], 'r') | ||||
|   endtry | ||||
| endfunction | ||||
|  | ||||
| function! s:debug(...) abort | ||||
| @ -20,7 +58,7 @@ function! s:debug(...) abort | ||||
|   endif | ||||
|  | ||||
|   try | ||||
|     let l:tmp = gotest#load_fixture('debugmain/debugmain.go') | ||||
|     let l:tmp = gotest#load_fixture('debug/debugmain/debugmain.go') | ||||
|  | ||||
|     call go#debug#Breakpoint(6) | ||||
|  | ||||
| @ -28,10 +66,10 @@ function! s:debug(...) abort | ||||
|  | ||||
|     if a:0 == 0 | ||||
|       let l:cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd' | ||||
|       execute l:cd . ' debugmain' | ||||
|       call go#debug#Start(0) | ||||
|       execute l:cd . ' debug/debugmain' | ||||
|       let l:job = go#debug#Start(0) | ||||
|     else | ||||
|       call go#debug#Start(0, a:1) | ||||
|       let l:job = go#debug#Start(0, a:1) | ||||
|     endif | ||||
|  | ||||
|     let l:start = reltime() | ||||
| @ -39,9 +77,17 @@ function! s:debug(...) abort | ||||
|       sleep 100m | ||||
|     endwhile | ||||
|  | ||||
|     call assert_true(exists(':GoDebugStop')) | ||||
|     call gotest#assert_quickfix(getqflist(), []) | ||||
|  | ||||
|     call go#debug#Stop() | ||||
|  | ||||
|     if !has('nvim') | ||||
|       call assert_equal(job_status(l:job), 'dead') | ||||
|     endif | ||||
|  | ||||
|     call assert_false(exists(':GoDebugStop')) | ||||
|  | ||||
|   finally | ||||
|     call delete(l:tmp, 'rf') | ||||
|   endtry | ||||
|  | ||||
| @ -84,7 +84,6 @@ function! s:jump_to_declaration_cb(mode, bin_name, job, exit_status, data) abort | ||||
|   endif | ||||
|  | ||||
|   call go#def#jump_to_declaration(a:data[0], a:mode, a:bin_name) | ||||
|   call go#util#EchoSuccess(fnamemodify(a:data[0], ":t")) | ||||
|  | ||||
|   " capture the active window so that after the exit_cb and close_cb callbacks | ||||
|   " can return to it when a:mode caused a split. | ||||
|  | ||||
| @ -486,7 +486,7 @@ function! s:same_ids_highlight(exit_val, output, mode) abort | ||||
|     " re-apply SameIds at the current cursor position at the time the buffer | ||||
|     " is redisplayed: e.g. :edit, :GoRename, etc. | ||||
|     augroup vim-go-sameids | ||||
|       autocmd! | ||||
|       autocmd! * <buffer> | ||||
|       autocmd BufWinEnter <buffer> nested call go#guru#SameIds(0) | ||||
|     augroup end | ||||
|   endif | ||||
| @ -511,7 +511,7 @@ function! go#guru#ClearSameIds() abort | ||||
|  | ||||
|   " remove the autocmds we defined | ||||
|   augroup vim-go-sameids | ||||
|     autocmd! | ||||
|     autocmd! * <buffer> | ||||
|   augroup end | ||||
|  | ||||
|   return 0 | ||||
|  | ||||
| @ -343,77 +343,19 @@ function! s:neooptions(options) | ||||
|         continue | ||||
|       endif | ||||
|  | ||||
|       " dealing with the channel lines of Neovim sucks. The docs (:help | ||||
|       " channel-lines) say: | ||||
|       " stream event handlers may receive partial (incomplete) lines. For a | ||||
|       " given invocation of on_stdout etc, `a:data` is not guaranteed to end | ||||
|       " with a newline. | ||||
|       "   - `abcdefg` may arrive as `['abc']`, `['defg']`. | ||||
|       "   - `abc\nefg` may arrive as `['abc', '']`, `['efg']` or `['abc']`, | ||||
|       "     `['','efg']`, or even `['ab']`, `['c','efg']`. | ||||
|       if key == 'callback' | ||||
|         let l:options['callback'] = a:options['callback'] | ||||
|  | ||||
|         if !has_key(a:options, 'out_cb') | ||||
|           function! s:callback2on_stdout(ch, data, event) dict | ||||
|             " a single empty string means EOF was reached. | ||||
|             if len(a:data) == 1 && a:data[0] == '' | ||||
|               " when there's nothing buffered, return early so that an | ||||
|               " erroneous message will not be added. | ||||
|               if self.stdout_buf == '' | ||||
|                 return | ||||
|               endif | ||||
|  | ||||
|               let l:data = [self.stdout_buf] | ||||
|               let self.stdout_buf = '' | ||||
|             else | ||||
|               let l:data = copy(a:data) | ||||
|               let l:data[0] = self.stdout_buf . l:data[0] | ||||
|  | ||||
|               " The last element may be a partial line; save it for next time. | ||||
|               let self.stdout_buf = l:data[-1] | ||||
|  | ||||
|               let l:data = l:data[:-2] | ||||
|  | ||||
|               if len(l:data) == 0 | ||||
|                 return | ||||
|               endif | ||||
|             endif | ||||
|  | ||||
|             for l:msg in l:data | ||||
|               call self.callback(a:ch, l:msg) | ||||
|             endfor | ||||
|             let self.stdout_buf = s:neocb(a:ch, self.stdout_buf, a:data, self.callback) | ||||
|           endfunction | ||||
|           let l:options['on_stdout'] = function('s:callback2on_stdout', [], l:options) | ||||
|         endif | ||||
|  | ||||
|         if !has_key(a:options, 'err_cb') | ||||
|           function! s:callback2on_stderr(ch, data, event) dict | ||||
|             " a single empty string means EOF was reached. | ||||
|             if len(a:data) == 1 && a:data[0] == '' | ||||
|               " when there's nothing buffered, return early so that an | ||||
|               " erroneous message will not be added. | ||||
|               if self.stderr_buf == '' | ||||
|                 return | ||||
|               endif | ||||
|               let l:data = [self.stderr_buf] | ||||
|               let self.stderr_buf = '' | ||||
|             else | ||||
|               let l:data = copy(a:data) | ||||
|               let l:data[0] = self.stderr_buf . l:data[0] | ||||
|  | ||||
|               " The last element may be a partial line; save it for next time. | ||||
|               let self.stderr_buf = l:data[-1] | ||||
|  | ||||
|               let l:data = l:data[:-2] | ||||
|               if len(l:data) == 0 | ||||
|                 return | ||||
|               endif | ||||
|             endif | ||||
|  | ||||
|             for l:msg in l:data | ||||
|               call self.callback(a:ch, l:msg) | ||||
|             endfor | ||||
|             let self.stderr_buf = s:neocb(a:ch, self.stderr_buf, a:data, self.callback) | ||||
|           endfunction | ||||
|           let l:options['on_stderr'] = function('s:callback2on_stderr', [], l:options) | ||||
|         endif | ||||
| @ -424,31 +366,7 @@ function! s:neooptions(options) | ||||
|       if key == 'out_cb' | ||||
|         let l:options['out_cb'] = a:options['out_cb'] | ||||
|         function! s:on_stdout(ch, data, event) dict | ||||
|           " a single empty string means EOF was reached. | ||||
|           if len(a:data) == 1 && a:data[0] == '' | ||||
|             " when there's nothing buffered, return early so that an | ||||
|             " erroneous message will not be added. | ||||
|             if self.stdout_buf == '' | ||||
|               return | ||||
|             endif | ||||
|             let l:data = [self.stdout_buf] | ||||
|             let self.stdout_buf = '' | ||||
|           else | ||||
|             let l:data = copy(a:data) | ||||
|             let l:data[0] = self.stdout_buf . l:data[0] | ||||
|  | ||||
|             " The last element may be a partial line; save it for next time. | ||||
|             let self.stdout_buf = l:data[-1] | ||||
|  | ||||
|             let l:data = l:data[:-2] | ||||
|             if len(l:data) == 0 | ||||
|               return | ||||
|             endif | ||||
|           endif | ||||
|  | ||||
|             for l:msg in l:data | ||||
|               call self.out_cb(a:ch, l:msg) | ||||
|             endfor | ||||
|           let self.stdout_buf = s:neocb(a:ch, self.stdout_buf, a:data, self.out_cb) | ||||
|         endfunction | ||||
|         let l:options['on_stdout'] = function('s:on_stdout', [], l:options) | ||||
|  | ||||
| @ -458,31 +376,7 @@ function! s:neooptions(options) | ||||
|       if key == 'err_cb' | ||||
|         let l:options['err_cb'] = a:options['err_cb'] | ||||
|         function! s:on_stderr(ch, data, event) dict | ||||
|           " a single empty string means EOF was reached. | ||||
|           if len(a:data) == 1 && a:data[0] == '' | ||||
|             " when there's nothing buffered, return early so that an | ||||
|             " erroneous message will not be added. | ||||
|             if self.stderr_buf == '' | ||||
|               return | ||||
|             endif | ||||
|             let l:data = [self.stderr_buf] | ||||
|             let self.stderr_buf = '' | ||||
|           else | ||||
|             let l:data = copy(a:data) | ||||
|             let l:data[0] = self.stderr_buf . l:data[0] | ||||
|  | ||||
|             " The last element may be a partial line; save it for next time. | ||||
|             let self.stderr_buf = l:data[-1] | ||||
|  | ||||
|             let l:data = l:data[:-2] | ||||
|             if len(l:data) == 0 | ||||
|               return | ||||
|             endif | ||||
|           endif | ||||
|  | ||||
|           for l:msg in l:data | ||||
|             call self.err_cb(a:ch, l:msg) | ||||
|           endfor | ||||
|           let self.stderr_buf = s:neocb(a:ch, self.stderr_buf, a:data, self.err_cb ) | ||||
|         endfunction | ||||
|         let l:options['on_stderr'] = function('s:on_stderr', [], l:options) | ||||
|  | ||||
| @ -542,6 +436,43 @@ function! s:winjobarg(idx, val) abort | ||||
|   return a:val | ||||
| endfunction | ||||
|  | ||||
| function! s:neocb(ch, buf, data, callback) | ||||
|   " dealing with the channel lines of Neovim is awful. The docs (:help | ||||
|   " channel-lines) say: | ||||
|   " stream event handlers may receive partial (incomplete) lines. For a | ||||
|   " given invocation of on_stdout etc, `a:data` is not guaranteed to end | ||||
|   " with a newline. | ||||
|   "   - `abcdefg` may arrive as `['abc']`, `['defg']`. | ||||
|   "   - `abc\nefg` may arrive as `['abc', '']`, `['efg']` or `['abc']`, | ||||
|   "     `['','efg']`, or even `['ab']`, `['c','efg']`. | ||||
|  | ||||
|   " a single empty string means EOF was reached. | ||||
|   if len(a:data) == 1 && a:data[0] == '' | ||||
|     " when there's nothing buffered, return early so that an | ||||
|     " erroneous message will not be added. | ||||
|     if a:buf == '' | ||||
|       return '' | ||||
|     endif | ||||
|  | ||||
|     let l:data = [a:buf] | ||||
|     let l:buf = '' | ||||
|   else | ||||
|     let l:data = copy(a:data) | ||||
|     let l:data[0] = a:buf . l:data[0] | ||||
|  | ||||
|     " The last element may be a partial line; save it for next time. | ||||
|     let l:buf = l:data[-1] | ||||
|  | ||||
|     let l:data = l:data[:-2] | ||||
|   endif | ||||
|  | ||||
|   for l:msg in l:data | ||||
|     call a:callback(a:ch, l:msg) | ||||
|   endfor | ||||
|  | ||||
|   return l:buf | ||||
| endfunction | ||||
|  | ||||
| " restore Vi compatibility settings | ||||
| let &cpo = s:cpo_save | ||||
| unlet s:cpo_save | ||||
|  | ||||
| @ -9,15 +9,22 @@ function! go#lint#Gometa(bang, autosave, ...) abort | ||||
|     let goargs = a:000 | ||||
|   endif | ||||
|  | ||||
|   let bin_path = go#path#CheckBinPath("gometalinter") | ||||
|   if empty(bin_path) | ||||
|     return | ||||
|   endif | ||||
|   if empty(go#config#MetalinterCommand()) | ||||
|     let bin_path = go#path#CheckBinPath("gometalinter") | ||||
|     if empty(bin_path) | ||||
|       return | ||||
|     endif | ||||
|  | ||||
|   let cmd = [bin_path] | ||||
|   let cmd += ["--disable-all"] | ||||
|     let cmd = [bin_path] | ||||
|     let cmd += ["--disable-all"] | ||||
|  | ||||
|     " gometalinter has a --tests flag to tell its linters whether to run | ||||
|     " against tests. While not all of its linters respect this flag, for those | ||||
|     " that do, it means if we don't pass --tests, the linter won't run against | ||||
|     " test files. One example of a linter that will not run against tests if | ||||
|     " we do not specify this flag is errcheck. | ||||
|     let cmd += ["--tests"] | ||||
|  | ||||
|   if a:autosave || empty(go#config#MetalinterCommand()) | ||||
|     " linters | ||||
|     let linters = a:autosave ? go#config#MetalinterAutosaveEnabled() : go#config#MetalinterEnabled() | ||||
|     for linter in linters | ||||
| @ -27,16 +34,9 @@ function! go#lint#Gometa(bang, autosave, ...) abort | ||||
|     for linter in go#config#MetalinterDisabled() | ||||
|       let cmd += ["--disable=".linter] | ||||
|     endfor | ||||
|  | ||||
|     " gometalinter has a --tests flag to tell its linters whether to run | ||||
|     " against tests. While not all of its linters respect this flag, for those | ||||
|     " that do, it means if we don't pass --tests, the linter won't run against | ||||
|     " test files. One example of a linter that will not run against tests if | ||||
|     " we do not specify this flag is errcheck. | ||||
|     let cmd += ["--tests"] | ||||
|   else | ||||
|     " the user wants something else, let us use it. | ||||
|     let cmd += split(go#config#MetalinterCommand(), " ") | ||||
|     let cmd = split(go#config#MetalinterCommand(), " ") | ||||
|   endif | ||||
|  | ||||
|   if a:autosave | ||||
| @ -78,8 +78,8 @@ function! go#lint#Gometa(bang, autosave, ...) abort | ||||
|     echon "vim-go: " | echohl Function | echon "[metalinter] PASS" | echohl None | ||||
|   else | ||||
|     " GoMetaLinter can output one of the two, so we look for both: | ||||
|     "   <file>:<line>:[<column>]: <message> (<linter>) | ||||
|     "   <file>:<line>:: <message> (<linter>) | ||||
|     "   <file>:<line>:<column>:<severity>: <message> (<linter>) | ||||
|     "   <file>:<line>::<severity>: <message> (<linter>) | ||||
|     " This can be defined by the following errorformat: | ||||
|     let errformat = "%f:%l:%c:%t%*[^:]:\ %m,%f:%l::%t%*[^:]:\ %m" | ||||
|  | ||||
| @ -123,7 +123,9 @@ endfunction | ||||
| function! go#lint#Vet(bang, ...) abort | ||||
|   call go#cmd#autowrite() | ||||
|  | ||||
|   call go#util#EchoProgress('calling vet...') | ||||
|   if go#config#EchoCommandInfo() | ||||
|     call go#util#EchoProgress('calling vet...') | ||||
|   endif | ||||
|  | ||||
|   if a:0 == 0 | ||||
|     let [l:out, l:err] = go#util#Exec(['go', 'vet', go#package#ImportPath()]) | ||||
| @ -140,7 +142,6 @@ function! go#lint#Vet(bang, ...) abort | ||||
|     if !empty(errors) && !a:bang | ||||
|       call go#list#JumpToFirst(l:listtype) | ||||
|     endif | ||||
|     call go#util#EchoError('[vet] FAIL') | ||||
|   else | ||||
|     call go#list#Clean(l:listtype) | ||||
|     call go#util#EchoSuccess('[vet] PASS') | ||||
|  | ||||
| @ -138,6 +138,7 @@ endfunction | ||||
| " in g:go_list_type_commands. | ||||
| let s:default_list_type_commands = { | ||||
|       \ "GoBuild":              "quickfix", | ||||
|       \ "GoDebug":              "quickfix", | ||||
|       \ "GoErrCheck":           "quickfix", | ||||
|       \ "GoFmt":                "locationlist", | ||||
|       \ "GoGenerate":           "quickfix", | ||||
|  | ||||
| @ -89,7 +89,6 @@ function s:parse_errors(exit_val, bang, out) | ||||
|  | ||||
|   let l:listtype = go#list#Type("GoRename") | ||||
|   if a:exit_val != 0 | ||||
|     call go#util#EchoError("FAILED") | ||||
|     let errors = go#tool#ParseErrors(a:out) | ||||
|     call go#list#Populate(l:listtype, errors, 'Rename') | ||||
|     call go#list#Window(l:listtype, len(errors)) | ||||
|  | ||||
| @ -8,39 +8,34 @@ function! go#template#create() abort | ||||
|   let l:go_template_use_pkg = go#config#TemplateUsePkg() | ||||
|   let l:root_dir = fnamemodify(s:current_file, ':h:h:h') | ||||
|  | ||||
|   let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' | ||||
|   let dir = getcwd() | ||||
|   let l:package_name = -1 | ||||
|   let l:package_name = go#tool#PackageName() | ||||
|  | ||||
|   if isdirectory(expand('%:p:h')) | ||||
|     execute cd . fnameescape(expand('%:p:h')) | ||||
|     let l:package_name = go#tool#PackageName() | ||||
|   endif | ||||
|  | ||||
|   " if we can't figure out any package name(no Go files or non Go package | ||||
|   " files) from the directory create the template or use the cwd | ||||
|   " as the name | ||||
|   if l:package_name == -1 && l:go_template_use_pkg != 1 | ||||
|     let l:filename = fnamemodify(expand("%"), ':t') | ||||
|     if l:filename =~ "_test.go$" | ||||
|       let l:template_file = go#config#TemplateTestFile() | ||||
|   " if we can't figure out any package name (i.e. no Go files in the directory) | ||||
|   " from the directory create the template or use the directory as the name. | ||||
|   if l:package_name == -1 | ||||
|     if l:go_template_use_pkg == 1 | ||||
|       let l:path = fnamemodify(expand('%:p:h'), ':t') | ||||
|       let l:content = printf("package %s", l:path) | ||||
|       call append(0, l:content) | ||||
|     else | ||||
|       let l:template_file = go#config#TemplateFile() | ||||
|       let l:filename = expand('%:t') | ||||
|       if l:filename =~ "_test.go$" | ||||
|         let l:template_file = go#config#TemplateTestFile() | ||||
|       else | ||||
|         let l:template_file = go#config#TemplateFile() | ||||
|       endif | ||||
|       let l:template_path = go#util#Join(l:root_dir, "templates", l:template_file) | ||||
|       silent exe 'keepalt 0r ' . fnameescape(l:template_path) | ||||
|     endif | ||||
|     let l:template_path = go#util#Join(l:root_dir, "templates", l:template_file) | ||||
|     silent exe 'keepalt 0r ' . fnameescape(l:template_path) | ||||
|   elseif l:package_name == -1 && l:go_template_use_pkg == 1 | ||||
|     " cwd is now the dir of the package | ||||
|     let l:path = fnamemodify(getcwd(), ':t') | ||||
|     let l:content = printf("package %s", l:path) | ||||
|     call append(0, l:content) | ||||
|   else | ||||
|     let l:content = printf("package %s", l:package_name) | ||||
|     call append(0, l:content) | ||||
|   endif | ||||
|   $delete _ | ||||
|  | ||||
|   execute cd . fnameescape(dir) | ||||
|   " checking that the last line is empty shouldn't be necessary, but for some | ||||
|   " reason the last line isn't the expected empty line when run via tests. | ||||
|   if getline('$') is '' | ||||
|     $delete _ | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| function! go#template#ToggleAutoCreate() abort | ||||
|  | ||||
							
								
								
									
										62
									
								
								sources_non_forked/vim-go/autoload/go/template_test.vim
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								sources_non_forked/vim-go/autoload/go/template_test.vim
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,62 @@ | ||||
| " don't spam the user when Vim is started in Vi compatibility mode | ||||
| let s:cpo_save = &cpo | ||||
| set cpo&vim | ||||
|  | ||||
| func! Test_TemplateCreate() abort | ||||
|   try | ||||
|     let l:tmp = gotest#write_file('foo/empty.txt', ['']) | ||||
|  | ||||
|     edit foo/bar.go | ||||
|  | ||||
|     call gotest#assert_buffer(1, [ | ||||
|           \ 'func main() {', | ||||
|           \ '\tfmt.Println("vim-go")', | ||||
|           \ '}']) | ||||
|   finally | ||||
|     call delete(l:tmp, 'rf') | ||||
|   endtry | ||||
|  | ||||
|   try | ||||
|     let l:tmp = gotest#write_file('foo/empty.txt', ['']) | ||||
|     edit foo/bar_test.go | ||||
|  | ||||
|     call gotest#assert_buffer(1, [ | ||||
|           \ 'func TestHelloWorld(t *testing.T) {', | ||||
|           \ '\t// t.Fatal("not implemented")', | ||||
|           \ '}']) | ||||
|   finally | ||||
|     call delete(l:tmp, 'rf') | ||||
|   endtry | ||||
| endfunc | ||||
|  | ||||
| func! Test_TemplateCreate_UsePkg() abort | ||||
|   try | ||||
|     let l:tmp = gotest#write_file('foo/empty.txt', ['']) | ||||
|  | ||||
|     let g:go_template_use_pkg = 1 | ||||
|     edit foo/bar.go | ||||
|  | ||||
|     call gotest#assert_buffer(0, ['package foo']) | ||||
|   finally | ||||
|     unlet g:go_template_use_pkg | ||||
|     call delete(l:tmp, 'rf') | ||||
|   endtry | ||||
| endfunc | ||||
|  | ||||
| func! Test_TemplateCreate_PackageExists() abort | ||||
|   try | ||||
|     let l:tmp = gotest#write_file('quux/quux.go', ['package foo']) | ||||
|  | ||||
|     edit quux/bar.go | ||||
|  | ||||
|     call gotest#assert_buffer(0, ['package foo']) | ||||
|   finally | ||||
|     call delete(l:tmp, 'rf') | ||||
|   endtry | ||||
| endfunc | ||||
|  | ||||
| " restore Vi compatibility settings | ||||
| let &cpo = s:cpo_save | ||||
| unlet s:cpo_save | ||||
|  | ||||
| " vim: sw=2 ts=2 et | ||||
| @ -0,0 +1,7 @@ | ||||
| package main | ||||
|  | ||||
| import "fmt" | ||||
|  | ||||
| func main() { | ||||
| 	fmt.Println("vim-go" | ||||
| } | ||||
| @ -84,7 +84,6 @@ function! go#test#Test(bang, compile, ...) abort | ||||
|       " failed to parse errors, output the original content | ||||
|       call go#util#EchoError(out) | ||||
|     endif | ||||
|     call go#util#EchoError("[test] FAIL") | ||||
|   else | ||||
|     call go#list#Clean(l:listtype) | ||||
|  | ||||
|  | ||||
| @ -130,8 +130,8 @@ function! go#tool#ParseErrors(lines) abort | ||||
|   return errors | ||||
| endfunction | ||||
|  | ||||
| "FilterValids filters the given items with only items that have a valid | ||||
| "filename. Any non valid filename is filtered out. | ||||
| " FilterValids filters the given items with only items that have a valid | ||||
| " filename. Any non valid filename is filtered out. | ||||
| function! go#tool#FilterValids(items) abort | ||||
|   " Remove any nonvalid filename from the location list to avoid opening an | ||||
|   " empty buffer. See https://github.com/fatih/vim-go/issues/287 for | ||||
|  | ||||
| @ -1836,13 +1836,13 @@ Highlight function and method declarations. | ||||
| > | ||||
|   let g:go_highlight_functions = 0 | ||||
| < | ||||
|                                          *'g:go_highlight_function_arguments'* | ||||
|                                        *'g:go_highlight_function_parameters'* | ||||
|  | ||||
| Highlight the variable names in arguments and return values in function | ||||
| declarations. Setting this implies the functionality from | ||||
| Highlight the variable names in parameters (including named return parameters) | ||||
| in function declarations. Setting this implies the functionality from | ||||
| |'g:go_highlight_functions'|. | ||||
| > | ||||
|   let g:go_highlight_function_arguments = 0 | ||||
|   let g:go_highlight_function_parameters = 0 | ||||
| < | ||||
|                                              *'g:go_highlight_function_calls'* | ||||
|  | ||||
|  | ||||
| @ -25,11 +25,11 @@ function! s:gofiletype_post() | ||||
| endfunction | ||||
|  | ||||
| " Note: should not use augroup in ftdetect (see :help ftdetect) | ||||
| au BufNewFile *.go setfiletype go | setlocal fileencoding=utf-8 fileformat=unix | ||||
| au BufNewFile *.go setfiletype go | if &modifiable | setlocal fileencoding=utf-8 fileformat=unix | endif | ||||
| au BufRead *.go call s:gofiletype_pre("go") | ||||
| au BufReadPost *.go call s:gofiletype_post() | ||||
|  | ||||
| au BufNewFile *.s setfiletype asm | setlocal fileencoding=utf-8 fileformat=unix | ||||
| au BufNewFile *.s setfiletype asm | if &modifiable | setlocal fileencoding=utf-8 fileformat=unix | endif | ||||
| au BufRead *.s call s:gofiletype_pre("asm") | ||||
| au BufReadPost *.s call s:gofiletype_post() | ||||
|  | ||||
|  | ||||
| @ -277,7 +277,7 @@ endfunction | ||||
|  | ||||
| function! s:template_autocreate() | ||||
|   " create new template from scratch | ||||
|   if get(g:, "go_template_autocreate", 1) | ||||
|   if get(g:, "go_template_autocreate", 1) && &modifiable | ||||
|     call go#template#create() | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| @ -48,7 +48,7 @@ redir @q | ||||
| redir END | ||||
| let s:tests = split(substitute(@q, 'function \(\k\+()\)', '\1', 'g')) | ||||
|  | ||||
| " log any messages that we may already accumulated. | ||||
| " log any messages already accumulated. | ||||
| call s:logmessages() | ||||
| " Iterate over all tests and execute them. | ||||
| for s:test in sort(s:tests) | ||||
|  | ||||
| @ -148,14 +148,14 @@ endif | ||||
| " var, const | ||||
| if go#config#FoldEnable('varconst') | ||||
|   syn region    goVar               start='var ('   end='^\s*)$' transparent fold | ||||
|                         \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments,goPointerOperator | ||||
|                         \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator | ||||
|   syn region    goConst             start='const (' end='^\s*)$' transparent fold | ||||
|                         \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments,goPointerOperator | ||||
|                         \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator | ||||
| else | ||||
|   syn region    goVar               start='var ('   end='^\s*)$' transparent | ||||
|                         \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments,goPointerOperator | ||||
|                         \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator | ||||
|   syn region    goConst             start='const (' end='^\s*)$' transparent | ||||
|                         \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments,goPointerOperator | ||||
|                         \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator | ||||
| endif | ||||
|  | ||||
| " Single-line var, const, and import. | ||||
| @ -263,19 +263,20 @@ endif | ||||
| hi def link     goOperator          Operator | ||||
|  | ||||
| " Functions; | ||||
| if go#config#HighlightFunctions() || go#config#HighlightFunctionArguments() | ||||
|   syn match goDeclaration       /\<func\>/ nextgroup=goReceiver,goFunction,goSimpleArguments skipwhite skipnl | ||||
| if go#config#HighlightFunctions() || go#config#HighlightFunctionParameters() | ||||
|   syn match goDeclaration       /\<func\>/ nextgroup=goReceiver,goFunction,goSimpleParams skipwhite skipnl | ||||
|   syn match goReceiverVar       /\w\+\ze\s\+\(\w\|\*\)/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained | ||||
|   syn match goPointerOperator   /\*/ nextgroup=goReceiverType contained skipwhite skipnl | ||||
|   syn match goFunction          /\w\+/ nextgroup=goSimpleArguments contained skipwhite skipnl | ||||
|   syn match goFunction          /\w\+/ nextgroup=goSimpleParams contained skipwhite skipnl | ||||
|   syn match goReceiverType      /\w\+/ contained | ||||
| if go#config#HighlightFunctionArguments() | ||||
|   syn match goSimpleArguments   /(\(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goArgumentName nextgroup=goSimpleArguments skipwhite skipnl | ||||
|   syn match goArgumentName      /\w\+\(\s*,\s*\w\+\)*\ze\s\+\(\w\|\.\|\*\|\[\)/ contained nextgroup=goArgumentType skipwhite skipnl | ||||
|   syn match goArgumentType      /\([^,)]\|\_s\)\+,\?/ contained nextgroup=goArgumentName skipwhite skipnl | ||||
| if go#config#HighlightFunctionParameters() | ||||
|   syn match goSimpleParams     /(\(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType nextgroup=goFunctionReturn skipwhite skipnl | ||||
|   syn match goFunctionReturn   /(\(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType skipwhite skipnl | ||||
|   syn match goParamName        /\w\+\(\s*,\s*\w\+\)*\ze\s\+\(\w\|\.\|\*\|\[\)/ contained nextgroup=goParamType skipwhite skipnl | ||||
|   syn match goParamType     /\([^,)]\|\_s\)\+,\?/ contained nextgroup=goParamName skipwhite skipnl | ||||
|                         \ contains=goVarArgs,goType,goSignedInts,goUnsignedInts,goFloats,goComplexes,goDeclType,goBlock | ||||
|   hi def link   goReceiverVar       goArgumentName | ||||
|   hi def link   goArgumentName      Identifier | ||||
|   hi def link   goReceiverVar    goParamName | ||||
|   hi def link   goParamName      Identifier | ||||
| endif | ||||
|   syn match goReceiver          /(\s*\w\+\(\s\+\*\?\s*\w\+\)\?\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl | ||||
| else | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Amir Salihefendic
					Amir Salihefendic