mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 18:45:08 +02:00
fix: rollback plugin loader changes (#3402)
This commit is contained in:
parent
f6e5dc0d44
commit
531ddb459e
5 changed files with 103 additions and 40 deletions
2
init.lua
2
init.lua
|
@ -10,7 +10,7 @@ end
|
|||
|
||||
require("lvim.bootstrap"):init(base_dir)
|
||||
|
||||
require("lvim.config").load()
|
||||
require("lvim.config"):load()
|
||||
|
||||
local plugins = require "lvim.plugins"
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ local user_config_file = utils.join_paths(user_config_dir, "config.lua")
|
|||
|
||||
---Get the full path to the user configuration file
|
||||
---@return string
|
||||
function M.get_user_config_path()
|
||||
function M:get_user_config_path()
|
||||
return user_config_file
|
||||
end
|
||||
|
||||
--- Initialize lvim default configuration and variables
|
||||
function M.init()
|
||||
function M:init()
|
||||
lvim = vim.deepcopy(require "lvim.config.defaults")
|
||||
|
||||
require("lvim.keymappings").load_defaults()
|
||||
|
@ -29,20 +29,100 @@ function M.init()
|
|||
local lvim_lsp_config = require "lvim.lsp.config"
|
||||
lvim.lsp = vim.deepcopy(lvim_lsp_config)
|
||||
|
||||
---@deprecated replaced with lvim.builtin.alpha
|
||||
lvim.builtin.dashboard = {
|
||||
active = false,
|
||||
on_config_done = nil,
|
||||
search_handler = "",
|
||||
disable_at_vim_enter = 0,
|
||||
session_directory = "",
|
||||
custom_header = {},
|
||||
custom_section = {},
|
||||
footer = {},
|
||||
}
|
||||
|
||||
lvim.builtin.luasnip = {
|
||||
sources = {
|
||||
friendly_snippets = true,
|
||||
},
|
||||
}
|
||||
|
||||
require("lvim.config._deprecated").handle()
|
||||
---@deprecated
|
||||
lvim.builtin.notify = {
|
||||
active = false,
|
||||
}
|
||||
end
|
||||
|
||||
local function handle_deprecated_settings()
|
||||
local function deprecation_notice(setting, new_setting)
|
||||
local in_headless = #vim.api.nvim_list_uis() == 0
|
||||
if in_headless then
|
||||
return
|
||||
end
|
||||
|
||||
local msg = string.format(
|
||||
"Deprecation notice: [%s] setting is no longer supported. %s",
|
||||
setting,
|
||||
new_setting or "See https://github.com/LunarVim/LunarVim#breaking-changes"
|
||||
)
|
||||
vim.schedule(function()
|
||||
vim.notify_once(msg, vim.log.levels.WARN)
|
||||
end)
|
||||
end
|
||||
|
||||
---lvim.lang.FOO.lsp
|
||||
for lang, entry in pairs(lvim.lang) do
|
||||
local deprecated_config = entry.formatters or entry.linters or {}
|
||||
if not vim.tbl_isempty(deprecated_config) then
|
||||
deprecation_notice(string.format("lvim.lang.%s", lang))
|
||||
end
|
||||
end
|
||||
|
||||
-- lvim.lsp.override
|
||||
if lvim.lsp.override and not vim.tbl_isempty(lvim.lsp.override) then
|
||||
deprecation_notice("lvim.lsp.override", "Use `lvim.lsp.automatic_configuration.skipped_servers` instead")
|
||||
vim.tbl_map(function(c)
|
||||
if not vim.tbl_contains(lvim.lsp.automatic_configuration.skipped_servers, c) then
|
||||
table.insert(lvim.lsp.automatic_configuration.skipped_servers, c)
|
||||
end
|
||||
end, lvim.lsp.override)
|
||||
end
|
||||
|
||||
-- lvim.lsp.popup_border
|
||||
if vim.tbl_contains(vim.tbl_keys(lvim.lsp), "popup_border") then
|
||||
deprecation_notice "lvim.lsp.popup_border"
|
||||
end
|
||||
|
||||
-- dashboard.nvim
|
||||
if lvim.builtin.dashboard.active then
|
||||
deprecation_notice("lvim.builtin.dashboard", "Use `lvim.builtin.alpha` instead. See LunarVim#1906")
|
||||
end
|
||||
|
||||
-- notify.nvim
|
||||
if lvim.builtin.notify.active then
|
||||
deprecation_notice("lvim.builtin.notify", "See LunarVim#3294")
|
||||
end
|
||||
|
||||
if lvim.autocommands.custom_groups then
|
||||
deprecation_notice(
|
||||
"lvim.autocommands.custom_groups",
|
||||
"Use vim.api.nvim_create_autocmd instead or check LunarVim#2592 to learn about the new syntax"
|
||||
)
|
||||
end
|
||||
|
||||
if lvim.lsp.automatic_servers_installation then
|
||||
deprecation_notice(
|
||||
"lvim.lsp.automatic_servers_installation",
|
||||
"Use `lvim.lsp.installer.setup.automatic_installation` instead"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
--- Override the configuration with a user provided one
|
||||
-- @param config_path The path to the configuration overrides
|
||||
function M.load(config_path)
|
||||
function M:load(config_path)
|
||||
local autocmds = reload "lvim.core.autocmds"
|
||||
config_path = config_path or M.get_user_config_path()
|
||||
config_path = config_path or self:get_user_config_path()
|
||||
local ok, err = pcall(dofile, config_path)
|
||||
if not ok then
|
||||
if utils.is_file(user_config_file) then
|
||||
|
@ -58,6 +138,8 @@ function M.load(config_path)
|
|||
|
||||
Log:set_level(lvim.log.level)
|
||||
|
||||
handle_deprecated_settings()
|
||||
|
||||
autocmds.define_autocmds(lvim.autocommands)
|
||||
|
||||
vim.g.mapleader = (lvim.leader == "space" and " ") or lvim.leader
|
||||
|
@ -75,7 +157,7 @@ end
|
|||
|
||||
--- Override the configuration with a user provided one
|
||||
-- @param config_path The path to the configuration overrides
|
||||
function M.reload()
|
||||
function M:reload()
|
||||
vim.schedule(function()
|
||||
reload("lvim.utils.hooks").run_pre_reload()
|
||||
|
||||
|
|
|
@ -69,9 +69,6 @@ local function pcall_packer_command(cmd, kwargs)
|
|||
end
|
||||
|
||||
function plugin_loader.cache_clear()
|
||||
if not utils.is_file(compile_path) then
|
||||
return
|
||||
end
|
||||
if vim.fn.delete(compile_path) == 0 then
|
||||
Log:debug "deleted packer_compiled.lua"
|
||||
end
|
||||
|
@ -79,17 +76,10 @@ end
|
|||
|
||||
function plugin_loader.recompile()
|
||||
plugin_loader.cache_clear()
|
||||
vim.cmd [[LuaCacheClear]]
|
||||
pcall_packer_command "compile"
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "PackerCompileDone",
|
||||
once = true,
|
||||
callback = function()
|
||||
if utils.is_file(compile_path) then
|
||||
Log:debug "generated packer_compiled.lua"
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
function plugin_loader.reload(configurations)
|
||||
|
@ -160,11 +150,7 @@ function plugin_loader.sync_core_plugins()
|
|||
require("lvim.plugin-loader").load_snapshot(default_snapshot)
|
||||
end,
|
||||
})
|
||||
|
||||
plugin_loader.cache_clear()
|
||||
local core_plugins = plugin_loader.get_core_plugins()
|
||||
Log:trace(string.format("Syncing core plugins: [%q]", table.concat(core_plugins, ", ")))
|
||||
pcall_packer_command("sync", core_plugins)
|
||||
pcall_packer_command "sync"
|
||||
end
|
||||
|
||||
function plugin_loader.ensure_plugins()
|
||||
|
|
|
@ -2,7 +2,6 @@ local M = {}
|
|||
|
||||
local Log = require "lvim.core.log"
|
||||
local in_headless = #vim.api.nvim_list_uis() == 0
|
||||
local plugin_loader = require "lvim.plugin-loader"
|
||||
|
||||
function M.run_pre_update()
|
||||
Log:debug "Starting pre-update hook"
|
||||
|
@ -16,14 +15,10 @@ function M.run_on_packer_complete()
|
|||
Log:debug "Packer operation complete"
|
||||
vim.api.nvim_exec_autocmds("User", { pattern = "PackerComplete" })
|
||||
|
||||
vim.g.colors_name = lvim.colorscheme
|
||||
pcall(vim.cmd, "colorscheme " .. lvim.colorscheme)
|
||||
|
||||
if M._reload_triggered then
|
||||
if not in_headless then
|
||||
vim.schedule(function()
|
||||
-- FIXME(kylo252): nvim-tree.lua/lua/nvim-tree/view.lua:442: Invalid window id
|
||||
-- pcall(vim.api.nvim_exec_autocmds, "ColorScheme", { pattern = "*" })
|
||||
pcall(vim.cmd.colorscheme, lvim.colorscheme)
|
||||
end)
|
||||
end
|
||||
Log:debug "Reloaded configuration"
|
||||
M._reload_triggered = nil
|
||||
end
|
||||
|
@ -39,7 +34,7 @@ end
|
|||
---It also forces regenerating any template ftplugin files
|
||||
---Tip: Useful for clearing any outdated settings
|
||||
function M.reset_cache()
|
||||
plugin_loader.recompile()
|
||||
vim.cmd [[LuaCacheClear]]
|
||||
local lvim_modules = {}
|
||||
for module, _ in pairs(package.loaded) do
|
||||
if module:match "lvim.core" or module:match "lvim.lsp" then
|
||||
|
@ -73,7 +68,7 @@ function M.run_post_update()
|
|||
M.reset_cache()
|
||||
|
||||
Log:debug "Syncing core plugins"
|
||||
plugin_loader.sync_core_plugins()
|
||||
require("lvim.plugin-loader").sync_core_plugins()
|
||||
|
||||
if not in_headless then
|
||||
vim.schedule(function()
|
||||
|
|
|
@ -28,14 +28,14 @@ a.describe("config-loader", function()
|
|||
end)
|
||||
|
||||
a.it("should be able to load user-config without errors", function()
|
||||
config.load(user_config_path)
|
||||
config:load(user_config_path)
|
||||
end)
|
||||
|
||||
a.it("should be able to reload user-config without errors", function()
|
||||
config.load(user_config_path)
|
||||
config:load(user_config_path)
|
||||
local test_path = "/tmp/lvim"
|
||||
os.execute(string.format([[echo "vim.opt.undodir = '%s'" >> %s]], test_path, user_config_path))
|
||||
config.reload()
|
||||
config:reload()
|
||||
vim.schedule(function()
|
||||
assert.equal(vim.opt.undodir:get()[1], test_path)
|
||||
end)
|
||||
|
@ -44,11 +44,11 @@ a.describe("config-loader", function()
|
|||
a.it("should not get interrupted by errors in user-config", function()
|
||||
local test_path = "/tmp/lunarvim"
|
||||
os.execute(string.format([[echo "vim.opt.undodir = '%s'" >> %s]], test_path, user_config_path))
|
||||
config.load(user_config_path)
|
||||
config:load(user_config_path)
|
||||
assert.equal(vim.opt.undodir:get()[1], test_path)
|
||||
require("lvim.core.log"):set_level "error"
|
||||
os.execute(string.format("echo 'invalid_function()' >> %s", user_config_path))
|
||||
config.load(user_config_path)
|
||||
config:load(user_config_path)
|
||||
require("lvim.core.log"):set_level "error"
|
||||
assert.equal(vim.opt.undodir:get()[1], test_path)
|
||||
end)
|
||||
|
|
Loading…
Reference in a new issue