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

Tag.find equivalent in new api #111

Closed
vtrvtr opened this issue Mar 9, 2024 · 5 comments · Fixed by #114
Closed

Tag.find equivalent in new api #111

vtrvtr opened this issue Mar 9, 2024 · 5 comments · Fixed by #114

Comments

@vtrvtr
Copy link

vtrvtr commented Mar 9, 2024

Hi, I used to have the following function

function file_name_from_tag(key)
  local tag = require("grapple").find { key = key }
  if tag == nil then return string.format("Mark %s", key) end
  return string.format("Mark %s %s", key, truncate_path(tag["file_path"]))
end

I used this to display the current tag in various places (telescope/whichkey). It seems this function was removed in the new update. Is there a way I can do something equivalent in the new api?

Thanks, awesome plugin.

@cbochs
Copy link
Owner

cbochs commented Mar 10, 2024

I'm happy to add back something like Grapple.find. However, would something that returns all tags for a given scope work for you? Right now the following function is used for Grapple's default telescope integration:

---Return the tags for a given scope. Used for integrations like telescope
---@param opts? { scope?: string }
---@return grapple.tag[] | nil, string? error
require("grapple").tags(opts)

Where grapple.tag is

---@class grapple.tag
---@field path string absolute path
---@field name string | nil (optional) tag name
---@field cursor integer[] (1, 0)-indexed cursor position

Note: key has been removed in favour of an explicit tag name or index in the list. See: Grapple.exists

@vtrvtr
Copy link
Author

vtrvtr commented Mar 11, 2024

Yes, that works fine. Thanks. Please close this issue if you prefer to not implement it.

@cbochs
Copy link
Owner

cbochs commented Mar 11, 2024

@vtrvtr added Grapple.find 🙂 I am curious, however, what was your use-case for whichkey?

@vtrvtr
Copy link
Author

vtrvtr commented Mar 12, 2024

Awesome, thanks

I used it in which key for this:

image

I use grapple more like vanilla vim marks, so in which key I can see which file is marked with that particular name

@cbochs
Copy link
Owner

cbochs commented Mar 12, 2024

Very neat!

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 a pull request may close this issue.

2 participants