Wrong file icon for custom filetype #1497
-
I use 'mini.icons' and when modify filetype config as in the following example, the corresponding file's icon displayed incorrectly in fzf-lua window. Is there some workaround maybe? vim.filetype.add({
filename = {
["somefile"] = "lua",
},
}) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 17 replies
-
For performance reasons fzf-lua caches the internal mappings in mini, can you try loading fzf-lua for the first time only after calling |
Beta Was this translation helpful? Give feedback.
-
I notice something similar although not exactly the same. I have created a utility function to use for file browser-like experience (in an effort to get rid of other file explorer plugins, if it suits my needs after some time). The function is the following function M.fzf_dirs(opts)
local fzf = require("fzf-lua")
local path = require("fzf-lua.path")
-- require("fzf-lua.devicons").plugin_load("mini")
local uv = vim.uv or vim.loop
local cmd = "fd -d1"
local function get_full_path(selected)
if #selected < 1 then
return
end
local entry = path.entry_to_file(selected[1], { cwd = uv.cwd() })
if entry.path == "<none>" then
return
end
-- Taken from require('fzf-lua').files, maybe there's a better way?
local fullpath = entry.path or entry.uri and entry.uri:match("^%a+://(.*)")
if not path.is_absolute(fullpath) then
fullpath = path.join({ uv.cwd(), fullpath })
end
return fullpath
end
opts = opts or {}
opts = {
defaults = {},
prompt = "Fzf Browser> " .. vim.fn.fnamemodify(uv.cwd(), ":~") .. "/",
cwd = uv.cwd(),
cwd_prompt_shorten_len = 32,
cwd_prompt_shorten_val = 1,
file_icons = true,
fzf_opts = {
["--tiebreak"] = "end",
["--preview"] = {
type = "cmd",
fn = function(selected)
local fullpath = get_full_path(selected)
return string.format("command ls -Alhv --group-directories-first %s", fullpath)
end,
},
},
fn_transform = function(x)
return fzf.make_entry.file(x, { file_icons = true, color_icons = true, cwd = uv.cwd() })
end,
actions = {
["default"] = {
function(selected)
local fullpath = get_full_path(selected)
vim.cmd("cd " .. fullpath)
-- fzf_lua.fzf_exec("fd -td", opts)
opts.cwd = fullpath
M.fzf_dirs()
end,
},
["alt-f"] = function(selected)
local fullpath = get_full_path(selected)
if uv.fs_stat(fullpath).type ~= "directory" then
fullpath = vim.fn.fnamemodify(fullpath, ":p:h") .. "/"
end
vim.ui.input({ prompt = "File Name: " }, function(name)
if name == nil then
return
end
vim.cmd("e " .. fullpath .. name)
vim.cmd("w ++p") -- will create directory if not exists, so you can write new/dir/some_file.lua
end)
end,
["alt-g"] = {
function(selected)
local cwd = selected[1] --[[@as string]]
local parent = require("fzf-lua.path").parent(cwd, false)
vim.cmd("cd ..")
opts.cwd = parent
M.fzf_dirs()
end,
},
},
}
fzf.fzf_exec(cmd, opts)
end I use LazyVim distro for my Neovim setup. I've observed the following:
From scourging through the code (although I'm not comfortable with the codebase and struggle a lot understanding), my guess is that So, if I open LazyVim also uses Am I maybe not using the PS: If I do |
Beta Was this translation helpful? Give feedback.
#1498 (comment)