-
Notifications
You must be signed in to change notification settings - Fork 184
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
feat(#168): add prefixes #370
Conversation
0a281f8
to
896af6e
Compare
{}, | ||
icons_by_filename, | ||
icons_by_file_prefix, | ||
icons_by_file_extension, |
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.
I'm not sure we can do that - prefixes will clobber extensions, in this case "dockerfile"
.
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.
I've gone cold on this one; it's introducing breaking changes.
We need to refactor this change - specifically the API - such that existing behaviour does not change. For the user to return the prefix icon they will need to explicitly specify it.
Unfortunately we haven't used named parameters for all API methods however we cannot change that. options
is available in some cases but not all.
Proposal:
Draft an API that preserves existing behaviour and allows prefixes to be selected.
Extension:
New API that uses all name parameters via options
The name is passed in to check for an exact match e.g. `.bashrc` if there is no exact name match the extension | ||
is used. Calls `.setup()` if it hasn't already ran. | ||
|
||
```lua | ||
require'nvim-web-devicons'.get_icon(filename, extension, options) | ||
require'nvim-web-devicons'.get_icon(filename, pre_or_ext, options) |
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 will break existing behaviour - a prefixed icon will be returned where none was before.
else | ||
icon_data = icons[name] or get_icon_by_extension(name, ext, opts) or (has_default and default_icon) | ||
icon_data = icons[name] | ||
or get_icon_by_prefix(name, pre_or_ext, opts) |
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 will result in a prefix being returned when users were previously expecting an extension, when the key is the same.
Please reopen if you wish to continue this change. |
Closes #168