Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add :GoExpandErr #1470

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions autoload/go/expanderr.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function! go#expanderr#ExpandErr() abort
let binpath = go#path#CheckBinPath('expanderr')
if empty(binpath)
return
endif

let l:cmd = [binpath, '-format', 'json',
\ bufname('') . ':#' . go#util#OffsetCursor()]

let l:out = go#util#System(go#util#Shelljoin(l:cmd))
if go#util#ShellError() != 0
call go#util#EchoError(l:out)
return
endif

try
let l:json = json_decode(l:out)
catch
call go#util#EchoError(l:out)
return
endtry

let l:code = l:json['lines']
let l:pos = getpos('.')

try
call setline('.', l:code[0])
call append('.', l:code[1:])
finally
call setpos('.', l:pos)
endtry
endfunction

" vim: sw=2 ts=2 et
2 changes: 1 addition & 1 deletion doc/vim-go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ CTRL-t
Becomes:
>
addr := net.Address{
Name: "Ford Prefect",
Name: "Ford Prefect",
Email: "",
}
<
Expand Down
3 changes: 3 additions & 0 deletions ftplugin/go/commands.vim
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,7 @@ command! -nargs=0 GoKeyify call go#keyify#Keyify()
" -- fillstruct
command! -nargs=0 GoFillStruct call go#fillstruct#FillStruct()

" -- expanderr
command! -nargs=0 GoExpandErr call go#expanderr#ExpandErr()

" vim: sw=2 ts=2 et