non-working checkpoint
This commit is contained in:
@@ -1 +1,91 @@
|
||||
vim.pack.add({ 'https://github.com/mason-org/mason.nvim' })
|
||||
local M = {}
|
||||
|
||||
function M.install_pm()
|
||||
local path = vim.fn.stdpath('data') .. '/site/pack/paqs/opt/paq-nvim'
|
||||
if not vim.uv.fs_stat(path) then
|
||||
local repo = 'https://github.com/savq/paq-nvim.git'
|
||||
local cmd = { 'git', 'clone', '--depth=1', repo, path }
|
||||
vim.system(cmd):wait()
|
||||
print("Installed: paq")
|
||||
end
|
||||
end
|
||||
|
||||
function M.install_packages()
|
||||
print("Installing packages...")
|
||||
vim.cmd.packadd('paq-nvim')
|
||||
local packages = require('setup.packages').get()
|
||||
local paq = require('paq')
|
||||
|
||||
paq(packages)
|
||||
|
||||
-- capture list of jobs before starting
|
||||
local install_list = paq.install()
|
||||
|
||||
-- if nothing to install, skip wait
|
||||
if not install_list or vim.tbl_isempty(install_list) then
|
||||
vim.cmd('packloadall')
|
||||
vim.cmd('silent! helptags ALL')
|
||||
return
|
||||
end
|
||||
|
||||
local done = false
|
||||
vim.api.nvim_create_autocmd('User', {
|
||||
pattern = 'PaqDoneInstall',
|
||||
once = true,
|
||||
callback = function()
|
||||
vim.cmd('packloadall')
|
||||
vim.cmd('silent! helptags ALL')
|
||||
done = true
|
||||
end,
|
||||
})
|
||||
|
||||
-- wait until done or timeout
|
||||
vim.wait(300000, function()
|
||||
return done
|
||||
end, 200)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function M.install_languages()
|
||||
local lm = require('plugins.language-manager')
|
||||
lm.invalidate_cache()
|
||||
lm.load_specs()
|
||||
lm.install()
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command('InstallAll', function()
|
||||
M.install_pm()
|
||||
M.install_packages()
|
||||
M.install_languages()
|
||||
end, {})
|
||||
|
||||
vim.api.nvim_create_user_command('FetchLspConfigs', function()
|
||||
local base_url = 'https://raw.githubusercontent.com/neovim/nvim-lspconfig/master/lsp/'
|
||||
|
||||
local lm = require('plugins.language-manager')
|
||||
lm.invalidate_cache()
|
||||
local general = lm.load_specs()
|
||||
|
||||
local lsp_dir = vim.fs.joinpath(vim.fn.getcwd(), 'lsp')
|
||||
vim.fn.mkdir(lsp_dir, 'p')
|
||||
|
||||
for _, name in ipairs(general.language_servers) do
|
||||
local file = vim.fs.joinpath(lsp_dir, name .. '.lua')
|
||||
if vim.fn.filereadable(file) == 0 then
|
||||
local url = base_url .. name .. '.lua'
|
||||
local cmd = string.format('curl -fsSL -o %q %q', file, url)
|
||||
vim.fn.system(cmd)
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.notify('Failed to fetch ' .. name .. '.lua', vim.log.levels.ERROR)
|
||||
vim.fn.delete(file)
|
||||
else
|
||||
vim.notify('Fetched ' .. name .. '.lua', vim.log.levels.INFO)
|
||||
end
|
||||
else
|
||||
vim.notify('Skipped existing ' .. name .. '.lua', vim.log.levels.INFO)
|
||||
end
|
||||
end
|
||||
end, { desc = 'Fetch default LSP configs into ./lsp in cwd' })
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user