package-info.nvim
package-info.nvim copied to clipboard
[FEATURE REQUEST] Custom command to find outdated packages
Issues
- [X] I have checked existing issues and there are no existing ones with the same request.
Feature description
It would be useful for user to specify npm
options or entirely override npm oudated
command.
For example, I have a project where package.json is placed in a subdirectory, so the plugin doesn't work because I need to run npm --prefix <subdirectory> outdated
.
I also believe that the plugin could provide some kind of interface and work with other languages / package managers, e.g.
Rust: { filename = "Cargo.toml", command = "cargo outdated -R --format json" }
Python: { filename = "pyproject.toml", command = "poetry show --outdated" }
Help
Yes
Implementation help
No response
Hey, thanks for opening an issue.
I plan on supporting custom package managers per project in #25, would something similar where you specify the command as well help?
As for the interface, it's a bit tricky since not all package files have the same format, for example, cargo.toml
is not in the same format as package.json
, so the parsing differs.
It's definitely on the to-do list down the line. I want to provide a great experience for package.json
and npm
first with deleting
/adding
/upgrading
etc... After that is finished, I'll try to abstract as much functionality as possible and have it work with other languages/package managers. Thanks for the suggestion.
I plan on supporting custom package managers per project in #25, would something similar where you specify the command as well help?
Yes, it would be great.
Regarding other languages. I understand that every tool has its own format and now it's hard to support something different from package.json
, but we can introduce some abstractions for future use. As soon as there are abstractions for parsing packages and command output, I can help with adding other tools. Here is an example configuration
setup{
...
autostart = true,
package_managers = {
["package.json"] = {
exe = "npm",
args = {"--prefix", vim.fn.getcwd() .. "/ui", "outdated"},
parser = parsers["package.json"], -- built-in package.json parser
transformer = transformers["npm"], -- built-in `npm outdated` transformer
},
["Cargo.toml"] = {
command = "~/.local/bin/cargo"
args = { "outdated" },
parser = parsers["Cargo.toml"], -- built-in Cargo.toml parser,
transformer = function ... end -- custom `cargo outdated` transformer
}
}
Cool, thanks for the suggestions. I will likely start with abstractions in 3.0
. Not sure yet.