migrate to lazy.nvim
This commit is contained in:
parent
5db2f0978d
commit
1b8eff7516
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ spell
|
|||||||
ftplugin
|
ftplugin
|
||||||
coc-settings.json
|
coc-settings.json
|
||||||
.luarc.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"
|
||||||
require "core.options"
|
require "core.options"
|
||||||
|
require("core.utils").load_mappings()
|
||||||
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
|
|
||||||
|
|
||||||
local custom_init_path = vim.api.nvim_get_runtime_file("lua/custom/init.lua", false)[1]
|
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)
|
dofile(custom_init_path)
|
||||||
end
|
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 = {}
|
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)
|
vim.fn.system {
|
||||||
print "Cloning packer .."
|
"git",
|
||||||
vim.fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }
|
"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
|
-- install plugins + compile their configs
|
||||||
vim.cmd "packadd packer.nvim"
|
|
||||||
require "plugins"
|
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
|
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
|
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) : "
|
local input = vim.fn.input "Do you want to install chadrc template? (y/n) : "
|
||||||
vim.cmd "redraw|echo ''"
|
vim.cmd "redraw|echo ''"
|
||||||
@ -34,18 +47,4 @@ M.chadrc_template = function()
|
|||||||
end
|
end
|
||||||
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
|
return M
|
||||||
|
@ -38,17 +38,3 @@ autocmd("FileType", {
|
|||||||
vim.opt_local.buflisted = false
|
vim.opt_local.buflisted = false
|
||||||
end,
|
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
|
-- go to beginning and end
|
||||||
["<C-b>"] = { "<ESC>^i", "beginning of line" },
|
["<C-b>"] = { "<ESC>^i", "beginning of line" },
|
||||||
["<C-e>"] = { "<End>", "end 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 = {
|
n = {
|
||||||
|
@ -49,40 +49,6 @@ opt.whichwrap:append "<>[]hl"
|
|||||||
|
|
||||||
g.mapleader = " "
|
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 = {
|
local default_providers = {
|
||||||
"node",
|
"node",
|
||||||
"perl",
|
"perl",
|
||||||
|
@ -116,49 +116,12 @@ M.load_override = function(options_table, name)
|
|||||||
return merge_tb("force", options_table, plugin_options)
|
return merge_tb("force", options_table, plugin_options)
|
||||||
end
|
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)
|
M.lazy_load = function(plugin)
|
||||||
vim.api.nvim_create_autocmd({ "BufRead", "BufWinEnter", "BufNewFile" }, {
|
vim.api.nvim_create_autocmd({ "BufRead", "BufWinEnter", "BufNewFile" }, {
|
||||||
group = vim.api.nvim_create_augroup("BeLazyOnFileOpen" .. plugin, {}),
|
group = vim.api.nvim_create_augroup("BeLazyOnFileOpen" .. plugin, {}),
|
||||||
callback = function()
|
callback = function()
|
||||||
local file = vim.fn.expand "%"
|
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
|
if condition then
|
||||||
vim.api.nvim_del_augroup_by_name("BeLazyOnFileOpen" .. plugin)
|
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
|
-- dont defer for treesitter as it will show slow highlighting
|
||||||
-- This deferring only happens only when we do "nvim filename"
|
-- This deferring only happens only when we do "nvim filename"
|
||||||
if plugin ~= "nvim-treesitter" then
|
if plugin ~= "nvim-treesitter" then
|
||||||
vim.defer_fn(function()
|
vim.schedule(function()
|
||||||
require("packer").loader(plugin)
|
require("lazy").load { plugins = plugin }
|
||||||
|
|
||||||
if plugin == "nvim-lspconfig" then
|
if plugin == "nvim-lspconfig" then
|
||||||
vim.cmd "silent! do FileType"
|
vim.cmd "silent! do FileType"
|
||||||
end
|
end
|
||||||
end, 0)
|
end, 0)
|
||||||
else
|
else
|
||||||
require("packer").loader(plugin)
|
require("lazy").load { plugins = plugin }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
70
lua/plugins/configs/lazy_nvim.lua
Normal file
70
lua/plugins/configs/lazy_nvim.lua
Normal file
@ -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
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_create_augroup("_mason", { clear = true })
|
loadfile(vim.g.base46_cache .. "mason")()
|
||||||
vim.api.nvim_create_autocmd("Filetype", {
|
|
||||||
pattern = "mason",
|
|
||||||
callback = function()
|
|
||||||
loadfile(vim.g.base46_cache .. "mason")()
|
|
||||||
end,
|
|
||||||
group = "_mason",
|
|
||||||
})
|
|
||||||
|
|
||||||
local options = {
|
local options = {
|
||||||
ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim
|
ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim
|
||||||
|
@ -37,7 +37,7 @@ M.blankline = function()
|
|||||||
filetype_exclude = {
|
filetype_exclude = {
|
||||||
"help",
|
"help",
|
||||||
"terminal",
|
"terminal",
|
||||||
"packer",
|
"lazy",
|
||||||
"lspinfo",
|
"lspinfo",
|
||||||
"TelescopePrompt",
|
"TelescopePrompt",
|
||||||
"TelescopeResults",
|
"TelescopeResults",
|
||||||
@ -76,6 +76,7 @@ M.colorizer = function()
|
|||||||
css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
|
css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
|
||||||
css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
|
css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
|
||||||
mode = "background", -- Set the display mode.
|
mode = "background", -- Set the display mode.
|
||||||
|
tailwind = true, -- Enable tailwind colors
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,22 +169,4 @@ M.devicons = function()
|
|||||||
end
|
end
|
||||||
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
|
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
|
-- List of all default plugins & their definitions
|
||||||
local plugins = {
|
local plugins = {
|
||||||
|
|
||||||
["nvim-lua/plenary.nvim"] = { module = "plenary" },
|
["nvim-lua/plenary.nvim"] = {},
|
||||||
|
|
||||||
["lewis6991/impatient.nvim"] = {},
|
["NvChad/extensions"] = { branch = "lazy" },
|
||||||
|
|
||||||
["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/base46"] = {
|
["NvChad/base46"] = {
|
||||||
module = "base46",
|
branch = "lazy",
|
||||||
branch = "dev",
|
|
||||||
},
|
},
|
||||||
|
|
||||||
["NvChad/ui"] = {
|
["NvChad/ui"] = {
|
||||||
branch = "dev",
|
branch = "lazy",
|
||||||
|
lazy = false,
|
||||||
config = function()
|
config = function()
|
||||||
pcall(require, "nvchad_ui")
|
require "nvchad_ui"
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
["NvChad/nvterm"] = {
|
["NvChad/nvterm"] = {
|
||||||
module = "nvterm",
|
|
||||||
config = function()
|
config = function()
|
||||||
require "plugins.configs.nvterm"
|
require "plugins.configs.nvterm"
|
||||||
end,
|
end,
|
||||||
setup = function()
|
init = function()
|
||||||
require("core.utils").load_mappings "nvterm"
|
require("core.utils").load_mappings "nvterm"
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
["kyazdani42/nvim-web-devicons"] = {
|
["kyazdani42/nvim-web-devicons"] = {
|
||||||
after = "ui",
|
|
||||||
module = "nvim-web-devicons",
|
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.configs.others").devicons()
|
require("plugins.configs.others").devicons()
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
["lukas-reineke/indent-blankline.nvim"] = {
|
["lukas-reineke/indent-blankline.nvim"] = {
|
||||||
opt = true,
|
init = function()
|
||||||
setup = function()
|
|
||||||
require("core.utils").lazy_load "indent-blankline.nvim"
|
require("core.utils").lazy_load "indent-blankline.nvim"
|
||||||
require("core.utils").load_mappings "blankline"
|
require("core.utils").load_mappings "blankline"
|
||||||
end,
|
end,
|
||||||
@ -68,8 +44,7 @@ local plugins = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
["NvChad/nvim-colorizer.lua"] = {
|
["NvChad/nvim-colorizer.lua"] = {
|
||||||
opt = true,
|
init = function()
|
||||||
setup = function()
|
|
||||||
require("core.utils").lazy_load "nvim-colorizer.lua"
|
require("core.utils").lazy_load "nvim-colorizer.lua"
|
||||||
end,
|
end,
|
||||||
config = function()
|
config = function()
|
||||||
@ -78,12 +53,10 @@ local plugins = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
["nvim-treesitter/nvim-treesitter"] = {
|
["nvim-treesitter/nvim-treesitter"] = {
|
||||||
module = "nvim-treesitter",
|
init = function()
|
||||||
setup = function()
|
|
||||||
require("core.utils").lazy_load "nvim-treesitter"
|
require("core.utils").lazy_load "nvim-treesitter"
|
||||||
end,
|
end,
|
||||||
cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSEnable", "TSDisable", "TSModuleInfo" },
|
cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSEnable", "TSDisable", "TSModuleInfo" },
|
||||||
|
|
||||||
run = ":TSUpdate",
|
run = ":TSUpdate",
|
||||||
config = function()
|
config = function()
|
||||||
require "plugins.configs.treesitter"
|
require "plugins.configs.treesitter"
|
||||||
@ -93,7 +66,7 @@ local plugins = {
|
|||||||
-- git stuff
|
-- git stuff
|
||||||
["lewis6991/gitsigns.nvim"] = {
|
["lewis6991/gitsigns.nvim"] = {
|
||||||
ft = "gitcommit",
|
ft = "gitcommit",
|
||||||
setup = function()
|
init = function()
|
||||||
-- load gitsigns only when a git file is opened
|
-- load gitsigns only when a git file is opened
|
||||||
vim.api.nvim_create_autocmd({ "BufRead" }, {
|
vim.api.nvim_create_autocmd({ "BufRead" }, {
|
||||||
group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }),
|
group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }),
|
||||||
@ -102,7 +75,7 @@ local plugins = {
|
|||||||
if vim.v.shell_error == 0 then
|
if vim.v.shell_error == 0 then
|
||||||
vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad"
|
vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad"
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
require("packer").loader "gitsigns.nvim"
|
require("lazy").load { plugins = "gitsigns.nvim" }
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -122,8 +95,7 @@ local plugins = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
["neovim/nvim-lspconfig"] = {
|
["neovim/nvim-lspconfig"] = {
|
||||||
opt = true,
|
init = function()
|
||||||
setup = function()
|
|
||||||
require("core.utils").lazy_load "nvim-lspconfig"
|
require("core.utils").lazy_load "nvim-lspconfig"
|
||||||
end,
|
end,
|
||||||
config = function()
|
config = function()
|
||||||
@ -132,46 +104,47 @@ local plugins = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
-- load luasnips + cmp related in insert mode only
|
-- load luasnips + cmp related in insert mode only
|
||||||
|
|
||||||
["rafamadriz/friendly-snippets"] = { },
|
|
||||||
|
|
||||||
["hrsh7th/nvim-cmp"] = {
|
["hrsh7th/nvim-cmp"] = {
|
||||||
module = { "cmp", "cmp_nvim_lsp" },
|
event = "InsertEnter",
|
||||||
event = { "InsertEnter", "CmdlineEnter" }, -- for users that may use nvim-cmp-cmdline
|
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()
|
config = function()
|
||||||
require "plugins.configs.cmp"
|
require "plugins.configs.cmp"
|
||||||
end,
|
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"] = {
|
["numToStr/Comment.nvim"] = {
|
||||||
module = "Comment",
|
-- keys = { "gc", "gb" },
|
||||||
keys = { "gc", "gb" },
|
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.configs.others").comment()
|
require("plugins.configs.others").comment()
|
||||||
end,
|
end,
|
||||||
setup = function()
|
init = function()
|
||||||
require("core.utils").load_mappings "comment"
|
require("core.utils").load_mappings "comment"
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
@ -182,7 +155,7 @@ local plugins = {
|
|||||||
config = function()
|
config = function()
|
||||||
require "plugins.configs.nvimtree"
|
require "plugins.configs.nvimtree"
|
||||||
end,
|
end,
|
||||||
setup = function()
|
init = function()
|
||||||
require("core.utils").load_mappings "nvimtree"
|
require("core.utils").load_mappings "nvimtree"
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
@ -192,35 +165,28 @@ local plugins = {
|
|||||||
config = function()
|
config = function()
|
||||||
require "plugins.configs.telescope"
|
require "plugins.configs.telescope"
|
||||||
end,
|
end,
|
||||||
setup = function()
|
init = function()
|
||||||
require("core.utils").load_mappings "telescope"
|
require("core.utils").load_mappings "telescope"
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Only load whichkey after all the gui
|
-- Only load whichkey after all the gui
|
||||||
["folke/which-key.nvim"] = {
|
["folke/which-key.nvim"] = {
|
||||||
disable = true,
|
enabled = false,
|
||||||
module = "which-key",
|
|
||||||
keys = { "<leader>", '"', "'", "`" },
|
keys = { "<leader>", '"', "'", "`" },
|
||||||
config = function()
|
config = function()
|
||||||
require "plugins.configs.whichkey"
|
require "plugins.configs.whichkey"
|
||||||
end,
|
end,
|
||||||
setup = function()
|
init = function()
|
||||||
require("core.utils").load_mappings "whichkey"
|
require("core.utils").load_mappings "whichkey"
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local present, packer = pcall(require, "packer")
|
plugins = require("core.utils").merge_plugins(plugins)
|
||||||
|
|
||||||
if present then
|
-- load lazy.nvim options
|
||||||
-- Override with default plugins with user ones
|
local lazy_config = require "plugins.configs.lazy_nvim"
|
||||||
plugins = require("core.utils").merge_plugins(plugins)
|
lazy_config = require("core.utils").load_override(lazy_config, "folke/lazy.nvim")
|
||||||
|
|
||||||
-- load packer init options
|
require("lazy").setup(plugins, lazy_config)
|
||||||
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
|
|
||||||
|
Loading…
Reference in New Issue
Block a user