[RFC] improvements to :tselect and :tjump

11 views
Skip to first unread message

Brandon Richardson

unread,
Aug 11, 2022, 7:32:58 PM8/11/22
to vim_dev
Hello all,

I've been prototyping some alternative commands to :tselect and :tjump and I'm looking to get a bit of feedback from the community on whether this functionality is something worth introducing into the core project. This functionality originally started it's life as small plugin in my dotfiles and I've grown to really enjoy the experience it provides. I figured that the community could benefit, so I've been working to implement it as a core feature in vim.

When there are multiple tag matches for a particular keyword, :tag and CTRL-] both jump to the first match by default. Alternatively, :tselect and :tjump can be used to select which match to jump to by showing a message and prompting for input.

I'd like to propose two new commands, :pwtselect and :pwtjump and perhaps a new key mapping that displays the tag matches in a popup window at the cursor position. The user may then select which tag to jump to. It would look and feel very similar to the completion popup features, and it leverages much of the existing foundation for :tselect and friends.

Each entry in the popup window could have the format "[<kind>] <tagname> <fname>". We could also include "info" fields and the the line from the file (massaged from the "cmd" field like in the current implementation of :tselect and friends).

If this is something the community deems worth pursuing, I'll continue pressing forward on my patch series. I'd love to hear people's thoughts and opinions.

Thanks,
- Brandon

Gary Johnson

unread,
Aug 12, 2022, 12:26:26 AM8/12/22
to vim_dev
There is a plugin that implements some of what you are proposing,
tagselect.vim, "Provides a better :tselect command," by Hari
Krishna Dara. It was last updated on June 9, 2005.

https://www.vim.org/scripts/script.php?script_id=1282

It provides the same display of tag information as :tselect and
related commands do, but in an easier-to-use menu. I have Ctrl-]
mapped to the :Tjump command.

It could use some updating. I think what you propose is a good
idea. I'm not sure that it needs to be incorporated into Vim if it
works well as a plugin. That is, if it's not missing some
functionality or performance that it would have if made part of Vim,
then it's probably better to leave it as a plugin. For one thing,
a plugin is easier to modify, so it is a better medium for proposing
new functionality than changes to core Vim.

If the functionality was to be added to Vim, I don't think there is
a need for more commands. I think users will prefer either your
interface or the original, but will probably not switch between the
two. Therefore, I would propose an option that let the user choose
between interfaces, perhaps with choices of legacy, Hari's style
with the menu in a split window, and your style with the menu in
a pop-up window.

On the other hand, having an option that changes the behavior of an
existing command could break plugins that use :tselect and related
commands. So maybe it would be better to have new functions that
the user can map, although that's not as convenient.

My rambling $0.02.

Regards,
Gary

Yegappan Lakshmanan

unread,
Aug 12, 2022, 1:06:04 AM8/12/22
to vim_dev
Hi,
Another alternative is the ":ltag" command which adds the matching
tags to the location list. You can then use the location list commands
to browse the tags. The location list functionality was originally added
to support this functionality.

- Yegappan
Reply all
Reply to author
Forward
0 new messages