vuki656/package-info.nvim
À propos
✍️ Toutes les commandes npm/yarn/pnpm que je ne veux pas saisir
Outils de développementWhat you can do
- Display latest dependency versions as virtual text
- Upgrade dependency on current line to latest version
- Delete dependency on current line
- Install a different version of a dependency on current line
Progression mesurée des étoiles
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- 0
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
Original
All the npm/yarn/pnpm/bun commands I don't want to type
✨ Features
- Display latest dependency versions as virtual text
- Upgrade dependency on current line to latest version
- Delete dependency on current line
- Install a different version of a dependency on current line
- Install new dependency
- Automatic package manager detection
- Loading animation hook (to be placed in status bar or anywhere else)
Display Latest Package Version

Runs npm outdated --json in the background and then compares the output with versions in package.json and displays them as virtual text.
Keybinding
vim.keymap.set({ "n" }, "<leader>ns", "<cmd>PackageInfoShow<cr>", { silent = true, noremap = true })
- NOTE: after the first outdated dependency fetch, it will show the cached results for the next hour instead of re-fetching every time.
- If you would like to force re-fetching every time, use
PackageInfoShowForcelike in the example below:
vim.keymap.set({ "n" }, "<leader>ns", "<cmd>PackageInfoShowForce<cr>", { silent = true, noremap = true })
Delete Dependency

Runs yarn remove, npm uninstall, pnpm uninstall or bun remove in the background and reloads the buffer.
Keybinding
vim.keymap.set({ "n" }, "<leader>nd", "<cmd>PackageInfoDelete<cr>", { silent = true, noremap = true })
Install Different Version

Runs npm install dependency@version, yarn upgrade dependency@version, pnpm update dependency or bun add dependency@version in the background and reloads the buffer.
Keybinding
vim.keymap.set({ "n" }, "<leader>np", "<cmd>PackageInfoChangeVersion<cr>", { silent = true, noremap = true })
Install New Dependency

Runs npm install dependency, yarn add dependency, pnpm add dependency or bun add dependency in the background and reloads the buffer.
Keybinding
vim.keymap.set({ "n" }, "<leader>ni", "<cmd>PackageInfoInstall<cr>", { silent = true, noremap = true })
Loading Hook

