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

Stack/history for TernDef #83

Open
bajtos opened this issue Dec 29, 2014 · 7 comments
Open

Stack/history for TernDef #83

bajtos opened this issue Dec 29, 2014 · 7 comments

Comments

@bajtos
Copy link

bajtos commented Dec 29, 2014

As a ViM user used to the behaviour of the builtin tags commands (:tag Ctrl-], :pop Ctrl-T), where I can easily return back to previous location after jump to a tag definition, I am missing this feature in Tern.

In an ideal world, Tern would either integrate with built-in tag stack. If that's not possible, then it should at least provide an equivalent of :pop command, e.g. TernDefBack.

See also :help tagstack

@marijnh
Copy link
Member

marijnh commented Dec 29, 2014

The Emacs and Sublime Text plugins have this feature. If vim itself has a tag stack, it'd indeed be great if we integrate with that. I unfortunately know very little about vim scripting. Do you maybe want to take a stab at an implementation?

@bajtos
Copy link
Author

bajtos commented Dec 30, 2014

I am not familiar with vim scripting either :(

I did a bit of searching on the internet, and there are apparently two lists maintained by vim: a Tag Stack and a Jump List. The latter works well with the Tern plugin, one can use Ctrl-O to get back. The drawback is that Jump List is shared with other jump commands like G or /, but I find that as an acceptable limitation.

I am proposing to improve the documentation and mention that Ctrl-O can be used to navigate back from TernDefjump. What is the best place for that - doc/tern.txt, README.md or something else? I am happy to make the change myself.

@bajtos
Copy link
Author

bajtos commented Dec 30, 2014

Link to relevant Vim's docs: :help jump-motions

@marijnh
Copy link
Member

marijnh commented Jan 20, 2015

A quick look over the docs does not show any way to push something onto the tagstack without actually using the tag functionality to jump somewhere. Since the vim docs are not the cleanest docs around, that does not necessarily mean that there is no such functionality. If someone knows a way, a pull request would be very welcome.

@Slava
Copy link

Slava commented Mar 16, 2015

I just stumbled upon this issue and have to say that jump lists work well for me with :TernDef. I can press Ctrl-o right after the command and it gets me back to the line where I started.

@cjbassi
Copy link

cjbassi commented Nov 16, 2017

jedi-vim has a goto-definition command that implements vim's jump stack and allows for using C-t. It looks like the relevant python code is located here. I haven't taken enough time to understand all of it but hopefully it isn't too hard to port over.

@PauloPhagula
Copy link

Meanwhile work happens to provide a solution to this problem, I use this work-around:

# file: .vim/ftplugin/javascript.vim
noremap <buffer> <silent><c-]> :<C-u> TagImposterAnticipateJump <Bar> :TernDef<CR>

It is powered by idbrii/vim-tagimposter which was made for this very purpose, given the need has risen since LSP plugins become more popular. Its description says:

Do you have a LSP or other magic that helps you jump to symbols? Are you frustrated that C-t doesn't work with that magic? tagimposter will commit tag forgery for you!

Hope it helps

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

No branches or pull requests

5 participants