-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] No Colors for both up_to_date
and outdated
#155
Comments
I am having the same issue. I am also using lazyvim. I wonder if it has to do with lazy loading? |
I can confirm it seems the problem is when using any kind of lazy loading with lazyvim. If you set "lazy = false" it should work (but ofcourse is always loading at startup). @Saplyn can you confirm that lazy = false works for you as well? |
I think it is related to #141 |
Ok I believe here is the problem: package-info.nvim/lua/package-info/config.lua Lines 123 to 127 in 018bc10
This runs during plugin setup and when not using lazyvim lazy loading then the color scheme will be "default" as it has not been set yet and therefore the When we use any sort of lazy loading then the color scheme is NOT default and therefore this does not run and the highlight groups never get registered. I confirmed my hunch by NOT lazy loading which normally the highlight groups then get registered properly, but I added a vim.schedule(fn()) wrapper around the plugin setup() function so that it gets run "last" after the current call stack and by that time the problem exists as the color scheme is set and therefore no longer "default". Basically vim.schedule() is a way of representing the effect of lazy loading. config = function(_, opts)
vim.schedule(function()
require('package-info').setup(opts)
end)
end, cc @vuki656 |
Thanks for you comments! The bad news is that your solution doesn't seem to work out for me, but good news is that I found a workaround: return {
"vuki656/package-info.nvim",
dependencies = { "MunifTanjim/nui.nvim" },
ft = "json",
opts = {
colors = { -- specify both colors
up_to_date = "#0DB9D7",
outdated = "#d19a66",
},
},
config = function(_, opts)
require("package-info").setup(opts)
-- manually register them
vim.cmd([[highlight PackageInfoUpToDateVersion guifg=]] .. opts.colors.up_to_date)
vim.cmd([[highlight PackageInfoOutdatedVersion guifg=]] .. opts.colors.outdated)
end,
} This workaround works with or without lazy load, and demonstrates that the problem should be related to the highlight group does not correct registered. |
I found that:
|
Yes you are correct. The problem is highlight groups not being registered. The root cause of the problem is lazy loading because the plugin assumes you are loading the plugin immediately at startup. As described in more detail here: #155 (comment) I also added something similar where I registered the highlights in my config function which is a temporary fix for now. I also re-registered the autocmds the plugin adds to make sure they are done properly when lazy loading. |
Is it better to allow the user to control the style/color by setting the highlight groups directly themselves (or inside their theme plugins), instead of using a configuration option? When the plugin is loaded, it can check whether the highlight groups were already defined. If none is found, the default values will be set. |
Yeah that makes more sense. Feel free to open a PR |
- fixed package-info coler issue - Closes:#7 - ref discussiong: [[BUG] No Colors for both up_to_date and outdated](vuki656/package-info.nvim#155)
- fixed package-info coler issue - closes #7 - ref discussiong: [[BUG] No Colors for both up_to_date and outdated](vuki656/package-info.nvim#155
- fixed package-info coler issue - closes #7 - ref discussiong: [[BUG] No Colors for both up_to_date and outdated](vuki656/package-info.nvim#155)
- fixed package-info coler issue - closes #7 - ref discussiong: [ No Colors for both up_to_date and outdated](vuki656/package-info.nvim#155)
Issues
Plugin Version
Neovim Version
Neovim Version
Branch
master
Actual behavior
Both
up_to_date
andoutdated
has no color, no matter the config.Expected behavior
The color should appear, at least the default ones.
Steps to reproduce
package.json
Package info config
I'm using
lazy.nvim
for package manager andLazyVim
distro.Other information
echo $TERM
isxterm-256color
Help
No, sorry.
Implementation help
Sorry I'm new to this editor, however I would try my best to help provide any information needed.
The text was updated successfully, but these errors were encountered: