chore(nvim): optimize lazy loading

This commit is contained in:
js0ny 2025-03-05 01:31:11 +00:00
parent 6f3665bf47
commit f12260deb2
8 changed files with 79 additions and 13 deletions

View file

@ -21,8 +21,8 @@ return {
variant = "dawn", variant = "dawn",
}, },
}, },
{ "olimorris/onedarkpro.nvim" }, { "olimorris/onedarkpro.nvim", cmd = "Telescope colorscheme" },
{ "rebelot/kanagawa.nvim" }, { "rebelot/kanagawa.nvim", cmd = "Telescope colorscheme" },
-- Highlight objects under the cursor -- Highlight objects under the cursor
{ "RRethy/vim-illuminate" }, { "RRethy/vim-illuminate" },
{ -- Modern Status Line { -- Modern Status Line

View file

@ -6,6 +6,7 @@ return {
{ {
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
build = "make install_jsregexp", build = "make install_jsregexp",
event = "InsertEnter",
config = function() config = function()
require("luasnip.loaders.from_vscode").lazy_load({ paths = "~/.config/lsp-snippets" }) require("luasnip.loaders.from_vscode").lazy_load({ paths = "~/.config/lsp-snippets" })
-- require("luasnip.loaders.from_vscode").lazy_load() -- require("luasnip.loaders.from_vscode").lazy_load()

View file

@ -7,7 +7,8 @@ return {
-- { import = "plugins.mod.markview" }, -- { import = "plugins.mod.markview" },
{ {
"lervag/vimtex", "lervag/vimtex",
lazy = false, -- we don't want to lazy load VimTeX ft = { "tex", "bib" },
-- lazy = false, -- we don't want to lazy load VimTeX
-- tag = "v2.15", -- uncomment to pin to a specific release -- tag = "v2.15", -- uncomment to pin to a specific release
init = function() init = function()
-- VimTeX configuration goes here, e.g. -- VimTeX configuration goes here, e.g.
@ -45,13 +46,13 @@ return {
}, },
{ {
"akinsho/org-bullets.nvim", "akinsho/org-bullets.nvim",
ft = { "org" },
config = function() config = function()
require("org-bullets").setup() require("org-bullets").setup()
end, end,
}, },
{ {
"nvim-orgmode/orgmode", "nvim-orgmode/orgmode",
event = "VeryLazy",
ft = { "org" }, ft = { "org" },
config = function() config = function()
-- Setup orgmode -- Setup orgmode
@ -80,6 +81,14 @@ return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
run = ":TSUpdate", run = ":TSUpdate",
cmd = {
"TSInstall",
"TSUpdate",
"TSUpdateSync",
},
event = {
"VeryLazy",
},
opts = { opts = {
ensure_installed = { "markdown", "markdown_inline", "latex", "python" }, ensure_installed = { "markdown", "markdown_inline", "latex", "python" },
highlight = { enable = true }, highlight = { enable = true },

View file

@ -25,6 +25,10 @@ return {
{ {
"kawre/leetcode.nvim", "kawre/leetcode.nvim",
build = ":TSUpdate html", -- if you have `nvim-treesitter` installed build = ":TSUpdate html", -- if you have `nvim-treesitter` installed
cmd = {
"Leet",
},
event = "VeryLazy",
dependencies = { dependencies = {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
-- "ibhagwan/fzf-lua", -- "ibhagwan/fzf-lua",

View file

@ -1,7 +1,7 @@
return { return {
"yetone/avante.nvim", "yetone/avante.nvim",
event = "VeryLazy", event = "BufRead",
lazy = false, -- lazy = false,
version = false, -- Set this to "*" to always pull the latest release version, or set it to false to update to the latest code changes. version = false, -- Set this to "*" to always pull the latest release version, or set it to false to update to the latest code changes.
opts = { opts = {
-- add any opts here -- add any opts here

View file

@ -9,6 +9,7 @@ elseif vim.env.TERM_PROGRAM == "alacritty" then
else else
return { return {
"3rd/image.nvim", "3rd/image.nvim",
opts = {} opts = {},
event = "BufReadPre",
} }
end end

View file

@ -8,7 +8,8 @@ end
return { return {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
lazy = false, -- lazy = false,
event = "InsertEnter",
dependencies = { dependencies = {
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer", "hrsh7th/cmp-buffer",
@ -58,15 +59,32 @@ return {
}) })
-- 配置 cmdline 模式 -- 配置 cmdline 模式
cmp.setup.cmdline(":", { -- cmp.setup.cmdline(":", {
-- mapping = cmp.mapping.preset.cmdline(),
-- sources = {
-- { name = "cmdline" },
-- },
-- })
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ "/", "?" }, {
mapping = cmp.mapping.preset.cmdline(), mapping = cmp.mapping.preset.cmdline(),
sources = { sources = {
{ name = "cmdline" }, { name = "buffer" },
-- path completion is slow under WSL
-- Since WSL loads Windows Environment Variables
}, },
}) })
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" },
}, {
{ name = "cmdline" },
}),
matching = { disallow_symbol_nonprefix_matching = false },
})
-- 配置 LSP -- 配置 LSP
for _, server in ipairs(servers) do for _, server in ipairs(servers) do
local config = vim.tbl_deep_extend("force", default_server_config, servers_config[server] or {}) local config = vim.tbl_deep_extend("force", default_server_config, servers_config[server] or {})

View file

@ -1,8 +1,35 @@
return { return {
"epwalsh/obsidian.nvim", "epwalsh/obsidian.nvim",
version = "*", -- recommended, use latest release instead of latest commit version = "*", -- recommended, use latest release instead of latest commit
lazy = false, -- lazy = false,
ft = "markdown", ft = "markdown",
cmd = {
"ObsidianNewFromTemplate",
"ObsidianToggleCheckbox",
"ObsidianQuickSwitch",
"ObsidianExtractNote",
"ObsidianFollowLink",
"ObsidianBacklinks",
"ObsidianWorkspace",
"ObsidianYesterday",
"ObsidianPasteImg",
"ObsidianTomorrow",
"ObsidianTemplate",
"ObsidianDailies",
"ObsidianLinkNew",
"ObsidianRename",
"ObsidianSearch",
"ObsidianCheck",
"ObsidianLinks",
"ObsidianToday",
"ObsidianDebug",
"ObsidianOpen",
"ObsidianTags",
"ObsidianLink",
"ObsidianNew",
"ObsidianTOC",
},
-- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault:
-- event = { -- event = {
-- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. -- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'.
@ -32,5 +59,11 @@ return {
enable = false, enable = false,
}, },
-- see below for full list of options 👇 -- see below for full list of options 👇
attachments = {
img_folder = "_Global/Assets",
img_name_func = function()
return string.format("%s-", os.time())
end,
},
}, },
} }