Skip to content

🤘 Install luarocks packages for Neovim's built-in Lua interpreter.

Notifications You must be signed in to change notification settings

theHamsta/nvim_rocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

nvim_rocks 🤘

Install luarock packages for Neovim's built-in Lua interpreter.

Important Note

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.

Installation

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.

Usage

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

Alternatives

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

About

🤘 Install luarocks packages for Neovim's built-in Lua interpreter.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published