mirror of
1
0
Fork 0

Updated plugins

This commit is contained in:
amix 2016-04-12 09:31:09 +01:00
parent ad875b0e0a
commit 5f6aa8fe09
54 changed files with 1236 additions and 291 deletions

View File

@ -1,14 +1,15 @@
==== ack.vim quick help ===============
*?:* Show/quit this help
*t:* Open in a new tab
*T:* Open in a new tab silently
*o:* Open
*O:* Open and close result window
*go:* Preview
*h:* Horizontal open
*H:* Horizontal open silently
*v:* Vertical open
*gv:* Vertical open silently
*?:* a quick summary of these keys, repeat to close
*o:* to open (same as Enter)
*O:* to open and close the quickfix window
*go:* to preview file, open but maintain focus on ack.vim results
*t:* to open in new tab
*T:* to open in new tab without moving to it
*h:* to open in horizontal split
*H:* to open in horizontal split, keeping focus on the results
*v:* to open in vertical split
*gv:* to open in vertical split, keeping focus on the results
*q:* to close the quickfix window
========================================

View File

@ -161,6 +161,8 @@ function! s:maps_resize()
return mapped
endfunction
nnoremap <silent> <plug>(goyo-resize) :<c-u>call <sid>resize_pads()<cr>
function! s:goyo_on(dim)
let dim = s:parse_arg(a:dim)
if empty(dim)
@ -263,6 +265,9 @@ function! s:goyo_on(dim)
autocmd ColorScheme * call s:tranquilize()
autocmd BufWinEnter * call s:hide_linenr() | call s:hide_statusline()
autocmd WinEnter,WinLeave * call s:hide_statusline()
if has('nvim')
autocmd TermClose * call feedkeys("\<plug>(goyo-resize)")
endif
augroup END
call s:hide_statusline()

View File

@ -190,7 +190,7 @@ let g:syntastic_check_on_wq = 0
__4.1. Q. I installed syntastic but it isn't reporting any errors...__
A. The most likely reason is that none of the syntax checkers that it requires
is installed. For example: by default, python requires either `flake8` or
are installed. For example: by default, python requires either `flake8` or
`pylint` to be installed and in your `$PATH`. To see which executables are
supported, look at the [wiki][3]. Note that aliases do not work; the actual
executables must be available in your `$PATH`. Symbolic links are okay though.

View File

@ -227,12 +227,12 @@ function! syntastic#preprocess#prospector(errors) abort " {{{2
call add(out, msg)
catch /\m^Vim\%((\a\+)\)\=:E716/
call syntastic#log#warn('checker python/prospector: unrecognized error format')
call syntastic#log#warn('checker python/prospector: unrecognized error item ' . string(e))
let out = []
break
endtry
else
call syntastic#log#warn('checker python/prospector: unrecognized error format')
call syntastic#log#warn('checker python/prospector: unrecognized error item ' . string(e))
let out = []
break
endif
@ -394,12 +394,12 @@ function! syntastic#preprocess#vint(errors) abort " {{{2
call add(out, msg)
catch /\m^Vim\%((\a\+)\)\=:E716/
call syntastic#log#warn('checker vim/vint: unrecognized error format')
call syntastic#log#warn('checker vim/vint: unrecognized error item ' . string(e))
let out = []
break
endtry
else
call syntastic#log#warn('checker vim/vint: unrecognized error format')
call syntastic#log#warn('checker vim/vint: unrecognized error item ' . string(e))
let out = []
break
endif

View File

@ -334,6 +334,12 @@ function! syntastic#util#stamp() abort " {{{2
return split( split(reltimestr(reltime(g:_SYNTASTIC_START)))[0], '\.' )
endfunction " }}}2
function! syntastic#util#setChangedtick() abort " {{{2
unlockvar! b:syntastic_changedtick
let b:syntastic_changedtick = b:changedtick
lockvar! b:syntastic_changedtick
endfunction " }}}2
let s:_wid_base = 'syntastic_' . getpid() . '_' . reltimestr(g:_SYNTASTIC_START) . '_'
let s:_wid_pool = 0

