mirror of https://github.com/NvChad/NvChad
avoid un-needed lazy loading of packer | improve packer bootstrapping
parent
bdf45a447a
commit
a2ff5c285e
@ -1,73 +0,0 @@
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
|
||||
-- Disable statusline in dashboard
|
||||
autocmd("FileType", {
|
||||
pattern = "alpha",
|
||||
callback = function()
|
||||
vim.opt.laststatus = 0
|
||||
end,
|
||||
})
|
||||
|
||||
autocmd("BufUnload", {
|
||||
buffer = 0,
|
||||
callback = function()
|
||||
vim.opt.laststatus = 3
|
||||
end,
|
||||
})
|
||||
|
||||
-- open nvim with a dir while still lazy loading nvimtree
|
||||
-- autocmd("BufEnter", {
|
||||
-- callback = function()
|
||||
-- if vim.api.nvim_buf_get_option(0, "buftype") ~= "terminal" then
|
||||
-- vim.cmd "lcd %:p:h"
|
||||
-- end
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
-- Use relative & absolute line numbers in 'n' & 'i' modes respectively
|
||||
-- autocmd("InsertEnter", {
|
||||
-- callback = function()
|
||||
-- vim.opt.relativenumber = false
|
||||
-- end,
|
||||
-- })
|
||||
-- autocmd("InsertLeave", {
|
||||
-- callback = function()
|
||||
-- vim.opt.relativenumber = true
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
-- Open a file from its last left off position
|
||||
-- autocmd("BufReadPost", {
|
||||
-- callback = function()
|
||||
-- if not vim.fn.expand("%:p"):match ".git" and vim.fn.line "'\"" > 1 and vim.fn.line "'\"" <= vim.fn.line "$" then
|
||||
-- vim.cmd "normal! g'\""
|
||||
-- vim.cmd "normal zz"
|
||||
-- end
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
-- File extension specific tabbing
|
||||
-- autocmd("Filetype", {
|
||||
-- pattern = "python",
|
||||
-- callback = function()
|
||||
-- vim.opt_local.expandtab = true
|
||||
-- vim.opt_local.tabstop = 4
|
||||
-- vim.opt_local.shiftwidth = 4
|
||||
-- vim.opt_local.softtabstop = 4
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
-- Highlight yanked text
|
||||
-- autocmd("TextYankPost", {
|
||||
-- callback = function()
|
||||
-- vim.highlight.on_yank { higroup = "Visual", timeout = 200 }
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
-- Enable spellchecking in markdown, text and gitcommit files
|
||||
-- autocmd("FileType", {
|
||||
-- pattern = { "gitcommit", "markdown", "text" },
|
||||
-- callback = function()
|
||||
-- vim.opt_local.spell = true
|
||||
-- end,
|
||||
-- })
|
@ -1,37 +0,0 @@
|
||||
local user_cmd = vim.api.nvim_create_user_command
|
||||
local cmd = vim.cmd
|
||||
|
||||
-- snapshot stuff
|
||||
user_cmd("PackerSnapshot", function(info)
|
||||
require "plugins"
|
||||
require("packer").snapshot(info.args)
|
||||
end, { nargs = "+" })
|
||||
|
||||
user_cmd("PackerSnapshotDelete", function(info)
|
||||
require "plugins"
|
||||
require("packer.snapshot").delete(info.args)
|
||||
end, { nargs = "+" })
|
||||
|
||||
user_cmd("PackerSnapshotRollback", function(info)
|
||||
require "plugins"
|
||||
require("packer").rollback(info.args)
|
||||
end, { nargs = "+" })
|
||||
|
||||
-- Add Packer commands because we are not loading it at startup
|
||||
|
||||
local packer_cmd = function(callback)
|
||||
return function()
|
||||
require "plugins"
|
||||
require("packer")[callback]()
|
||||
end
|
||||
end
|
||||
|
||||
user_cmd("PackerClean", packer_cmd "clean", {})
|
||||
user_cmd("PackerCompile", packer_cmd "compile", {})
|
||||
user_cmd("PackerInstall", packer_cmd "install", {})
|
||||
user_cmd("PackerStatus", packer_cmd "status", {})
|
||||
user_cmd("PackerSync", packer_cmd "sync", {})
|
||||
user_cmd("PackerUpdate", packer_cmd "update", {})
|
||||
|
||||
-- add NvChadUpdate command and mapping
|
||||
cmd "silent! command! NvChadUpdate lua require('nvchad').update_nvchad()"
|
@ -0,0 +1,18 @@
|
||||
vim.cmd "silent! command! NvChadUpdate lua require('nvchad').update_nvchad()"
|
||||
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
|
||||
-- Disable statusline in dashboard
|
||||
autocmd("FileType", {
|
||||
pattern = "alpha",
|
||||
callback = function()
|
||||
vim.opt.laststatus = 0
|
||||
end,
|
||||
})
|
||||
|
||||
autocmd("BufUnload", {
|
||||
buffer = 0,
|
||||
callback = function()
|
||||
vim.opt.laststatus = 3
|
||||
end,
|
||||
})
|
@ -0,0 +1,62 @@
|
||||
local M = {}
|
||||
|
||||
M.bootstrap = function()
|
||||
local fn = vim.fn
|
||||
local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim"
|
||||
|
||||
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#1e222a" })
|
||||
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
print "Cloning packer .."
|
||||
|
||||
fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }
|
||||
|
||||
print "Packer cloned successfully!"
|
||||
|
||||
-- install plugins + compile their configs
|
||||
vim.cmd "packadd packer.nvim"
|
||||
require "plugins"
|
||||
vim.cmd "PackerSync"
|
||||
end
|
||||
end
|
||||
|
||||
M.options = {
|
||||
auto_clean = true,
|
||||
compile_on_sync = true,
|
||||
git = { clone_timeout = 6000 },
|
||||
display = {
|
||||
working_sym = "ﲊ",
|
||||
error_sym = "✗",
|
||||
done_sym = "",
|
||||
removed_sym = "",
|
||||
moved_sym = "",
|
||||
open_fn = function()
|
||||
return require("packer.util").float { border = "single" }
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
-- merge overrides if there are any
|
||||
M.options = nvchad.load_override(M.options, "wbthomason/packer.nvim")
|
||||
|
||||
M.run = function(plugins)
|
||||
local present, packer = pcall(require, "packer")
|
||||
|
||||
if not present then
|
||||
return
|
||||
end
|
||||
|
||||
-- Override with chadrc values
|
||||
plugins = nvchad.remove_default_plugins(plugins)
|
||||
plugins = nvchad.merge_plugins(plugins)
|
||||
|
||||
packer.init(M.options)
|
||||
|
||||
packer.startup(function(use)
|
||||
for _, v in pairs(plugins) do
|
||||
use(v)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
return M
|
@ -1,48 +0,0 @@
|
||||
vim.cmd "packadd packer.nvim"
|
||||
|
||||
local present, packer = pcall(require, "packer")
|
||||
|
||||
if not present then
|
||||
local packer_path = vim.fn.stdpath "data" .. "/site/pack/packer/opt/packer.nvim"
|
||||
|
||||
print "Cloning packer.."
|
||||
-- remove the dir before cloning
|
||||
vim.fn.delete(packer_path, "rf")
|
||||
vim.fn.system {
|
||||
"git",
|
||||
"clone",
|
||||
"https://github.com/wbthomason/packer.nvim",
|
||||
"--depth",
|
||||
"20",
|
||||
packer_path,
|
||||
}
|
||||
|
||||
vim.cmd "packadd packer.nvim"
|
||||
present, packer = pcall(require, "packer")
|
||||
|
||||
if present then
|
||||
print "Packer cloned successfully."
|
||||
else
|
||||
error("Couldn't clone packer !\nPacker path: " .. packer_path .. "\n" .. packer)
|
||||
end
|
||||
end
|
||||
|
||||
local options = {
|
||||
display = {
|
||||
open_fn = function()
|
||||
return require("packer.util").float { border = "single" }
|
||||
end,
|
||||
},
|
||||
git = {
|
||||
clone_timeout = 6000, -- seconds
|
||||
},
|
||||
auto_clean = true,
|
||||
compile_on_sync = true,
|
||||
snapshot = nil,
|
||||
}
|
||||
|
||||
options = nvchad.load_override(options, "wbthomason/packer.nvim")
|
||||
|
||||
packer.init(options)
|
||||
|
||||
return packer
|
Loading…
Reference in New Issue