mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-31 15:19:26 +02:00
feat: reload and lir color update (#3123)
This commit is contained in:
parent
488d95b3b8
commit
1c03ac8052
9 changed files with 157 additions and 52 deletions
|
@ -3,6 +3,7 @@
|
||||||
stds.nvim = {
|
stds.nvim = {
|
||||||
globals = {
|
globals = {
|
||||||
"lvim",
|
"lvim",
|
||||||
|
"reload",
|
||||||
vim = { fields = { "g" } },
|
vim = { fields = { "g" } },
|
||||||
"TERMINAL",
|
"TERMINAL",
|
||||||
"USER",
|
"USER",
|
||||||
|
|
17
init.lua
17
init.lua
|
@ -5,17 +5,20 @@ if not vim.tbl_contains(vim.opt.rtp:get(), base_dir) then
|
||||||
vim.opt.rtp:append(base_dir)
|
vim.opt.rtp:append(base_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
require("lvim.bootstrap"):init(base_dir)
|
reload = require("lvim.utils.reload").reload
|
||||||
|
|
||||||
require("lvim.config"):load()
|
reload("lvim.bootstrap"):init(base_dir)
|
||||||
|
|
||||||
local plugins = require "lvim.plugins"
|
reload("lvim.config"):load()
|
||||||
require("lvim.plugin-loader").load { plugins, lvim.plugins }
|
|
||||||
|
|
||||||
local Log = require "lvim.core.log"
|
local plugins = reload "lvim.plugins"
|
||||||
|
|
||||||
|
reload("lvim.plugin-loader").load { plugins, lvim.plugins }
|
||||||
|
|
||||||
|
local Log = reload "lvim.core.log"
|
||||||
Log:debug "Starting LunarVim"
|
Log:debug "Starting LunarVim"
|
||||||
|
|
||||||
local commands = require "lvim.core.commands"
|
local commands = reload "lvim.core.commands"
|
||||||
commands.load(commands.defaults)
|
commands.load(commands.defaults)
|
||||||
|
|
||||||
require("lvim.lsp").setup()
|
reload("lvim.lsp").setup()
|
||||||
|
|
|
@ -26,7 +26,8 @@ local builtins = {
|
||||||
|
|
||||||
function M.config(config)
|
function M.config(config)
|
||||||
for _, builtin_path in ipairs(builtins) do
|
for _, builtin_path in ipairs(builtins) do
|
||||||
local builtin = require(builtin_path)
|
local builtin = require("lvim.utils.reload").reload(builtin_path)
|
||||||
|
|
||||||
builtin.config(config)
|
builtin.config(config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,7 +27,7 @@ M.config = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
M.setup = function()
|
M.setup = function()
|
||||||
local status_ok, indent_blankline = pcall(require, "indent_blankline")
|
local status_ok, indent_blankline = pcall(reload, "indent_blankline")
|
||||||
if not status_ok then
|
if not status_ok then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
-- local Log = require "lvim.core.log"
|
|
||||||
|
|
||||||
M.config = function()
|
M.config = function()
|
||||||
lvim.builtin.lir = {
|
lvim.builtin.lir = {
|
||||||
active = true,
|
active = true,
|
||||||
on_config_done = nil,
|
on_config_done = nil,
|
||||||
|
icon = "",
|
||||||
}
|
}
|
||||||
|
|
||||||
local status_ok, lir = pcall(require, "lir")
|
local status_ok, lir = pcall(reload, "lir")
|
||||||
if not status_ok then
|
if not status_ok then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local actions = require "lir.actions"
|
local actions = reload "lir.actions"
|
||||||
local mark_actions = require "lir.mark.actions"
|
local mark_actions = reload "lir.mark.actions"
|
||||||
local clipboard_actions = require "lir.clipboard.actions"
|
local clipboard_actions = reload "lir.clipboard.actions"
|
||||||
|
|
||||||
lir.setup {
|
lir.setup {
|
||||||
show_hidden_files = false,
|
show_hidden_files = false,
|
||||||
|
@ -84,31 +83,45 @@ M.config = function()
|
||||||
}
|
}
|
||||||
|
|
||||||
-- custom folder icon
|
-- custom folder icon
|
||||||
require("nvim-web-devicons").set_icon {
|
reload("nvim-web-devicons").set_icon {
|
||||||
lir_folder_icon = {
|
lir_folder_icon = {
|
||||||
icon = "",
|
icon = "",
|
||||||
-- color = "#7ebae4",
|
|
||||||
-- color = "#569CD6",
|
|
||||||
color = "#42A5F5",
|
color = "#42A5F5",
|
||||||
name = "LirFolderNode",
|
name = "LirFolderNode",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.icon_setup()
|
||||||
|
local function get_hl_by_name(name)
|
||||||
|
local ret = vim.api.nvim_get_hl_by_name(name.group, true)
|
||||||
|
return string.format("#%06x", ret[name.property])
|
||||||
|
end
|
||||||
|
|
||||||
|
local found, icon_hl = pcall(get_hl_by_name, { group = "NvimTreeFolderIcon", property = "foreground" })
|
||||||
|
if not found then
|
||||||
|
icon_hl = "#42A5F5"
|
||||||
|
end
|
||||||
|
|
||||||
|
reload("nvim-web-devicons").set_icon {
|
||||||
|
lir_folder_icon = {
|
||||||
|
icon = lvim.builtin.lir.icon,
|
||||||
|
color = icon_hl,
|
||||||
|
name = "LirFolderNode",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
if lvim.builtin.nvimtree.active then
|
if lvim.builtin.nvimtree.active then
|
||||||
-- Log:warn "Unable to configure lir while nvimtree is active! Please set 'lvim.builtin.nvimtree.active=false'"
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local status_ok, lir = pcall(require, "lir")
|
local status_ok, lir = pcall(reload, "lir")
|
||||||
if not status_ok then
|
if not status_ok then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
lir.setup(lvim.builtin.lir.setup)
|
|
||||||
require("nvim-web-devicons").set_icon(lvim.builtin.lir.icons)
|
|
||||||
|
|
||||||
if lvim.builtin.lir.on_config_done then
|
if lvim.builtin.lir.on_config_done then
|
||||||
lvim.builtin.lir.on_config_done(lir)
|
lvim.builtin.lir.on_config_done(lir)
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ function M.config()
|
||||||
"dashboard",
|
"dashboard",
|
||||||
"alpha",
|
"alpha",
|
||||||
},
|
},
|
||||||
auto_reload_on_write = true,
|
auto_reload_on_write = false,
|
||||||
hijack_directories = {
|
hijack_directories = {
|
||||||
enable = false,
|
enable = false,
|
||||||
},
|
},
|
||||||
|
|
|
@ -44,8 +44,14 @@ local opts = {
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
telemetry = { enable = false },
|
telemetry = { enable = false },
|
||||||
|
runtime = {
|
||||||
|
version = "LuaJIT",
|
||||||
|
special = {
|
||||||
|
reload = "require",
|
||||||
|
},
|
||||||
|
},
|
||||||
diagnostics = {
|
diagnostics = {
|
||||||
globals = { "vim", "lvim", "packer_plugins" },
|
globals = { "vim", "lvim", "packer_plugins", "reload" },
|
||||||
},
|
},
|
||||||
workspace = default_workspace,
|
workspace = default_workspace,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
local reload = require("lvim.utils.reload").reload
|
||||||
local core_plugins = {
|
local core_plugins = {
|
||||||
-- Packer can manage itself as an optional plugin
|
-- Packer can manage itself as an optional plugin
|
||||||
{ "wbthomason/packer.nvim" },
|
{ "wbthomason/packer.nvim" },
|
||||||
|
@ -10,20 +11,20 @@ local core_plugins = {
|
||||||
{
|
{
|
||||||
"williamboman/mason.nvim",
|
"williamboman/mason.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.mason").setup()
|
reload("lvim.core.mason").setup()
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"folke/tokyonight.nvim",
|
"folke/tokyonight.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.theme").setup()
|
reload("lvim.core.theme").setup()
|
||||||
end,
|
end,
|
||||||
-- disable = not vim.startswith(lvim.colorscheme, "tokyonight"),
|
-- disable = not vim.startswith(lvim.colorscheme, "tokyonight"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rcarriga/nvim-notify",
|
"rcarriga/nvim-notify",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.notify").setup()
|
reload("lvim.core.notify").setup()
|
||||||
end,
|
end,
|
||||||
requires = { "nvim-telescope/telescope.nvim" },
|
requires = { "nvim-telescope/telescope.nvim" },
|
||||||
disable = not lvim.builtin.notify.active or not lvim.builtin.telescope.active,
|
disable = not lvim.builtin.notify.active or not lvim.builtin.telescope.active,
|
||||||
|
@ -37,7 +38,7 @@ local core_plugins = {
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
branch = "0.1.x",
|
branch = "0.1.x",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.telescope").setup()
|
reload("lvim.core.telescope").setup()
|
||||||
end,
|
end,
|
||||||
disable = not lvim.builtin.telescope.active,
|
disable = not lvim.builtin.telescope.active,
|
||||||
},
|
},
|
||||||
|
@ -52,7 +53,7 @@ local core_plugins = {
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
config = function()
|
config = function()
|
||||||
if lvim.builtin.cmp then
|
if lvim.builtin.cmp then
|
||||||
require("lvim.core.cmp").setup()
|
reload("lvim.core.cmp").setup()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
requires = {
|
requires = {
|
||||||
|
@ -66,7 +67,7 @@ local core_plugins = {
|
||||||
{
|
{
|
||||||
"L3MON4D3/LuaSnip",
|
"L3MON4D3/LuaSnip",
|
||||||
config = function()
|
config = function()
|
||||||
local utils = require "lvim.utils"
|
local utils = reload "lvim.utils"
|
||||||
local paths = {}
|
local paths = {}
|
||||||
if lvim.builtin.luasnip.sources.friendly_snippets then
|
if lvim.builtin.luasnip.sources.friendly_snippets then
|
||||||
paths[#paths + 1] = utils.join_paths(get_runtime_dir(), "site", "pack", "packer", "start", "friendly-snippets")
|
paths[#paths + 1] = utils.join_paths(get_runtime_dir(), "site", "pack", "packer", "start", "friendly-snippets")
|
||||||
|
@ -75,11 +76,11 @@ local core_plugins = {
|
||||||
if utils.is_directory(user_snippets) then
|
if utils.is_directory(user_snippets) then
|
||||||
paths[#paths + 1] = user_snippets
|
paths[#paths + 1] = user_snippets
|
||||||
end
|
end
|
||||||
require("luasnip.loaders.from_lua").lazy_load()
|
reload("luasnip.loaders.from_lua").lazy_load()
|
||||||
require("luasnip.loaders.from_vscode").lazy_load {
|
reload("luasnip.loaders.from_vscode").lazy_load {
|
||||||
paths = paths,
|
paths = paths,
|
||||||
}
|
}
|
||||||
require("luasnip.loaders.from_snipmate").lazy_load()
|
reload("luasnip.loaders.from_snipmate").lazy_load()
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -104,7 +105,7 @@ local core_plugins = {
|
||||||
"windwp/nvim-autopairs",
|
"windwp/nvim-autopairs",
|
||||||
-- event = "InsertEnter",
|
-- event = "InsertEnter",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.autopairs").setup()
|
reload("lvim.core.autopairs").setup()
|
||||||
end,
|
end,
|
||||||
disable = not lvim.builtin.autopairs.active,
|
disable = not lvim.builtin.autopairs.active,
|
||||||
},
|
},
|
||||||
|
@ -114,7 +115,7 @@ local core_plugins = {
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
-- run = ":TSUpdate",
|
-- run = ":TSUpdate",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.treesitter").setup()
|
reload("lvim.core.treesitter").setup()
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -128,7 +129,7 @@ local core_plugins = {
|
||||||
-- event = "BufWinOpen",
|
-- event = "BufWinOpen",
|
||||||
-- cmd = "NvimTreeToggle",
|
-- cmd = "NvimTreeToggle",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.nvimtree").setup()
|
reload("lvim.core.nvimtree").setup()
|
||||||
end,
|
end,
|
||||||
disable = not lvim.builtin.nvimtree.active,
|
disable = not lvim.builtin.nvimtree.active,
|
||||||
},
|
},
|
||||||
|
@ -136,7 +137,7 @@ local core_plugins = {
|
||||||
{
|
{
|
||||||
"christianchiarulli/lir.nvim",
|
"christianchiarulli/lir.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.lir").setup()
|
reload("lvim.core.lir").setup()
|
||||||
end,
|
end,
|
||||||
disable = not lvim.builtin.lir.active,
|
disable = not lvim.builtin.lir.active,
|
||||||
},
|
},
|
||||||
|
@ -144,7 +145,7 @@ local core_plugins = {
|
||||||
"lewis6991/gitsigns.nvim",
|
"lewis6991/gitsigns.nvim",
|
||||||
|
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.gitsigns").setup()
|
reload("lvim.core.gitsigns").setup()
|
||||||
end,
|
end,
|
||||||
event = "BufRead",
|
event = "BufRead",
|
||||||
disable = not lvim.builtin.gitsigns.active,
|
disable = not lvim.builtin.gitsigns.active,
|
||||||
|
@ -154,7 +155,7 @@ local core_plugins = {
|
||||||
{
|
{
|
||||||
"folke/which-key.nvim",
|
"folke/which-key.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.which-key").setup()
|
reload("lvim.core.which-key").setup()
|
||||||
end,
|
end,
|
||||||
event = "BufWinEnter",
|
event = "BufWinEnter",
|
||||||
disable = not lvim.builtin.which_key.active,
|
disable = not lvim.builtin.which_key.active,
|
||||||
|
@ -165,7 +166,7 @@ local core_plugins = {
|
||||||
"numToStr/Comment.nvim",
|
"numToStr/Comment.nvim",
|
||||||
event = "BufRead",
|
event = "BufRead",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.comment").setup()
|
reload("lvim.core.comment").setup()
|
||||||
end,
|
end,
|
||||||
disable = not lvim.builtin.comment.active,
|
disable = not lvim.builtin.comment.active,
|
||||||
},
|
},
|
||||||
|
@ -174,7 +175,7 @@ local core_plugins = {
|
||||||
{
|
{
|
||||||
"ahmedkhalf/project.nvim",
|
"ahmedkhalf/project.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.project").setup()
|
reload("lvim.core.project").setup()
|
||||||
end,
|
end,
|
||||||
disable = not lvim.builtin.project.active,
|
disable = not lvim.builtin.project.active,
|
||||||
},
|
},
|
||||||
|
@ -191,7 +192,7 @@ local core_plugins = {
|
||||||
"nvim-lualine/lualine.nvim",
|
"nvim-lualine/lualine.nvim",
|
||||||
-- "Lunarvim/lualine.nvim",
|
-- "Lunarvim/lualine.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.lualine").setup()
|
reload("lvim.core.lualine").setup()
|
||||||
end,
|
end,
|
||||||
disable = not lvim.builtin.lualine.active,
|
disable = not lvim.builtin.lualine.active,
|
||||||
},
|
},
|
||||||
|
@ -200,7 +201,7 @@ local core_plugins = {
|
||||||
{
|
{
|
||||||
"SmiteshP/nvim-navic",
|
"SmiteshP/nvim-navic",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.breadcrumbs").setup()
|
reload("lvim.core.breadcrumbs").setup()
|
||||||
end,
|
end,
|
||||||
disable = not lvim.builtin.breadcrumbs.active,
|
disable = not lvim.builtin.breadcrumbs.active,
|
||||||
},
|
},
|
||||||
|
@ -208,7 +209,7 @@ local core_plugins = {
|
||||||
{
|
{
|
||||||
"akinsho/bufferline.nvim",
|
"akinsho/bufferline.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.bufferline").setup()
|
reload("lvim.core.bufferline").setup()
|
||||||
end,
|
end,
|
||||||
branch = "main",
|
branch = "main",
|
||||||
event = "BufWinEnter",
|
event = "BufWinEnter",
|
||||||
|
@ -220,7 +221,7 @@ local core_plugins = {
|
||||||
"mfussenegger/nvim-dap",
|
"mfussenegger/nvim-dap",
|
||||||
-- event = "BufWinEnter",
|
-- event = "BufWinEnter",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.dap").setup()
|
reload("lvim.core.dap").setup()
|
||||||
end,
|
end,
|
||||||
disable = not lvim.builtin.dap.active,
|
disable = not lvim.builtin.dap.active,
|
||||||
},
|
},
|
||||||
|
@ -238,7 +239,7 @@ local core_plugins = {
|
||||||
{
|
{
|
||||||
"goolord/alpha-nvim",
|
"goolord/alpha-nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.alpha").setup()
|
reload("lvim.core.alpha").setup()
|
||||||
end,
|
end,
|
||||||
disable = not lvim.builtin.alpha.active,
|
disable = not lvim.builtin.alpha.active,
|
||||||
},
|
},
|
||||||
|
@ -249,7 +250,7 @@ local core_plugins = {
|
||||||
event = "BufWinEnter",
|
event = "BufWinEnter",
|
||||||
branch = "main",
|
branch = "main",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.terminal").setup()
|
reload("lvim.core.terminal").setup()
|
||||||
end,
|
end,
|
||||||
disable = not lvim.builtin.terminal.active,
|
disable = not lvim.builtin.terminal.active,
|
||||||
},
|
},
|
||||||
|
@ -262,7 +263,7 @@ local core_plugins = {
|
||||||
{
|
{
|
||||||
"RRethy/vim-illuminate",
|
"RRethy/vim-illuminate",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.illuminate").setup()
|
reload("lvim.core.illuminate").setup()
|
||||||
end,
|
end,
|
||||||
disable = not lvim.builtin.illuminate.active,
|
disable = not lvim.builtin.illuminate.active,
|
||||||
},
|
},
|
||||||
|
@ -270,7 +271,7 @@ local core_plugins = {
|
||||||
{
|
{
|
||||||
"lukas-reineke/indent-blankline.nvim",
|
"lukas-reineke/indent-blankline.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("lvim.core.indentlines").setup()
|
reload("lvim.core.indentlines").setup()
|
||||||
end,
|
end,
|
||||||
disable = not lvim.builtin.indentlines.active,
|
disable = not lvim.builtin.indentlines.active,
|
||||||
},
|
},
|
||||||
|
@ -281,7 +282,7 @@ local core_plugins = {
|
||||||
config = function()
|
config = function()
|
||||||
pcall(function()
|
pcall(function()
|
||||||
if lvim and lvim.colorscheme == "onedarker" then
|
if lvim and lvim.colorscheme == "onedarker" then
|
||||||
require("onedarker").setup()
|
reload("onedarker").setup()
|
||||||
lvim.builtin.lualine.options.theme = "onedarker"
|
lvim.builtin.lualine.options.theme = "onedarker"
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -295,7 +296,7 @@ local content = vim.fn.readfile(default_snapshot_path)
|
||||||
local default_sha1 = vim.fn.json_decode(content)
|
local default_sha1 = vim.fn.json_decode(content)
|
||||||
|
|
||||||
local get_default_sha1 = function(spec)
|
local get_default_sha1 = function(spec)
|
||||||
local short_name, _ = require("packer.util").get_plugin_short_name(spec)
|
local short_name, _ = reload("packer.util").get_plugin_short_name(spec)
|
||||||
return default_sha1[short_name] and default_sha1[short_name].commit
|
return default_sha1[short_name] and default_sha1[short_name].commit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
80
lua/lvim/utils/reload.lua
Normal file
80
lua/lvim/utils/reload.lua
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
-- revisit this
|
||||||
|
-- function prequire(package)
|
||||||
|
-- local status, lib = pcall(require, package)
|
||||||
|
-- if status then
|
||||||
|
-- return lib
|
||||||
|
-- else
|
||||||
|
-- vim.notify("Failed to require '" .. package .. "' from " .. debug.getinfo(2).source)
|
||||||
|
-- return nil
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
|
||||||
|
local function _assign(old, new, k)
|
||||||
|
local otype = type(old[k])
|
||||||
|
local ntype = type(new[k])
|
||||||
|
-- print("hi")
|
||||||
|
if (otype == "thread" or otype == "userdata") or (ntype == "thread" or ntype == "userdata") then
|
||||||
|
vim.notify(string.format("warning: old or new attr %s type be thread or userdata", k))
|
||||||
|
end
|
||||||
|
old[k] = new[k]
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _replace(old, new, repeat_tbl)
|
||||||
|
if repeat_tbl[old] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
repeat_tbl[old] = true
|
||||||
|
|
||||||
|
local dellist = {}
|
||||||
|
for k, _ in pairs(old) do
|
||||||
|
if not new[k] then
|
||||||
|
table.insert(dellist, k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for _, v in ipairs(dellist) do
|
||||||
|
old[v] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
for k, _ in pairs(new) do
|
||||||
|
if not old[k] then
|
||||||
|
old[k] = new[k]
|
||||||
|
else
|
||||||
|
if type(old[k]) ~= type(new[k]) then
|
||||||
|
vim.notify(string.format("warning: attr %s old type no equal new type!!!", k))
|
||||||
|
_assign(old, new, k)
|
||||||
|
else
|
||||||
|
if type(old[k]) == "table" then
|
||||||
|
_replace(old[k], new[k], repeat_tbl)
|
||||||
|
else
|
||||||
|
_assign(old, new, k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
M.reload = function(mod)
|
||||||
|
if not package.loaded[mod] then
|
||||||
|
local m = require(mod)
|
||||||
|
return m
|
||||||
|
end
|
||||||
|
-- vim.notify "begin reload!!!"
|
||||||
|
|
||||||
|
local old = package.loaded[mod]
|
||||||
|
package.loaded[mod] = nil
|
||||||
|
local new = require(mod)
|
||||||
|
|
||||||
|
if type(old) == "table" and type(new) == "table" then
|
||||||
|
-- vim.notify "pick object in new module to old module!!!"
|
||||||
|
local repeat_tbl = {}
|
||||||
|
_replace(old, new, repeat_tbl)
|
||||||
|
end
|
||||||
|
|
||||||
|
package.loaded[mod] = old
|
||||||
|
-- vim.notify "finish reload!!!"
|
||||||
|
return old
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
Loading…
Add table
Add a link
Reference in a new issue