Install luarock packages for Neovim's built-in Lua interpreter.
Functionality of this plugin has been added to https://github.com/wbthomason/packer.nvim. You will not need this plugin when you are using packer.nvim.
I use hererock to set up a luajit local enviroment. Adapt if you use a different pip binary or you want to use a different luarocks version (latest was not working for me).
If using Lazy.nvim
return {
{
"theHamsta/nvim_rocks",
event = "VeryLazy",
build = "pip3 install --user hererocks && python3 -mhererocks . -j2.1.0-beta3 -r3.0.0 && cp nvim_rocks.lua lua",
config = function()
---- Add here the packages you want to make sure that they are installed
--local nvim_rocks = require "nvim_rocks"
--nvim_rocks.ensure_installed "uuid
end,
},
}
or for vim-plug
Plug 'theHamsta/nvim_rocks', {'do': 'pip3 install --user hererocks && python3 -mhererocks . -j2.1.0-beta3 -r3.0.0 && cp nvim_rocks.lua lua'}
I am currently using the latest nightly of Neovim.
local nvim_rocks = require'nvim_rocks'
-- Force installation of rock
nvim_rocks.install('30log')
-- Ensure that certain rocks are installed
nvim_rocks.ensure_installed('lua-cjson')
nvim_rocks.ensure_installed({'lua-cjson', 'stdlib'})
nvim_rocks.ensure_installed('fun') -- nice functional programming for LuaJIT!
-- require stuff from binary rock
local cjson = require "cjson"
local cjson2 = cjson.new()
local cjson_safe = require "cjson.safe"
print(vim.inspect(cjson_safe))
-- List installed rocks with version numbers
print(vim.inspect(nvim_rocks.list()))
-- List installed rocks as strings
local simple = true
print(vim.inspect(nvim_rocks.list(simple)))
-- Remove rock
nvim_rocks.remove('lua-cjson')
There's also three commands for install/uninstall and listing the installed packages:
NvimRocksInstall <package>
NvimRocksRemove <package>
NvimRocksList
If you want to install just pure Lua packages you might also install them manually:
Plug 'Yonaba/30log', {'do': 'mkdir -p lua && cp *.lua lua'}
Plug 'lua-stdlib/lua-stdlib', {'do': 'cp -r lib lua'}
Now https://github.com/wbthomason/packer.nvim has luarocks support