Closed liujoey closed 1 year ago
If I remove this line from providers/buffers.lua:181
, it will just work:
if opts.color_icons then
-- buficon = utils.ansi_codes[hl](buficon)
end
If I open a file without ext, say the file name is just build
, the value of hl
is nil
, seems like the buficon, hl = make_entry.get_devicon(filename, extension)
function didn't return a valid hl
When I open a txt file or a java file, the hl
is DevIconTxt
or DevIconJava
respectively, but the utils.ansi_codes
does not have these keys. Here is the key dump of utils.ansi_codes
:
DevIconCss DevIconYml DevIconGraphQL DevIconClojure DevIconZig DevIconH DevIconVerilog DevIconJavaScriptReactSpec DevIconPhp DevIconReScriptInterface DevIconVala DevIconPsManifestfile FzfLuaBufFlagAlt DevIconTcl DevIconSpecJs DevIconDsStore DevIconPsScriptfile DevIconTestJs DevIconTerminal FzfLuaBufFlagCur DevIconCMake DevIconBashProfile DevIconDiff DevIconClojureJS FzfLuaBufNr DevIconNPMrc DevIconClojureDart DevIconKotlin DevIconGitlabCI DevIconC DevIconSml DevIconKotlinScript DevIconImportConfiguration DevIconHbs DevIconJl DevIconLess DevIconSettingsJson DevIconGo DevIconPy DevIconWebmanifest DevIconJson5 DevIconDrools DevIconVim DevIconToml DevIconSolidity DevIconMixLock DevIconNim DevIconXcPlayground DevIconJsx DevIconHxx DevIconPsScriptModulefile DevIconRb DevIconSuo clear DevIconCPlusPlus DevIconSql DevIconJs blue DevIconPrisma dark_grey DevIconMjs DevIconHpp DevIconCrystal DevIconPackageJson white DevIconScss DevIconTs DevIconR DevIconPyc DevIconCson yellow DevIconPyo green DevIconPsb DevIconLuau DevIconPackageLockJson DevIconLicense DevIconYaml DevIconHaml DevIconTex grey DevIconBmp DevIconZshprofile DevIconFavicon red DevIconBashrc DevIconEnv DevIconMakefile DevIconZshenv DevIconDart DevIconOPUS DevIconNodeModules cyan DevIconPsd DevIconCobol DevIconMint DevIconLua DevIconVagrantfile DevIconRlib DevIconRakefile DevIconProlog DevIconMaterial DevIconStyl DevIconVimrc DevIconFsharp DevIconGvimrc DevIconDockerfile bold underline DevIconJson DevIconCMakeLists DevIconLog DevIconLiquid DevIconNPMIgnore black italic DevIconZshrc DevIconHtm magenta DevIconPdf DevIconSln DevIconJavaScriptReactTest DevIconCsv
seems like the
buficon, hl = make_entry.get_devicon(filename, extension)
function didn't return a valid hl
It should return a default icon, do you have any customization for the devicons plugin?
Does it with with mini.sh
within the same folder with the problematic extensions?
When I open a txt file or a java file, the hl is DevIconTxt or DevIconJava respectively, but the utils.ansi_codes does not have these keys. Here is the key dump of utils.ansi_codes:
This can easily be solved with a default color/icon fallback but I’m wondering why these don’t return the default icon on your system.
I’ll do some testing on my end.
It should return a default icon
The buficon
variable is correct (which is the default icon), but the hl
is nil
.
If I step into the make_entry.lua:190
if M._devicons then
icon, hl = M._devicons.get_icon(file, ext:lower(), { default = true })
-- here the hl is already nil
elseif M._devicons_map then
On my system I also face a lot of errors like this, I feel they are related. I'm using the latest version of nvim-web-devicons plugin:
Unable to stat file Error loading remote config section '_devicons_geticons()'
https://github.com/ibhagwan/fzf-lua/commit/8b855fedfd50ef0e9e0484e2ee59e8dbac326c24
The above commit should get rid of the error.
Let's also try to understand what happened to your devicons setup, can you run the same commands and paste the output?
:lua vim.print(require("nvim-web-devicons").get_icon("build", "build", { default =true }))
DevIconBazelBuild
:lua vim.print(require("nvim-web-devicons").get_icon("1.java", "java", { default=true }))
DevIconJava
:lua vim.print(vim.api.nvim_get_hl(0, { name = "DevIconBazelBuild", link = true }))
{
ctermfg = 113,
fg = 9035857
}
:lua vim.print(vim.api.nvim_get_hl(0, { name = "DevIconJava", link = true }))
{
ctermfg = 167,
fg = 13385284
}
:lua vim.print(require("fzf-lua").utils.ansi_from_hl("DevIconBazelBuild", ""))
^[[38;2;137;224;81m^[[0m
^[[38;2;137;224;81m
:lua vim.print(require("fzf-lua").utils.ansi_from_hl("DevIconJava", ""))
^[[38;2;204;62;68m^[[0m
^[[38;2;204;62;68m
Unable to stat file Error loading remote config section '_devicons_geticons()'
This is also related, fzf-lua runs the heavier operations in a separate process and then queries the main instance (over named pipe) for the icon configuration, it seems this is failing.
(1) Can you try the running the min.sh
and see if you get the same errors or the icons work as expected (i.e. with colors)?
sh -c "$(curl -s https://raw.githubusercontent.com/ibhagwan/fzf-lua/main/scripts/mini.sh)"
(2) Can you post the full output of:
:lua vim.print(require("nvim-web-devicons").get_icons())
For your last comment:
running mini.sh
working all good. Icon and color looks correct.
Is this has something to do with lazy.nvim lazy loading mechanism?
Here is the dump of the second command when I use Astronvim:
{ <1>{
icon = ""
},
[".babelrc"] = {
color = "#666620",
cterm_color = "58",
icon = "",
name = "Babelrc"
},
--- edited to make this thread scrollable again
}
Let's also try to understand what happened to your devicons setup, can you run the same commands and paste the output?
All of these commands are correct with no errors, even in the Astronvim setup. I use light background so the color values are different from yours as expected.
https://github.com/ibhagwan/fzf-lua/commit/9babc8e2104b55f6b8913d32e59c07a4fd73378e
Can you try the above commit?
It seems that the default icon in your setup is weird, according to what you posted the default icon contains no color or name in your setup:
<1>{
icon = ""
},
Whereas mine returns:
:lua vim.print(require("nvim-web-devicons").get_icons()[1])
{
color = "#6d8086",
cterm_color = "66",
icon = "",
name = "Default"
}
Is there any way for me to try your config? Is it on github?
Appreciate your effort for helping!!
Yes, it's Astronvim so you need to first clone their repo, and then clone my user
repo inside their directory. My repo's readme has the two clone commands that you need to use.
Appreciate your effort for helping!! Yes, it's Astronvim so you need to first clone their repo, and then clone my
user
repo inside their directory. My repo's readme has the two clone commands that you need to use.
I think I found the issue where they mangle the default icon: https://github.com/AstroNvim/AstroNvim/blob/43d458135a534beead8f32158c1d9293adb202dc/lua/plugins/configs/nvim-web-devicons.lua#L3
Can you try the latest commit and see if everything works and you're no longer getting errors?
Running on your latest commit, the buffers window show all icon in dark_grey so I guess it's not fixed.
Also, same issue after run FzfLua grep
: Unable to stat file Error loading remote config section '_devicons_geticons()'
Running on your latest commit, the buffers window show all icon in dark_grey so I guess it's not fixed. Also, same issue after run
FzfLua grep
:Unable to stat file Error loading remote config section '_devicons_geticons()'
Alright, I'll try your repo.
Another input, when I open buffers in my nvim project, with a bunch of lua files opened, the buffers window shows all icon in correct color. But when I open a java project, and open some files like pom.xml
, README.md
and build
, all of their icon color was gone. However both projects having the grep
issue. I'm super confused now.
Another input, when I open buffers in my nvim project, with a bunch of lua files opened, the buffers window shows all icon in correct color. But when I open a java project, and open some files like
pom.xml
,README.md
andbuild
, all of their icon color was gone. However both projects having thegrep
issue. I'm super confused now.
That's ok I'll figure this out, the reason this happens with grep
(and files
) is because these run in a separate process vs buffers
runs within the main instance so they have slightly different methods of acquiring the icons/colors.
https://github.com/ibhagwan/fzf-lua/commit/000845dea264b3dca268ade5a807a1b7ff94fc8d - this should solve the Error loading remote config section '_devicons_geticons()'
error.
But when I open a java project, and open some files like pom.xml, README.md and build, all of their icon color was gone
This I'm still unsure what's happening here, can you narrow down this issue?
.xml
files or just after you open a java project?buffers
, files
or grep
(or all)?I see you have a special setup for Java (nvim-jdtls, etc), perhaps something in the file is causing this error?
If this happens only after opening .java
file can you try running lua vim.print(require("nvim-web-devicons").get_icon("build", "build", { default =true }))
before and after opening the java project?
Confirmed that with 00854d the grep issue was gong! Thank you so much!!!
Now for the icons: The java configuration will only be load if I open a java file, but the issue I'm experiencing happens without open a java file. All I opened are these three files:
If you create a new folder with only those three files, and create a git repo by just git init
, and open all three files with nvim build pom.xml README.md
, then open buffers with FzfLua buffers
. Unless it's really something strange happened on my system, you would be able to reproduce.
- Does this happen in
buffers
,files
orgrep
(or all)?
Yes, happens to all of them. And it's pretty random, sometimes one file's icon got its color, sometimes all three files showing dark_grey. Even if you just open buffers/files multiple times, each time the result could be different.
Yes, happens to all of them. And it's pretty random, sometimes one file's icon got its color, sometimes all three files showing dark_grey. Even if you just open buffers multiple times, each time the result could be different.
Following your exact instructions it doesn’t reproduce, given the randomness I’m thinking this could also be some weird terminal bug affecting all colors, can you post a screenshot of the buffers screen when this happens?
I want to see if other colors such as the current and alternate buffers (# and %
) appear colorful or are also grayed out.
some weird terminal bug affecting all colors
Tested on both iTerm2 and WezTerm, exact same issue.
And you can see from this last screenshot, now all xml files got the color, as previously they don't. Super random. I hope this is not related to performance, as if I open git_files
a few more times, those already presented color will disappear again, feels like the cache got somehow refreshed? Our corporate laptop was heavily protected with a lot of virus scanner etc. So most of the time if it is related to I/O it could be slow down by the scanner.
ssh to a remote Linux VM, run the same setting on the same project with 15k+ files (with a different version of nvim 0.8.0), seems the issue is gone there. Maybe it is performance related?
ssh to a remote Linux VM, run the same setting on the same project with 15k+ files (with a different version of nvim 0.8.0), seems the issue is gone there. Maybe it is performance related?
I'm still struggling with this, why would performance impact the highlights? Why only some and why randomly?
how do you update the util.ansi_code
table? I would assume this table gets build only once? But from the behavior on my laptop, sometimes this table gets wiped out? So at one time util.ansi_code['WhateverJava'] is valid but a few moment later the same call failed? Tomorrow when I get some spare time I will trace into this and figure out why and how this happens. It's mid night for me need to go to bed. Really appreciate all your help, you are one of the best plugin author! Keep the good work.
Ty for the kind words @liujoey!
Would you be able to try https://github.com/ibhagwan/fzf-lua/commit/c3983ed7d9cfeeb6617a57dadfaa0cede27614b5, I have a feeling this might help the situation.
how do you update the util.ansi_code table?
As for your question, util.ansi_code
is never cleared or updated that's why I'm confused about your finding and the fact this is reproduced in buffers
(which doesn't use an external process).
However, with files
, git_files
and grep
it's a different story, since an external process is used, utils.ansi_code
is being rebuilt each time at the startup of the external process from the table returned by _devicons_geticons()
and then built inside setup_devicons_term_hls
:
https://github.com/ibhagwan/fzf-lua/blob/c3983ed7d9cfeeb6617a57dadfaa0cede27614b5/lua/fzf-lua/make_entry.lua#L95-L113
with https://github.com/ibhagwan/fzf-lua/commit/c3983ed7d9cfeeb6617a57dadfaa0cede27614b5 the returned table should be consistent as it's no longer built in runtime but cached at startup instead, this should help performance and hopefully solve this issue as well.
Another unrelated issue I noticed with your setup is that your buffer names aren't aligned properly, the issue is due to your colorscheme defining a background value for FzfLuaBufNr
in:
https://github.com/liujoey/astronvim/blob/0b4170533924789fa3cbd58f69e694587c259a32/highlights/edge.lua#L33
This causes the string to be too long (due to extra ansi escape sequence for both fg and bg) to negate the effect of the string.format
alignment in:
https://github.com/ibhagwan/fzf-lua/blob/c3983ed7d9cfeeb6617a57dadfaa0cede27614b5/lua/fzf-lua/providers/buffers.lua#L187-L190
Let me know if you'd like this solved, I can make the alignment width configurable via opts
.
I think I found the issue. In make_entry.lua:103
you have assert(info.name)
Given the setup from Astronvim, the _devicons.get_icons()
can very well return a list of 273 icons, but two of them have NO NAME
{
icon = ""
}
{
icon = ""
}
And most bazrrrr thing is that, the position of these two icons appears random in the table, so in your for loop, because of that assert
, the loop can be interrupted randomly when ever one of this nameless icon appears.
If I change this loop to this:
for _, info in pairs(M._devicons and M._devicons.get_icons() or M._devicons_map) do
-- assert(info.name)
if info.name then
local hlgroup = "DevIcon" .. info.name
-- some devicons customizations remove `info.color`
-- retrieve the color from the highlight group (#801)
local hexcol = info.color or utils.hexcol_from_hl(hlgroup, "fg")
if hexcol and #hexcol > 0 then
local r, g, b = hex(hexcol)
utils.cache_ansi_escseq(hlgroup, string.format("[38;2;%s;%s;%sm", r, g, b))
end
end
end
Then everything works.
Good catch @liujoey!
I guess my last update does solve it for the external process since that uses M._devicons_map
, does make me wonder how come the assert doesn’t popup.
I’ll remove the asset from the code.
That's also surprised me, I'm not a lua programmer, so I originally would assume assert
at least should report an error if condition not met. But in this case it silently interrupt the for loop.
Yeah, please remove that assert and wrap the code with
if info.name then
...
end
https://github.com/ibhagwan/fzf-lua/commit/35c9795dde0cfea7fbac6fc38ec4bfbdb98eef89
Slightly improved on that, will use the map key as fallback since it usually matches the name
anyways:
https://github.com/ibhagwan/fzf-lua/blob/35c9795dde0cfea7fbac6fc38ec4bfbdb98eef89/lua/fzf-lua/make_entry.lua#L104-L105
Let me know if this solves the last remaining issue and we can finally close this :-)
That's great, work perfectly!
That's great, work perfectly!
Ty for the help and excellent troubleshooting skills :)
Info
nvim --version
: 0.91 releasefzf --version
: 0.37.0 (brew)mini.sh
fzf-lua configuration
Using neovim with Astronvim distribution ```lua -- using lazy.nvim { "ibhagwan/fzf-lua", -- optional for icon support dependencies = { "nvim-tree/nvim-web-devicons" }, config = function() -- calling `setup` is optional for customization local fzf = require("fzf-lua") fzf.setup() fzf.register_ui_select() end }, ```Description
Open nvim within the project folder (git), no buffer opened. Run cmd
FzfLua buffers
, all looking good, shows empty list. open 2 or 3 files, runFzfLua buffers
again, it shows this following errorsThis only happens in some of my projects. Don't know why/how this happens. And I don't know why it only happens in certain project folders.