Improve startuptime | remove un-needed plugins | lazy load plugin highlights too
removed nvim-gps as nvim-navic or winbar.nvim will be added when v0.8 neovim releases. Removed lsp signature as I was able to emulate showing args with the default signature help() window
This commit is contained in:
parent
d42ffe1ac7
commit
0bde81a074
21 changed files with 463 additions and 391 deletions
111
lua/core/lazy_load.lua
Normal file
111
lua/core/lazy_load.lua
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
-- https://github.com/max397574/omega-nvim/blob/master/lua/omega/modules/ui/bufferline.lua
|
||||
local lazy_load = function(tb)
|
||||
vim.api.nvim_create_autocmd(tb.events, {
|
||||
pattern = "*",
|
||||
group = vim.api.nvim_create_augroup(tb.augroup_name, {}),
|
||||
callback = function()
|
||||
if tb.condition() then
|
||||
vim.api.nvim_del_augroup_by_name(tb.augroup_name)
|
||||
|
||||
-- dont defer for treesitter as it will show slow highlighting
|
||||
-- This deferring only happens only when we do "nvim filename"
|
||||
if tb.plugins ~= "nvim-treesitter" then
|
||||
vim.defer_fn(function()
|
||||
vim.cmd("PackerLoad " .. tb.plugins)
|
||||
end, 0)
|
||||
else
|
||||
vim.cmd("PackerLoad " .. tb.plugins)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
local M = {}
|
||||
|
||||
M.bufferline = function()
|
||||
lazy_load {
|
||||
events = { "BufNewFile", "BufAdd", "TabEnter" },
|
||||
augroup_name = "BufferLineLazy",
|
||||
plugins = "bufferline.nvim",
|
||||
|
||||
condition = function()
|
||||
return #vim.fn.getbufinfo { buflisted = 1 } >= 2
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
M.colorizer = function()
|
||||
lazy_load {
|
||||
events = { "BufRead", "BufNewFile" },
|
||||
augroup_name = "ColorizerLazy",
|
||||
plugins = "nvim-colorizer.lua",
|
||||
|
||||
condition = function()
|
||||
local items = { "#", "rgb", "hsl" }
|
||||
|
||||
for _, val in ipairs(items) do
|
||||
if vim.fn.search(val) ~= 0 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
-- load certain plugins only when there's a file opened in the buffer
|
||||
-- if "nvim-file" is executed -> load the plugin after nvim gui loads
|
||||
-- This gives an instant preview of nvim with the file opened
|
||||
|
||||
M.on_file_open = function()
|
||||
lazy_load {
|
||||
events = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
augroup_name = "BeLazyOnFileOpen",
|
||||
plugins = "nvim-lsp-installer indent-blankline.nvim",
|
||||
|
||||
condition = function()
|
||||
local file = vim.fn.expand "%"
|
||||
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
M.treesitter = function()
|
||||
lazy_load {
|
||||
events = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
augroup_name = "Treesitter_lazy",
|
||||
plugins = "nvim-treesitter",
|
||||
|
||||
condition = function()
|
||||
local file = vim.fn.expand "%"
|
||||
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
M.gitsigns = function()
|
||||
-- taken from https://github.com/max397574
|
||||
vim.api.nvim_create_autocmd({ "BufAdd", "VimEnter" }, {
|
||||
callback = function()
|
||||
local function onexit(code, _)
|
||||
if code == 0 then
|
||||
vim.schedule(function()
|
||||
require("packer").loader "gitsigns.nvim"
|
||||
end)
|
||||
end
|
||||
end
|
||||
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
|
||||
if lines ~= { "" } then
|
||||
vim.loop.spawn("git", {
|
||||
args = {
|
||||
"ls-files",
|
||||
"--error-unmatch",
|
||||
vim.fn.expand "%",
|
||||
},
|
||||
}, onexit)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
local opt = vim.opt
|
||||
local g = vim.g
|
||||
|
||||
local config = require("core.utils").load_config()
|
||||
|
||||
g.nvchad_theme = config.ui.theme
|
||||
g.toggle_theme_icon = " "
|
||||
g.transparency = config.ui.transparency
|
||||
g.theme_switcher_loaded = false
|
||||
|
||||
-- use filetype.lua instead of filetype.vim
|
||||
g.did_load_filetypes = 0
|
||||
g.do_filetype_lua = 1
|
||||
g.toggle_theme_icon = " "
|
||||
g.transparency = config.ui.transparency
|
||||
|
||||
opt.laststatus = 3 -- global statusline
|
||||
opt.statusline = config.plugins.options.statusline.config
|
||||
|
|
@ -76,6 +76,19 @@ local default_plugins = {
|
|||
"vimballPlugin",
|
||||
"zip",
|
||||
"zipPlugin",
|
||||
"python3_provider",
|
||||
"python_provider",
|
||||
"node_provider",
|
||||
"ruby_provider",
|
||||
"perl_provider",
|
||||
"tutor",
|
||||
"rplugin",
|
||||
"syntax",
|
||||
"synmenu",
|
||||
"optwin",
|
||||
"compiler",
|
||||
"bugreport",
|
||||
"ftplugin",
|
||||
}
|
||||
|
||||
for _, plugin in pairs(default_plugins) do
|
||||
|
|
|
|||
|
|
@ -114,13 +114,6 @@ M.load_mappings = function(mappings, mapping_opt)
|
|||
end
|
||||
end
|
||||
|
||||
-- load plugin after entering vim ui
|
||||
M.packer_lazy_load = function(plugin)
|
||||
vim.defer_fn(function()
|
||||
require("packer").loader(plugin)
|
||||
end, 0)
|
||||
end
|
||||
|
||||
-- remove plugins defined in chadrc
|
||||
M.remove_default_plugins = function(plugins)
|
||||
local removals = M.load_config().plugins.remove or {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue