Home

Awesome

<div align="center"> <img src="https://github.com/vuki656/vuki656/blob/master/media/package-info/logo.png" width=315>

All the npm/yarn/pnpm commands I don't want to type

</div> <div align="center">

Lua

</div> <div align="center">

License Status Neovim

</div>

✨ Features

<div align="center">

Display Latest Package Version

<img src="https://github.com/vuki656/vuki656/blob/master/media/package-info/display.gif" width=500>

Runs npm outdated --json in the background and then compares the output with versions in package.json and displays them as virtual text.

</div>

Keybinding

vim.api.nvim_set_keymap(
    "n",
    "<leader>ns",
    "<cmd>lua require('package-info').show()<cr>",
    { silent = true, noremap = true }
)
vim.api.nvim_set_keymap(
    "n",
    "<leader>ns",
    "<cmd>lua require('package-info').show({ force = true })<cr>",
    { silent = true, noremap = true }
)
<div align="center">

Delete Dependency

<img src="https://github.com/vuki656/vuki656/blob/master/media/package-info/delete.gif" width=500>

Runs yarn remove, npm uninstall, or pnpm uninstall in the background and reloads the buffer.

</div>

Keybinding

vim.api.nvim_set_keymap(
    "n",
    "<leader>nd",
    "<cmd>lua require('package-info').delete()<cr>",
    { silent = true, noremap = true }
)
<div align="center">

Install Different Version

<img src="https://github.com/vuki656/vuki656/blob/master/media/package-info/change.gif" width=500>

Runs npm install dependency@version, yarn upgrade dependency@version, or pnpm update dependency in the background and reloads the buffer.

</div>

Keybinding

vim.api.nvim_set_keymap(
    "n",
    "<leader>np",
    "<cmd>lua require('package-info').change_version()<cr>",
    { silent = true, noremap = true }
)
<div align="center">

Install New Dependency

<img src="https://github.com/vuki656/vuki656/blob/master/media/package-info/install.gif" width=500>

Runs npm install dependency, yarn add dependency, or pnpm add dependency in the background and reloads the buffer.

</div>

Keybinding

vim.api.nvim_set_keymap(
    "n",
    "<leader>ni",
    "<cmd>lua require('package-info').install()<cr>",
    { silent = true, noremap = true }
)
<div align="center">

Loading Hook

<img src="https://github.com/vuki656/vuki656/blob/master/media/package-info/loading.gif" width=500>

Function that can be placed anywhere to display the loading status from the plugin.

</div>

Usage

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

📦 Installation

packer

use({
    "vuki656/package-info.nvim",
    requires = "MunifTanjim/nui.nvim",
})

⚙️ Configuration

Usage

require('package-info').setup()

Defaults

{
    colors = {
        up_to_date = "#3C4048", -- Text color for up to date dependency virtual text
        outdated = "#d19a66", -- Text color for outdated dependency virtual text
        invalid = "#ee4b2b", -- Text color for invalid dependency virtual text
    },
    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
        },
    },
    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
    -- Can be `npm`, `yarn`, or `pnpm`. Used for `delete`, `install` etc...
    -- The plugin will try to auto-detect the package manager based on
    -- `yarn.lock` or `package-lock.json`. If none are found it will use the
    -- provided one, if nothing is provided it will use `yarn`
    package_manager = 'yarn'
}

256 Color Terminals

colors = {
    up_to_date = "237", -- cterm Grey237
    outdated = "173", -- cterm LightSalmon3
    invalid = "196", -- cterm Red1
}

⌨️ All Keybindings

Plugin has no default Keybindings.

You can copy the ones below:

-- Show dependency versions
vim.keymap.set({ "n" }, "<LEADER>ns", require("package-info").show, { silent = true, noremap = true })

-- Hide dependency versions
vim.keymap.set({ "n" }, "<LEADER>nc", require("package-info").hide, { silent = true, noremap = true })

-- Toggle dependency versions
vim.keymap.set({ "n" }, "<LEADER>nt", require("package-info").toggle, { silent = true, noremap = true })

-- Update dependency on the line
vim.keymap.set({ "n" }, "<LEADER>nu", require("package-info").update, { silent = true, noremap = true })

-- Delete dependency on the line
vim.keymap.set({ "n" }, "<LEADER>nd", require("package-info").delete, { silent = true, noremap = true })

-- Install a new dependency
vim.keymap.set({ "n" }, "<LEADER>ni", require("package-info").install, { silent = true, noremap = true })

-- Install a different dependency version
vim.keymap.set({ "n" }, "<LEADER>np", require("package-info").change_version, { 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

📝 Notes