Skip to content

feat(#168): opt-in prefix matching for filenames - #658

Open
dinhkarate wants to merge 1 commit into
nvim-tree:masterfrom
dinhkarate:feat/168-prefix-icons
Open

dinhkarate wants to merge 1 commit into
nvim-tree:masterfrom
dinhkarate:feat/168-prefix-icons

Conversation

@dinhkarate

Copy link
Copy Markdown

Closes #168

Adds a prefix option, usable per call (get_icon(name, ext, { prefix = true })) or globally via setup({ prefix = true }). When neither the filename nor the extension matches, the part of the name before the first dot is looked up in icons_by_filename, so Dockerfile.dev, Containerfile.prod and Makefile.inc get the Dockerfile/Makefile icons.

This addresses the review on #370: it is off by default, so existing behaviour does not change. Filename and extension matches still take precedence (Dockerfile.lua stays Lua). It reuses the existing filename table, so no new icon table or generation changes are needed.

Tested headless with Neovim 0.12:

  • default off: Dockerfile.dev → no icon (unchanged)
  • opt-in per call, with and without strict → Dockerfile
  • extension precedence: Dockerfile.lua → Lua
  • dockerfile. and .x.y → no match
  • global setup({ prefix = true }) → Containerfile.prod / Makefile.inc resolved

stylua --check . and luacheck lua scripts are clean.

AI disclosure: written with AI assistance (Claude Code, OpenCode/DeepSeek), reviewed and tested by me.

🤖 Co-authored with claude-chan

Add a `prefix` option (per call or via setup) that, when neither the
filename nor the extension matches, looks up the part of the name before
the first dot by filename, e.g. Dockerfile.dev uses the Dockerfile icon.

Disabled by default so existing behaviour is unchanged.

Co-authored-by: claude-chan <claude-chan@thatnghiep.dev>
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

1 participant