package-info.nvim
package-info.nvim copied to clipboard
[BUG] Plugin doesn't work when lazy loaded
Issues
- [X] I have checked existing issues and there are no issues with the same problem.
Plugin Version
- [X] I am using the latest version of the plugin
Neovim Version
- [X] I am using the 0.6 neovim version or later
Neovim Version
0.9.1
Branch
master
Actual behavior
I'm using lazy.nvim
to lazy load package-info
, but it doesn't seem to work
Expected behavior
It should work when triggerred
Steps to reproduce
- Load the below config
- Try
:lua require("package-info").delete()
Here's mypackage.json
file:
{
"dependencies": {
"peggy": "^3.0.2",
"ts-pattern": "^5.0.5"
},
"devDependencies": {
"@types/jest": "^29.4.0",
"@types/node": "^18.13.0",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"archiver": "^5.3.1",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-only-warn": "^1.1.0",
"jest": "^29.4.2",
"prettier": "^2.8.8",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
},
"scripts": {
"build": "tsc",
"build:submission": "npm run format && npm run build && node ./zip.js",
"format": "prettier --config .prettierrc --write src/",
"format:check": "prettier --config .prettierrc --check src/",
"lint": "eslint --config .eslintrc --max-warnings 0 src/",
"lint:fix": "eslint --config .eslintrc --fix src/",
"start": "ts-node ./src/main.ts",
"test": "jest ./src",
"test:coverage": "jest ./src --coverage",
"test:json": "jest ./src --json --outputFile=test-results.json",
"build:parser": "npx peggy ./include/grammar.pegjs -o ./include/peggyParser.js --format es"
},
"type": "module",
"engines": {
"node": ">=16.0.0 <20.0.0"
},
"name": "08-building-an-interpreter"
}
- Plugin shows output:
PackageInfo: Not in valid package.json file
Package info config
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
'vuki656/package-info.nvim',
dependencies = 'MunifTanjim/nui.nvim',
lazy = true,
config = function()
require('package-info').setup({
colors = {
up_to_date = '#3C4048',
outdated = '#e09443',
},
autostart = false,
hide_up_to_date = true,
})
end,
},
})
Other information
No response
Help
Yes, but I don't know how to start. I would need guidance (check question below)
Implementation help
No response
I personally lazy load it by checking the filetype:
{
"vuki656/package-info.nvim",
ft = "json",
dependencies = "MunifTanjim/nui.nvim",
opts = {},
}
If you want to use lazy = true
you will need to run:
-
:lua require('package-info').get_status()
- maybe
:e
- Use the plugin
When lazy loading I can sometimes get it to work by doing the vim.cmd.e() "hack" but the colors in the virtual text showing the versions are all turned to a grey color. It seems there are things going on in this plugin that are required to happen at startup (not allowing lazy loading).
I think I figured out the lazy loading problem. See here: https://github.com/vuki656/package-info.nvim/issues/155#issuecomment-2270512637