Skip to content

Conversation

BBboy01
Copy link
Contributor

@BBboy01 BBboy01 commented Dec 31, 2023

Closes #168

@BBboy01 BBboy01 changed the title feat: support icons_by_file_extension feat: support icons_by_file_prefix Dec 31, 2023
@BBboy01 BBboy01 force-pushed the master branch 3 times, most recently from 0a281f8 to 896af6e Compare December 31, 2023 11:54
@alex-courtis alex-courtis changed the title feat: support icons_by_file_prefix feat(#168): support icons_by_file_prefix Jan 6, 2024
@alex-courtis alex-courtis changed the title feat(#168): support icons_by_file_prefix feat(#168): add prefixes Jan 6, 2024
{},
icons_by_filename,
icons_by_file_prefix,
icons_by_file_extension,
Copy link
Member

@alex-courtis alex-courtis Jan 6, 2024

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".

Copy link
Member

@alex-courtis alex-courtis left a 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


```lua
require'nvim-web-devicons'.get_icon(filename, extension, options)
require'nvim-web-devicons'.get_icon(filename, pre_or_ext, options)
Copy link
Member

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)
Copy link
Member

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.

@alex-courtis
Copy link
Member

Please reopen if you wish to continue this change.

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.

feat: add by_prefix similar to by_suffix
2 participants