[vim/vim] settagstack can't natively replicate :tag behavior (#5405)

49 views
Skip to first unread message

Francisco Giordano

unread,
Dec 28, 2019, 1:50:25 PM12/28/19
to vim/vim, Subscribed

Plugins like LSP clients are now using settagstack to replicate the behavior of C-], but the provided API only allows replacing the entire stack or appending to it, which makes it non-trivial to replicate the native tagstack behavior.

Natively, jumping to a tag will insert the new tag at the current index, and remove everything that came after it. This allows "tree like" navigation through tags, by using C-T to go up in the stack and then jumping to a different tag branching off in a different direction.

I think settagstack should have a third mode to replace the tagstack entries from the current index up to the end, so as to easily replicate native tag navigation. Without this mode, plugin authors either manually reimplement it as in vim-lsp, or simply use append without being aware of the difference in behavior.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Andy Massimino

unread,
Dec 28, 2019, 3:49:16 PM12/28/19
to vim/vim, Subscribed

Use tagfunc

Bram Moolenaar

unread,
Dec 28, 2019, 5:14:16 PM12/28/19
to vim/vim, Subscribed

Francisco Giordano wrote:

> Plugins like LSP clients are now using `settagstack` to replicate the
> behavior of `C-]`, but the provided API only allows replacing the
> entire stack or appending to it, which makes it non-trivial to
> replicate the native tagstack behavior.
>
> Natively, jumping to a tag will insert the new tag at the current
> index, and remove everything that came after it. This allows "tree
> like" navigation through tags, by using `C-T` to go up in the stack
> and then jumping to a different tag branching off in a different
> direction.
>
> I think `settagstack` should have a third mode to replace the tagstack
> entries from the current index up to the end, so as to easily
> replicate native tag navigation. Without this mode, plugin authors
> either manually reimplement it [as in
> vim-lsp](https://github.com/prabirshrestha/vim-lsp/blob/master/autoload/lsp/ui/vim.vim#L456-L476),

> or simply use append without being aware of the difference in
> behavior.

Can't you get the existing stack with gettagsack() and modify it any way
before using settagstack() ?

--
Some say the world will end in fire; some say in segfaults.
I say it will end in a curly bracket.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Francisco Giordano

unread,
Dec 28, 2019, 5:20:37 PM12/28/19
to vim/vim, Subscribed

Can't you get the existing stack with gettagsack() and modify it any way
before using settagstack() ?

Yes, this is what vim-lsp is doing. I'm trying to say that since it will almost always be the right thing to do, the functionality should exist out of the box.

Bram Moolenaar

unread,
Dec 29, 2019, 9:21:24 AM12/29/19
to vim/vim, Subscribed

> >Can't you get the existing stack with gettagsack() and modify it any way
> >before using settagstack() ?
>
> Yes, this is what vim-lsp is doing. I'm trying to say that since it
> will almost always be the right thing to do, the functionality should
> exist out of the box.

So it would be sufficient to add an action "t" (for truncate), that
works like "a" (append), but first truncates at the current index?

--
I'm sure that I asked CBuilder to do a "full" install. Looks like I got
a "fool" install, instead. Charles E Campbell, Jr, PhD



/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Francisco Giordano

unread,
Dec 29, 2019, 10:14:14 AM12/29/19
to vim/vim, Subscribed

That's what I had in mind yes!

Yegappan Lakshmanan

unread,
Dec 30, 2019, 1:24:25 AM12/30/19
to vim_dev, reply+ACY5DGEOO3DKU4PJYN...@reply.github.com, vim/vim, Subscribed
Hi,

On Sun, Dec 29, 2019 at 8:44 PM Francisco Giordano <vim-dev...@256bit.org> wrote:

That's what I had in mind yes!



I have created PR #5417 to add support for truncating the tag stack before
pushing new items onto the stack.

- Yegappan


 

vim-dev ML

unread,
Dec 30, 2019, 1:24:50 AM12/30/19
to vim/vim, vim-dev ML, Your activity

Christian Brabandt

unread,
Jan 4, 2020, 6:34:54 AM1/4/20
to vim/vim, vim-dev ML, Comment

included as of https://github.com/vim/vim/releases/tag/v8.2.0077


You are receiving this because you commented.

Christian Brabandt

unread,
Jan 4, 2020, 6:34:56 AM1/4/20
to vim/vim, vim-dev ML, Comment

Closed #5405.


You are receiving this because you commented.

Yegappan Lakshmanan

unread,
Jan 4, 2020, 6:44:53 AM1/4/20
to reply+ACY5DGHWCHLIZABY5N...@reply.github.com, vim...@googlegroups.com, Subscribed, vim/vim
Hi,

On Sun, Dec 29, 2019 at 12:20 AM Francisco Giordano <vim-dev...@256bit.org> wrote:

Plugins like LSP clients are now using settagstack to replicate the behavior of C-], but the provided API only allows replacing the entire stack or appending to it, which makes it non-trivial to replicate the native tagstack behavior.

Natively, jumping to a tag will insert the new tag at the current index, and remove everything that came after it. This allows "tree like" navigation through tags, by using C-T to go up in the stack and then jumping to a different tag branching off in a different direction.

I think settagstack should have a third mode to replace the tagstack entries from the current index up to the end, so as to easily replicate native tag navigation. Without this mode, plugin authors either manually reimplement it as in vim-lsp, or simply use append without being aware of the difference in behavior.


Can you try the latest version of Vim and see whether the new truncate tagstack functionality meets your requirement?

Thanks,
Yegappan

vim-dev ML

unread,
Jan 4, 2020, 6:45:02 AM1/4/20
to vim/vim, vim-dev ML, Your activity
Hi,

On Sun, Dec 29, 2019 at 12:20 AM Francisco Giordano <
vim-dev...@256bit.org> wrote:

> Plugins like LSP clients are now using settagstack to replicate the
> behavior of C-], but the provided API only allows replacing the entire
> stack or appending to it, which makes it non-trivial to replicate the
> native tagstack behavior.
>
> Natively, jumping to a tag will insert the new tag at the current index,
> and remove everything that came after it. This allows "tree like"
> navigation through tags, by using C-T to go up in the stack and then
> jumping to a different tag branching off in a different direction.
>
> I think settagstack should have a third mode to replace the tagstack
> entries from the current index up to the end, so as to easily replicate
> native tag navigation. Without this mode, plugin authors either manually
> reimplement it as in vim-lsp
> <https://github.com/prabirshrestha/vim-lsp/blob/master/autoload/lsp/ui/vim.vim#L456-L476>,

> or simply use append without being aware of the difference in behavior.
>

Can you try the latest version of Vim and see whether the new truncate
tagstack functionality meets your requirement?

Thanks,
Yegappan
Reply all
Reply to author
Forward
0 new messages