mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Updated plugins
This commit is contained in:
@ -1,26 +1,10 @@
|
||||
if !exists("g:go_gorename_bin")
|
||||
let g:go_gorename_bin = "gorename"
|
||||
endif
|
||||
|
||||
" Set the default value. A value of "1" is a shortcut for this, for
|
||||
" compatibility reasons.
|
||||
function! s:default() abort
|
||||
if !exists("g:go_gorename_prefill") || g:go_gorename_prefill == 1
|
||||
let g:go_gorename_prefill = 'expand("<cword>") =~# "^[A-Z]"' .
|
||||
\ '? go#util#pascalcase(expand("<cword>"))' .
|
||||
\ ': go#util#camelcase(expand("<cword>"))'
|
||||
endif
|
||||
endfunction
|
||||
call s:default()
|
||||
|
||||
function! go#rename#Rename(bang, ...) abort
|
||||
call s:default()
|
||||
|
||||
let to_identifier = ""
|
||||
if a:0 == 0
|
||||
let ask = printf("vim-go: rename '%s' to: ", expand("<cword>"))
|
||||
if g:go_gorename_prefill != ''
|
||||
let to_identifier = input(ask, eval(g:go_gorename_prefill))
|
||||
let prefill = go#config#GorenamePrefill()
|
||||
if prefill != ''
|
||||
let to_identifier = input(ask, eval(prefill))
|
||||
else
|
||||
let to_identifier = input(ask)
|
||||
endif
|
||||
@ -33,7 +17,7 @@ function! go#rename#Rename(bang, ...) abort
|
||||
endif
|
||||
|
||||
" return with a warning if the bin doesn't exist
|
||||
let bin_path = go#path#CheckBinPath(g:go_gorename_bin)
|
||||
let bin_path = go#path#CheckBinPath(go#config#GorenameBin())
|
||||
if empty(bin_path)
|
||||
return
|
||||
endif
|
||||
@ -41,19 +25,7 @@ function! go#rename#Rename(bang, ...) abort
|
||||
let fname = expand('%:p')
|
||||
let pos = go#util#OffsetCursor()
|
||||
let offset = printf('%s:#%d', fname, pos)
|
||||
|
||||
" no need to escape for job call
|
||||
let bin_path = go#util#has_job() ? bin_path : shellescape(bin_path)
|
||||
let offset = go#util#has_job() ? offset : shellescape(offset)
|
||||
let to_identifier = go#util#has_job() ? to_identifier : shellescape(to_identifier)
|
||||
|
||||
let cmd = [bin_path, "-offset", offset, "-to", to_identifier]
|
||||
|
||||
" check for any tags
|
||||
if exists('g:go_build_tags')
|
||||
let tags = get(g:, 'go_build_tags')
|
||||
call extend(cmd, ["-tags", tags])
|
||||
endif
|
||||
let cmd = [bin_path, "-offset", offset, "-to", to_identifier, '-tags', go#config#BuildTags()]
|
||||
|
||||
if go#util#has_job()
|
||||
call go#util#EchoProgress(printf("renaming to '%s' ...", to_identifier))
|
||||
@ -64,11 +36,8 @@ function! go#rename#Rename(bang, ...) abort
|
||||
return
|
||||
endif
|
||||
|
||||
let command = join(cmd, " ")
|
||||
let out = go#tool#ExecuteInDir(command)
|
||||
|
||||
let splitted = split(out, '\n')
|
||||
call s:parse_errors(go#util#ShellError(), a:bang, splitted)
|
||||
let [l:out, l:err] = go#tool#ExecuteInDir(l:cmd)
|
||||
call s:parse_errors(l:err, a:bang, split(l:out, '\n'))
|
||||
endfunction
|
||||
|
||||
function s:rename_job(args)
|
||||
|
Reference in New Issue
Block a user