BREAKING CHANGE: utilize lazy.nvim fully, remove un-needed functions
This commit is contained in:
parent
5246faa09a
commit
6590372791
9 changed files with 140 additions and 217 deletions
|
@ -85,37 +85,6 @@ M.load_mappings = function(section, mapping_opt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- merge default/user plugin tables
|
|
||||||
M.merge_plugins = function(plugins)
|
|
||||||
local user_plugins = M.load_config().plugins
|
|
||||||
plugins = merge_tb("force", plugins, M.load_config().plugins)
|
|
||||||
|
|
||||||
local final_table = {}
|
|
||||||
|
|
||||||
for key, val in pairs(plugins) do
|
|
||||||
if val then
|
|
||||||
plugins[key] = (val.rm_default_opts and user_plugins[key]) or plugins[key]
|
|
||||||
plugins[key][1] = key
|
|
||||||
final_table[#final_table + 1] = plugins[key]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return final_table
|
|
||||||
end
|
|
||||||
|
|
||||||
-- override plugin options table with custom ones
|
|
||||||
M.load_override = function(options_table, name)
|
|
||||||
local user_plugins = M.load_config().plugins
|
|
||||||
local plugin_options = {}
|
|
||||||
|
|
||||||
if user_plugins[name] then
|
|
||||||
plugin_options = user_plugins[name].override_options or {}
|
|
||||||
plugin_options = type(plugin_options) == "table" and plugin_options or plugin_options()
|
|
||||||
end
|
|
||||||
|
|
||||||
return merge_tb("force", options_table, plugin_options)
|
|
||||||
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, {}),
|
||||||
|
|
|
@ -115,7 +115,4 @@ if cmp_style ~= "atom" and cmp_style ~= "atom_colored" then
|
||||||
options.window.completion.border = border "CmpBorder"
|
options.window.completion.border = border "CmpBorder"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check for any override
|
return options
|
||||||
options = require("core.utils").load_override(options, "hrsh7th/nvim-cmp")
|
|
||||||
|
|
||||||
cmp.setup(options)
|
|
||||||
|
|
|
@ -27,10 +27,4 @@ local options = {
|
||||||
max_concurrent_installers = 10,
|
max_concurrent_installers = 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
options = require("core.utils").load_override(options, "williamboman/mason.nvim")
|
return options
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("MasonInstallAll", function()
|
|
||||||
vim.cmd("MasonInstall " .. table.concat(options.ensure_installed, " "))
|
|
||||||
end, {})
|
|
||||||
|
|
||||||
require("mason").setup(options)
|
|
||||||
|
|
|
@ -75,8 +75,6 @@ local options = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- check for any override
|
|
||||||
options = require("core.utils").load_override(options, "nvim-tree/nvim-tree.lua")
|
|
||||||
vim.g.nvimtree_side = options.view.side
|
vim.g.nvimtree_side = options.view.side
|
||||||
|
|
||||||
require("nvim-tree").setup(options)
|
return options
|
||||||
|
|
|
@ -1,26 +1,7 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local load_override = require("core.utils").load_override
|
|
||||||
local utils = require "core.utils"
|
local utils = require "core.utils"
|
||||||
|
|
||||||
M.autopairs = function()
|
M.blankline = {
|
||||||
local options = {
|
|
||||||
fast_wrap = {},
|
|
||||||
disable_filetype = { "TelescopePrompt", "vim" },
|
|
||||||
}
|
|
||||||
|
|
||||||
options = load_override(options, "windwp/nvim-autopairs")
|
|
||||||
require("nvim-autopairs").setup(options)
|
|
||||||
|
|
||||||
-- setup cmp for autopairs
|
|
||||||
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
|
|
||||||
require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
|
||||||
end
|
|
||||||
|
|
||||||
M.blankline = function()
|
|
||||||
dofile(vim.g.base46_cache .. "blankline")
|
|
||||||
|
|
||||||
local options = {
|
|
||||||
indentLine_enabled = 1,
|
indentLine_enabled = 1,
|
||||||
filetype_exclude = {
|
filetype_exclude = {
|
||||||
"help",
|
"help",
|
||||||
|
@ -37,26 +18,7 @@ M.blankline = function()
|
||||||
show_first_indent_level = false,
|
show_first_indent_level = false,
|
||||||
show_current_context = true,
|
show_current_context = true,
|
||||||
show_current_context_start = true,
|
show_current_context_start = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
options = load_override(options, "lukas-reineke/indent-blankline.nvim")
|
|
||||||
require("indent_blankline").setup(options)
|
|
||||||
end
|
|
||||||
|
|
||||||
M.colorizer = function()
|
|
||||||
local options = {}
|
|
||||||
options = load_override(options, "NvChad/nvim-colorizer.lua")
|
|
||||||
require("colorizer").setup(options)
|
|
||||||
|
|
||||||
-- execute colorizer as soon as possible
|
|
||||||
vim.defer_fn(function()
|
|
||||||
require("colorizer").attach_to_buffer(0)
|
|
||||||
end, 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
M.comment = function()
|
|
||||||
require("Comment").setup(load_override({}, "numToStr/Comment.nvim"))
|
|
||||||
end
|
|
||||||
|
|
||||||
M.luasnip = function()
|
M.luasnip = function()
|
||||||
local options = {
|
local options = {
|
||||||
|
@ -64,7 +26,6 @@ M.luasnip = function()
|
||||||
updateevents = "TextChanged,TextChangedI",
|
updateevents = "TextChanged,TextChangedI",
|
||||||
}
|
}
|
||||||
|
|
||||||
options = load_override(options, "L3MON4D3/LuaSnip")
|
|
||||||
require("luasnip").config.set_config(options)
|
require("luasnip").config.set_config(options)
|
||||||
|
|
||||||
require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.luasnippets_path or "" }
|
require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.luasnippets_path or "" }
|
||||||
|
@ -83,9 +44,7 @@ M.luasnip = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
M.gitsigns = function()
|
M.gitsigns = function()
|
||||||
dofile(vim.g.base46_cache .. "git")
|
return {
|
||||||
|
|
||||||
local options = {
|
|
||||||
signs = {
|
signs = {
|
||||||
add = { hl = "DiffAdd", text = "│", numhl = "GitSignsAddNr" },
|
add = { hl = "DiffAdd", text = "│", numhl = "GitSignsAddNr" },
|
||||||
change = { hl = "DiffChange", text = "│", numhl = "GitSignsChangeNr" },
|
change = { hl = "DiffChange", text = "│", numhl = "GitSignsChangeNr" },
|
||||||
|
@ -98,18 +57,6 @@ M.gitsigns = function()
|
||||||
utils.load_mappings("gitsigns", { buffer = bufnr })
|
utils.load_mappings("gitsigns", { buffer = bufnr })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
options = load_override(options, "lewis6991/gitsigns.nvim")
|
|
||||||
require("gitsigns").setup(options)
|
|
||||||
end
|
|
||||||
|
|
||||||
M.devicons = function()
|
|
||||||
dofile(vim.g.base46_cache .. "devicons")
|
|
||||||
|
|
||||||
local options = { override = require("nvchad_ui.icons").devicons }
|
|
||||||
options = require("core.utils").load_override(options, "nvim-tree/nvim-web-devicons")
|
|
||||||
|
|
||||||
require("nvim-web-devicons").setup(options)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -54,13 +54,4 @@ local options = {
|
||||||
extensions_list = { "themes", "terms" },
|
extensions_list = { "themes", "terms" },
|
||||||
}
|
}
|
||||||
|
|
||||||
local telescope = require "telescope"
|
return options
|
||||||
|
|
||||||
-- check for any override
|
|
||||||
options = require("core.utils").load_override(options, "nvim-telescope/telescope.nvim")
|
|
||||||
telescope.setup(options)
|
|
||||||
|
|
||||||
-- load extensions
|
|
||||||
for _, ext in ipairs(options.extensions_list) do
|
|
||||||
telescope.load_extension(ext)
|
|
||||||
end
|
|
||||||
|
|
|
@ -11,7 +11,4 @@ local options = {
|
||||||
indent = { enable = true },
|
indent = { enable = true },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- check for any override
|
return options
|
||||||
options = require("core.utils").load_override(options, "nvim-treesitter/nvim-treesitter")
|
|
||||||
|
|
||||||
require("nvim-treesitter.configs").setup(options)
|
|
||||||
|
|
|
@ -30,6 +30,4 @@ local options = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
options = require("core.utils").load_override(options, "folke/which-key.nvim")
|
return options
|
||||||
|
|
||||||
require("which-key").setup(options)
|
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
-- All plugins have lazy=true by default,to load a plugin on startup just lazy=false
|
-- 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 default_plugins = {
|
||||||
|
|
||||||
["nvim-lua/plenary.nvim"] = {},
|
"nvim-lua/plenary.nvim",
|
||||||
|
|
||||||
["NvChad/extensions"] = { branch = "v2.0" },
|
-- nvchad plugins
|
||||||
|
{ "NvChad/extensions", branch = "v2.0" },
|
||||||
|
{ "NvChad/base46", branch = "v2.0" },
|
||||||
|
|
||||||
["NvChad/base46"] = {
|
{
|
||||||
branch = "v2.0",
|
"NvChad/ui",
|
||||||
},
|
|
||||||
|
|
||||||
["NvChad/ui"] = {
|
|
||||||
branch = "v2.0",
|
branch = "v2.0",
|
||||||
lazy = false,
|
lazy = false,
|
||||||
config = function()
|
config = function()
|
||||||
|
@ -18,55 +17,67 @@ local plugins = {
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
["NvChad/nvterm"] = {
|
{
|
||||||
config = function()
|
"NvChad/nvterm",
|
||||||
|
init = require("core.utils").load_mappings "nvterm",
|
||||||
|
opts = {},
|
||||||
|
config = function(_, opts)
|
||||||
require "base46.term"
|
require "base46.term"
|
||||||
local options = require("core.utils").load_override({}, "NvChad/nvterm")
|
require("nvterm").setup(opts)
|
||||||
require("nvterm").setup(options)
|
|
||||||
end,
|
|
||||||
init = function()
|
|
||||||
require("core.utils").load_mappings "nvterm"
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
["nvim-tree/nvim-web-devicons"] = {
|
{
|
||||||
|
"NvChad/nvim-colorizer.lua",
|
||||||
|
init = require("core.utils").lazy_load "nvim-colorizer.lua",
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.configs.others").devicons()
|
require("colorizer").setup()
|
||||||
|
|
||||||
|
-- execute colorizer as soon as possible
|
||||||
|
vim.defer_fn(function()
|
||||||
|
require("colorizer").attach_to_buffer(0)
|
||||||
|
end, 0)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
["lukas-reineke/indent-blankline.nvim"] = {
|
{
|
||||||
|
"nvim-tree/nvim-web-devicons",
|
||||||
|
opts = function()
|
||||||
|
return { override = require("nvchad_ui.icons").devicons }
|
||||||
|
end,
|
||||||
|
config = function(_, opts)
|
||||||
|
dofile(vim.g.base46_cache .. "devicons")
|
||||||
|
require("nvim-web-devicons").setup(opts)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"lukas-reineke/indent-blankline.nvim",
|
||||||
init = function()
|
init = 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,
|
||||||
config = function()
|
opts = require("plugins.configs.others").blankline,
|
||||||
require("plugins.configs.others").blankline()
|
config = function(_, opts)
|
||||||
|
dofile(vim.g.base46_cache .. "blankline")
|
||||||
|
require("indent_blankline").setup(opts)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
["NvChad/nvim-colorizer.lua"] = {
|
{
|
||||||
init = function()
|
"nvim-treesitter/nvim-treesitter",
|
||||||
require("core.utils").lazy_load "nvim-colorizer.lua"
|
init = require("core.utils").lazy_load "nvim-treesitter",
|
||||||
end,
|
cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" },
|
||||||
config = function()
|
|
||||||
require("plugins.configs.others").colorizer()
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
["nvim-treesitter/nvim-treesitter"] = {
|
|
||||||
init = function()
|
|
||||||
require("core.utils").lazy_load "nvim-treesitter"
|
|
||||||
end,
|
|
||||||
cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSEnable", "TSDisable", "TSModuleInfo" },
|
|
||||||
build = ":TSUpdate",
|
build = ":TSUpdate",
|
||||||
config = function()
|
opts = require "plugins.configs.treesitter",
|
||||||
require "plugins.configs.treesitter"
|
config = function(_, opts)
|
||||||
|
require("nvim-treesitter.configs").setup(opts)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- git stuff
|
-- git stuff
|
||||||
["lewis6991/gitsigns.nvim"] = {
|
{
|
||||||
|
"lewis6991/gitsigns.nvim",
|
||||||
ft = "gitcommit",
|
ft = "gitcommit",
|
||||||
init = function()
|
init = function()
|
||||||
-- load gitsigns only when a git file is opened
|
-- load gitsigns only when a git file is opened
|
||||||
|
@ -83,30 +94,37 @@ local plugins = {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
config = function()
|
opts = require("plugins.configs.others").gitsigns,
|
||||||
require("plugins.configs.others").gitsigns()
|
config = function(_, opts)
|
||||||
|
dofile(vim.g.base46_cache .. "git")
|
||||||
|
require("gitsigns").setup(opts)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- lsp stuff
|
-- lsp stuff
|
||||||
["williamboman/mason.nvim"] = {
|
{
|
||||||
|
"williamboman/mason.nvim",
|
||||||
cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" },
|
cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" },
|
||||||
config = function()
|
config = function(_, opts)
|
||||||
require "plugins.configs.mason"
|
require("mason").setup(opts)
|
||||||
|
-- custom nvchad cmd to install all mason binaries listed
|
||||||
|
vim.api.nvim_create_user_command("MasonInstallAll", function()
|
||||||
|
vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " "))
|
||||||
|
end, {})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
["neovim/nvim-lspconfig"] = {
|
{
|
||||||
init = function()
|
"neovim/nvim-lspconfig",
|
||||||
require("core.utils").lazy_load "nvim-lspconfig"
|
init = require("core.utils").lazy_load "nvim-lspconfig",
|
||||||
end,
|
|
||||||
config = function()
|
config = function()
|
||||||
require "plugins.configs.lspconfig"
|
require "plugins.configs.lspconfig"
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- load luasnips + cmp related in insert mode only
|
-- load luasnips + cmp related in insert mode only
|
||||||
["hrsh7th/nvim-cmp"] = {
|
{
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
event = "InsertEnter",
|
event = "InsertEnter",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
{
|
{
|
||||||
|
@ -121,8 +139,16 @@ local plugins = {
|
||||||
-- autopairing of (){}[] etc
|
-- autopairing of (){}[] etc
|
||||||
{
|
{
|
||||||
"windwp/nvim-autopairs",
|
"windwp/nvim-autopairs",
|
||||||
config = function()
|
opts = {
|
||||||
require("plugins.configs.others").autopairs()
|
fast_wrap = {},
|
||||||
|
disable_filetype = { "TelescopePrompt", "vim" },
|
||||||
|
},
|
||||||
|
config = function(_, opts)
|
||||||
|
require("nvim-autopairs").setup(opts)
|
||||||
|
|
||||||
|
-- setup cmp for autopairs
|
||||||
|
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
|
||||||
|
require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -136,64 +162,70 @@ local plugins = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
config = function()
|
opts = function()
|
||||||
require "plugins.configs.cmp"
|
return require "plugins.configs.cmp"
|
||||||
|
end,
|
||||||
|
config = function(_, opts)
|
||||||
|
require("cmp").setup(opts)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
["numToStr/Comment.nvim"] = {
|
{
|
||||||
|
"numToStr/Comment.nvim",
|
||||||
-- keys = { "gc", "gb" },
|
-- keys = { "gc", "gb" },
|
||||||
|
init = require("core.utils").load_mappings "comment",
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.configs.others").comment()
|
require("Comment").setup()
|
||||||
end,
|
|
||||||
init = function()
|
|
||||||
require("core.utils").load_mappings "comment"
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- file managing , picker etc
|
-- file managing , picker etc
|
||||||
["nvim-tree/nvim-tree.lua"] = {
|
{
|
||||||
|
"nvim-tree/nvim-tree.lua",
|
||||||
cmd = { "NvimTreeToggle", "NvimTreeFocus" },
|
cmd = { "NvimTreeToggle", "NvimTreeFocus" },
|
||||||
config = function()
|
init = require("core.utils").load_mappings "nvimtree",
|
||||||
require "plugins.configs.nvimtree"
|
opts = require "plugins.configs.nvimtree",
|
||||||
end,
|
config = function(_, opts)
|
||||||
init = function()
|
require("nvim-tree").setup(opts)
|
||||||
require("core.utils").load_mappings "nvimtree"
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
["nvim-telescope/telescope.nvim"] = {
|
{
|
||||||
|
"nvim-telescope/telescope.nvim",
|
||||||
cmd = "Telescope",
|
cmd = "Telescope",
|
||||||
config = function()
|
init = require("core.utils").load_mappings "telescope",
|
||||||
require "plugins.configs.telescope"
|
|
||||||
|
opts = function()
|
||||||
|
return require "plugins.configs.telescope"
|
||||||
end,
|
end,
|
||||||
init = function()
|
|
||||||
require("core.utils").load_mappings "telescope"
|
config = function(_, opts)
|
||||||
|
local telescope = require "telescope"
|
||||||
|
telescope.setup(opts)
|
||||||
|
|
||||||
|
-- load extensions
|
||||||
|
for _, ext in ipairs(opts.extensions_list) do
|
||||||
|
telescope.load_extension(ext)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Only load whichkey after all the gui
|
-- Only load whichkey after all the gui
|
||||||
["folke/which-key.nvim"] = {
|
{
|
||||||
|
"folke/which-key.nvim",
|
||||||
enabled = false,
|
enabled = false,
|
||||||
keys = { "<leader>", '"', "'", "`" },
|
keys = { "<leader>", '"', "'", "`" },
|
||||||
config = function()
|
init = require("core.utils").load_mappings "whichkey",
|
||||||
require "plugins.configs.whichkey"
|
opts = require "plugins.configs.whichkey",
|
||||||
end,
|
config = function(_, opts)
|
||||||
init = function()
|
require("which-key").setup(opts)
|
||||||
require("core.utils").load_mappings "whichkey"
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ import = require("core.utils").load_config().plugins },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- pin commits for all default plugins
|
-- load lazy.nvim _,opts
|
||||||
for _, value in pairs(plugins) do
|
|
||||||
value.pin = true
|
|
||||||
end
|
|
||||||
|
|
||||||
plugins = require("core.utils").merge_plugins(plugins)
|
|
||||||
|
|
||||||
-- load lazy.nvim options
|
|
||||||
local lazy_config = require "plugins.configs.lazy_nvim"
|
local lazy_config = require "plugins.configs.lazy_nvim"
|
||||||
lazy_config = require("core.utils").load_override(lazy_config, "folke/lazy.nvim")
|
|
||||||
|
|
||||||
require("lazy").setup(plugins, lazy_config)
|
require("lazy").setup(default_plugins, lazy_config)
|
||||||
|
|
Loading…
Reference in a new issue