Skip to content

Commit

Permalink
scripts: rework minimal_init.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
mochaaP committed Nov 30, 2024
1 parent 87f3c77 commit e8f1fee
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 39 deletions.
49 changes: 16 additions & 33 deletions scripts/minimal_init.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
-- this template is borrowed from nvim-lspconfig
local on_windows = vim.uv.os_uname().version:match("Windows")

local function join_paths(...)
local path_sep = on_windows and "\\" or "/"
local result = table.concat({ ... }, path_sep)
return result
end

vim.g.loaded_remote_plugins = ""
vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.o.runtimepath = vim.env["VIMRUNTIME"]

local temp_dir = vim.env.TEMP or "/tmp"
local temp_dir = vim.fs.dirname(vim.fn.tempname())

vim.cmd("set packpath=" .. join_paths(temp_dir, "nvim", "site"))
vim.o.packpath = vim.fs.joinpath(temp_dir, "nvim", "site")

local package_root = join_paths(temp_dir, "nvim", "site", "pack")
local install_path = join_paths(package_root, "packer", "start", "packer.nvim")
local compile_path = join_paths(install_path, "plugin", "packer_compiled.lua")
local package_root = vim.fs.joinpath(temp_dir, "nvim", "site", "pack")
local install_path = vim.fs.joinpath(package_root, "deps", "start", "mini.deps")

local null_ls_config = function()
local null_ls = require("null-ls")
Expand All @@ -29,27 +19,20 @@ end

local function load_plugins()
-- only add other plugins if they are necessary to reproduce the issue
require("packer").startup({
{
"wbthomason/packer.nvim",
{
"nvimtools/none-ls.nvim",
requires = { "nvim-lua/plenary.nvim" },
config = null_ls_config,
},
},
config = {
package_root = package_root,
compile_path = compile_path,
local deps = require("mini.deps")
deps.setup({
path = {
package = package_root,
},
})
deps.add({
source = "nvimtools/none-ls.nvim",
depends = { "nvim-lua/plenary.nvim" },
})
deps.later(null_ls_config)
end

if vim.fn.isdirectory(install_path) == 0 then
vim.fn.system({ "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path })
load_plugins()
require("packer").sync()
else
load_plugins()
require("packer").sync()
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/echasnovski/mini.deps", install_path })
end
load_plugins()
13 changes: 7 additions & 6 deletions test/minimal_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@ function M.load(plugin)
"git",
"clone",
"--depth=1",
"--filter=blob:none",
"https://github.com/" .. plugin .. ".git",
package_root .. "/" .. name,
vim.fs.joinpath(package_root, name),
})
end
end

function M.setup()
vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.o.runtimepath = vim.env["VIMRUNTIME"]
vim.opt.runtimepath:append(M.root())
vim.opt.packpath = { M.root(".tests/site") }
M.load("nvim-lua/plenary.nvim")
vim.env.XDG_CONFIG_HOME = M.root(".tests/config")
vim.env.XDG_DATA_HOME = M.root(".tests/data")
vim.env.XDG_STATE_HOME = M.root(".tests/state")
vim.env.XDG_CACHE_HOME = M.root(".tests/cache")
vim.env["XDG_CONFIG_HOME"] = M.root(".tests/config")
vim.env["XDG_DATA_HOME"] = M.root(".tests/data")
vim.env["XDG_STATE_HOME"] = M.root(".tests/state")
vim.env["XDG_CACHE_HOME"] = M.root(".tests/cache")
require("null-ls.config")._set({ log = { enable = false } })
end

Expand Down

0 comments on commit e8f1fee

Please sign in to comment.