1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 09:35:01 +08:00

Updated plugins

This commit is contained in:
Amir Salihefendic
2018-11-01 11:03:42 +01:00
parent 44dca49794
commit d2d303593e
105 changed files with 2141 additions and 510 deletions

View File

@ -55,7 +55,15 @@ IMPROVEMENTS:
[[GH-1978]](https://github.com/fatih/vim-go/pull/1978)
* Internal: install tools by their custom names
[[GH-1984]](https://github.com/fatih/vim-go/pull/1984)
* Support the go-debugger features in Neovim.
[[GH-2007]](https://github.com/fatih/vim-go/pull/2007)
* color the statusline for termguicolors and Neovim.
[[GH-2014]](https://github.com/fatih/vim-go/pull/2014)
* add an option to disable highlighting of breakpoints and the current line
when debugging.
[[GH-2025]](https://github.com/fatih/vim-go/pull/2025)
* Update autocompletion to work with Go modules.
[[GH-1988]](https://github.com/fatih/vim-go/pull/1988)
BUG FIXES:
* Fix `:GoRun %` on Windows.
@ -70,6 +78,14 @@ BUG FIXES:
[[GH-1794]](https://github.com/fatih/vim-go/pull/1794)
* Fix `:GoImport` when adding to an empty import block (i.e`import ()`)
[[GH-1938]](https://github.com/fatih/vim-go/pull/1938)
* Run shell commands with shellcmdflag set to `-c`.
[[GH-2006]](https://github.com/fatih/vim-go/pull/2006)
* Use the correct log output option for delve.
[[GH-1992]](https://github.com/fatih/vim-go/pull/1992)
* Pass empty arguments correctly in async jobs on Windows.
[[GH-2011]](https://github.com/fatih/vim-go/pull/2011)
* Don't close godoc scratch window when using arrow keys.
[[GH-2021]](https://github.com/fatih/vim-go/pull/2021)
BACKWARDS INCOMPATIBILITIES:
* Bump minimum required version of Vim to 7.4.2009.
@ -153,8 +169,7 @@ BUG FIXES:
* The `gohtmltmpl` filetype will now highlight `{{ .. }}` syntax HTML attributes
and some other locations.
[[GH-1790]](https://github.com/fatih/vim-go/pull/1790)
* Update using the correct logging flag option that was caused with the recent
delve changes
* Use the correct logging flag argument for delve.
[[GH-1809]](https://github.com/fatih/vim-go/pull/1809)
* Fix gocode option string values that would cause gocode settings not to set
correctly

View File

@ -1,5 +1,20 @@
function! s:gocodeCommand(cmd, args) abort
let bin_path = go#path#CheckBinPath("gocode")
let l:gocode_bin = "gocode"
let l:gomod = go#util#gomod()
if filereadable(l:gomod)
" Save the file when in module mode so that go list can read the
" imports. If the user doesn't have autowrite or autorwriteall enabled,
" they'll need to write the file manually to get reliable results.
" See https://github.com/fatih/vim-go/pull/1988#issuecomment-428576989.
"
" TODO(bc): don't save the file when in module mode once
" golang.org/x/tools/go/packages has support for an overlay and it's used
" by gocode.
call go#cmd#autowrite()
let l:gocode_bin = "gocode-gomod"
endif
let bin_path = go#path#CheckBinPath(l:gocode_bin)
if empty(bin_path)
return []
endif
@ -18,6 +33,10 @@ function! s:gocodeCommand(cmd, args) abort
let cmd = extend(cmd, ['-source'])
endif
if go#config#GocodeUnimportedPackages()
let cmd = extend(cmd, ['-unimported-packages'])
endif
let cmd = extend(cmd, [a:cmd])
let cmd = extend(cmd, a:args)

View File

@ -135,6 +135,10 @@ function! go#config#SetGuruScope(scope) abort
endif
endfunction
function! go#config#GocodeUnimportedPackages() abort
return get(g:, 'go_gocode_unimported_packages', 0)
endfunction
let s:sock_type = (has('win32') || has('win64')) ? 'tcp' : 'unix'
function! go#config#GocodeSocketType() abort
return get(g:, 'go_gocode_socket_type', s:sock_type)
@ -420,6 +424,10 @@ function! go#config#HighlightVariableDeclarations() abort
return get(g:, 'go_highlight_variable_declarations', 0)
endfunction
function! go#config#HighlightDebug() abort
return get(g:, 'go_highlight_debug', 1)
endfunction
function! go#config#FoldEnable(...) abort
if a:0 > 0
return index(go#config#FoldEnable(), a:1) > -1

View File

@ -29,6 +29,11 @@ function! s:complete(job, exit_status, data) abort
if has_key(s:state, 'job')
call remove(s:state, 'job')
endif
if has_key(s:state, 'ready')
call remove(s:state, 'ready')
endif
call s:clearState()
if a:exit_status > 0
call go#util#EchoError(s:state['message'])
@ -66,7 +71,6 @@ function! s:call_jsonrpc(method, ...) abort
let Cb = a:000[0]
let args = a:000[1:]
else
let Cb = v:none
let args = a:000
endif
let s:state['rpcid'] += 1
@ -78,9 +82,26 @@ function! s:call_jsonrpc(method, ...) abort
try
" Use callback
if type(Cb) == v:t_func
let s:ch = ch_open('127.0.0.1:8181', {'mode': 'nl', 'callback': Cb})
call ch_sendraw(s:ch, req_json)
if exists('l:Cb')
if has('nvim')
let state = {'callback': Cb}
function! state.on_data(ch, msg, event) abort
call self.state.callback(a:ch, a:msg)
endfunction
let l:ch = sockconnect('tcp', go#config#DebugAddress(), {'on_data': state.on_data, 'state': state})
call chansend(l:ch, req_json)
if go#util#HasDebug('debugger-commands')
let g:go_debug_commands = add(g:go_debug_commands, {
\ 'request': req_json,
\ 'response': Cb,
\ })
endif
return
endif
let l:ch = ch_open(go#config#DebugAddress(), {'mode': 'nl', 'callback': Cb})
call ch_sendraw(l:ch, req_json)
if go#util#HasDebug('debugger-commands')
let g:go_debug_commands = add(g:go_debug_commands, {
@ -91,9 +112,23 @@ function! s:call_jsonrpc(method, ...) abort
return
endif
let ch = ch_open('127.0.0.1:8181', {'mode': 'nl', 'timeout': 20000})
call ch_sendraw(ch, req_json)
let resp_json = ch_readraw(ch)
if has('nvim')
let state = {'done': 0}
function! state.on_data(ch, msg, event) abort
let self.state.resp = a:msg
let self.state.done = 1
endfunction
let l:ch = sockconnect('tcp', go#config#DebugAddress(), {'on_data': state.on_data, 'state': state})
call chansend(l:ch, req_json)
while state.done == 0
sleep 50m
endwhile
let resp_json = state.resp
else
let ch = ch_open(go#config#DebugAddress(), {'mode': 'raw', 'timeout': 20000})
call ch_sendraw(ch, req_json)
let resp_json = ch_readraw(ch)
endif
if go#util#HasDebug('debugger-commands')
let g:go_debug_commands = add(g:go_debug_commands, {
@ -115,7 +150,7 @@ endfunction
" Update the location of the current breakpoint or line we're halted on based on
" response from dlv.
function! s:update_breakpoint(res) abort
if type(a:res) ==# v:t_none
if type(a:res) ==# type(v:null)
return
endif
@ -216,11 +251,17 @@ function! s:clearState() abort
endfunction
function! s:stop() abort
" TODO(bc): call Detach
call go#job#Stop(s:state['job'])
call s:clearState()
if has_key(s:state, 'job')
call job_stop(s:state['job'])
call remove(s:state, 'job')
endif
if has_key(s:state, 'ready')
call remove(s:state, 'ready')
endif
endfunction
function! go#debug#Stop() abort
@ -257,8 +298,10 @@ function! go#debug#Stop() abort
silent! exe bufwinnr(bufnr('__GODEBUG_VARIABLES__')) 'wincmd c'
silent! exe bufwinnr(bufnr('__GODEBUG_OUTPUT__')) 'wincmd c'
set noballooneval
set balloonexpr=
if has('balloon_eval')
set noballooneval
set balloonexpr=
endif
augroup vim-go-debug
autocmd!
@ -453,8 +496,10 @@ function! s:start_cb(ch, json) abort
nnoremap <silent> <Plug>(go-debug-stop) :<C-u>call go#debug#Stop()<CR>
nnoremap <silent> <Plug>(go-debug-print) :<C-u>call go#debug#Print(expand('<cword>'))<CR>
set balloonexpr=go#debug#BalloonExpr()
set ballooneval
if has('balloon_eval')
set balloonexpr=go#debug#BalloonExpr()
set ballooneval
endif
exe bufwinnr(oldbuf) 'wincmd w'
@ -470,20 +515,29 @@ function! s:start_cb(ch, json) abort
endfunction
function! s:err_cb(ch, msg) abort
if get(s:state, 'ready', 0) != 0
call call('s:logger', ['ERR: ', a:ch, a:msg])
return
endif
call go#util#EchoError(a:msg)
let s:state['message'] += [a:msg]
endfunction
function! s:out_cb(ch, msg) abort
if get(s:state, 'ready', 0) != 0
call call('s:logger', ['OUT: ', a:ch, a:msg])
return
endif
call go#util#EchoProgress(a:msg)
let s:state['message'] += [a:msg]
" TODO: why do this in this callback?
if stridx(a:msg, go#config#DebugAddress()) != -1
call ch_setoptions(a:ch, {
\ 'out_cb': function('s:logger', ['OUT: ']),
\ 'err_cb': function('s:logger', ['ERR: ']),
\})
" After this block executes, Delve will be running with all the
" breakpoints setup, so this callback doesn't have to run again; just log
" future messages.
let s:state['ready'] = 1
" Tell dlv about the breakpoints that the user added before delve started.
let l:breaks = copy(s:state.breakpoint)
@ -501,17 +555,13 @@ endfunction
function! go#debug#Start(is_test, ...) abort
call go#cmd#autowrite()
if has('nvim')
call go#util#EchoError('This feature only works in Vim for now; Neovim is not (yet) supported. Sorry :-(')
return
endif
if !go#util#has_job()
call go#util#EchoError('This feature requires Vim 8.0.0087 or newer with +job.')
call go#util#EchoError('This feature requires either Vim 8.0.0087 or newer with +job or Neovim.')
return
endif
" It's already running.
if has_key(s:state, 'job') && job_status(s:state['job']) == 'run'
if has_key(s:state, 'job')
return
endif
@ -556,7 +606,7 @@ function! go#debug#Start(is_test, ...) abort
\ '--output', tempname(),
\ '--headless',
\ '--api-version', '2',
\ '--log', 'debugger',
\ '--log', '--log-output', 'debugger,rpc',
\ '--listen', go#config#DebugAddress(),
\ '--accept-multiclient',
\]
@ -807,10 +857,7 @@ function! go#debug#Restart() abort
call go#cmd#autowrite()
try
call job_stop(s:state['job'])
while has_key(s:state, 'job') && job_status(s:state['job']) is# 'run'
sleep 50m
endwhile
call go#job#Stop(s:state['job'])
let l:breaks = s:state['breakpoint']
let s:state = {
@ -857,7 +904,7 @@ function! go#debug#Breakpoint(...) abort
try
" Check if we already have a breakpoint for this line.
let found = v:none
let found = {}
for k in keys(s:state.breakpoint)
let bt = s:state.breakpoint[k]
if bt.file == l:filename && bt.line == linenr
@ -867,7 +914,7 @@ function! go#debug#Breakpoint(...) abort
endfor
" Remove breakpoint.
if type(found) == v:t_dict
if type(found) == v:t_dict && !empty(found)
call remove(s:state['breakpoint'], bt.id)
exe 'sign unplace '. found.id .' file=' . found.file
if s:isActive()

View File

@ -122,9 +122,12 @@ function! s:GodocView(newposition, position, content) abort
setlocal nomodifiable
sil normal! gg
" close easily with <esc> or enter
" close easily with enter
noremap <buffer> <silent> <CR> :<C-U>close<CR>
noremap <buffer> <silent> <Esc> :<C-U>close<CR>
" make sure any key that sends an escape as a prefix (e.g. the arrow keys)
" don't cause the window to close.
nnoremap <buffer> <silent> <Esc>[ <Esc>[
endfunction
function! s:gogetdoc(json) abort

View File

@ -0,0 +1,95 @@
function! Test_gomodVersion_highlight() abort
try
syntax on
let l:dir= gotest#write_file('gomodtest/go.mod', [
\ 'module github.com/fatih/vim-go',
\ '',
\ '\x1frequire (',
\ '\tversion/simple v1.0.0',
\ '\tversion/pseudo/premajor v1.0.0-20060102150405-0123456789abcdef',
\ '\tversion/pseudo/prerelease v1.0.0-prerelease.0.20060102150405-0123456789abcdef',
\ '\tversion/pseudo/prepatch v1.0.1-0.20060102150405-0123456789abcdef',
\ '\tversion/simple/incompatible v2.0.0+incompatible',
\ '\tversion/pseudo/premajor/incompatible v2.0.0-20060102150405-0123456789abcdef+incompatible',
\ '\tversion/pseudo/prerelease/incompatible v2.0.0-prerelease.0.20060102150405-0123456789abcdef+incompatible',
\ '\tversion/pseudo/prepatch/incompatible v2.0.1-0.20060102150405-0123456789abcdef+incompatible',
\ ')'])
let l:lineno = 4
let l:lineclose = line('$')
while l:lineno < l:lineclose
let l:line = getline(l:lineno)
let l:col = col([l:lineno, '$']) - 1
let l:idx = len(l:line) - 1
let l:from = stridx(l:line, ' ') + 1
while l:idx >= l:from
call cursor(l:lineno, l:col)
let l:synname = synIDattr(synID(l:lineno, l:col, 1), 'name')
let l:errlen = len(v:errors)
call assert_equal('gomodVersion', l:synname, 'version on line ' . l:lineno)
" continue at the next line if there was an error at this column;
" there's no need to test each column once an error is detected.
if l:errlen < len(v:errors)
break
endif
let l:col -= 1
let l:idx -= 1
endwhile
let l:lineno += 1
endwhile
finally
call delete(l:dir, 'rf')
endtry
endfunc
function! Test_gomodVersion_incompatible_highlight() abort
try
syntax on
let l:dir= gotest#write_file('gomodtest/go.mod', [
\ 'module github.com/fatih/vim-go',
\ '',
\ '\x1frequire (',
\ '\tversion/invalid/incompatible v1.0.0+incompatible',
\ '\tversion/invalid/premajor/incompatible v1.0.0-20060102150405-0123456789abcdef+incompatible',
\ '\tversion/invalid/prerelease/incompatible v1.0.0-prerelease.0.20060102150405-0123456789abcdef+incompatible',
\ '\tversion/invalid/prepatch/incompatible v1.0.1-0.20060102150405-0123456789abcdef+incompatible',
\ ')'])
let l:lineno = 4
let l:lineclose = line('$')
while l:lineno < l:lineclose
let l:line = getline(l:lineno)
let l:col = col([l:lineno, '$']) - 1
let l:idx = len(l:line) - 1
let l:from = stridx(l:line, '+')
while l:idx >= l:from
call cursor(l:lineno, l:col)
let l:synname = synIDattr(synID(l:lineno, l:col, 1), 'name')
let l:errlen = len(v:errors)
call assert_notequal('gomodVersion', l:synname, 'version on line ' . l:lineno)
" continue at the next line if there was an error at this column;
" there's no need to test each column once an error is detected.
if l:errlen < len(v:errors)
break
endif
let l:col -= 1
let l:idx -= 1
endwhile
let l:lineno += 1
endwhile
finally
call delete(l:dir, 'rf')
endtry
endfunc
" vim: sw=2 ts=2 et

View File

@ -1,4 +1,7 @@
func! Test_indent_raw_string() abort
" The goRawString discovery requires that syntax be enabled.
syntax on
try
let l:dir= gotest#write_file('indent/indent.go', [
\ 'package main',
@ -17,6 +20,43 @@ func! Test_indent_raw_string() abort
finally
call delete(l:dir, 'rf')
endtry
endfunc
" vim: sw=2 ts=2 et
try
let l:dir= gotest#write_file('indent/indent.go', [
\ 'package main',
\ '',
\ 'import "fmt"',
\ '',
\ 'func main() {',
\ "\t\x1fmsg := `",
\ '`',
\ '\tfmt.Println(msg)',
\ '}'])
silent execute "normal o" . "not indented\<Esc>"
let l:indent = indent(line('.'))
call assert_equal(0, l:indent)
finally
call delete(l:dir, 'rf')
endtry
try
let l:dir= gotest#write_file('indent/indent.go', [
\ 'package main',
\ '',
\ 'import "fmt"',
\ '',
\ 'func main() {',
\ "\tconst msg = `",
\ "\t\x1findented",
\ '`',
\ '\tfmt.Println(msg)',
\ '}'])
silent execute "normal o" . "indented\<Esc>"
let l:indent = indent(line('.'))
call assert_equal(shiftwidth(), l:indent)
finally
call delete(l:dir, 'rf')
endtry
endfunc

View File

@ -293,6 +293,10 @@ function! go#job#Start(cmd, options)
unlet l:options._start
endif
if go#util#HasDebug('shell-commands')
call go#util#EchoInfo('job command: ' . string(a:cmd))
endif
if has('nvim')
let l:input = []
if has_key(a:options, 'in_io') && a:options.in_io ==# 'file' && !empty(a:options.in_name)
@ -307,7 +311,12 @@ function! go#job#Start(cmd, options)
call chanclose(job, 'stdin')
endif
else
let job = job_start(a:cmd, l:options)
let l:cmd = a:cmd
if go#util#IsWin()
let l:cmd = join(map(copy(a:cmd), function('s:winjobarg')), " ")
endif
let job = job_start(l:cmd, l:options)
endif
if !has_key(l:options, 'cwd')
@ -501,4 +510,33 @@ function! s:neooptions(options)
return l:options
endfunction
function! go#job#Stop(job) abort
if has('nvim')
call jobstop(a:job)
return
endif
call job_stop(a:job)
call go#job#Wait(a:job)
return
endfunction
function! go#job#Wait(job) abort
if has('nvim')
call jobwait(a:job)
return
endif
while job_status(a:job) is# 'run'
sleep 50m
endwhile
endfunction
function! s:winjobarg(idx, val) abort
if empty(a:val)
return '""'
endif
return a:val
endfunction
" vim: sw=2 ts=2 et

View File

@ -3,7 +3,7 @@ let s:go_major_version = ""
function! go#mod#Format() abort
" go mod only exists in `v1.11`
if empty(s:go_major_version)
let tokens = matchlist(go#util#System("go version"), '\d\+.\(\d\+\) ')
let tokens = matchlist(go#util#System("go version"), '\d\+.\(\d\+\)\(\.\d\+\)\? ')
let s:go_major_version = str2nr(tokens[1])
endif

View File

@ -54,11 +54,11 @@ function! go#statusline#Show() abort
" only update highlight if status has changed.
if status_text != s:last_status
if status.state =~ "success" || status.state =~ "finished" || status.state =~ "pass"
hi goStatusLineColor cterm=bold ctermbg=76 ctermfg=22
hi goStatusLineColor cterm=bold ctermbg=76 ctermfg=22 guibg=#5fd700 guifg=#005f00
elseif status.state =~ "started" || status.state =~ "analysing" || status.state =~ "compiling"
hi goStatusLineColor cterm=bold ctermbg=208 ctermfg=88
hi goStatusLineColor cterm=bold ctermbg=208 ctermfg=88 guibg=#ff8700 guifg=#870000
elseif status.state =~ "failed"
hi goStatusLineColor cterm=bold ctermbg=196 ctermfg=52
hi goStatusLineColor cterm=bold ctermbg=196 ctermfg=52 guibg=#ff0000 guifg=#5f0000
endif
endif

View File

@ -127,6 +127,13 @@ function! go#util#gopath() abort
return substitute(s:exec(['go', 'env', 'GOPATH'])[0], '\n', '', 'g')
endfunction
" gomod returns 'go env GOMOD'. gomod changes depending on the folder. Don't
" use go#util#env as it caches the value.
function! go#util#gomod() abort
return substitute(s:exec(['go', 'env', 'GOMOD'])[0], '\n', '', 'g')
endfunction
function! go#util#osarch() abort
return go#util#env("goos") . '_' . go#util#env("goarch")
endfunction
@ -137,12 +144,13 @@ endfunction
" so that we always use a standard POSIX-compatible Bourne shell (and not e.g.
" csh, fish, etc.) See #988 and #1276.
function! s:system(cmd, ...) abort
" Preserve original shell and shellredir values
" Preserve original shell, shellredir and shellcmdflag values
let l:shell = &shell
let l:shellredir = &shellredir
let l:shellcmdflag = &shellcmdflag
if !go#util#IsWin() && executable('/bin/sh')
set shell=/bin/sh shellredir=>%s\ 2>&1
set shell=/bin/sh shellredir=>%s\ 2>&1 shellcmdflag=-c
endif
try
@ -151,6 +159,7 @@ function! s:system(cmd, ...) abort
" Restore original values
let &shell = l:shell
let &shellredir = l:shellredir
let &shellcmdflag = l:shellcmdflag
endtry
endfunction

View File

@ -148,9 +148,6 @@ The following plugins are supported for use with vim-go:
https://github.com/SirVer/ultisnips or
https://github.com/joereynolds/vim-minisnip
* For a better documentation viewer check out:
https://github.com/garyburd/go-explorer
* Integration with `delve` (Neovim only):
https://github.com/jodosha/vim-godebug
@ -1614,6 +1611,14 @@ package and packages that have been installed will proposed.
>
let g:go_gocode_propose_source = 1
<
*'g:go_gocode_unimported_packages'*
Specifies whether `gocode` should include suggestions from unimported
packages. By default it is disabled.
>
let g:go_gocode_unimported_packages = 0
<
*'g:go_gocode_socket_type'*
Specifies whether `gocode` should use a different socket type. By default
@ -1902,7 +1907,7 @@ The `gohtmltmpl` filetype is automatically set for `*.tmpl` files; the
*gomod* *ft-gomod-syntax*
go.mod file syntax~
The `gomod` 'filetype' provides syntax highlighting for Go's module file
The `gomod` 'filetype' provides syntax highlighting for Go's module file
`go.mod`
@ -1924,10 +1929,10 @@ features:
* Toggle breakpoint.
* Stack operation continue/next/step out.
This feature requires Vim 8.0.0087 or newer with the |+job| feature. Neovim
does _not_ work (yet).
This requires Delve 1.0.0 or newer, and it is recommended to use Go 1.10 or
newer, as its new caching will speed up recompiles.
This feature requires either Vim 8.0.0087 or newer with the |+job| feature or
Neovim. This features also requires Delve 1.0.0 or newer, and it is
recommended to use Go 1.10 or newer, as its new caching will speed up
recompiles.
*go-debug-intro*
GETTING STARTED WITH THE DEBUGGER~
@ -2112,6 +2117,14 @@ Defaults to `127.0.0.1:8181`:
let g:go_debug_address = '127.0.0.1:8181'
<
*'g:go_highlight_debug'*
Highlight the current line and breakpoints in the debugger.
>
let g:go_highlight_debug = 1
<
==============================================================================
FAQ TROUBLESHOOTING *go-troubleshooting*

View File

@ -31,6 +31,11 @@ au BufReadPost *.s call s:gofiletype_post()
au BufRead,BufNewFile *.tmpl set filetype=gohtmltmpl
" remove the autocommands for modsim3, and lprolog files so that their
" highlight groups, syntax, etc. will not be loaded. *.MOD is included, so
" that on case insensitive file systems the module2 autocmds will not be
" executed.
au! BufNewFile,BufRead *.mod,*.MOD
" Set the filetype if the first non-comment and non-blank line starts with
" 'module <path>'.
au BufNewFile,BufRead go.mod call s:gomod()

View File

@ -24,7 +24,7 @@ if exists("*GoIndent")
finish
endif
function! GoIndent(lnum)
function! GoIndent(lnum) abort
let prevlnum = prevnonblank(a:lnum-1)
if prevlnum == 0
" top of file
@ -38,10 +38,17 @@ function! GoIndent(lnum)
let ind = previ
if prevl =~ ' = `[^`]*$'
" previous line started a multi-line raw string
return 0
endif
for synid in synstack(a:lnum, 1)
if synIDattr(synid, 'name') == 'goRawString'
if prevl =~ '\%(\%(:\?=\)\|(\|,\)\s*`[^`]*$'
" previous line started a multi-line raw string
return 0
endif
" return -1 to keep the current indent.
return -1
endif
endfor
if prevl =~ '[({]\s*$'
" previous line opened a block
let ind += shiftwidth()

View File

@ -47,10 +47,11 @@ let s:packages = {
\ 'errcheck': ['github.com/kisielk/errcheck'],
\ 'fillstruct': ['github.com/davidrjenni/reftools/cmd/fillstruct'],
\ 'gocode': ['github.com/mdempsky/gocode', {'windows': ['-ldflags', '-H=windowsgui']}],
\ 'gocode-gomod': ['github.com/stamblerre/gocode'],
\ 'godef': ['github.com/rogpeppe/godef'],
\ 'gogetdoc': ['github.com/zmb3/gogetdoc'],
\ 'goimports': ['golang.org/x/tools/cmd/goimports'],
\ 'golint': ['github.com/golang/lint/golint'],
\ 'golint': ['golang.org/x/lint/golint'],
\ 'gometalinter': ['github.com/alecthomas/gometalinter'],
\ 'gomodifytags': ['github.com/fatih/gomodifytags'],
\ 'gorename': ['golang.org/x/tools/cmd/gorename'],

View File

@ -374,8 +374,10 @@ function! s:hi()
hi def goCoverageUncover ctermfg=red guifg=#F92672
" :GoDebug commands
hi GoDebugBreakpoint term=standout ctermbg=117 ctermfg=0 guibg=#BAD4F5 guifg=Black
hi GoDebugCurrent term=reverse ctermbg=12 ctermfg=7 guibg=DarkBlue guifg=White
if go#config#HighlightDebug()
hi GoDebugBreakpoint term=standout ctermbg=117 ctermfg=0 guibg=#BAD4F5 guifg=Black
hi GoDebugCurrent term=reverse ctermbg=12 ctermfg=7 guibg=DarkBlue guifg=White
endif
endfunction
augroup vim-go-hi

View File

@ -37,10 +37,26 @@ syntax match gomodReplaceOperator "\v\=\>"
highlight default link gomodReplaceOperator Operator
" highlight semver, note that this is very simple. But it works for now
syntax match gomodVersion "v\d\+\.\d\+\.\d\+"
syntax match gomodVersion "v\d\+\.\d\+\.\d\+-\S*"
syntax match gomodVersion "v\d\+\.\d\+\.\d\++incompatible"
" highlight versions:
" * vX.Y.Z
" * vX.0.0-yyyyymmddhhmmss-abcdefabcdef
" * vX.Y.Z-pre.0.yyyymmddhhmmss-abcdefabcdef
" * vX.Y.(Z+1)-0.yyyymmddhhss-abcdefabcdef
" * +incompatible suffix when X > 1
" match vX.Y.Z and their prereleases
syntax match gomodVersion "v\d\+\.\d\+\.\d\+\%(-\%(\w\+\.\)\+0\.\d\{14}-\x\+\)\?"
" match target when most recent version before the target is X.Y.Z
syntax match gomodVersion "v\d\+\.\d\+\.[1-9]\{1}\d*\%(-0\.\%(\d\{14}-\x\+\)\)\?"
" match target without a major version before the commit (e.g. vX.0.0-yyyymmddhhmmss-abcdefabcdef)
syntax match gomodVersion "v\d\+\.0\.0-\d\{14\}-\x\+"
" match vX.Y.Z and their prereleases for X>1
syntax match gomodVersion "v[2-9]\{1}\d\?\.\d\+\.\d\+\%(-\%(\w\+\.\)\+0\.\d\{14\}-\x\+\)\?\%(+incompatible\>\)\?"
" match target when most recent version before the target is X.Y.Z for X>1
syntax match gomodVersion "v[2-9]\{1}\d\?\.\d\+\.[1-9]\{1}\d*\%(-0\.\%(\d\{14\}-\x\+\)\)\?\%(+incompatible\>\)\?"
" match target without a major version before the commit (e.g. vX.0.0-yyyymmddhhmmss-abcdefabcdef) for X>1
syntax match gomodVersion "v[2-9]\{1}\d\?\.0\.0-\d\{14\}-\x\+\%(+incompatible\>\)\?"
highlight default link gomodVersion Identifier
let b:current_syntax = "gomod"