feat(icon): add opt-in filetype detection via file contents

Problem: files without standard extensions (e.g. scripts with
shebangs, Makefile, Dockerfile) got incorrect or default icons since
icon providers match by filename or extension only.

Solution: add use_slow_filetype_detection option to the icon column
config. When enabled, reads the first 16 lines of each file and
passes them to vim.filetype.match for content-based detection. The
detected filetype is forwarded to mini.icons or nvim-web-devicons as
a trailing parameter, preserving backwards compatibility with
existing icon provider implementations.

Based on: stevearc/oil.nvim#618
This commit is contained in:
Barrett Ruth 2026-02-20 16:56:17 -05:00
parent 41556ec87f
commit ded17258cd
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
4 changed files with 36 additions and 5 deletions

View file

@ -438,6 +438,10 @@ icon *column-ico
{directory} `string` Icon for directories
{add_padding} `boolean` Set to false to remove the extra whitespace after
the icon
{use_slow_filetype_detection} `boolean` Set to true to detect filetypes
by reading the first lines of each file (e.g. shebangs).
This improves icon accuracy for extensionless scripts but
performs synchronous I/O per file per render.
size *column-size*
Adapters: files, ssh, s3