View File

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START
endif
let g:_SYNTASTIC_VERSION = '3.7.0-106'
let g:_SYNTASTIC_VERSION = '3.7.0-112'
lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1
@ -94,7 +94,7 @@ let g:_SYNTASTIC_DEFAULTS = {
\ 'loc_list_height': 10,
\ 'nested_autocommands': 0,
\ 'quiet_messages': {},
\ 'reuse_loc_lists': 0,
\ 'reuse_loc_lists': 1,
\ 'shell': &shell,
\ 'sort_aggregated_errors': 1,
\ 'stl_format': '[Syntax: line:%F (%t)]',
@ -292,7 +292,7 @@ function! s:BufEnterHook() abort " {{{2
let loclist = filter(copy(getloclist(0)), 'v:val["valid"] == 1')
let owner = str2nr(getbufvar(bufnr(''), 'syntastic_owner_buffer'))
let buffers = syntastic#util#unique(map(loclist, 'v:val["bufnr"]') + (owner ? [owner] : []))
if get(w:, 'syntastic_loclist_set', 0) && !empty(loclist) && empty(filter( buffers, 'syntastic#util#bufIsActive(v:val)' ))
if !empty(get(w:, 'syntastic_loclist_set', [])) && !empty(loclist) && empty(filter( buffers, 'syntastic#util#bufIsActive(v:val)' ))
call SyntasticLoclistHide()
endif
endif
@ -307,7 +307,7 @@ function! s:QuitPreHook(fname) abort " {{{2
call add(s:_quit_pre, buf . '_' . getbufvar(buf, 'changetick') . '_' . w:syntastic_wid)
endif
if get(w:, 'syntastic_loclist_set', 0)
if !empty(get(w:, 'syntastic_loclist_set', []))
call SyntasticLoclistHide()
endif
endfunction " }}}2
@ -333,9 +333,7 @@ function! s:UpdateErrors(auto_invoked, checker_names) abort " {{{2
let run_checks = !a:auto_invoked || s:modemap.doAutoChecking()
if run_checks
call s:CacheErrors(a:checker_names)
unlockvar! b:syntastic_changedtick
let b:syntastic_changedtick = b:changedtick
lockvar! b:syntastic_changedtick
call syntastic#util#setChangedtick()
else
if a:auto_invoked
return
@ -358,11 +356,14 @@ function! s:UpdateErrors(auto_invoked, checker_names) abort " {{{2
let do_jump = 0
endif
let w:syntastic_loclist_set = 0
let w:syntastic_loclist_set = []
if syntastic#util#var('always_populate_loc_list') || do_jump
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: setloclist (new)')
call setloclist(0, loclist.getRaw())
let w:syntastic_loclist_set = 1
if !exists('b:syntastic_changedtick')
call syntastic#util#setChangedtick()
endif
let w:syntastic_loclist_set = [bufnr(''), b:syntastic_changedtick]
if run_checks && do_jump && !loclist.isEmpty()
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: jump')
execute 'silent! lrewind ' . do_jump

View File

@ -291,12 +291,15 @@ endfunction " }}}2
function! g:SyntasticLoclist.setloclist() abort " {{{2
if !exists('w:syntastic_loclist_set')
let w:syntastic_loclist_set = 0
let w:syntastic_loclist_set = []
endif
if empty(w:syntastic_loclist_set) || w:syntastic_loclist_set != [bufnr(''), b:changedtick]
let replace = g:syntastic_reuse_loc_lists && !empty(w:syntastic_loclist_set)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: setloclist ' . (replace ? '(replace)' : '(new)'))
call setloclist(0, self.getRaw(), replace ? 'r' : ' ')
call syntastic#util#setChangedtick()
let w:syntastic_loclist_set = [bufnr(''), b:syntastic_changedtick]
endif
let replace = g:syntastic_reuse_loc_lists && w:syntastic_loclist_set
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: setloclist ' . (replace ? '(replace)' : '(new)'))
call setloclist(0, self.getRaw(), replace ? 'r' : ' ')
let w:syntastic_loclist_set = 1
endfunction " }}}2
"display the cached errors for this buf in the location list

View File

@ -24,22 +24,28 @@ if !exists('g:syntastic_d_compiler_options')
let g:syntastic_d_compiler_options = ''
endif
if !exists('g:syntastic_d_use_dub')
let g:syntastic_d_use_dub = 1
endif
if !exists('g:syntastic_d_dub_exec')
let g:syntastic_d_dub_exec = 'dub'
endif
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_d_dmd_IsAvailable() dict
function! SyntaxCheckers_d_dmd_IsAvailable() dict " {{{1
if !exists('g:syntastic_d_compiler')
let g:syntastic_d_compiler = self.getExec()
endif
call self.log('g:syntastic_d_compiler =', g:syntastic_d_compiler)
return executable(expand(g:syntastic_d_compiler, 1))
endfunction
endfunction " }}}1
function! SyntaxCheckers_d_dmd_GetLocList() dict
function! SyntaxCheckers_d_dmd_GetLocList() dict " {{{1
if !exists('g:syntastic_d_include_dirs')
let g:syntastic_d_include_dirs = filter(glob($HOME . '/.dub/packages/*', 1, 1), 'isdirectory(v:val)')
call map(g:syntastic_d_include_dirs, 'isdirectory(v:val . "/source") ? v:val . "/source" : v:val')
call add(g:syntastic_d_include_dirs, './source')
let g:syntastic_d_include_dirs = s:GetIncludes(self, expand('%:p:h'))
endif
return syntastic#c#GetLocList('d', 'dmd', {
@ -48,7 +54,73 @@ function! SyntaxCheckers_d_dmd_GetLocList() dict
\ '%f:%l: %m',
\ 'main_flags': '-c -of' . syntastic#util#DevNull(),
\ 'header_names': '\m\.di$' })
endfunction
endfunction " }}}1
" Utilities {{{1
function! s:GetIncludes(checker, base) " {{{2
let includes = []
if g:syntastic_d_use_dub && !exists('s:dub_ok')
let s:dub_ok = s:ValidateDub(a:checker)
endif
if g:syntastic_d_use_dub && s:dub_ok
let where = escape(a:base, ' ') . ';'
let old_suffixesadd = &suffixesadd
let dirs = syntastic#util#unique(map(filter(
\ findfile('dub.json', where, -1) +
\ findfile('dub.sdl', where, -1) +
\ findfile('package.json', where, -1),
\ 'filereadable(v:val)'), 'fnamemodify(v:val, ":h")'))
let &suffixesadd = old_suffixesadd
call a:checker.log('using dub: looking for includes in', dirs)
for dir in dirs
try
execute 'silent lcd ' . fnameescape(dir)
let paths = split(syntastic#util#system(syntastic#util#shescape(g:syntastic_d_dub_exec) . ' describe --import-paths'), "\n")
silent lcd -
if v:shell_error == 0
call extend(includes, paths)
call a:checker.log('using dub: found includes', paths)
endif
catch /\m^Vim\%((\a\+)\)\=:E472/
" evil directory is evil
endtry
endfor
endif
if empty(includes)
let includes = filter(glob($HOME . '/.dub/packages/*', 1, 1), 'isdirectory(v:val)')
call map(includes, 'isdirectory(v:val . "/source") ? v:val . "/source" : v:val')
call add(includes, './source')
endif
return syntastic#util#unique(includes)
endfunction " }}}2
function! s:ValidateDub(checker) " {{{2
let ok = 0
if executable(g:syntastic_d_dub_exec)
let command = syntastic#util#shescape(g:syntastic_d_dub_exec) . ' --version'
let version_output = syntastic#util#system(command)
call a:checker.log('getVersion: ' . string(command) . ': ' .
\ string(split(version_output, "\n", 1)) .
\ (v:shell_error ? ' (exit code ' . v:shell_error . ')' : '') )
let parsed_ver = syntastic#util#parseVersion(version_output)
call a:checker.log(g:syntastic_d_dub_exec . ' version =', parsed_ver)
if len(parsed_ver)
let ok = syntastic#util#versionIsAtLeast(parsed_ver, [0, 9, 24])
endif
endif
return ok
endfunction " }}}2
" }}}1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'd',

View File

@ -16,25 +16,25 @@ let s:gui0D = "#0d61ac"
let s:gui0E = "#c594c5"
let s:gui0F = "#ab7967"
let s:cterm00 = "234"
let s:cterm00 = "233"
let s:cterm01 = "235"
let s:cterm02 = "239"
let s:cterm03 = "59"
let s:cterm02 = "59"
let s:cterm03 = "66"
let s:cterm04 = "145"
let s:cterm05 = "152"
let s:cterm06 = "188"
let s:cterm07 = "15"
let s:cterm07 = "189"
let s:cterm08 = "88"
let s:cterm09 = "209"
let s:cterm0A = "221"
let s:cterm0B = "28"
let s:cterm0B = "64"
let s:cterm0C = "73"
let s:cterm0D = "04"
let s:cterm0D = "25"
let s:cterm0E = "176"
let s:cterm0F = "137"
let s:guiWhite = "#ffffff"
let s:ctermWhite = "15"
let s:ctermWhite = "231"
let g:airline#themes#jellybeans#palette = {}

View File

@ -4,26 +4,26 @@
" Normal mode
" [ guifg, guibg, ctermfg, ctermbg, opts ]
let s:N1 = [ '#141413' , '#CAE682' , 232 , 192 ] " mode
let s:N2 = [ '#CAE682' , '#32322F' , 192 , 236 ] " info
let s:N3 = [ '#CAE682' , '#242424' , 192 , 234 ] " statusline
let s:N2 = [ '#CAE682' , '#32322F' , 192 , 238 ] " info
let s:N3 = [ '#CAE682' , '#242424' , 192 , 235 ] " statusline
let s:N4 = [ '#86CD74' , 113 ] " mode modified
" Insert mode
let s:I1 = [ '#141413' , '#FDE76E' , 232 , 227 ]
let s:I2 = [ '#FDE76E' , '#32322F' , 227 , 236 ]
let s:I3 = [ '#FDE76E' , '#242424' , 227 , 234 ]
let s:I2 = [ '#FDE76E' , '#32322F' , 227 , 238 ]
let s:I3 = [ '#FDE76E' , '#242424' , 227 , 235 ]
let s:I4 = [ '#FADE3E' , 221 ]
" Visual mode
let s:V1 = [ '#141413' , '#B5D3F3' , 232 , 153 ]
let s:V2 = [ '#B5D3F3' , '#32322F' , 153 , 236 ]
let s:V3 = [ '#B5D3F3' , '#242424' , 153 , 234 ]
let s:V2 = [ '#B5D3F3' , '#32322F' , 153 , 238 ]
let s:V3 = [ '#B5D3F3' , '#242424' , 153 , 235 ]
let s:V4 = [ '#7CB0E6' , 111 ]
" Replace mode
let s:R1 = [ '#141413' , '#E5786D' , 232 , 173 ]
let s:R2 = [ '#E5786D' , '#32322F' , 173 , 236 ]
let s:R3 = [ '#E5786D' , '#242424' , 173 , 234 ]
let s:R2 = [ '#E5786D' , '#32322F' , 173 , 238 ]
let s:R3 = [ '#E5786D' , '#242424' , 173 , 235 ]
let s:R4 = [ '#E55345' , 203 ]
" Paste mode

View File

@ -45,17 +45,17 @@ function! airline#extensions#tabline#tabs#get()
for i in range(1, tabpagenr('$'))
if i == curtab
let group = 'airline_tabsel_right'
let group = 'airline_tabsel'
if g:airline_detect_modified
for bi in tabpagebuflist(i)
if getbufvar(bi, '&modified')
let group = 'airline_tabmod_right'
let group = 'airline_tabmod'
endif
endfor
endif
let s:current_modified = (group == 'airline_tabmod_right') ? 1 : 0
let s:current_modified = (group == 'airline_tabmod') ? 1 : 0
else
let group = 'airline_tab_right'
let group = 'airline_tab'
endif
let val = '%('
if s:show_tab_nr
@ -81,7 +81,7 @@ function! airline#extensions#tabline#tabs#get()
if s:show_splits == 1
let buffers = tabpagebuflist(curtab)
for nr in buffers
let group = airline#extensions#tabline#group_of_bufnr(buffers, nr)
let group = airline#extensions#tabline#group_of_bufnr(buffers, nr) . "_right"
call b.add_section_spaced(group, '%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)')
endfor
elseif s:show_tab_type == 1

View File

@ -18,7 +18,7 @@ let s:max_lines = get(g:, 'airline#extensions#whitespace#max_lines', 20000)
let s:enabled = get(g:, 'airline#extensions#whitespace#enabled', 1)
let s:c_like_langs = ['c', 'cpp', 'javascript', 'ld']
let s:c_like_langs = ['c', 'cpp', 'cuda', 'java', 'javascript', 'ld']
function! s:check_mixed_indent()
if s:indent_algo == 1

View File

@ -1,7 +1,7 @@
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
let s:filetypes = get(g:, 'airline#extensions#wordcount#filetypes', '\vhelp|markdown|rst|org|text')
let s:filetypes = get(g:, 'airline#extensions#wordcount#filetypes', '\vhelp|markdown|rst|org|text|asciidoc')
let s:format = get(g:, 'airline#extensions#wordcount#format', '%d words')
let s:formatter = get(g:, 'airline#extensions#wordcount#formatter', 'default')

View File

@ -2327,7 +2327,7 @@ function! s:Browse(bang,line1,count,...) abort
let url = s:gsub(url, '[ <>]', '\="%".printf("%02X",char2nr(submatch(0)))')
if a:bang
if has('clipboard')
let @* = url
let @+ = url
endif
return 'echomsg '.string(url)
elseif exists(':Browse') == 2

View File

@ -0,0 +1,27 @@
## 1.6 (unreleased)
FEATURES:
* New `CHANGELOG.md` file (which you're reading now). This will make it easier
for me to track changes and release versions
* **`:GoCoverage`**: is now highlighting the current source file for
covered/uncovered lines. If called again it clears the highlighting. This is
a pretty good addition to vim-go and I suggest to check out the gif that shows
it in action: https://twitter.com/fatih/status/716722650383564800 [gh-786]
* **`:GoCoverageBrowser`**: opens a new annotated HTML page. This is the old
`:GoCoverage` behavior [gh-786]
* **`GoDoc`**: uses now `[gogetdoc](https://github.com/zmb3/gogetdoc)` to
lookup and display the comment documentation for the identifier under the
cursor. This is more superior as it support looking up dot imports, named
imports and imports where package name and file name are different [gh-782]
IMPROVEMENTS:
* **`:GoCoverage`** is now executed async when used within Neovim [gh-686]
BUG FIXES:
* Fix not showing documentation for dot, named and package/file name being different imports [gh-332]
* Term mode: fix closing location list if result is successful after a failed attempt [gh-768]
* Syntax: fix gotexttmpl identifier highlighting [gh-778]

View File

@ -9,8 +9,6 @@ disabled/enabled easily.
![vim-go](https://dl.dropboxusercontent.com/u/174404/vim-go-2.png)
## Features
* Improved Syntax highlighting with items such as Functions, Operators, Methods.
@ -26,8 +24,8 @@ disabled/enabled easily.
* Automatic `GOPATH` detection based on the directory structure (i.e. `gb`
projects, `godep` vendored projects)
* Change or display `GOPATH` with `:GoPath`
* Create a coverage profile and display annotated source code in browser to see
which functions are covered with `:GoCoverage`
* Create a coverage profile and display annotated source code to see which
functions are covered with `:GoCoverage`
* Call `gometalinter` with `:GoMetaLinter`, which invokes all possible linters
(golint, vet, errcheck, deadcode, etc..) and shows the warnings/errors
* Lint your code with `:GoLint`
@ -45,6 +43,7 @@ disabled/enabled easily.
* Tagbar support to show tags of the source code in a sidebar with `gotags`
* Custom vim text objects such as `a function` or `inner function`
list.
* Jump to function or type declarations with `:GoDecls` or `:GoDeclsDir`
* A async launcher for the go command is implemented for Neovim, fully async
building and testing (beta).
* Integrated with the Neovim terminal, launch `:GoRun` and other go commands

View File

@ -0,0 +1,13 @@
#!/usr/bin/env rake
task :ci => [:dump, :test]
task :dump do
sh 'vim --version'
end
# Firstly, `bundle install; bundle install --deployment`
# Then, `rake test`
task :test do
sh 'bundle exec vim-flavor test'
end

View File

@ -213,11 +213,11 @@ function! go#cmd#Test(bang, compile, ...)
if has('nvim')
if get(g:, 'go_term_enabled', 0)
call go#term#new(a:bang, ["go"] + args)
let id = go#term#new(a:bang, ["go"] + args)
else
call go#jobcontrol#Spawn(a:bang, "test", args)
let id = go#jobcontrol#Spawn(a:bang, "test", args)
endif
return
return id
endif
call go#cmd#autowrite()
@ -290,36 +290,6 @@ function! go#cmd#TestFunc(bang, ...)
call call('go#cmd#Test', args)
endfunction
" Coverage creates a new cover profile with 'go test -coverprofile' and opens
" a new HTML coverage page from that profile.
function! go#cmd#Coverage(bang, ...)
let l:tmpname=tempname()
let command = "go test -coverprofile=" . l:tmpname . ' ' . go#util#Shelljoin(a:000)
let l:listtype = "quickfix"
call go#cmd#autowrite()
let out = go#tool#ExecuteInDir(command)
if v:shell_error
let errors = go#tool#ParseErrors(split(out, '\n'))
call go#list#Populate(l:listtype, errors)
call go#list#Window(l:listtype, len(errors))
if !empty(errors) && !a:bang
call go#list#JumpToFirst(l:listtype)
endif
else
" clear previous location list
call go#list#Clean(l:listtype)
call go#list#Window(l:listtype)
let openHTML = 'go tool cover -html='.l:tmpname
call go#tool#ExecuteInDir(openHTML)
endif
call delete(l:tmpname)
endfunction
" Generate runs 'go generate' in similar fashion to go#cmd#Build()
function! go#cmd#Generate(bang, ...)
let default_makeprg = &makeprg

View File

@ -0,0 +1,251 @@
let s:toggle = 0
" Buffer creates a new cover profile with 'go test -coverprofile' and changes
" teh current buffers highlighting to show covered and uncovered sections of
" the code. If run again it clears the annotation
function! go#coverage#Buffer(bang, ...)
if s:toggle
call go#coverage#Clear()
return
endif
let s:toggle = 1
let l:tmpname=tempname()
let args = [a:bang, 0, "-coverprofile", l:tmpname]
if a:0
call extend(args, a:000)
endif
let disabled_term = 0
if get(g:, 'go_term_enabled')
let disabled_term = 1
let g:go_term_enabled = 0
endif
let id = call('go#cmd#Test', args)
if disabled_term
let g:go_term_enabled = 1
endif
if has('nvim')
call go#jobcontrol#AddHandler(function('s:coverage_handler'))
let s:coverage_handler_jobs[id] = l:tmpname
return
endif
if !v:shell_error
call go#coverage#overlay(l:tmpname)
endif
call delete(l:tmpname)
endfunction
" Clear clears and resets the buffer annotation matches
function! go#coverage#Clear()
if exists("g:syntax_on") | syntax enable | endif
if exists("s:toggle") | let s:toggle = 0 | endif
" remove the autocmd we defined
if exists("#BufWinLeave#<buffer>")
autocmd! BufWinLeave <buffer>
endif
call clearmatches()
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, ...)
let l:tmpname=tempname()
let args = [a:bang, 0, "-coverprofile", l:tmpname]
if a:0
call extend(args, a:000)
endif
let id = call('go#cmd#Test', args)
if has('nvim')
call go#jobcontrol#AddHandler(function('s:coverage_browser_handler'))
let s:coverage_browser_handler_jobs[id] = l:tmpname
return
endif
if !v:shell_error
let openHTML = 'go tool cover -html='.l:tmpname
call go#tool#ExecuteInDir(openHTML)
endif
call delete(l:tmpname)
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)
" file:startline.col,endline.col numstmt count
let mx = '\([^:]\+\):\(\d\+\)\.\(\d\+\),\(\d\+\)\.\(\d\+\)\s\(\d\+\)\s\(\d\+\)'
let tokens = matchlist(a:line, mx)
let ret = {}
let ret.file = tokens[1]
let ret.startline = str2nr(tokens[2])
let ret.startcol = str2nr(tokens[3])
let ret.endline = str2nr(tokens[4])
let ret.endcol = str2nr(tokens[5])
let ret.numstmt = tokens[6]
let ret.cnt = tokens[7]
return ret
endfunction
" Generates matches to be added to matchaddpos for the given coverage profile
" block
function! go#coverage#genmatch(cov)
let color = 'covered'
if a:cov.cnt == 0
let color = 'uncover'
endif
let matches = []
" if start and end are the same, also specify the byte length
" example: foo.go:92.2,92.65 1 0
if a:cov.startline == a:cov.endline
call add(matches, {
\ 'group': color,
\ 'pos': [[a:cov.startline, a:cov.startcol, a:cov.endcol - a:cov.startcol]],
\ 'priority': 2,
\ })
return matches
endif
" add start columns. Because we don't know the length of the of
" the line, we assume it is at maximum 200 bytes. I know this is hacky,
" but that's only way of fixing the issue
call add(matches, {
\ 'group': color,
\ 'pos': [[a:cov.startline, a:cov.startcol, 200]],
\ 'priority': 2,
\ })
" and then the remaining lines
let start_line = a:cov.startline
while start_line < a:cov.endline
let start_line += 1
call add(matches, {
\ 'group': color,
\ 'pos': [[start_line]],
\ 'priority': 2,
\ })
endwhile
" finally end columns
call add(matches, {
\ 'group': color,
\ 'pos': [[a:cov.endline, a:cov.endcol-1]],
\ 'priority': 2,
\ })
return matches
endfunction
" Reads the given coverprofile file and annotates the current buffer
function! go#coverage#overlay(file)
if !filereadable(a:file)
return
endif
let lines = readfile(a:file)
" cover mode, by default it's 'set'. Just here for debugging purposes
let mode = lines[0]
" contains matches for matchaddpos()
let matches = []
" first mark all lines as normaltext. We use a custom group to not
" interfere with other buffers highlightings. Because the priority is
" lower than the cover and uncover matches, it'll be overriden.
let cnt = 1
while cnt <= line('$')
call add(matches, {'group': 'normaltext', 'pos': [cnt], 'priority': 1})
let cnt += 1
endwhile
let fname = expand('%:t')
" when called for a _test.go file, run the coverage for the actuall file
" file
if fname =~# '^\f\+_test\.go$'
let l:root = split(fname, '_test.go$')[0]
let fname = l:root . ".go"
if !filereadable(fname)
call go#util#EchoError("couldn't find ".fname)
return
endif
" open the alternate file to show the coverage
exe ":edit ". fnamemodify(fname, ":p")
endif
for line in lines[1:]
let cov = go#coverage#parsegocoverline(line)
" TODO(arslan): for now only include the coverage for the current
" buffer
if fname != fnamemodify(cov.file, ':t')
continue
endif
call extend(matches, go#coverage#genmatch(cov))
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
" clear the matches if we leave the buffer
autocmd BufWinLeave <buffer> call go#coverage#Clear()
for m in matches
call matchaddpos(m.group, m.pos)
endfor
endfunction
" -----------------------
" | Neovim job handlers |
" -----------------------
let s:coverage_handler_jobs = {}
let s:coverage_browser_handler_jobs = {}
function! s:coverage_handler(job, exit_status, data)
if !has_key(s:coverage_handler_jobs, a:job.id)
return
endif
let l:tmpname = s:coverage_handler_jobs[a:job.id]
if a:exit_status == 0
call go#coverage#overlay(l:tmpname)
endif
call delete(l:tmpname)
unlet s:coverage_handler_jobs[a:job.id]
endfunction
function! s:coverage_browser_handler(job, exit_status, data)
if !has_key(s:coverage_browser_handler_jobs, a:job.id)
return
endif
let l:tmpname = s:coverage_browser_handler_jobs[a:job.id]
if a:exit_status == 0
let openHTML = 'go tool cover -html='.l:tmpname
call go#tool#ExecuteInDir(openHTML)
endif
call delete(l:tmpname)
unlet s:coverage_browser_handler_jobs[a:job.id]
endfunction
" vim:ts=4:sw=4:et

View File

@ -29,13 +29,17 @@ function! go#def#Jump(...)
let $GOPATH = go#path#Detect()
let fname = fnamemodify(expand("%"), ':p:gs?\\?/?')
let command = bin_path . " -f=" . shellescape(fname) . " -i " . shellescape(arg)
let command = bin_path . " -t -f=" . shellescape(fname) . " -i " . shellescape(arg)
" get output of godef
let out = s:system(command, join(getbufline(bufnr('%'), 1, '$'), go#util#LineEnding()))
" First line is <file>:<line>:<col>
" Second line is <identifier><space><type>
let godefout=split(out, go#util#LineEnding())
" jump to it
call s:godefJump(out, "")
call s:godefJump(godefout, "")
let $GOPATH = old_gopath
endfunction
@ -52,12 +56,17 @@ function! go#def#JumpMode(mode)
let $GOPATH = go#path#Detect()
let fname = fnamemodify(expand("%"), ':p:gs?\\?/?')
let command = bin_path . " -f=" . shellescape(fname) . " -i " . shellescape(arg)
let command = bin_path . " -t -f=" . shellescape(fname) . " -i " . shellescape(arg)
" get output of godef
let out = s:system(command, join(getbufline(bufnr('%'), 1, '$'), go#util#LineEnding()))
call s:godefJump(out, a:mode)
" First line is <file>:<line>:<col>
" Second line is <identifier><space><type>
let godefout=split(out, go#util#LineEnding())
" jump to it
call s:godefJump(godefout, a:mode)
let $GOPATH = old_gopath
endfunction
@ -71,41 +80,181 @@ function! s:godefJump(out, mode)
let old_errorformat = &errorformat
let &errorformat = "%f:%l:%c"
if a:out =~ 'godef: '
let out = substitute(a:out, go#util#LineEnding() . '$', '', '')
echom out
else
let parts = split(a:out, ':')
" parts[0] contains filename
let fileName = parts[0]
" Location is the first line of godef output. Ideally in the proper format
" but it could also be an error
let location = a:out[0]
" put the error format into location list so we can jump automatically to
" it
lgetexpr a:out
" Echo the godef error if we had one.
if location =~ 'godef: '
let gderr=substitute(location, go#util#LineEnding() . '$', '', '')
call go#util#EchoError(gderr)
return
endif
" 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
let parts = split(a:out[0], ':')
if a:mode == "tab"
let &switchbuf = "usetab"
" parts[0] contains filename
let fileName = parts[0]
if bufloaded(fileName) == 0
tab split
endif
else
if a:mode == "split"
split
elseif a:mode == "vsplit"
vsplit
endif
endif
" Don't jump if it's the same identifier we just jumped to
if len(w:go_stack) > 0 && w:go_stack[w:go_stack_level-1]['ident'] == a:out[1] && w:go_stack[w:go_stack_level-1]['file'] == fileName
return
endif
" jump to file now
sil ll 1
normal! zz
" 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
let &switchbuf = old_switchbuf
end
let &errorformat = old_errorformat
if a:mode == "tab"
let &switchbuf = "usetab"
if bufloaded(fileName) == 0
tab split
endif
elseif a:mode == "split"
split
elseif a:mode == "vsplit"
vsplit
else
" Don't jump in this window if it's been modified
if getbufvar(bufnr('%'), "&mod")
call go#util#EchoError("No write since last change")
return
endif
endif
let stack_entry = {'line': line("."), 'col': col("."),
\'file': expand('%:p'), 'ident': a:out[1]}
" jump to file now
call s:goToFileLocation(location)
"
" Remove anything newer than the current position, just like basic
" vim tag support
if w:go_stack_level == 0
let w:go_stack = []
else
let w:go_stack = w:go_stack[0:w:go_stack_level-1]
endif
" increment the stack counter
let w:go_stack_level += 1
" push it on to the jumpstack
call add(w:go_stack, stack_entry)
let &switchbuf = old_switchbuf
endfunction
function! go#def#StackUI()
if len(w:go_stack) == 0
call go#util#EchoError("godef stack empty")
return
endif
let stackOut = ['" <Up>,<Down>:navigate <Enter>:jump <Esc>,q:exit']
let i = 0
while i < len(w:go_stack)
let entry = w:go_stack[i]
let prefix = ""
if i == w: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
if w:go_stack_level == i
call add(stackOut, "> ")
endif
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>
endfunction
function! go#def#StackPop(...)
if len(w:go_stack) == 0
call go#util#EchoError("godef stack empty")
return
endif
if w: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
let newLevel = str2nr(w:go_stack_level) - str2nr(numPop)
call go#def#StackJump(newLevel + 1)
endfunction
function! go#def#StackJump(...)
if len(w: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 jumpTarget !~ '^\d\+$'
if jumpTarget !~ '^\s*$'
call go#util#EchoError("location must be a number")
endif
return
endif
let jumpTarget=str2nr(jumpTarget) - 1
if jumpTarget >= 0 && jumpTarget < len(w:go_stack)
let w:go_stack_level = jumpTarget
let target = w:go_stack[w:go_stack_level]
" jump
call s:goToFileLocation(target["file"], target["line"], target["col"])
else
call go#util#EchoError("invalid godef stack location. Try :GoDefJump to see the list of valid entries")
endif
endfunction
function! s:goToFileLocation(...)
let old_errorformat = &errorformat
let &errorformat = "%f:%l:%c"
" put the error format into location list so we can jump automatically to
" it
if a:0 == 3
lgetexpr printf("%s:%s:%s", a:1, a:2, a:3)
elseif a:0 == 1
lgetexpr a:1
else
lgetexpr ""
endif
sil ll 1
normal zz
let &errorformat = old_errorformat
endfunction
function! go#def#SelectStackEntry()
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#StackJump(str2nr(highlighted_stack_entry))
endif
call go#ui#CloseWindow()
endfunction

View File

@ -1,22 +1,6 @@
" Copyright 2011 The Go Authors. All rights reserved.
" Use of this source code is governed by a BSD-style
" license that can be found in the LICENSE file.
"
" godoc.vim: Vim command to see godoc.
"
"
" Commands:
"
" :GoDoc
"
" Open the relevant Godoc for either the word[s] passed to the command or
" the, by default, the word under the cursor.
"
" Options:
"
" g:go_godoc_commands [default=1]
"
" Flag to indicate whether to enable the commands listed above.
let s:buf_nr = -1
@ -33,10 +17,9 @@ endif
" ie: github.com/fatih/set and New
function! s:godocWord(args)
if !executable('godoc')
echohl WarningMsg
echo "godoc command not found."
echo " install with: go get golang.org/x/tools/cmd/godoc"
echohl None
let msg = "godoc command not found."
let msg .= " install with: go get golang.org/x/tools/cmd/godoc"
call go#util#echoWarning(msg)
return []
endif
@ -94,47 +77,24 @@ function! go#doc#OpenBrowser(...)
endfunction
function! go#doc#Open(newmode, mode, ...)
let pkgs = s:godocWord(a:000)
if empty(pkgs)
" check if we have 'gogetdoc' and use it automatically
let bin_path = go#path#CheckBinPath('gogetdoc')
if empty(bin_path)
return
endif
let pkg = pkgs[0]
let exported_name = pkgs[1]
let offset = go#util#OffsetCursor()
let fname = expand("%:p")
let command = g:go_doc_command . ' ' . g:go_doc_options . ' ' . pkg
let command = printf("%s -pos %s:#%s", bin_path, fname, offset)
silent! let content = system(command)
if v:shell_error || s:godocNotFound(content)
echo 'No documentation found for "' . pkg . '".'
return -1
let out = system(command)
if v:shell_error != 0
call go#util#EchoError(out)
return
endif
call s:GodocView(a:newmode, a:mode, content)
if exported_name == ''
silent! normal! gg
return -1
endif
" jump to the specified name
if search('^func ' . exported_name . '(')
silent! normal! zt
return -1
endif
if search('^type ' . exported_name)
silent! normal! zt
return -1
endif
if search('^\%(const\|var\|type\|\s\+\) ' . pkg . '\s\+=\s')
silent! normal! zt
return -1
endif
" nothing found, jump to top
silent! normal! gg
call s:GodocView(a:newmode, a:mode, out)
endfunction
function! s:GodocView(newposition, position, content)
@ -150,6 +110,15 @@ function! s:GodocView(newposition, position, content)
execute bufwinnr(s:buf_nr) . 'wincmd w'
endif
" cap buffer height to 20, but resize it for smaller contents
let max_height = 20
let content_height = len(split(a:content, "\n"))
if content_height > max_height
exe 'resize ' . max_height
else
exe 'resize ' . content_height
endif
setlocal filetype=godoc
setlocal bufhidden=delete
setlocal buftype=nofile
@ -165,7 +134,10 @@ function! s:GodocView(newposition, position, content)
call append(0, split(a:content, "\n"))
sil $delete _
setlocal nomodifiable
" close easily with <esc> or enter
noremap <buffer> <silent> <CR> :<C-U>close<CR>
noremap <buffer> <silent> <Esc> :<C-U>close<CR>
endfunction
" vim:ts=4:sw=4:et
" vim:ts=2:sw=2:et

View File

@ -127,7 +127,10 @@ function! go#fmt#Format(withGoimport)
endif
if exists('b:goimports_vendor_compatible') && b:goimports_vendor_compatible
let command = command . '-srcdir ' . fnameescape(expand("%:p:h"))
let ssl_save = &shellslash
set noshellslash
let command = command . '-srcdir ' . shellescape(expand("%:p:h"))
let &shellslash = ssl_save
endif
endif

View File

@ -2,6 +2,10 @@
" internal function s:spawn
let s:jobs = {}
" s:handlers is a global event handlers for all jobs started with Spawn() or
" with the internal function s:spawn
let s:handlers = {}
" Spawn is a wrapper around s:spawn. It can be executed by other files and
" scripts if needed. Desc defines the description for printing the status
" during the job execution (useful for statusline integration).
@ -36,6 +40,22 @@ function! go#jobcontrol#Statusline() abort
return ''
endfunction
" AddHandler adds a on_exit callback handler and returns the id.
function! go#jobcontrol#AddHandler(handler)
let i = len(s:handlers)
while has_key(s:handlers, string(i))
let i += 1
break
endwhile
let s:handlers[string(i)] = a:handler
return string(i)
endfunction
" RemoveHandler removes a callback handler by id.
function! go#jobcontrol#RemoveHandler(id)
unlet s:handlers[a:id]
endfunction
" spawn spawns a go subcommand with the name and arguments with jobstart. Once
" a job is started a reference will be stored inside s:jobs. spawn changes the
" GOPATH when g:go_autodetect_gopath is enabled. The job is started inside the
@ -95,6 +115,8 @@ endfunction
" it'll be closed.
function! s:on_exit(job_id, exit_status)
let std_combined = self.stderr + self.stdout
call s:callback_handlers_on_exit(s:jobs[a:job_id], a:exit_status, std_combined)
if a:exit_status == 0
call go#list#Clean(0)
call go#list#Window(0)
@ -134,6 +156,17 @@ function! s:on_exit(job_id, exit_status)
endif
endfunction
" callback_handlers_on_exit runs all handlers for job on exit event.
function! s:callback_handlers_on_exit(job, exit_status, data)
if empty(s:handlers)
return
endif
for s:handler in values(s:handlers)
call s:handler(a:job, a:exit_status, a:data)
endfor
endfunction
" on_stdout is the stdout handler for jobstart(). It collects the output of
" stderr and stores them to the jobs internal stdout list.
function! s:on_stdout(job_id, data)

View File

@ -92,36 +92,46 @@ function! s:on_stderr(job_id, data)
call extend(job.stderr, a:data)
endfunction
function! s:on_exit(job_id, data)
function! s:on_exit(job_id, exit_status)
if !has_key(s:jobs, a:job_id)
return
endif
let job = s:jobs[a:job_id]
let l:listtype = "locationlist"
" usually there is always output so never branch into this clause
if empty(job.stdout)
call go#list#Clean(l:listtype)
call go#list#Window(l:listtype)
else
let errors = go#tool#ParseErrors(job.stdout)
let errors = go#tool#FilterValids(errors)
if !empty(errors)
" close terminal we don't need it
close
call go#list#Populate(l:listtype, errors)
call go#list#Window(l:listtype, len(errors))
if !self.bang
call go#list#JumpToFirst(l:listtype)
endif
else
call go#list#Clean(l:listtype)
call go#list#Window(l:listtype)
endif
unlet s:jobs[a:job_id]
return
endif
let errors = go#tool#ParseErrors(job.stdout)
let errors = go#tool#FilterValids(errors)
if !empty(errors)
" close terminal we don't need it anymore
close
call go#list#Populate(l:listtype, errors)
call go#list#Window(l:listtype, len(errors))
if !self.bang
call go#list#JumpToFirst(l:listtype)
endif
unlet s:jobs[a:job_id]
return
endif
" tests are passing clean the list and close the list. But we only can
" close them from a normal view, so jump back, close the list and then
" again jump back to the terminal
wincmd p
call go#list#Clean(l:listtype)
call go#list#Window(l:listtype)
wincmd p
unlet s:jobs[a:job_id]
endfunction

View File

@ -1,7 +1,12 @@
let s:buf_nr = -1
"OpenWindow opens a new scratch window and put's the content into the window
function! go#ui#OpenWindow(title, content)
function! go#ui#OpenWindow(title, content, filetype)
" Ensure there's only one return window in this session/tabpage
call go#util#Windo("unlet! w:vim_go_return_window")
" Mark the window we're leaving as such
let w:vim_go_return_window = 1
" reuse existing buffer window if it exists otherwise create a new one
if !bufexists(s:buf_nr)
execute 'botright new'
@ -14,46 +19,65 @@ function! go#ui#OpenWindow(title, content)
exec