minor improvements to startuptime

This commit is contained in:
siduck 2022-06-01 00:49:23 +05:30
parent 59de298d8f
commit f78dc30508
3 changed files with 31 additions and 26 deletions

View File

@ -7,7 +7,10 @@ end
require "core" require "core"
require "core.utils" require "core.utils"
require "core.options" require "core.options"
vim.defer_fn(function()
require("core.utils").load_mappings() require("core.utils").load_mappings()
end, 0)
-- setup packer + plugins -- setup packer + plugins
require("core.packer").bootstrap() require("core.packer").bootstrap()

View File

@ -74,9 +74,7 @@ M.remove_default_keys = function()
end end
M.load_mappings = function(mappings, mapping_opt) M.load_mappings = function(mappings, mapping_opt)
mappings = mappings or M.load_config().mappings -- set mapping function with/without whichkey
-- set mapping function with/without whichkye
local map_func local map_func
local whichkey_exists, wk = pcall(require, "which-key") local whichkey_exists, wk = pcall(require, "which-key")
@ -92,9 +90,11 @@ M.load_mappings = function(mappings, mapping_opt)
end end
end end
for section, section_mappings in pairs(mappings) do mappings = mappings or vim.deepcopy(M.load_config().mappings)
if section ~= "lspconfig" then mappings.lspconfig = nil
-- skip mapping this as its mapppings are loaded in lspconfiguti
for _, section_mappings in pairs(mappings) do
-- skip mapping this as its mapppings are loaded in lspconfig
for mode, mode_mappings in pairs(section_mappings) do for mode, mode_mappings in pairs(section_mappings) do
for keybind, mapping_info in pairs(mode_mappings) do for keybind, mapping_info in pairs(mode_mappings) do
-- merge default + user opts -- merge default + user opts
@ -111,16 +111,12 @@ M.load_mappings = function(mappings, mapping_opt)
end end
end end
end end
end
-- load plugin after entering vim ui -- load plugin after entering vim ui
M.packer_lazy_load = function(plugin, timer) M.packer_lazy_load = function(plugin)
if plugin then
timer = timer or 0
vim.defer_fn(function() vim.defer_fn(function()
require("packer").loader(plugin) require("packer").loader(plugin)
end, timer) end, 0)
end
end end
-- remove plugins defined in chadrc -- remove plugins defined in chadrc

View File

@ -50,7 +50,8 @@ options.icon_styles = {
}, },
} }
options.separator_style = options.icon_styles[require("core.utils").load_config().plugins.options.statusline.separator_style] options.separator_style =
options.icon_styles[require("core.utils").load_config().plugins.options.statusline.separator_style]
options.main_icon = { options.main_icon = {
provider = options.separator_style.main_icon, provider = options.separator_style.main_icon,
@ -126,6 +127,11 @@ options.git_branch = {
icon = "", icon = "",
} }
options.empty_space_git = {
provider = " " .. options.separator_style.left,
hl = "Feline_EmptySpace_git",
}
-- lsp -- lsp
options.diagnostic = { options.diagnostic = {
@ -255,7 +261,7 @@ options.empty_spaceColored = {
hl = function() hl = function()
return { return {
fg = get_color(options.mode_hlgroups[vim.fn.mode()][2], "fg#"), fg = get_color(options.mode_hlgroups[vim.fn.mode()][2], "fg#"),
bg = get_color("Feline_EmptySpace", "fg#"), bg = get_color("Feline_EmptySpace", "bg#"),
} }
end, end,
} }
@ -346,8 +352,8 @@ add_table(options.right, options.diff.add)
add_table(options.right, options.diff.change) add_table(options.right, options.diff.change)
add_table(options.right, options.diff.remove) add_table(options.right, options.diff.remove)
add_table(options.right, options.git_branch) add_table(options.right, options.git_branch)
add_table(options.right, options.empty_space_git)
add_table(options.right, options.empty_space)
add_table(options.right, options.empty_spaceColored) add_table(options.right, options.empty_spaceColored)
add_table(options.right, options.mode_icon) add_table(options.right, options.mode_icon)
add_table(options.right, options.mode_name) add_table(options.right, options.mode_name)