Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kent Sibilev committed Nov 20, 2016
2 parents 02e8bca + 362decf commit c2b4e83
Show file tree
Hide file tree
Showing 28 changed files with 184 additions and 169 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

IMPROVEMENTS:

* Function calls are now highligted as wel when `g:go_highlight_functions` is enabled [gh-1048]
* Add completion support for uninported packages. This allows to complete even if the package is not improted [gh-1084]
* Function calls are now highligted as well when `g:go_highlight_functions` is enabled [gh-1048]
* Add completion support for unimported packages. This allows to complete even if the package is not imported. By default it's disabled, enable by adding `let g:go_gocode_unimported_packages = 1` [gh-1084]
* Tools that embeds GOROOT into their binaries do not work when people update their Go version and the GOROOT contains the vesion as part of their path (i.e: `/usr/local/Cellar/go/1.7.2/libexec`, [more info](https://blog.filippo.io/stale-goroot-and-gorebuild/)) . This is now fixed by introducing automatic GOROOT set/unset before each tool invoke. [gh-954]
* Added new setting `g:go_echo_go_info` to enable/disable printing identifier information when completion is done [gh-1101]

BUG FIXES:

Expand All @@ -16,6 +17,7 @@ BUG FIXES:
* Highlight nested structs correctly [gh-1075]
* Highlight builtin functions correctly if `g:go_highlight_functions` is enabled [gh-1070]
* Fix `:GoSameIds` highlighting if a new buffer is opened in the same window [gh-1067]
* Internal: add `abort` to all vim function to return in case of errors [gh-1100]

## 1.9 (September 13, 2016)

Expand Down
12 changes: 6 additions & 6 deletions autoload/ctrlp/decls.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ else
let g:ctrlp_ext_vars = [s:go_decls_var]
endif

function! ctrlp#decls#init()
function! ctrlp#decls#init() abort
cal s:enable_syntax()
return s:decls
endfunction

function! ctrlp#decls#exit()
function! ctrlp#decls#exit() abort
unlet! s:decls s:current_dir s:target
endfunction

Expand All @@ -28,7 +28,7 @@ endfunction
" a:mode the mode that has been chosen by pressing <cr> <c-v> <c-t> or <c-x>
" the values are 'e', 'v', 't' and 'h', respectively
" a:str the selected string
function! ctrlp#decls#accept(mode, str)
function! ctrlp#decls#accept(mode, str) abort
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
let dir = getcwd()
try
Expand Down Expand Up @@ -56,7 +56,7 @@ function! ctrlp#decls#accept(mode, str)
endtry
endfunction

function! ctrlp#decls#enter()
function! ctrlp#decls#enter() abort
let s:current_dir = fnameescape(expand('%:p:h'))
let s:decls = []

Expand Down Expand Up @@ -130,7 +130,7 @@ function! ctrlp#decls#enter()
endfor
endfunc

function! s:enable_syntax()
function! s:enable_syntax() abort
if !(has('syntax') && exists('g:syntax_on'))
return
endif
Expand All @@ -148,7 +148,7 @@ endfunction

let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)

function! ctrlp#decls#cmd(mode, ...)
function! ctrlp#decls#cmd(mode, ...) abort
let s:mode = a:mode
if a:0 && !empty(a:1)
let s:target = a:1
Expand Down
2 changes: 1 addition & 1 deletion autoload/go/alternate.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if !exists("g:go_alternate_mode")
endif

" Test alternates between the implementation of code and the test code.
function! go#alternate#Switch(bang, cmd)
function! go#alternate#Switch(bang, cmd) abort
let file = expand('%')
if empty(file)
call go#util#EchoError("no buffer name")
Expand Down
4 changes: 2 additions & 2 deletions autoload/go/asmfmt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let s:got_fmt_error = 0

" This is a trimmed-down version of the logic in fmt.vim.

function! go#asmfmt#Format()
function! go#asmfmt#Format() abort
" Save state.
let l:curw = winsaveview()

Expand Down Expand Up @@ -55,7 +55,7 @@ function! go#asmfmt#Format()
call winrestview(l:curw)
endfunction

function! go#asmfmt#ToggleAsmFmtAutoSave()
function! go#asmfmt#ToggleAsmFmtAutoSave() abort
if get(g:, "go_asmfmt_autosave", 1)
let g:go_asmfmt_autosave = 0
call go#util#EchoProgress("auto asmfmt disabled")
Expand Down
18 changes: 9 additions & 9 deletions autoload/go/cmd.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if !exists("g:go_dispatch_enabled")
let g:go_dispatch_enabled = 0
endif

function! go#cmd#autowrite()
function! go#cmd#autowrite() abort
if &autowrite == 1
silent wall
endif
Expand All @@ -13,7 +13,7 @@ endfunction
" an editor so the best is to build it to catch errors and fix them. By
" default it tries to call simply 'go build', but it first tries to get all
" dependent files for the current folder and passes it to go build.
function! go#cmd#Build(bang, ...)
function! go#cmd#Build(bang, ...) abort
" expand all wildcards(i.e: '%' to the current file name)
let goargs = map(copy(a:000), "expand(v:val)")

Expand Down Expand Up @@ -75,7 +75,7 @@ endfunction


" Run runs the current file (and their dependencies if any) in a new terminal.
function! go#cmd#RunTerm(bang, mode, files)
function! go#cmd#RunTerm(bang, mode, files) abort
if empty(a:files)
let cmd = "go run ". go#util#Shelljoin(go#tool#Files())
else
Expand All @@ -88,7 +88,7 @@ endfunction
" This is intented to test small programs and play with them. It's not
" suitable for long running apps, because vim is blocking by default and
" calling long running apps will block the whole UI.
function! go#cmd#Run(bang, ...)
function! go#cmd#Run(bang, ...) abort
if has('nvim')
call go#cmd#RunTerm(a:bang, '', a:000)
return
Expand Down Expand Up @@ -143,7 +143,7 @@ endfunction
" Install installs the package by simple calling 'go install'. If any argument
" is given(which are passed directly to 'go install') it tries to install those
" packages. Errors are populated in the location window.
function! go#cmd#Install(bang, ...)
function! go#cmd#Install(bang, ...) abort
let old_gopath = $GOPATH
let $GOPATH = go#path#Detect()
let default_makeprg = &makeprg
Expand Down Expand Up @@ -189,7 +189,7 @@ endfunction
" Test runs `go test` in the current directory. If compile is true, it'll
" compile the tests instead of running them (useful to catch errors in the
" test files). Any other argument is appendend to the final `go test` command
function! go#cmd#Test(bang, compile, ...)
function! go#cmd#Test(bang, compile, ...) abort
let args = ["test"]

" don't run the test, only compile it. Useful to capture and fix errors.
Expand Down Expand Up @@ -276,7 +276,7 @@ endfunction

" Testfunc runs a single test that surrounds the current cursor position.
" Arguments are passed to the `go test` command.
function! go#cmd#TestFunc(bang, ...)
function! go#cmd#TestFunc(bang, ...) abort
" search flags legend (used only)
" 'b' search backward instead of forward
" 'c' accept a match at the cursor position
Expand Down Expand Up @@ -304,7 +304,7 @@ function! go#cmd#TestFunc(bang, ...)
endfunction

" Generate runs 'go generate' in similar fashion to go#cmd#Build()
function! go#cmd#Generate(bang, ...)
function! go#cmd#Generate(bang, ...) abort
let default_makeprg = &makeprg

let old_gopath = $GOPATH
Expand Down Expand Up @@ -351,7 +351,7 @@ endfunction
" -----------------------
let s:test_compile_handlers = {}

function! s:test_compile_handler(job, exit_status, data)
function! s:test_compile_handler(job, exit_status, data) abort
if !has_key(s:test_compile_handlers, a:job.id)
return
endif
Expand Down
24 changes: 12 additions & 12 deletions autoload/go/complete.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let s:sock_type = (has('win32') || has('win64')) ? 'tcp' : 'unix'

function! s:gocodeCurrentBuffer()
function! s:gocodeCurrentBuffer() abort
let buf = getline(1, '$')
if &encoding != 'utf-8'
let buf = map(buf, 'iconv(v:val, &encoding, "utf-8")')
Expand All @@ -16,7 +16,7 @@ function! s:gocodeCurrentBuffer()
return file
endfunction

function! s:gocodeCommand(cmd, preargs, args)
function! s:gocodeCommand(cmd, preargs, args) abort
for i in range(0, len(a:args) - 1)
let a:args[i] = go#util#Shellescape(a:args[i])
endfor
Expand Down Expand Up @@ -59,12 +59,12 @@ function! s:gocodeCommand(cmd, preargs, args)
endif
endfunction

function! s:gocodeCurrentBufferOpt(filename)
function! s:gocodeCurrentBufferOpt(filename) abort
return '-in=' . a:filename
endfunction

let s:optionsEnabled = 0
function! s:gocodeEnableOptions()
function! s:gocodeEnableOptions() abort
if s:optionsEnabled
return
endif
Expand All @@ -78,14 +78,14 @@ function! s:gocodeEnableOptions()

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))))
call go#util#System(printf('%s set unimported-packages %s', go#util#Shellescape(bin_path), s:toBool(get(g:, 'go_gocode_unimported_packages', 1))))
call go#util#System(printf('%s set unimported-packages %s', go#util#Shellescape(bin_path), s:toBool(get(g:, 'go_gocode_unimported_packages', 0))))
endfunction

