migrate to lazy.nvim
This commit is contained in:
parent
5db2f0978d
commit
1b8eff7516
|
@ -4,3 +4,4 @@ spell
|
|||
ftplugin
|
||||
coc-settings.json
|
||||
.luarc.json
|
||||
lazy-lock.json
|
||||
|
|
34
init.lua
34
init.lua
|
@ -1,22 +1,6 @@
|
|||
vim.defer_fn(function()
|
||||
pcall(require, "impatient")
|
||||
end, 0)
|
||||
|
||||
require "core"
|
||||
require "core.options"
|
||||
|
||||
pcall(function()
|
||||
loadfile(vim.g.base46_cache .. "bg")()
|
||||
end)
|
||||
|
||||
-- setup packer + 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
|
||||
require("core.bootstrap").chadrc_template()
|
||||
require("core.bootstrap").packer(install_path)
|
||||
end
|
||||
require("core.utils").load_mappings()
|
||||
|
||||
local custom_init_path = vim.api.nvim_get_runtime_file("lua/custom/init.lua", false)[1]
|
||||
|
||||
|
@ -24,4 +8,18 @@ if custom_init_path then
|
|||
dofile(custom_init_path)
|
||||
end
|
||||
|
||||
require("core.utils").load_mappings()
|
||||
-- bootstrap lazy.nvim!
|
||||
local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
|
||||
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
require("core.bootstrap").gen_chadrc_template()
|
||||
require("core.bootstrap").lazy(lazypath)
|
||||
end
|
||||
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
require "plugins"
|
||||
|
||||
-- load compiled base46 themes
|
||||
loadfile(vim.g.base46_cache .. "bg")()
|
||||
loadfile(vim.g.base46_cache .. "defaults")()
|
||||
loadfile(vim.g.base46_cache .. "statusline")()
|
||||
|
|
|
@ -1,20 +1,33 @@
|
|||
local M = {}
|
||||
|
||||
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#1e222a" })
|
||||
M.lazy = function(install_path)
|
||||
print "Bootstrapping lazy.nvim .."
|
||||
|
||||
M.packer = function(install_path)
|
||||
print "Cloning packer .."
|
||||
vim.fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }
|
||||
vim.fn.system {
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
"--branch=stable", -- latest stable release
|
||||
install_path,
|
||||
}
|
||||
|
||||
vim.fn.mkdir(vim.g.base46_cache, "p")
|
||||
vim.opt.rtp:prepend(install_path)
|
||||
|
||||
-- install plugins + compile their configs
|
||||
vim.cmd "packadd packer.nvim"
|
||||
require "plugins"
|
||||
vim.cmd "PackerSync"
|
||||
|
||||
vim.fn.mkdir(vim.g.base46_cache, "p")
|
||||
vim.cmd "CompileNvTheme"
|
||||
require("lazy").load { plugins = "nvim-treesitter" }
|
||||
|
||||
-- install binaries from mason.nvim & tsparsers on LazySync
|
||||
vim.schedule(function()
|
||||
vim.cmd "bw | silent! MasonInstallAll" -- close lazy window
|
||||
end, 0)
|
||||
end
|
||||
|
||||
M.chadrc_template = function()
|
||||
M.gen_chadrc_template = function()
|
||||
if not vim.api.nvim_get_runtime_file("lua/custom/chadrc.lua", false)[1] then
|
||||
local input = vim.fn.input "Do you want to install chadrc template? (y/n) : "
|
||||
vim.cmd "redraw|echo ''"
|
||||
|
@ -34,18 +47,4 @@ M.chadrc_template = function()
|
|||
end
|
||||
end
|
||||
|
||||
-- install binaries from mason.nvim & tsparsers on PackerComplete
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "PackerComplete",
|
||||
callback = function()
|
||||
require("base46").load_all_highlights()
|
||||
|
||||
vim.cmd "bw | silent! MasonInstallAll" -- close packer window
|
||||
require("packer").loader "nvim-treesitter"
|
||||
|
||||
local statusline_theme = require("core.utils").load_config().ui.statusline.theme
|
||||
vim.opt.statusline = "%!v:lua.require('nvchad_ui.statusline." .. statusline_theme .. "').run()"
|
||||
end,
|
||||
})
|
||||
|
||||
return M
|
||||
|
|
|
@ -38,17 +38,3 @@ autocmd("FileType", {
|
|||
vim.opt_local.buflisted = false
|
||||
end,
|
||||
})
|
||||
|
||||
-- wrap the PackerSync command to warn people before using it in NvChadSnapshots
|
||||
autocmd("VimEnter", {
|
||||
callback = function()
|
||||
vim.api.nvim_create_user_command("PackerSync", function(opts)
|
||||
require "plugins"
|
||||
require("core.utils").packer_sync(opts.fargs)
|
||||
end, {
|
||||
bang = true,
|
||||
nargs = "*",
|
||||
complete = require("packer").plugin_complete,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -11,6 +11,12 @@ M.general = {
|
|||
-- go to beginning and end
|
||||
["<C-b>"] = { "<ESC>^i", "beginning of line" },
|
||||
["<C-e>"] = { "<End>", "end of line" },
|
||||
|
||||
-- navigate within insert mode
|
||||
["<C-h>"] = { "<Left>", "move left" },
|
||||
["<C-l>"] = { "<Right>", "move right" },
|
||||
["<C-j>"] = { "<Down>", "move down" },
|
||||
["<C-k>"] = { "<Up>", "move up" },
|
||||
},
|
||||
|
||||
n = {
|
||||
|
|
|
@ -49,40 +49,6 @@ opt.whichwrap:append "<>[]hl"
|
|||
|
||||
g.mapleader = " "
|
||||
|
||||
-- disable some builtin vim plugins
|
||||
local default_plugins = {
|
||||
"2html_plugin",
|
||||
"getscript",
|
||||
"getscriptPlugin",
|
||||
"gzip",
|
||||
"logipat",
|
||||
"netrw",
|
||||
"netrwPlugin",
|
||||
"netrwSettings",
|
||||
"netrwFileHandlers",
|
||||
"matchit",
|
||||
"tar",
|
||||
"tarPlugin",
|
||||
"rrhelper",
|
||||
"spellfile_plugin",
|
||||
"vimball",
|
||||
"vimballPlugin",
|
||||
"zip",
|
||||
"zipPlugin",
|
||||
"tutor",
|
||||
"rplugin",
|
||||
"syntax",
|
||||
"synmenu",
|
||||
"optwin",
|
||||
"compiler",
|
||||
"bugreport",
|
||||
"ftplugin",
|
||||
}
|
||||
|
||||
for _, plugin in pairs(default_plugins) do
|
||||
g["loaded_" .. plugin] = 1
|
||||
end
|
||||
|
||||
local default_providers = {
|
||||
"node",
|
||||
"perl",
|
||||
|
|
|
@ -116,49 +116,12 @@ M.load_override = function(options_table, name)
|
|||
return merge_tb("force", options_table, plugin_options)
|
||||
end
|
||||
|
||||
M.packer_sync = function(...)
|
||||
local git_exists, git = pcall(require, "nvchad.utils.git")
|
||||
local defaults_exists, defaults = pcall(require, "nvchad.utils.config")
|
||||
local packer_exists, packer = pcall(require, "packer")
|
||||
|
||||
if git_exists and defaults_exists then
|
||||
local current_branch_name = git.get_current_branch_name()
|
||||
|
||||
-- warn the user if we are on a snapshot branch
|
||||
if current_branch_name:match(defaults.snaps.base_snap_branch_name .. "(.+)" .. "$") then
|
||||
vim.api.nvim_echo({
|
||||
{ "WARNING: You are trying to use ", "WarningMsg" },
|
||||
{ "PackerSync" },
|
||||
{
|
||||
" on a NvChadSnapshot. This will cause issues if NvChad dependencies contain "
|
||||
.. "any breaking changes! Plugin updates will not be included in this "
|
||||
.. "snapshot, so they will be lost after switching between snapshots! Would "
|
||||
.. "you still like to continue? [y/N]\n",
|
||||
"WarningMsg",
|
||||
},
|
||||
}, false, {})
|
||||
|
||||
local ans = vim.trim(string.lower(vim.fn.input "-> "))
|
||||
|
||||
if ans ~= "y" then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if packer_exists then
|
||||
packer.sync(...)
|
||||
else
|
||||
error "Packer could not be loaded!"
|
||||
end
|
||||
end
|
||||
|
||||
M.lazy_load = function(plugin)
|
||||
vim.api.nvim_create_autocmd({ "BufRead", "BufWinEnter", "BufNewFile" }, {
|
||||
group = vim.api.nvim_create_augroup("BeLazyOnFileOpen" .. plugin, {}),
|
||||
callback = function()
|
||||
local file = vim.fn.expand "%"
|
||||
local condition = file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
|
||||
local condition = file ~= "NvimTree_1" and file ~= "[lazy]" and file ~= ""
|
||||
|
||||
if condition then
|
||||
vim.api.nvim_del_augroup_by_name("BeLazyOnFileOpen" .. plugin)
|
||||
|
@ -166,14 +129,15 @@ M.lazy_load = function(plugin)
|
|||
-- dont defer for treesitter as it will show slow highlighting
|
||||
-- This deferring only happens only when we do "nvim filename"
|
||||
if plugin ~= "nvim-treesitter" then
|
||||
vim.defer_fn(function()
|
||||
require("packer").loader(plugin)
|
||||
vim.schedule(function()
|
||||
require("lazy").load { plugins = plugin }
|
||||
|
||||
if plugin == "nvim-lspconfig" then
|
||||
vim.cmd "silent! do FileType"
|
||||
end
|
||||
end, 0)
|
||||
else
|
||||
require("packer").loader(plugin)
|
||||
require("lazy").load { plugins = plugin }
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
return {
|
||||
defaults = {
|
||||
lazy = true,
|
||||
},
|
||||
|
||||
install = {
|
||||
-- try to load one of these colorschemes when starting an installation during startup
|
||||
colorscheme = { "nvchad" },
|
||||
},
|
||||
|
||||
ui = {
|
||||
icons = {
|
||||
cmd = " ",
|
||||
config = "",
|
||||
event = "",
|
||||
ft = " ",
|
||||
init = " ",
|
||||
import = " ",
|
||||
keys = " ",
|
||||
lazy = "鈴 ",
|
||||
loaded = "",
|
||||
not_loaded = "",
|
||||
plugin = " ",
|
||||
runtime = " ",
|
||||
source = " ",
|
||||
start = "",
|
||||
task = "✔ ",
|
||||
list = {
|
||||
"●",
|
||||
"➜",
|
||||
"★",
|
||||
"‒",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
performance = {
|
||||
rtp = {
|
||||
disabled_plugins = {
|
||||
"2html_plugin",
|
||||
"tohtml",
|
||||
"getscript",
|
||||
"getscriptPlugin",
|
||||
"gzip",
|
||||
"logipat",
|
||||
"netrw",
|
||||
"netrwPlugin",
|
||||
"netrwSettings",
|
||||
"netrwFileHandlers",
|
||||
"matchit",
|
||||
"tar",
|
||||
"tarPlugin",
|
||||
"rrhelper",
|
||||
"spellfile_plugin",
|
||||
"vimball",
|
||||
"vimballPlugin",
|
||||
"zip",
|
||||
"zipPlugin",
|
||||
"tutor",
|
||||
"rplugin",
|
||||
"syntax",
|
||||
"synmenu",
|
||||
"optwin",
|
||||
"compiler",
|
||||
"bugreport",
|
||||
"ftplugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
|
@ -4,14 +4,7 @@ if not present then
|
|||
return
|
||||
end
|
||||
|
||||
vim.api.nvim_create_augroup("_mason", { clear = true })
|
||||
vim.api.nvim_create_autocmd("Filetype", {
|
||||
pattern = "mason",
|
||||
callback = function()
|
||||
loadfile(vim.g.base46_cache .. "mason")()
|
||||
end,
|
||||
group = "_mason",
|
||||
})
|
||||
loadfile(vim.g.base46_cache .. "mason")()
|
||||
|
||||
local options = {
|
||||
ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim
|
||||
|
|
|
@ -37,7 +37,7 @@ M.blankline = function()
|
|||
filetype_exclude = {
|
||||
"help",
|
||||
"terminal",
|
||||
"packer",
|
||||
"lazy",
|
||||
"lspinfo",
|
||||
"TelescopePrompt",
|
||||
"TelescopeResults",
|
||||
|
@ -76,6 +76,7 @@ M.colorizer = function()
|
|||
css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
|
||||
css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
|
||||
mode = "background", -- Set the display mode.
|
||||
tailwind = true, -- Enable tailwind colors
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -168,22 +169,4 @@ M.devicons = function()
|
|||
end
|
||||
end
|
||||
|
||||
M.packer_init = function()
|
||||
return {
|
||||
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,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -1,64 +1,40 @@
|
|||
-- All plugins have lazy=true by default,to load a plugin on startup just lazy=false
|
||||
-- List of all default plugins & their definitions
|
||||
local plugins = {
|
||||
|
||||
["nvim-lua/plenary.nvim"] = { module = "plenary" },
|
||||
["nvim-lua/plenary.nvim"] = {},
|
||||
|
||||
["lewis6991/impatient.nvim"] = {},
|
||||
|
||||
["wbthomason/packer.nvim"] = {
|
||||
cmd = {
|
||||
"PackerSnapshot",
|
||||
"PackerSnapshotRollback",
|
||||
"PackerSnapshotDelete",
|
||||
"PackerInstall",
|
||||
"PackerUpdate",
|
||||
"PackerSync",
|
||||
"PackerClean",
|
||||
"PackerCompile",
|
||||
"PackerStatus",
|
||||
"PackerProfile",
|
||||
"PackerLoad",
|
||||
},
|
||||
config = function()
|
||||
require "plugins"
|
||||
end,
|
||||
},
|
||||
|
||||
["NvChad/extensions"] = { branch = "dev", module = { "telescope", "nvchad" } },
|
||||
["NvChad/extensions"] = { branch = "lazy" },
|
||||
|
||||
["NvChad/base46"] = {
|
||||
module = "base46",
|
||||
branch = "dev",
|
||||
branch = "lazy",
|
||||
},
|
||||
|
||||
["NvChad/ui"] = {
|
||||
branch = "dev",
|
||||
branch = "lazy",
|
||||
lazy = false,
|
||||
config = function()
|
||||
pcall(require, "nvchad_ui")
|
||||
require "nvchad_ui"
|
||||
end,
|
||||
},
|
||||
|
||||
["NvChad/nvterm"] = {
|
||||
module = "nvterm",
|
||||
config = function()
|
||||
require "plugins.configs.nvterm"
|
||||
end,
|
||||
setup = function()
|
||||
init = function()
|
||||
require("core.utils").load_mappings "nvterm"
|
||||
end,
|
||||
},
|
||||
|
||||
["kyazdani42/nvim-web-devicons"] = {
|
||||
after = "ui",
|
||||
module = "nvim-web-devicons",
|
||||
config = function()
|
||||
require("plugins.configs.others").devicons()
|
||||
end,
|
||||
},
|
||||
|
||||
["lukas-reineke/indent-blankline.nvim"] = {
|
||||
opt = true,
|
||||
setup = function()
|
||||
init = function()
|
||||
require("core.utils").lazy_load "indent-blankline.nvim"
|
||||
require("core.utils").load_mappings "blankline"
|
||||
end,
|
||||
|
@ -68,8 +44,7 @@ local plugins = {
|
|||
},
|
||||
|
||||
["NvChad/nvim-colorizer.lua"] = {
|
||||
opt = true,
|
||||
setup = function()
|
||||
init = function()
|
||||
require("core.utils").lazy_load "nvim-colorizer.lua"
|
||||
end,
|
||||
config = function()
|
||||
|
@ -78,12 +53,10 @@ local plugins = {
|
|||
},
|
||||
|
||||
["nvim-treesitter/nvim-treesitter"] = {
|
||||
module = "nvim-treesitter",
|
||||
setup = function()
|
||||
init = function()
|
||||
require("core.utils").lazy_load "nvim-treesitter"
|
||||
end,
|
||||
cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSEnable", "TSDisable", "TSModuleInfo" },
|
||||
|
||||
run = ":TSUpdate",
|
||||
config = function()
|
||||
require "plugins.configs.treesitter"
|
||||
|
@ -93,7 +66,7 @@ local plugins = {
|
|||
-- git stuff
|
||||
["lewis6991/gitsigns.nvim"] = {
|
||||
ft = "gitcommit",
|
||||
setup = function()
|
||||
init = function()
|
||||
-- load gitsigns only when a git file is opened
|
||||
vim.api.nvim_create_autocmd({ "BufRead" }, {
|
||||
group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }),
|
||||
|
@ -102,7 +75,7 @@ local plugins = {
|
|||
if vim.v.shell_error == 0 then
|
||||
vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad"
|
||||
vim.schedule(function()
|
||||
require("packer").loader "gitsigns.nvim"
|
||||
require("lazy").load { plugins = "gitsigns.nvim" }
|
||||
end)
|
||||
end
|
||||
end,
|
||||
|
@ -122,8 +95,7 @@ local plugins = {
|
|||
},
|
||||
|
||||
["neovim/nvim-lspconfig"] = {
|
||||
opt = true,
|
||||
setup = function()
|
||||
init = function()
|
||||
require("core.utils").lazy_load "nvim-lspconfig"
|
||||
end,
|
||||
config = function()
|
||||
|
@ -132,46 +104,47 @@ local plugins = {
|
|||
},
|
||||
|
||||
-- load luasnips + cmp related in insert mode only
|
||||
|
||||
["rafamadriz/friendly-snippets"] = { },
|
||||
|
||||
["hrsh7th/nvim-cmp"] = {
|
||||
module = { "cmp", "cmp_nvim_lsp" },
|
||||
event = { "InsertEnter", "CmdlineEnter" }, -- for users that may use nvim-cmp-cmdline
|
||||
event = "InsertEnter",
|
||||
dependencies = {
|
||||
{
|
||||
-- snippet plugin
|
||||
"L3MON4D3/LuaSnip",
|
||||
dependencies = "rafamadriz/friendly-snippets",
|
||||
config = function()
|
||||
require("plugins.configs.others").luasnip()
|
||||
end,
|
||||
},
|
||||
|
||||
-- autopairing of (){}[] etc
|
||||
{
|
||||
"windwp/nvim-autopairs",
|
||||
config = function()
|
||||
require("plugins.configs.others").autopairs()
|
||||
end,
|
||||
},
|
||||
|
||||
-- cmp sources plugins
|
||||
{
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"hrsh7th/cmp-nvim-lua",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
},
|
||||
},
|
||||
|
||||
config = function()
|
||||
require "plugins.configs.cmp"
|
||||
end,
|
||||
},
|
||||
|
||||
["L3MON4D3/LuaSnip"] = {
|
||||
requires = "friendly-snippets",
|
||||
after = "nvim-cmp",
|
||||
config = function()
|
||||
require("plugins.configs.others").luasnip()
|
||||
end,
|
||||
},
|
||||
|
||||
["saadparwaiz1/cmp_luasnip"] = { after = "LuaSnip" },
|
||||
["hrsh7th/cmp-nvim-lua"] = { after = "cmp_luasnip" },
|
||||
["hrsh7th/cmp-nvim-lsp"] = { after = "cmp-nvim-lua" },
|
||||
["hrsh7th/cmp-buffer"] = { after = "cmp-nvim-lsp" },
|
||||
["hrsh7th/cmp-path"] = { after = "cmp-buffer" },
|
||||
|
||||
-- misc plugins
|
||||
["windwp/nvim-autopairs"] = {
|
||||
after = "nvim-cmp",
|
||||
config = function()
|
||||
require("plugins.configs.others").autopairs()
|
||||
end,
|
||||
},
|
||||
|
||||
["numToStr/Comment.nvim"] = {
|
||||
module = "Comment",
|
||||
keys = { "gc", "gb" },
|
||||
-- keys = { "gc", "gb" },
|
||||
config = function()
|
||||
require("plugins.configs.others").comment()
|
||||
end,
|
||||
setup = function()
|
||||
init = function()
|
||||
require("core.utils").load_mappings "comment"
|
||||
end,
|
||||
},
|
||||
|
@ -182,7 +155,7 @@ local plugins = {
|
|||
config = function()
|
||||
require "plugins.configs.nvimtree"
|
||||
end,
|
||||
setup = function()
|
||||
init = function()
|
||||
require("core.utils").load_mappings "nvimtree"
|
||||
end,
|
||||
},
|
||||
|
@ -192,35 +165,28 @@ local plugins = {
|
|||
config = function()
|
||||
require "plugins.configs.telescope"
|
||||
end,
|
||||
setup = function()
|
||||
init = function()
|
||||
require("core.utils").load_mappings "telescope"
|
||||
end,
|
||||
},
|
||||
|
||||
-- Only load whichkey after all the gui
|
||||
["folke/which-key.nvim"] = {
|
||||
disable = true,
|
||||
module = "which-key",
|
||||
enabled = false,
|
||||
keys = { "<leader>", '"', "'", "`" },
|
||||
config = function()
|
||||
require "plugins.configs.whichkey"
|
||||
end,
|
||||
setup = function()
|
||||
init = function()
|
||||
require("core.utils").load_mappings "whichkey"
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
local present, packer = pcall(require, "packer")
|
||||
plugins = require("core.utils").merge_plugins(plugins)
|
||||
|
||||
if present then
|
||||
-- Override with default plugins with user ones
|
||||
plugins = require("core.utils").merge_plugins(plugins)
|
||||
-- load lazy.nvim options
|
||||
local lazy_config = require "plugins.configs.lazy_nvim"
|
||||
lazy_config = require("core.utils").load_override(lazy_config, "folke/lazy.nvim")
|
||||
|
||||
-- load packer init options
|
||||
local init_options = require("plugins.configs.others").packer_init()
|
||||
init_options = require("core.utils").load_override(init_options, "wbthomason/packer.nvim")
|
||||
|
||||
packer.init(init_options)
|
||||
packer.startup { plugins }
|
||||
end
|
||||
require("lazy").setup(plugins, lazy_config)
|
||||
|
|
Loading…
Reference in New Issue