https://github.com/martin-ro/composer-version.nvim
Show installed Composer package versions as virtual text in composer.json
https://github.com/martin-ro/composer-version.nvim
composer lua neovim neovim-plugin php
Last synced: 11 days ago
JSON representation
Show installed Composer package versions as virtual text in composer.json
- Host: GitHub
- URL: https://github.com/martin-ro/composer-version.nvim
- Owner: martin-ro
- License: mit
- Created: 2026-06-11T06:22:12.000Z (15 days ago)
- Default Branch: main
- Last Pushed: 2026-06-11T06:43:26.000Z (15 days ago)
- Last Synced: 2026-06-11T08:15:48.940Z (15 days ago)
- Topics: composer, lua, neovim, neovim-plugin, php
- Language: Lua
- Size: 46.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# composer-version.nvim
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.

## Requirements
- Neovim ≥ 0.10
## Installation
### [lazy.nvim](https://github.com/folke/lazy.nvim)
```lua
{
"martin-ro/composer-version.nvim",
event = { "BufReadPre composer.json" },
}
```
### [packer.nvim](https://github.com/wbthomason/packer.nvim)
```lua
use("martin-ro/composer-version.nvim")
```
### [vim-plug](https://github.com/junegunn/vim-plug)
```vim
Plug 'martin-ro/composer-version.nvim'
```
## Configuration
The plugin works out of the box with zero configuration. Calling `setup()` is optional:
```lua
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:
```lua
vim.api.nvim_set_hl(0, "ComposerVersion", { fg = "#6c7086", italic = true })
```
## Commands
| Command | Description |
| -------------------------- | -------------------------------------------- |
| `:ComposerVersion refresh` | Re-read `composer.lock` and re-render |
| `:ComposerVersion toggle` | Toggle the virtual text on/off |
## How it works
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.
## License
[MIT](LICENSE)