Skip to content

Installing rocks.nvim manually, without the installation script

Marc Jakobi edited this page Mar 19, 2024 · 8 revisions

We recommend using our installation script to install rocks.nvim, but that may not be possible on every system.

If are having issues with our installer, you can also install rocks.nvim manually.

Tip

By default, our installer installs luarocks for you, but you can also tell it to use an existing installation.

Prerequisites

  • An up-to-date Neovim nightly installation.
  • A luarocks and a Lua 5.1 installation.
  • If you are not on one of the following architectures, a C++17 and Rust toolchain:

Important

It may be possible to install luarocks with your distribution's package manager, but it may be outdated.

Steps

In Neovim, in cmd mode, confirm that your luarocks installation can be found on the PATH:

:lua =vim.fn.executable("luarocks")
-- should output 1

Copy the following to the beginning of your init.lua:

-- Copied from installer.lua
local rocks_config = {
    rocks_path = vim.fn.stdpath("data") .. "/rocks",
    luarocks_binary = "luarocks",
}

vim.g.rocks_nvim = rocks_config

local luarocks_path = {
    vim.fs.joinpath(rocks_config.rocks_path, "share", "lua", "5.1", "?.lua"),
    vim.fs.joinpath(rocks_config.rocks_path, "share", "lua", "5.1", "?", "init.lua"),
}
package.path = package.path .. ";" .. table.concat(luarocks_path, ";")

local luarocks_cpath = {
    vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.so"),
    vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.so"),
}
package.cpath = package.cpath .. ";" .. table.concat(luarocks_cpath, ";")

vim.opt.runtimepath:append(vim.fs.joinpath(rocks_config.rocks_path, "lib", "luarocks", "rocks-5.1", "rocks.nvim", "*"))

Start Neovim and, in cmd mode, enter:

:lua =vim.g.rocks_nvim.rocks_path
-- On Linux, this should output something like '/home/<user>/.local/share/nvim/rocks'

Note down the path.

Install rocks.nvim, substituting <rocks_path> for the path that was output in the previous step.

luarocks --lua-version=5.1 --tree <rocks_path> --server='https://nvim-neorocks.github.io/rocks-binaries/' install rocks.nvim
Clone this wiki locally