-
Notifications
You must be signed in to change notification settings - Fork 0
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
Added smart_path option for file name getters. #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Before I look too deep into code, can you explain what exactly is a
smart path
? From your examples in File paths are relatively shown depending on other files tom-anders/telescope-vim-bookmarks.nvim#2, it looks like smart relative paths. Could we come up with a more specific name? - Still not exactly sure how we are going to do enums, but TJ just responded in Consistent filepath display and code cleanup. nvim-telescope/telescope.nvim#839, so I'm gonna let that play out first
- Since I still don't fully understand, depending on how complicated this is, I might just let the current PR merge first, and then we can create this as a separate PR
I thought it should be a separate implementation as well but I was directed to this by one of the main contributors - which makes it safe to merge in my mind. The function itself can benefit from open source community as well. |
I updated my pull request in the main repo to not use enums: nvim-telescope#839 I think these changes would benefit Telescope, but I think these should be merged as a separate PR in the main repo in favor of smaller PRs. @Conni2461 would you prefer combining into one PR, or try to merge this separately after the current PR is merged? I can work with either way. |
I don't really prefer one over the other. I am fine with both, tbh. Note: we are squashing PRs so if you want full commit credit you probably want to make a separate PR to telescope :) |
Hey! Wanted to say I don’t really care about that when it’s improving the product I’m using day to day. Thanks for y’all’s effort. I can do the PR creation after this PR is merged if the owner prefers that way because I feel like that’s the case. Also maybe I can improve it in the meanwhile. I’ve been using it locally for a while now and it’s working accordingly. there is a bug that happens every once in a while - the second file in the results shows up as full path sometimes when there are 4+ results. (i’m suspecting that there is a bug with initial loop logic) but if you hover over it, it corrects itself (i’m assuming because of rerender). i can make the logic more solid to prevent such a thing and make it “production ready”. but we are going to go in a release cycle at work in a month or so — but i can make time here and there. if you guys can give me an approximate merge time that’d be perfect for my planning. also if things comes down to it @Conni2461 you can copy my code and improve it and push to the main repo. you have my explicit permission. |
@@ -147,6 +148,83 @@ utils.path_tail = (function() | |||
end | |||
end)() | |||
|
|||
utils.slice = function(tbl, s, e) | |||
local pos, new = 1, {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you actually want to copy all elements between s and e into a new table? Thats not great.
Maybe this plenary module can help https://github.com/nvim-lua/plenary.nvim/blob/master/lua/plenary/iterators.lua
No idea how it works tho. But i saw a range function. This is the spec file https://github.com/nvim-lua/plenary.nvim/blob/master/tests/plenary/iterators_spec.lua
|
||
|
||
|
||
PATHS = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be a global right?
final = utils.slice(initial_path, length - 1, length) | ||
final = table.concat(final, "/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are only using slice for create a string afterwards you should look for a different method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i figured that but i was like “i’m already using it 🤷🏻♀️“.
it’s a quick hack, not production ready at all. i’ll fix these if i’m going to open the pr on the main repo. i appreciate the feedback
edit: and i honestly wasn’t hopeful about the initial PR. i didn’t know we would get you involved
Maybe can merge in a week-ish. I've linked to this pull request as a TODO from this Telescope wiki, to make sure this is on our radars. |
Hi, I also looking for smart file paths. My idea would be naive and simple. could you just allow me to configure the depths of the file path to be displayed? This would be ideal for my usecase. may be before the depth it could be "hidden/shorten"!!! |
Hey, this is my fork that I use for my own pull requests. You might want to check nvim-telescope#914, although seems that pull request is not active. |
tom-anders/telescope-vim-bookmarks.nvim#2
Hey!
So I've done this after the discussion with @Conni2461 and how this would overall benefit the project.
Placing myself at mercy, I've also decided to change the enum logic as well. So that a user doesn't have to deal with importing/exporting/creating enums but configure the options as it is (ie. smart_path = true)
Just to have the preview here as well:
Let me know what you think!