Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Better godef integration: local defs, imports #261

Merged
merged 2 commits into from
Aug 24, 2015

Conversation

greensnark
Copy link
Contributor

go-plus' current godef integration is limited to top-level and exported names,
and does not work for method calls:

buf := bytes.Buffer{}
buf.Write([]byte{0x0}) // godef on Write and buf didn't work.

This is because godef was being run as:

godef -f filebeingedited.go buf.Write

which doesn't give godef enough context to know what "buf" and "Write" are.

The fix is to run godef with the offset (-o) option to give it the offset
in the file where the cursor is, and let godef figure out what the user's
trying to navigate to.

This commit also keeps track of godef navigation on a stack and allows going
back to previous locations where godef was triggered with the godef-return
command.

go-plus' current godef integration is limited to top-level and exported names,
and does not work for method calls:

    buf := bytes.Buffer{}
    buf.Write([]byte{0x0}) // godef on Write and buf didn't work.

This is because godef was being run as:

    godef -f filebeingedited.go buf.Write

which doesn't give godef enough context to know what "buf" and "Write" are.

The fix is to run godef with the offset (-o) option to give it the offset
in the file where the cursor is, and let godef figure out what the user's
trying to navigate to.

This commit also keeps track of godef navigation on a stack and allows going
back to previous locations where godef was triggered with the godef-return
command.
@joefitzgerald
Copy link
Owner

LGTM. Thanks, this is great!

joefitzgerald added a commit that referenced this pull request Aug 24, 2015
Better godef integration: local defs, imports
@joefitzgerald joefitzgerald merged commit ab2ae56 into joefitzgerald:master Aug 24, 2015
@@ -3,4 +3,6 @@
'atom-text-editor[data-grammar="source go"]:not(.mini)':
'ctrl-alt-c': 'golang:gocover'
'ctrl-alt-shift-c': 'golang:cleargocover'
# Shouldn't these be ctrl-alt for portability?
Copy link
Owner

Choose a reason for hiding this comment

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

Yes, you're right.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants