Skip to content

[fork] Neovim plugin management inspired by Cargo.

License

Notifications You must be signed in to change notification settings

NStefan002/rocks.nvim

Β 
Β 

Repository files navigation


rocks.nvim


Explore the docs Β»

Report Bug Β· Request Feature Β· Ask Question

A modern approach to Neovim plugin management!

πŸŒ’

🌟 Features

  • Cargo-like rocks.toml file for declaring all your plugins.
  • Name-based installation ("nvim-neorg/neorg" becomes :Rocks install neorg instead).
  • Automatic dependency and build script management.
  • True semver versioning!
  • Minimal, non-intrusive UI.
  • Async execution.
  • Extensible, with a Lua API.
  • Command completions for plugins and versions on luarocks.org.
  • Binary rocks pulled from rocks-binaries so you don't have to compile them.

demo

πŸŒ” Introduction

rocks.nvim revolutionizes Neovim plugin management by streamlining the way users and developers handle plugins and dependencies. Integrating directly with luarocks, this plugin offers an automated approach that shifts the responsibility of specifying dependencies and build steps from users to plugin authors.

Why rocks.nvim?

The traditional approach to Neovim plugin management often places an unjust burden on users.

Consider the following example using lazy.nvim:

{
  'foo/bar.nvim',
  dependencies = {
    'nvim-lua/plenary.nvim',
    'MunifTanjim/nui.nvim',
    {
      '4O4/reactivex', -- LuaRocks dependency
      build = function(plugin)
        -- post-install build step required to link the luarocks dependency
        vim.uv.fs_symlink(plugin.dir, plugin.dir .. "/lua", { dir = true })
      end,
    },
  },
  build = "make install" -- Post-install build step of the main plugin
}

This setup illustrates several pain points in the status quo:

  • Manual dependency management: Users are often required to manually specify and manage dependencies.
  • Breaking changes: Updates to a plugin's dependencies can lead to breaking changes for users.
  • Platform-specific instructions: Build instructions and dependencies may vary by platform, adding complexity.
  • Because of this horrible UX, plugin authors have been reluctant to add dependencies, preferring to copy/paste code instead.

rocks.nvim simplifies the above example to:

:Rocks install bar.nvim

Welcome to a new era of Neovim plugin management - where simplicity meets efficiency!

Philosophy

rocks.nvim itself is designed based on the UNIX philosophy: Do one thing well.

It doesn't dictate how you as a user should configure your plugins. But there's an optional module for those seeking additional configuration capabilities: rocks-config.nvim.

We have packaged many Neovim plugins and tree-sitter parsers for luarocks, and an increasing number of plugin authors have been publishing themselves. Additionally, rocks-git.nvim ensures you're covered even when a plugin isn't directly available on LuaRocks.

πŸ“ Requirements

  • An up-to-date Neovim nightly (>= 0.10) installation.
  • The git command line utility.
  • wget or curl (if running on a UNIX system) - required for the remote :source command to work.
  • netrw enabled in your Neovim configuration - enabled by default but some configurations manually disable the plugin.

Important

If you are running on an esoteric architecture, rocks.nvim will attempt to compile its dependencies instead of pulling a prebuilt binary. For the process to succeed you must have a C++17 parser and Rust toolchain installed on your system.

πŸ”¨ Installation

⚑ Installation script (recommended)

The days of bootstrapping and editing your configuration are over. rocks.nvim can be installed directly through an interactive installer within Neovim.

We suggest starting nvim without loading RC files, such that already installed plugins do not interfere with the installer:

nvim -u NORC -c "source https://raw.githubusercontent.com/nvim-neorocks/rocks.nvim/master/installer.lua"

Important

For security reasons, we recommend that you read :help :source and the installer code before running it so you know exactly what it does.

Tip

To configure the luarocks installation to use a specific lua install, use environment variables LUA_BINDIR=<Directory of lua binary> and LUA_BINDIR_SET=yes.

For example:

LUA_BINDIR="${XDG_BIN_DIR:-$HOME/.local/bin}" LUA_BINDIR_SET=yes nvim -u NORC -c "source ...

πŸ“š Usage

Installing rocks

You can install rocks with the :Rocks install {rock} {version?} command.

Arguments:

  • rock: The luarocks package.
  • version: Optional. Used to pin a rock to a specific version.