Function that can be placed anywhere to display the loading status from the plugin.
Usage
- It can be used anywhere in
neovimby invokingreturn require('package-info').get_status()
local package_info = require("package-info")
-- Galaxyline
section.left[10] = {
PackageInfoStatus = {
provider = function()
return package_info.get_status()
end,
},
}
-- Feline
components.right.active[5] = {
provider = function()
return package_info.get_status()
end,
hl = {
style = "bold",
},
left_sep = " ",
right_sep = " ",
}
⚡️ Requirements
- Neovim >= 0.9.0
- Npm
- Patched font if you want icons
yqfor pnpm workspace support (optional)
📦 Installation
packer
use({
"vuki656/package-info.nvim",
requires = "MunifTanjim/nui.nvim",
})
⚙️ Configuration
Usage
require('package-info').setup()
Defaults
{
-- Check `:help nvim_set_hl()` for more attributes.
highlights = {
up_to_date = { -- highlight for up to date dependency virtual text
fg = "#3C4048"
},
outdated = { -- highlight for outdated dependency virtual text
fg = "#d19a66"
},
invalid = { -- highlight for invalid dependency virtual text
fg = "#ee4b2b"
},
},
icons = {
enable = true, -- Whether to display icons
style = {
up_to_date = "| ", -- Icon for up to date dependencies
outdated = "| ", -- Icon for outdated dependencies
invalid = "| ", -- Icon for invalid dependencies
},
},
notifications = true, -- Whether to display notifications when running commands
autostart = true, -- Whether to autostart when `package.json` is opened
hide_up_to_date = false, -- It hides up to date versions when displaying virtual text
hide_unstable_versions = false, -- It hides unstable versions from version list e.g next-11.1.3-canary3
timeout = 3000, -- Time in ms before notifications are dismissed
-- Can be `npm`, `yarn`, `pnpm` or `bun`. Used for `delete`, `install` etc...
-- The plugin will try to auto-detect the package manager based on
-- `yarn.lock`, `package-lock.json`, `bun.lock` or `pnpm-lock.yaml`, starting in the
-- directory of the `package.json` and walking up to the root of the repository, so a
-- package in a monorepo picks up the lock file of the workspace root. If none are found it
-- will use the provided one, if nothing is provided it will use `npm`
package_manager = 'npm'
}
256 Color Terminals
- If the vim option
termguicolorsis false, package-info switches to 256 color mode. - In this mode cterm color numbers (
ctermfgctermbg) are used instead of truecolor hex codes (fgbg) and the color defaults are:
highlights = {
up_to_date = {
ctermfg = 237
},
outdated = {
ctermfg = 173
},
invalid = {
ctermfg = 196
fg = "#ee4b2b" -- Set both cterm and fg
}
}
Check :help nvim_set_hl() for more attributes.
⚠️ Migration Notice
Old config (deprecated):
require("package-info").setup({
colors = {
up_to_date = "#3C4048",
outdated = "#d19a66",
invalid = "#ee4b2b",
},
})
New config:
require("package-info").setup({
highlights = {
up_to_date = { fg = "#3C4048" },
outdated = { fg = "#d19a66" },
invalid = { fg = "#ee4b2b" },
},
})
🤖 Commands
| Command | Description |
|---|---|
:PackageInfoShow |
Show the latest version of each dependency |
:PackageInfoShowForce |
Show the latest version of each dependency, ignoring the cache |
:PackageInfoHide |
Hide the dependency versions |
:PackageInfoToggle |
Toggle the dependency versions |
:PackageInfoUpdate |
Update the dependency on the current line |
:PackageInfoDelete |
Delete the dependency on the current line |
:PackageInfoInstall |
Install a new dependency |
:PackageInfoChangeVersion |
Change the version of the dependency on the current line |
⌨️ All Keybindings
Plugin has no default Keybindings.
You can copy the ones below:
-- Show dependency versions
vim.keymap.set({ "n" }, "<LEADER>ns", "<cmd>PackageInfoShow<cr>", { silent = true, noremap = true })
-- Hide dependency versions
vim.keymap.set({ "n" }, "<LEADER>nc", "<cmd>PackageInfoHide<cr>", { silent = true, noremap = true })
-- Toggle dependency versions
vim.keymap.set({ "n" }, "<LEADER>nt", "<cmd>PackageInfoToggle<cr>", { silent = true, noremap = true })
-- Update dependency on the line
vim.keymap.set({ "n" }, "<LEADER>nu", "<cmd>PackageInfoUpdate<cr>", { silent = true, noremap = true })
-- Delete dependency on the line
vim.keymap.set({ "n" }, "<LEADER>nd", "<cmd>PackageInfoDelete<cr>", { silent = true, noremap = true })
-- Install a new dependency
vim.keymap.set({ "n" }, "<LEADER>ni", "<cmd>PackageInfoInstall<cr>", { silent = true, noremap = true })
-- Install a different dependency version
vim.keymap.set({ "n" }, "<LEADER>np", "<cmd>PackageInfoChangeVersion<cr>", { silent = true, noremap = true })
🔭 Telescope
Highly inspired by telescope-lazy.nvim
Configuration
require("telescope").setup({
extensions = {
package_info = {
-- Optional theme (the extension doesn't set a default theme)
theme = "ivy",
},
},
})
require("telescope").load_extension("package_info")
Available Commands
:Telescope package_info
🌈 Highlight Groups
Click to see all highlight groups
| Highlight Group | Default value | Description |
|---|---|---|
| PackageInfoOutdatedVersion | fg = #d19a66 ctermfg = 173 | Highlight out of date dependencies virtual text |
| PackageInfoUpToDateVersion | fg = #3C4048 ctermfg = 237 | Highlight up to date dependencies virtual text |
| PackageInfoInErrorVersion | fg = #ee4b2b ctermfg = 196 | Highlight invalid dependencies virtual text |
🏢 Monorepos
- Commands run in the directory of the
package.jsonyou are in, sonpm,yarn,pnpmandbuninstall into that package instead of the workspace root - When the current file is not a
package.json, commands run in the closestpackage.jsondirectory above it - The package manager is detected from the closest lock file above the
package.json pnpmcatalogs are read from the closestpnpm-workspace.yamlabove thepackage.json- Fetched versions are cached per
package.json, so moving between packages doesn't refetch
📝 Notes
- Display might be slow on a project with a lot of dependencies. This is due to the
npm outdated --jsoncommand taking a long time. Nothing can be done about that - Idea was inspired by akinsho and his dependency-assist.nvim
- Readme template stolen from folke
Explorer des projets similaires
Chargement…