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:
parent
41556ec87f
commit
ded17258cd
4 changed files with 36 additions and 5 deletions
|
|
@ -154,6 +154,11 @@ COL_DEFS = [
|
|||
"boolean",
|
||||
"Set to false to remove the extra whitespace after the icon",
|
||||
),
|
||||
LuaParam(
|
||||
"use_slow_filetype_detection",
|
||||
"boolean",
|
||||
"Set to true to detect filetypes by reading the first lines of each file (e.g. shebangs).",
|
||||
),
|
||||
],
|
||||
),
|
||||
ColumnDef("size", "files, ssh, s3", False, True, "The size of the file", UNIVERSAL + []),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue