-
-
Notifications
You must be signed in to change notification settings - Fork 853
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
Consistent filepath display and code cleanup. #839
Conversation
😟 enum, seriously. I don't see any value of enums vs strings. It will just break setups. Strings doesn't require importing stuff and support future abstraction of configuration setup |
I will send some comments maybe later today, but probably tomorrow. This isn't exactly what I meant. No worries though 😁 |
local make_enum = function(t)
-- todo: enum maker... (i have implementation elsewhere)
return t
end
local types = {}
types.FileDisplay = make_enum {
HIDE_PATH = 1,
SHORTEN_PATH = 2,
TAIL_PATH = 4,
ABSOLUTE_PATH = 8,
-- ... future optiosn possible
}
require('telescope.builtin').find_files {
-- This would make paths short & absolute
file_display = types.FileDisplay.SHORTEN_PATH + types.FileDisplay.ABSOLUTE_PATH,
}
require('telescope.builtin').find_files {
-- This would hide the path.
-- It shouldn't matter what else you add here, as it will just hide the path.
file_display = types.FileDisplay.HIDE_PATH,
}
-- This method lets us continue to add other options to the display without having to create
-- an ever growing number of fields and have people be confused about which one each does. This is more along the lines of what I was thinking. We can use bit flags to check whether a value is present or not and do things with it depending on how it works. @tami5 does this make more sense? |
😭 idk @tjdevries, I definitely prefer if Don't get me wrong I absolutely like enums, but for lua and configs; 1. I don't see any value in it, 2. it feels more robust and requires extra code, 3. why bother Your call. |
@tjdevries I personally would slightly lean towards @tami5 's opinion. As a telescope user, configs will be a little easier to have raw strings then getting the enum type. I can see both sides though, since enums are more "proper" and can help catch configuration errors. Either works for me, I can go with what the maintainers prefer. |
How do you do this with strings: Perhaps we just enumerate all the string options "shortened_absolute", "shortened_relative", etc.? It seems a bit difficult to check them all (and prone to error as time goes on). |
Ah, so you're saying |
seems like @tjdevries, @Conni2461, and myself are in alignment to have the |
OK I actually just pushed a commit for using raw strings instead of enums. Apparently I don't know how to work with git well enough. I rebased against master and got a bunch of stuff not related to this PR. I'll try to figure it out tomorrow or the day after. |
Cleaned things up and should be reviewable now. |
LGTM |
Only other thing that I notice right away is that we should warn people if they pass something like |
Added more changes
|
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.
Looks very useful 🙂
Only additional suggestion would be that I think we can remove get_default
on line 7 of make_entry.lua
as it is no longer used in that file. (Not sure why GitHub isn't letting me review that line but 🤷)
Any of the maintainers want to take a look at this? |
I generated docs, written changelog and added the old options to deprecated file (because its a breaking change). I'll merge tomorrow, its too late for me now. :) Thanks for adding the docs and all your work here @caojoshua 😃 |
- adds option to configure the length of shortened parts of filenames - only affects paths when "shorten" is in `path_display` - reimplemented based on changes in nvim-telescope#473 and nvim-telescope#839
- adds option to configure the length of shortened parts of filenames - only affects paths when "shorten" is in `path_display` - reimplemented based on changes in nvim-telescope#473 and nvim-telescope#839
Changes
hide_filename
,shorten_path
, andtail_path
Caveats
Open Questions
shorten_path
andtail_path
shorten_path
to true by default