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

allow :GoDoc on modified buffers #1014

Merged
merged 2 commits into from
Aug 27, 2016
Merged
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
21 changes: 19 additions & 2 deletions autoload/go/doc.vim
Original file line number Diff line number Diff line change
@@ -85,6 +85,7 @@ function! go#doc#Open(newmode, mode, ...)
endif

let command = printf("%s %s", bin_path, join(a:000, ' '))
let out = go#util#System(command)
else
" check if we have 'gogetdoc' and use it automatically
let bin_path = go#path#CheckBinPath('gogetdoc')
@@ -95,11 +96,27 @@ function! go#doc#Open(newmode, mode, ...)
let offset = go#util#OffsetCursor()
let fname = expand("%:p:gs!\\!/!")
let pos = shellescape(fname.':#'.offset)

let command = printf("%s -pos %s", bin_path, pos)

if &modified
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment above this variable to indicate the gogetdoc has a feature that we can make use of

" gogetdoc supports the same archive format as guru for dealing with
" modified buffers.
" use the -modified flag
" write each archive entry on stdin as:
" filename followed by newline
" file size followed by newline
" file contents
let in = ""
let sep = go#util#LineEnding()
let content = join(getline(1, '$'), sep)
let in = fname . "\n" . strlen(content) . "\n" . content
let command .= " -modified"
let out = go#util#System(command, in)
else
let out = go#util#System(command)
endif
endif

let out = go#util#System(command)
if go#util#ShellError() != 0
call go#util#EchoError(out)
return