Skip to content

Commit

Permalink
Merge branch 'NvChad:main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
isqiwen authored Aug 9, 2022
2 parents deb9395 + 01b17d2 commit 0afc80b
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 146 deletions.
19 changes: 14 additions & 5 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
require "core"
require "core.options"

vim.defer_fn(function()
require("core.utils").load_mappings()
end, 0)
require("core.utils").load_mappings()

-- setup packer + plugins
require("core.packer").bootstrap()
require "plugins"
local fn = vim.fn
local install_path = fn.stdpath "data" .. "/site/pack/packer/opt/packer.nvim"

if fn.empty(fn.glob(install_path)) > 0 then
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#1e222a" })
print "Cloning packer .."
fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }

-- install plugins + compile their configs
vim.cmd "packadd packer.nvim"
require "plugins"
vim.cmd "PackerSync"
end

pcall(require, "custom")
2 changes: 1 addition & 1 deletion lua/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ autocmd("FileType", {
-- wrap the PackerSync command to warn people before using it in NvChadSnapshots
autocmd("VimEnter", {
callback = function()
vim.cmd "command! -nargs=* -complete=customlist,v:lua.require'packer'.plugin_complete PackerSync lua require('core.utils').packer_sync(<f-args>)"
vim.cmd "command! -nargs=* -complete=customlist,v:lua.require'packer'.plugin_complete PackerSync lua require('plugins') require('core.utils').packer_sync(<f-args>)"
end,
})

Expand Down
36 changes: 19 additions & 17 deletions lua/core/lazy_load.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ M.lazy_load = function(tb)
callback = function()
if tb.condition() then
vim.api.nvim_del_augroup_by_name(tb.augroup_name)
pcall(require, "impatient")

-- dont defer for treesitter as it will show slow highlighting
-- This deferring only happens only when we do "nvim filename"
Expand Down Expand Up @@ -44,6 +45,20 @@ M.on_file_open = function(plugin_name)
}
end

M.packer_cmds = {
"PackerSnapshot",
"PackerSnapshotRollback",
"PackerSnapshotDelete",
"PackerInstall",
"PackerUpdate",
"PackerSync",
"PackerClean",
"PackerCompile",
"PackerStatus",
"PackerProfile",
"PackerLoad",
}

M.treesitter_cmds = {
"TSInstall",
"TSBufEnable",
Expand All @@ -63,25 +78,12 @@ M.mason_cmds = {
}

M.gitsigns = function()
-- taken from https://github.com/max397574
autocmd({ "BufRead" }, {
callback = function()
local function onexit(code, _)
if code == 0 then
vim.schedule(function()
require("packer").loader "gitsigns.nvim"
end)
end
end
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
if lines ~= { "" } then
vim.loop.spawn("git", {
args = {
"ls-files",
"--error-unmatch",
vim.fn.expand "%:p:h",
},
}, onexit)
if vim.fn.isdirectory ".git" ~= 0 then
vim.schedule(function()
require("packer").loader "gitsigns.nvim"
end)
end
end,
})
Expand Down
Loading

0 comments on commit 0afc80b

Please sign in to comment.