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

Add kind to builtin.tags picker #3235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ecerulm
Copy link

@ecerulm ecerulm commented Aug 2, 2024

Description

The current tags picker will not show the kind

Current tags picker:
image

With this changes the picker will show the kind (method, field, package, class , etc):

image

It augments the regex match in the existing picker to get the extensions_fields that may be present on each line of the tags file (see TAG FILE FORMAT).

That extension_fields may contain a kind:xxx field, if it does it will be picked up and added to the entry otherwise the unknownkind will be used.

To generate a tags file that includes kinds use

git ls-files .  |  $(brew --prefix universal-ctags)/bin/ctags --fields=+zK -L - -f tags

where the --fields=+zK is the part that adds the kinds.

Fixes #3233

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list relevant details about your configuration

  • manual test, using a tags file generated with git ls-files . | $(brew --prefix universal-ctags)/bin/ctags --fields=+zK -L - -f tags

Tested the with the following keymap to trigger telescope

vim.keymap.set("n", ";c", function()
	require("telescope.builtin").tags({ only_sort_tags = true, show_line = false, path_display = {"filename_first"} })
end, opts)

Configuration:

  • Neovim version (nvim --version):
NVIM v0.11.0-dev-492+g0cdeb06db
Build type: RelWithDebInfo
LuaJIT 2.1.1720049189
  • Operating system and version: macOS Sonoma 14.5

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (lua annotations)

@ecerulm ecerulm mentioned this pull request Aug 2, 2024
5 tasks
@jamestrew
Copy link
Contributor

Hey, very sorry for the long delay. Finally got around to look at this.

I'm wondering if it's possible to dynamically choose to show/hide the extension depending on whether it is there.
Otherwise, using just ctags -R ., you can get a bunch of unknown in the rightmost column causing the middle tag column to be truncated to 16 or 30 characters (depending on show_line=true, this behavior feels a little off as well, maybe it always be 30 characters).
eg. this a garbage example but still demonstrates the issue I think
image

Ideally, we add an extra column upon generating the first row (the first call to the gen_from_ctags callback) only if a valid extension_fields exists, generating and caching the displayer. I'm not sure if that's something that can be determined with just one row from a ctags point of view.

If that's too much hassle, maybe just adding a new option to the picker to dictate this behavior.

@ecerulm
Copy link
Author

ecerulm commented Sep 11, 2024

I'm wondering if it's possible to dynamically choose to show/hide the extension depending on whether it is there

I'll guess you mean to hide the kind if all values are "unknownkind"?

Ideally, we add an extra column upon generating the first row (the first call to the gen_from_ctags callback) only if a valid extension_fields exists, generating and caching the displayer. I'm not sure if that's something that can be determined with just one row from a ctags point of view.

The things is that I don't think looking at the first row works. In a regular project you can have tags without kind.

If that's too much hassle, maybe just adding a new option to the picker to dictate this behavior.

I can certainly add a config to show/hide kind. I can also only add the tag.kind = kind if kind is no unknownkind I can try that and see how does show up on screen.

I'll update the PR with the an option show_kind and add it to the docs.
I'll also experiment with only adding tag.kind if present and see how nvim-telescope reacts to that

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

Successfully merging this pull request may close these issues.

Support for ctags kinds on picker builtin.tags
3 participants