function! s:toBool(val)
function! s:toBool(val) abort
if a:val | return 'true ' | else | return 'false' | endif
endfunction

function! s:gocodeAutocomplete()
function! s:gocodeAutocomplete() abort
call s:gocodeEnableOptions()

let filename = s:gocodeCurrentBuffer()
Expand All @@ -96,7 +96,7 @@ function! s:gocodeAutocomplete()
return result
endfunction

function! go#complete#GetInfo()
function! go#complete#GetInfo() abort
let offset = go#util#OffsetCursor()+1
let filename = s:gocodeCurrentBuffer()
let result = s:gocodeCommand('autocomplete',
Expand Down Expand Up @@ -137,7 +137,7 @@ function! go#complete#GetInfo()
return ""
endfunction

function! go#complete#Info(auto)
function! go#complete#Info(auto) abort
" auto is true if we were called by g:go_auto_type_info's autocmd
let result = go#complete#GetInfo()
if !empty(result)
Expand All @@ -147,12 +147,12 @@ function! go#complete#Info(auto)
endif
endfunction

function! s:trim_bracket(val)
function! s:trim_bracket(val) abort
let a:val.word = substitute(a:val.word, '[(){}\[\]]\+$', '', '')
return a:val
endfunction

function! go#complete#Complete(findstart, base)
function! go#complete#Complete(findstart, base) abort
"findstart = 1 when we need to get the text length
if a:findstart == 1
execute "silent let g:gocomplete_completions = " . s:gocodeAutocomplete()
Expand All @@ -167,7 +167,7 @@ function! go#complete#Complete(findstart, base)
endif
endf

function! go#complete#ToggleAutoTypeInfo()
function! go#complete#ToggleAutoTypeInfo() abort
if get(g:, "go_auto_type_info", 0)
let g:go_auto_type_info = 0
call go#util#EchoProgress("auto type info disabled")
Expand Down
18 changes: 9 additions & 9 deletions autoload/go/coverage.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let s:toggle = 0
" Buffer creates a new cover profile with 'go test -coverprofile' and changes
" the current buffers highlighting to show covered and uncovered sections of
" the code. If run again it clears the annotation.
function! go#coverage#BufferToggle(bang, ...)
function! go#coverage#BufferToggle(bang, ...) abort
if s:toggle
call go#coverage#Clear()
return
Expand All @@ -20,7 +20,7 @@ endfunction
" teh current buffers highlighting to show covered and uncovered sections of
" the code. Calling it again reruns the tests and shows the last updated
" coverage.
function! go#coverage#Buffer(bang, ...)
function! go#coverage#Buffer(bang, ...) abort
" we use matchaddpos() which was introduce with 7.4.330, be sure we have
" it: http://ftp.vim.org/vim/patches/7.4/7.4.330
if !exists("*matchaddpos")
Expand Down Expand Up @@ -75,7 +75,7 @@ function! go#coverage#Buffer(bang, ...)
endfunction

" Clear clears and resets the buffer annotation matches
function! go#coverage#Clear()
function! go#coverage#Clear() abort
" only reset the syntax if the user has syntax enabled
if !empty(&syntax)
if exists("g:syntax_on") | syntax enable | endif
Expand All @@ -93,7 +93,7 @@ endfunction

" Browser creates a new cover profile with 'go test -coverprofile' and opens
" a new HTML coverage page from that profile in a new browser
function! go#coverage#Browser(bang, ...)
function! go#coverage#Browser(bang, ...) abort
let l:tmpname = tempname()
let args = [a:bang, 0, "-coverprofile", l:tmpname]

Expand All @@ -116,7 +116,7 @@ endfunction

" Parses a single line from the cover file generated via go test -coverprofile
" and returns a single coverage profile block.
function! go#coverage#parsegocoverline(line)
function! go#coverage#parsegocoverline(line) abort
" file:startline.col,endline.col numstmt count
let mx = '\([^:]\+\):\(\d\+\)\.\(\d\+\),\(\d\+\)\.\(\d\+\)\s\(\d\+\)\s\(\d\+\)'
let tokens = matchlist(a:line, mx)
Expand All @@ -133,7 +133,7 @@ endfunction

" Generates matches to be added to matchaddpos for the given coverage profile
" block
function! go#coverage#genmatch(cov)
function! go#coverage#genmatch(cov) abort
let color = 'goCoverageCovered'
if a:cov.cnt == 0
let color = 'goCoverageUncover'
Expand Down Expand Up @@ -183,7 +183,7 @@ function! go#coverage#genmatch(cov)
endfunction

" Reads the given coverprofile file and annotates the current buffer
function! go#coverage#overlay(file)
function! go#coverage#overlay(file) abort
if !filereadable(a:file)
return
endif
Expand Down Expand Up @@ -251,7 +251,7 @@ endfunction
let s:coverage_handler_jobs = {}
let s:coverage_browser_handler_jobs = {}

function! s:coverage_handler(job, exit_status, data)
function! s:coverage_handler(job, exit_status, data) abort
if !has_key(s:coverage_handler_jobs, a:job.id)
return
endif
Expand All @@ -264,7 +264,7 @@ function! s:coverage_handler(job, exit_status, data)
unlet s:coverage_handler_jobs[a:job.id]
endfunction

function! s:coverage_browser_handler(job, exit_status, data)
function! s:coverage_browser_handler(job, exit_status, data) abort
if !has_key(s:coverage_browser_handler_jobs, a:job.id)
return
endif
Expand Down
Loading

0 comments on commit c2b4e83

Please sign in to comment.