图标空白或显示方块,主因是tree-view的show icons未开启或文件grammar被识别为plain text;需检查并开启tree-view图标开关、手动设置正确grammar、安装兼容版file-icons、配置项目级config.cson、调整styles.less样式。

图标空白或显示为方块?先看 tree-view 开关和 grammar 识别
图标不出现,90% 不是插件没装对,而是 tree-view 自身的图标开关被关了,或者 Atom 把当前文件识别成了 Plain text。右下角状态栏显示什么语言,就决定了 file-icons 能不能匹配到对应图标。
- 进
Settings → Packages → tree-view → Settings,确认Show Icons是开启状态(默认开,但手动关过不会自动恢复) - 打开任意文件,右下角若显示
Plain text,右键编辑区 →Grammar→ 手动选对语言(比如JavaScript、Vue Component) - 用
Ctrl+Shift+I打开开发者工具,检查 DOM 中某个文件节点是否有icon-js类和data-name="index.js"属性——没有就说明 grammar 没生效,或插件根本没加载
装了 file-icons 却没图标?大概率是版本或安装方式错了
Atom v1.60+ 移除了旧版 CSS 注入机制,直接 apm install file-icons 拉下来的包基本无效。主干分支已停更,必须指定兼容版本。
- 先卸载:
apm uninstall file-icons - 再装指定版本:
apm install https://github.com/file-icons/atom/releases/download/v2.1.45/file-icons-2.1.45.tgz - 装完别只点 Restart —— 必须进
Settings → Packages → file-icons → Settings,勾选Show icons in tree view和Display file names to the right of icons - 最后执行
Application: Reload Window(快捷键Ctrl+Alt+R或Cmd+Alt+R),强制重载样式表
自定义图标不生效?config.cson 位置和 priority 写错就白配
file-icons 只读取项目根目录下的 config.cson,全局 ~/.atom/config.cson 里的规则完全无效。而且多个规则匹配时,靠 priority 决胜负,不是按顺序。
- 把
config.cson放在你项目的最外层目录(和package.json同级) - 匹配正则要加
i标志,否则MyTest.js这种大写开头的就不匹配:match: /\.test\.js$/i - 想让某条规则优先,显式写
priority: 2;不写默认是0 - 图标名写
"lock"就行,别写"icon-lock"或"lock.svg",后者不识别
图标错位、文字截断、颜色发灰?别碰插件源码,改 styles.less
启用 Display file names to the right of icons 后,常见 UI 异常不是插件 bug,而是布局被主题或自定义样式挤压。直接改 styles.less 最快。
- 打开
Atom → Stylesheets…(或编辑~/.atom/styles.less) - 加这几行就能修复文字遮挡:
.tree-view .file.icon:before { margin-right: 6px; } - 如果图标颜色太淡,加:
.tree-view .file.icon:before { opacity: 0.85; } - 禁用其他图标类插件(如
atom-material-icons),它们和file-icons底层冲突,会导致 DOM 重复渲染、滚动卡顿
tree-view 的 Show Icons 开关是关的,或者当前文件 grammar 是 Plain text,图标就永远是空的。这两个开关不在插件设置里,而在两个不同路径的 Settings 页面中,且不会随插件重装自动恢复。











