[mini.icons] Adding icons like ansible to filetype #1017
-
Greetings, I just got mini.icons through the last update of lazyvim and would like to add icons to specific filetypes. What I did was adding the following to the lazyvim configuration:
Icon would be nf-md-ansible. But for some reason that does not work for me. Doing the same for filetype To detect the ansible filetype I am setting those through vim.add.filetype in a custom config in lazyvim. Which is correctly identified by the ansiblels. Does anyone has a hint for me what I might be doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 9 replies
-
Hi! First, just to make sure, is "yaml.ansible" is indeed a filetype? What it means is that when you open a target file, it has Second (if the first one is true), where do you expect it to be shown? If in the file explorer, then chances are that it uses "file" category. In this case, it has certain order of preference and if the file name ends with plain "yaml" or "yml" extension, then it stops on the second step as those are manually tracked extensions (you can see those with The reason it was added to manually tracked list is because it is fairly common (like, for example, around 3% of all files in this benchmark project) and always relying on |
Beta Was this translation helpful? Give feedback.
-
So, I've removed 'yml' and 'yaml' from the list of built-in (manually tracked) extensions, but upon investigation I don't think this will help your use case. Based on this filetype detection for 'yaml.ansible' it requires checking full path, which is currently not supported: only basename is taken into account for "file" and "directory" category. The reason for this is to make better use of caching: with full paths cache will not be reused for files with same basenames (which I think is a more common occurrence). I'll make some profiling (both memory and speed) for when full path is used and get back to you. Hope to do this in the near future. |
Beta Was this translation helpful? Give feedback.
-
@mstinsky, thanks to a series of refactors and optimizations (see this comment if you are curious which ones), this is now possible on latest local ext_skip = { yml = true }
require('mini.icons').setup({
use_file_extension = function(ext, _) return not ext_skip[ext:lower()] end,
}) This setup basically tells 'mini.icons' that 'yml' filetype should be ignored during "file" resolution which results in always relying on Assuming the Note that this requires that This question/issue was the main driving force for making those (overall positive) changes happen, so thanks for creating it! |
Beta Was this translation helpful? Give feedback.
-
@mstinsky, there was a slight change in how The approach with The suggested way now is to perform explicit string manipulation before comparing. So in your case it would be something like |
Beta Was this translation helpful? Give feedback.
@mstinsky, thanks to a series of refactors and optimizations (see this comment if you are curious which ones), this is now possible on latest
main
with a few necessary setup tweaks. Here is a setup that makes it work:This setup basically tells 'mini.icons' that 'yml' filetype should be ignored during "file" resolution which results in always relying on
vim.filetype.match()
output (which is essentially what is needed here). See help entry for more details.Assuming the
vim.filetype.add({ pattern = { ['.*/roles/.*/tasks/.*%.ya?ml'] = 'yaml.ansible' …