nvim-config

Log | Files | Refs | README

rocks-bootstrap.lua (1991B)


      1 do
      2     -- Specifies where to install/use rocks.nvim
      3     local install_location = vim.fs.joinpath(vim.fn.stdpath("data"), "rocks")
      4 
      5     -- Set up configuration options related to rocks.nvim (recommended to leave as default)
      6     local rocks_config = {
      7         rocks_path = vim.fs.normalize(install_location),
      8     }
      9 
     10     vim.g.rocks_nvim = rocks_config
     11 
     12     -- Configure the package path (so that plugin code can be found)
     13     local luarocks_path = {
     14         vim.fs.joinpath(rocks_config.rocks_path, "share", "lua", "5.1", "?.lua"),
     15         vim.fs.joinpath(rocks_config.rocks_path, "share", "lua", "5.1", "?", "init.lua"),
     16     }
     17     package.path = package.path .. ";" .. table.concat(luarocks_path, ";")
     18 
     19     -- Configure the C path (so that e.g. tree-sitter parsers can be found)
     20     local luarocks_cpath = {
     21         vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.so"),
     22         vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.so"),
     23     }
     24     package.cpath = package.cpath .. ";" .. table.concat(luarocks_cpath, ";")
     25 
     26     -- Load all installed plugins, including rocks.nvim itself
     27     vim.opt.runtimepath:append(vim.fs.joinpath(rocks_config.rocks_path, "lib", "luarocks", "rocks-5.1", "rocks.nvim", "*"))
     28 end
     29 
     30 -- If rocks.nvim is not installed then install it!
     31 if not pcall(require, "rocks") then
     32     local rocks_location = vim.fs.joinpath(vim.fn.stdpath("cache"), "rocks.nvim")
     33 
     34     if not vim.uv.fs_stat(rocks_location) then
     35         -- Pull down rocks.nvim
     36         vim.fn.system({
     37             "git",
     38             "clone",
     39             "--filter=blob:none",
     40             "https://github.com/nvim-neorocks/rocks.nvim",
     41             rocks_location,
     42         })
     43     end
     44 
     45     -- If the clone was successful then source the bootstrapping script
     46     assert(vim.v.shell_error == 0, "rocks.nvim installation failed. Try exiting and re-entering Neovim!")
     47 
     48     vim.cmd.source(vim.fs.joinpath(rocks_location, "bootstrap.lua"))
     49 
     50     vim.fn.delete(rocks_location, "rf")
     51 end