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:
amix
2017-09-02 12:43:18 +02:00
parent 3be3af28e5
commit 7fc202ec88
64 changed files with 1659 additions and 525 deletions

View File

@ -69,7 +69,10 @@ function! go#fmt#Format(withGoimport) abort
let bin_name = "goimports"
endif
let current_col = col('.')
let out = go#fmt#run(bin_name, l:tmpname, expand('%'))
let diff_offset = len(readfile(l:tmpname)) - line('$')
if go#util#ShellError() == 0
call go#fmt#update_file(l:tmpname, expand('%'))
elseif g:go_fmt_fail_silently == 0
@ -95,6 +98,9 @@ function! go#fmt#Format(withGoimport) abort
" Restore our cursor/windows positions.
call winrestview(l:curw)
endif
" be smart and jump to the line the new statement was added/removed
call cursor(line('.') + diff_offset, current_col)
endfunction
" update_file updates the target file with the given formatted source
@ -116,15 +122,25 @@ function! go#fmt#update_file(source, target)
endif
" reload buffer to reflect latest changes
silent! edit!
silent edit!
let &fileformat = old_fileformat
let &syntax = &syntax
" the title information was introduced with 7.4-2200
" https://github.com/vim/vim/commit/d823fa910cca43fec3c31c030ee908a14c272640
if !has('patch-7.4-2200')
return
endif
" clean up previous location list
let l:listtype = "locationlist"
call go#list#Clean(l:listtype)
call go#list#Window(l:listtype)
let l:list_title = getqflist({'title': 1})
if has_key(l:list_title, "title") && l:list_title['title'] == "Format"
let l:listtype = go#list#Type("quickfix")
call go#list#Clean(l:listtype)
call go#list#Window(l:listtype)
endif
endfunction
" run runs the gofmt/goimport command for the given source file and returns
@ -166,9 +182,10 @@ function! s:fmt_cmd(bin_name, source, target)
endif
" start constructing the command
let bin_path = go#util#Shellescape(bin_path)
let cmd = [bin_path]
call add(cmd, "-w")
" add the options for binary (if any). go_fmt_options was by default of type
" string, however to allow customization it's now a dictionary of binary
" name mapping to options.
@ -228,7 +245,7 @@ endfunction
" show_errors opens a location list and shows the given errors. If the given
" errors is empty, it closes the the location list
function! s:show_errors(errors) abort
let l:listtype = go#list#Type("locationlist")
let l:listtype = go#list#Type("quickfix")
if !empty(a:errors)
call go#list#Populate(l:listtype, a:errors, 'Format')
echohl Error | echomsg "Gofmt returned error" | echohl None