Note

  • The command provides fuzzy completions for rocks and versions on luarocks.org.
  • Installs the latest version if version is omitted.
  • This plugin keeps track of installed plugins in a rocks.toml file, which you can commit to version control.
  • If you specify dev or scm as the version, luarocks will search the dev manifest. This has the side-effect that it will prioritise dev versions of any dependencies that aren't declared with version constraints.

Updating rocks

Running the :Rocks update command will attempt to update every available rock if it is not pinned.

Syncing rocks

The :Rocks sync command synchronizes the installed rocks with the rocks.toml.

Note

  • Installs missing rocks.
  • Ensures that the correct versions are installed.
  • Uninstalls unneeded rocks.

Uninstalling rocks

To uninstall a rock and any of its dependencies, that are no longer needed, run the :Rocks prune {rock} command.

Note

  • The command provides fuzzy completions for rocks that can safely be pruned without breaking dependencies.

Editing rocks.toml

The :Rocks edit command opens the rocks.toml file for manual editing. Make sure to run :Rocks sync when you are done.

Lazy loading plugins

By default, rocks.nvim will source all plugins at startup. To prevent it from sourcing a plugin, you can specify opt = true in the rocks.toml file.

For example:

[plugins]
neorg = { version = "1.0.0", opt = true }

or

[plugins.neorg]
version = "1.0.0"
opt = true

You can then load the plugin with the :Rocks[!] packadd {rock} command.

Note

A note on loading rocks:

Luarocks packages are installed differently than you are used to from Git repositories.

Specifically, luarocks installs a rock's Lua API to the package.path and the package.cpath. It does not have to be added to Neovim's runtime path (e.g. using :Rocks packadd), for it to become available. This does not impact Neovim's startup time.

Runtime directories (:h runtimepath), on the other hand, are installed to a separate location. Plugins that utilise these directories may impact startup time (if it has ftdetect or plugin scripts), so you may or may not benefit from loading them lazily.

🌳 Enhanced tree-sitter support

We're revolutionizing the way Neovim users interact with tree-sitter parsers. With the introduction of the Neovim User Rocks Repository (NURR), we have automated the packaging and publishing of many plugins and curated1 tree-sitter parsers for luarocks, ensuring a seamless and efficient user experience.

When installing, rocks.nvim will also search our rocks-binaries server, which means you don't even need to compile many parsers on your machine2.

Simplifying dependencies

For plugin developers, specifying a tree-sitter parser as a dependency is now as straightforward as including it in their project's rockspec3. This eliminates the need for manual parser management and ensures that dependencies are automatically resolved and installed.

Example rockspec dependency specification:

dependencies = {
  "neotest",
  "tree-sitter-haskell"
}

Effortless installation for users

If you need a tree-sitter parser for syntax highlighting or other features, you can easily install them with rocks.nvim: :Rocks install tree-sitter-<lang>.

Or, if you want something that comes with lots of tree-sitter parsers and automatically configures nvim-treesitter for you, check out our rocks-treesiter.nvim module.

Important

You still need to install nvim-treesitter for tree-sitter based syntax highlighting, injections, etc., as the queries are not provided by the parsers.

πŸ“¦ Extending rocks.nvim

This plugin provides a Lua API for extensibility. See :h rocks.api for details.

Following are some examples:

To extend rocks.nvim, simply install a module with :Rocks install, and you're good to go!

🩺 Troubleshooting

The :Rocks log command opens a log file for the current session, which contains the luarocks stderr output, among other logs.

πŸ”— Related projects

  • luarocks-tag-release: A GitHub action that automates publishing to luarocks.org
  • NURR: A repository that publishes Neovim plugins and tree-sitter parsers to luarocks.org
  • luarocks.nvim: Adds basic support for installing lua rocks to lazy.nvim

πŸ“– License

rocks.nvim is licensed under GPLv3.

πŸ’š Contributing

Contributions are more than welcome! See CONTRIBUTING.md for a guide.

Footnotes

  1. We only upload parsers which we can install in the NURR CI. ↩

  2. We currently do not provide binary rocks for parsers that need to have their sources generated using the tree-sitter CLI. ↩

  3. example. ↩

About

[fork] Neovim plugin management inspired by Cargo.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Lua 89.9%
  • Nix 10.0%
  • Makefile 0.1%