add gd
and gD
to go to declaration and type definition
#250
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for the
gd
andgD
commands in a way that I think makes sense in the context of VS Code.In vim,
gd
seems to search up through the current code block to where it thinks the current identifier (variable/function) might have been defined. With this change, amVim will have the same effect, although it will also jump into a different file if the identifier you are on is defined elsewhere. This is the same action that happens in VS Code when you Ctrl-Click.In vim,
gD
seems to search down from line 0 to where it thinks the current identifier (variable/function) might have been defined as a global. With this change, amVim will jump to the type definition of the current identifier (even if it is in a different file). This does nothing in languages without type information, but if VS Code can figure out the type, it will take you to the definition. This is a different behavior to vim, but I think it is in the spirit of whatgD
is trying to help with.The benefit is that you can now easily jump around the source without taking your hands off the keyboard, using
gd
andgD
to take a look at where something is defined and what its type is, then Alt-Left to quickly take you back to where you were.