Show the exact installed version of every Composer package as virtual text in composer.json, just like PhpStorm's gray version numbers.
Versions are read from the adjacent composer.lock, so what you see is what's actually installed.
- Neovim ≥ 0.10
{
"martin-ro/composer-version.nvim",
event = { "BufReadPre composer.json" },
}use("martin-ro/composer-version.nvim")Plug 'martin-ro/composer-version.nvim'The plugin works out of the box with zero configuration. Calling setup() is optional:
require("composer-version").setup({
highlight = "ComposerVersion", -- highlight group for the virtual text
enabled = true, -- render on startup
})The ComposerVersion highlight group links to Comment by default. Override it to change the color:
vim.api.nvim_set_hl(0, "ComposerVersion", { fg = "#6c7086", italic = true })| Command | Description |
|---|---|
:ComposerVersion refresh |
Re-read composer.lock and re-render |
:ComposerVersion toggle |
Toggle the virtual text on/off |
When you open or save a composer.json, the plugin looks for a composer.lock in the same directory, parses the packages and packages-dev sections, and annotates every matching dependency line with its locked version using extmark virtual text. Saving composer.lock (e.g. after composer update in a terminal split) refreshes all open composer.json buffers.
If there is no lock file, or it can't be parsed, the plugin silently does nothing.
