Skip to content

WIP: builtin add tagstack function#210

Closed
DevonMorris wants to merge 2 commits intonvim-telescope:masterfrom
DevonMorris:master
Closed

WIP: builtin add tagstack function#210
DevonMorris wants to merge 2 commits intonvim-telescope:masterfrom
DevonMorris:master

Conversation

@DevonMorris
Copy link
Copy Markdown

This PR adds a tagstack function. I marked it work in progress because we probably want a make_entry.gen_from_tagstack and I want it to push/pop appropriately based on the selection.

Also any other comments you have are appreciated.

Comment thread lua/telescope/builtin.lua
opts = opts or {}
local tagstack = vim.fn.gettagstack()
if vim.tbl_isempty(tagstack.items) then
return
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably should print a message "No tagstack available" or similar.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread lua/telescope/builtin.lua Outdated
return
end

for i, value in pairs(tagstack.items) do
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should use ipairs when iterating over an array-like table.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread lua/telescope/builtin.lua Outdated
-- reverse the list
tags = {}
for i=#tagstack.items, 1, -1 do
tags[#tags+1] = tagstack.items[i]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use table.insert(tags, tagstack.items[i]) for simpler lua.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tjdevries
Copy link
Copy Markdown
Member

You had originally mentioned doing some stuff with manipulating the tagstack, are you still interested in doing that?

@DevonMorris
Copy link
Copy Markdown
Author

DevonMorris commented Nov 3, 2020

Yeah I'm definitely still interested in manipulating the tagstack based on the chosen tag. Specifically, I'd like

  • The picker to begin at your current position in the tagstack
  • The tagstack to push/pop the appropriate number of entries based on your selection

I'm really unsure where to begin when it comes to implementing those features. I've taken a cursory look at pickers.lua but couldn't figure out how to do it in the 5 minutes I looked through it.

Edit: Maybe Picker:set_selection for starting at the current position.

Edit edit: I played around with this a bit more looks like you can't call Picker:set_selection before calling find since self.max_results hasn't been set yet. Also find resets the selection so that wouldn't help anyway. Maybe it needs to be added as an option in the initialization and store a member for default/first selection?

@tjdevries
Copy link
Copy Markdown
Member

So the first part (setting it to be your current position) would probably be kind of difficult (but perhaps possible).

The pushing / popping you could do. You'd need to override the default mapping of to be some new action that has to do with tagstack. You can find out what tagstack entry you have and pop the entries til you arrive at that one or something like that.

Does that make sense at all?

@Conni2461
Copy link
Copy Markdown
Member

@DevonMorris do you mean setting the selection at the current position, because i have a change in #208 where you can set a default_selection_index which can be passed to the Picker when creating with new.

@DevonMorris
Copy link
Copy Markdown
Author

@tjdevries yeah definitely makes sense. I'll see if I can get some time this weekend to try it out.

@Conni2461 thanks, I'll check it out

@tjdevries
Copy link
Copy Markdown
Member

Implemented in #744

@tjdevries tjdevries closed this Apr 9, 2021
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.

3 participants