Skip to content
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] Plugin doesn't work when lazy loaded #141

Open
3 tasks done
TroySigX opened this issue Aug 23, 2023 · 3 comments
Open
3 tasks done

[BUG] Plugin doesn't work when lazy loaded #141

TroySigX opened this issue Aug 23, 2023 · 3 comments
Labels
🐛 Bug Something isn't working 🤝 Contributions Welcome Not on the roadmap but can be picked up by someone

Comments

@TroySigX
Copy link

TroySigX commented Aug 23, 2023

Issues

  • I have checked existing issues and there are no issues with the same problem.

Plugin Version

  • I am using the latest version of the plugin

Neovim Version

  • 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

  1. Load the below config
  2. Try :lua require("package-info").delete()
    Here's my package.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"
}
  1. 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

@TroySigX TroySigX added the 🐛 Bug Something isn't working label Aug 23, 2023
@agoodshort
Copy link
Contributor

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:

  1. :lua require('package-info').get_status()
  2. maybe :e
  3. Use the plugin

@GitMurf
Copy link

GitMurf commented Aug 6, 2024

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).

@GitMurf
Copy link

GitMurf commented Aug 6, 2024

I think I figured out the lazy loading problem. See here: #155 (comment)

@vuki656 vuki656 added the 🤝 Contributions Welcome Not on the roadmap but can be picked up by someone label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working 🤝 Contributions Welcome Not on the roadmap but can be picked up by someone
Projects
None yet
Development

No branches or pull requests

4 participants