Something went wrong. Try again.
Neovim config generator based on MINI nvim-mini.org/MiniMax
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990-- Determine the correct MiniMax version (if any)local versionif vim.fn.has('nvim-0.10') == 1 then version = 'nvim-0.10' endif vim.fn.has('nvim-0.11') == 1 then version = 'nvim-0.11' endif vim.fn.has('nvim-0.12') == 1 then version = 'nvim-0.12' endif vim.fn.has('nvim-0.13') == 1 then version = 'nvim-0.13' endif version == nil then print('There is no available MiniMax version. Try updating Neovim.\n') returnend
local script_dir = vim.fs.dirname((_G.arg or {})[0]) or vim.fn.getcwd()local version_dir = script_dir .. '/configs/' .. version
-- Ensure proper config directorylocal config_dir = vim.fn.fnamemodify(vim.fn.stdpath('config'), ':p'):gsub('[\\/]+$', '')vim.fn.mkdir(config_dir, 'p')
local backup_dir = config_dir .. '/MiniMax-backup'if vim.loop.fs_stat(backup_dir) ~= nil then print( 'MiniMax backup directory is already present: ' .. backup_dir .. '\nManage it first (go through it; preserve what is needed; delete it),' .. 'before attempting another installation\n' ) returnend
-- Safely (no delete) copy to config directory. Backup conflicting files.local backupbackup = function(rel_path) local from = config_dir .. '/' .. rel_path local to = backup_dir .. '/' .. rel_path if vim.loop.fs_stat(from) == nil then return end
vim.fn.mkdir(vim.fs.dirname(to), 'p') if vim.fn.isdirectory(from) == 0 then vim.loop.fs_rename(from, to) print('Backed up:\n ' .. from) return end
for f, _ in vim.fs.dir(from) do backup(rel_path .. '/' .. f) end vim.loop.fs_rmdir(from) -- Remove already empty directoryend
local safely_copysafely_copy = function(rel_path, skip_if_present) local from = version_dir .. '/' .. rel_path if vim.loop.fs_stat(from) == nil then return end local to = config_dir .. '/' .. rel_path if skip_if_present and vim.loop.fs_stat(to) ~= nil then print('Skipped copy:\n ' .. rel_path) return end
backup(rel_path)
vim.fn.mkdir(vim.fs.dirname(to), 'p') if vim.fn.isdirectory(from) == 0 then vim.loop.fs_copyfile(from, to) return end
for f, _ in vim.fs.dir(from) do safely_copy(rel_path .. '/' .. f) endend
safely_copy('init.lua')safely_copy('nvim-pack-lock.json')safely_copy('plugin') -- Back up whole 'plugin/' directory to avoid config conflictssafely_copy('after/ftplugin/markdown.lua', true) -- Prefer user's existing filessafely_copy('after/lsp/lua_ls.lua', true)safely_copy('after/snippets/lua.json', true)safely_copy('snippets/global.json', true)
-- Possibly Git init. It is a good practice and helps with root detection.if vim.loop.fs_stat(config_dir .. '/.git') == nil then vim.fn.system({ 'git', '-C', config_dir, 'init' }) vim.fn.system({ 'git', '-C', config_dir, 'add', '*' }) vim.fn.system({ 'git', '-C', config_dir, 'commit', '-m', 'feat: set up MiniMax' })end
print('Set up MiniMax config at ' .. config_dir)