Improve startup speed by properly lazy loading

This commit is contained in:
Dreaded_X 2025-05-31 05:06:46 +02:00
parent 649653ef8c
commit 7723d66cbf
Signed by: Dreaded_X
GPG Key ID: 5A0CBFE3C3377FAA
20 changed files with 170 additions and 86 deletions

View File

@ -5,6 +5,7 @@ return {
"saghen/blink.cmp", "saghen/blink.cmp",
-- optional: provides snippets for the snippet source -- optional: provides snippets for the snippet source
dependencies = { "rafamadriz/friendly-snippets" }, dependencies = { "rafamadriz/friendly-snippets" },
event = "InsertEnter",
-- use a release tag to download pre-built binaries -- use a release tag to download pre-built binaries
version = "1.*", version = "1.*",
@ -117,6 +118,10 @@ return {
}, },
}, },
cmdline = {
enabled = false,
},
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation, -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"` -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`

View File

@ -3,7 +3,6 @@
--- @type LazySpec --- @type LazySpec
return { return {
"NvChad/nvim-colorizer.lua", "NvChad/nvim-colorizer.lua",
event = "VeryLazy",
opts = { opts = {
lazy_load = true, lazy_load = true,
filetypes = { filetypes = {

View File

@ -3,6 +3,7 @@
--- @type LazySpec --- @type LazySpec
return { return {
{ {
enabled = false,
"mfussenegger/nvim-dap", "mfussenegger/nvim-dap",
config = function() config = function()
local dap = require("dap") local dap = require("dap")
@ -88,6 +89,7 @@ return {
end, end,
}, },
{ {
enabled = false,
"theHamsta/nvim-dap-virtual-text", "theHamsta/nvim-dap-virtual-text",
dependencies = { dependencies = {
"mfussenegger/nvim-dap", "mfussenegger/nvim-dap",

View File

@ -3,6 +3,7 @@
--- @type LazySpec --- @type LazySpec
return { return {
"j-hui/fidget.nvim", "j-hui/fidget.nvim",
event = "LspAttach",
opts = { opts = {
notification = { notification = {
window = { window = {

View File

@ -4,7 +4,7 @@
return { return {
-- Adds git related signs to the gutter, as well as utilities for managing changes -- Adds git related signs to the gutter, as well as utilities for managing changes
"lewis6991/gitsigns.nvim", "lewis6991/gitsigns.nvim",
event = "VeryLazy", event = { "BufWritePost", "BufReadPre" },
--- @module "gitsigns" --- @module "gitsigns"
--- @type Gitsigns.Config --- @type Gitsigns.Config
opts = { opts = {
@ -32,30 +32,42 @@ return {
}, },
}, },
init = function() init = function()
local ga = require("gitsigns.actions") vim.keymap.set("n", "gs", function()
require("gitsigns.actions").stage_hunk()
vim.keymap.set("n", "gs", ga.stage_hunk, { desc = "(Un)stage hunk" }) end, { desc = "(Un)stage hunk" })
vim.keymap.set("n", "gS", ga.stage_buffer, { desc = "Stage buffer" }) vim.keymap.set("n", "gS", function()
require("gitsigns.actions").stage_buffer()
end, { desc = "Stage buffer" })
vim.keymap.set("v", "gs", function() vim.keymap.set("v", "gs", function()
ga.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) require("gitsigns.actions").stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, { desc = "(Un)stage selection" }) end, { desc = "(Un)stage selection" })
vim.keymap.set("n", "gd", ga.preview_hunk, { desc = "Diff hunk" }) vim.keymap.set("n", "gd", function()
require("gitsigns.actions").preview_hunk()
end, { desc = "Diff hunk" })
vim.keymap.set("n", "<leader>tb", ga.toggle_current_line_blame, { desc = "Line blame" }) vim.keymap.set("n", "<leader>tb", function()
vim.keymap.set("n", "gb", ga.blame_line, { desc = "View blame" }) require("gitsigns.actions").toggle_current_line_blame()
end, { desc = "Line blame" })
vim.keymap.set("n", "gb", function()
require("gitsigns.actions").blame_line()
end, { desc = "View blame" })
vim.keymap.set("n", "<leader>gr", ga.reset_hunk, { desc = "Reset hunk" }) vim.keymap.set("n", "<leader>gr", function()
vim.keymap.set("n", "<leader>gR", ga.reset_buffer, { desc = "Reset buffer" }) require("gitsigns.actions").reset_hunk()
end, { desc = "Reset hunk" })
vim.keymap.set("n", "<leader>gR", function()
require("gitsigns.actions").reset_buffer()
end, { desc = "Reset buffer" })
vim.keymap.set("v", "<leader>gr", function() vim.keymap.set("v", "<leader>gr", function()
ga.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) require("gitsigns.actions").reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, { desc = "Git reset selection" }) end, { desc = "Git reset selection" })
vim.keymap.set("n", "]g", function() vim.keymap.set("n", "]g", function()
ga.nav_hunk("next") require("gitsigns.actions").nav_hunk("next")
end, { desc = "Next hunk" }) end, { desc = "Next hunk" })
vim.keymap.set("n", "[g", function() vim.keymap.set("n", "[g", function()
ga.nav_hunk("prev") require("gitsigns.actions").nav_hunk("prev")
end, { desc = "Previous hunk" }) end, { desc = "Previous hunk" })
end, end,
} }

View File

@ -3,6 +3,8 @@
--- @type LazySpec --- @type LazySpec
return { return {
"NMAC427/guess-indent.nvim", "NMAC427/guess-indent.nvim",
cmd = "GuessIndent",
event = { "BufReadPre" },
--- @module "guess-indent" --- @module "guess-indent"
--- @type GuessIndentConfig --- @type GuessIndentConfig
opts = {}, opts = {},

View File

@ -3,6 +3,9 @@
--- @type LazySpec --- @type LazySpec
return { return {
"smjonas/inc-rename.nvim", "smjonas/inc-rename.nvim",
cmd = "IncRename",
-- We can't load on just the command otherwise the preview does not work
event = "LspAttach",
--- @module "inc_rename" --- @module "inc_rename"
--- @type inc_rename.UserConfig --- @type inc_rename.UserConfig
opts = { opts = {

View File

@ -3,6 +3,7 @@
--- @type LazySpec --- @type LazySpec
return { return {
"diogo464/kubernetes.nvim", "diogo464/kubernetes.nvim",
ft = "yaml",
opts = { opts = {
schema_strict = true, schema_strict = true,
schema_generate_always = false, schema_generate_always = false,

View File

@ -3,4 +3,5 @@
--- @type LazySpec --- @type LazySpec
return { return {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
cmd = { "LspInfo", "LspStart", "LspStop", "LspRestart" },
} }

View File

@ -1,6 +1,10 @@
-- https://github.com/nvim-lualine/lualine.nvim -- https://github.com/nvim-lualine/lualine.nvim
local function get_schema() local function get_schema()
if vim.bo.filetype ~= "yaml" then
return ""
end
local schema = require("schema-companion.context").get_buffer_schema() local schema = require("schema-companion.context").get_buffer_schema()
if schema.name == "none" then if schema.name == "none" then
return "" return ""

View File

@ -3,6 +3,7 @@
--- @type LazySpec --- @type LazySpec
return { return {
"mason-org/mason-lspconfig.nvim", "mason-org/mason-lspconfig.nvim",
cmd = { "LspInstall", "LspUninstall" },
event = "VeryLazy", event = "VeryLazy",
--- @module "mason-lspconfig" --- @module "mason-lspconfig"
--- @type MasonLspconfigSettings --- @type MasonLspconfigSettings

View File

@ -36,6 +36,5 @@ return {
ensure_installed = ensure_installed, ensure_installed = ensure_installed,
auto_update = true, auto_update = true,
debounde_hours = 24, debounde_hours = 24,
start_delay = 1000,
}, },
} }

View File

@ -3,6 +3,7 @@
--- @type LazySpec --- @type LazySpec
return { return {
"mason-org/mason.nvim", "mason-org/mason.nvim",
cmd = { "Mason", "MasonUpdate", "MasonInstall", "MasonUninstall", "MasonUninstallAll", "MasonLog" },
--- @module "mason" --- @module "mason"
--- @type MasonSettings --- @type MasonSettings
opts = {}, opts = {},

View File

@ -3,6 +3,7 @@
--- @type LazySpec --- @type LazySpec
return { return {
"tadachs/ros-nvim", "tadachs/ros-nvim",
event = { "BufRead", "BufNewFile" },
opts = { opts = {
only_workspace = true, only_workspace = true,
}, },
@ -10,6 +11,5 @@ return {
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
"nvim-telescope/telescope.nvim",
}, },
} }

View File

@ -38,14 +38,16 @@ return {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
"diogo464/kubernetes.nvim", "diogo464/kubernetes.nvim",
}, },
init = function() keys = {
vim.keymap.set( {
"n",
"<leader>ys", "<leader>ys",
require("telescope").extensions.schema_companion.select_schema, function()
{ desc = "Yaml schema" } require("telescope").extensions.schema_companion.select_schema()
)
end, end,
desc = "Yaml schema",
ft = "yaml",
},
},
--- @module "schema-companion" --- @module "schema-companion"
--- @type schema_companion.Config --- @type schema_companion.Config
opts = { opts = {

View File

@ -3,4 +3,5 @@
--- @type LazySpec --- @type LazySpec
return { return {
"b0o/schemastore.nvim", "b0o/schemastore.nvim",
lazy = true,
} }

View File

@ -3,24 +3,51 @@
--- @type LazySpec --- @type LazySpec
return { return {
"mrjones2014/smart-splits.nvim", "mrjones2014/smart-splits.nvim",
event = "VeryLazy",
--- @module "smart-splits"
--- @type SmartSplitsConfig
opts = { opts = {
at_edge = "stop", at_edge = "stop",
cursor_follows_swapped_bufs = true, cursor_follows_swapped_bufs = true,
}, },
init = function() init = function()
vim.keymap.set("n", "<M-h>", require("smart-splits").move_cursor_left) vim.keymap.set("n", "<M-h>", function()
vim.keymap.set("n", "<M-j>", require("smart-splits").move_cursor_down) require("smart-splits").move_cursor_left()
vim.keymap.set("n", "<M-k>", require("smart-splits").move_cursor_up) end)
vim.keymap.set("n", "<M-l>", require("smart-splits").move_cursor_right) vim.keymap.set("n", "<M-j>", function()
require("smart-splits").move_cursor_down()
end)
vim.keymap.set("n", "<M-k>", function()
require("smart-splits").move_cursor_up()
end)
vim.keymap.set("n", "<M-l>", function()
require("smart-splits").move_cursor_right()
end)
vim.keymap.set("n", "<C-w>h", require("smart-splits").swap_buf_left, { desc = "Swap buffer to the left" }) vim.keymap.set("n", "<C-w>h", function()
vim.keymap.set("n", "<C-w>j", require("smart-splits").swap_buf_down, { desc = "Swap buffer to the bottom" }) require("smart-splits").swap_buf_left()
vim.keymap.set("n", "<C-w>k", require("smart-splits").swap_buf_up, { desc = "Swap buffer to the top" }) end, { desc = "Swap buffer to the left" })
vim.keymap.set("n", "<C-w>l", require("smart-splits").swap_buf_right, { desc = "Swap buffer to the right" }) vim.keymap.set("n", "<C-w>j", function()
require("smart-splits").swap_buf_down()
end, { desc = "Swap buffer to the bottom" })
vim.keymap.set("n", "<C-w>k", function()
require("smart-splits").swap_buf_up()
end, { desc = "Swap buffer to the top" })
vim.keymap.set("n", "<C-w>l", function()
require("smart-splits").swap_buf_right()
end, { desc = "Swap buffer to the right" })
vim.keymap.set("n", "<M-left>", require("smart-splits").resize_left, { desc = "Resize buffer to the left" }) vim.keymap.set("n", "<M-left>", function()
vim.keymap.set("n", "<M-down>", require("smart-splits").resize_down, { desc = "Resize buffer to the bottom" }) require("smart-splits").resize_left()
vim.keymap.set("n", "<M-up>", require("smart-splits").resize_up, { desc = "Resize buffer to the top" }) end, { desc = "Resize buffer to the left" })
vim.keymap.set("n", "<M-right>", require("smart-splits").resize_right, { desc = "Resize buffer to the right" }) vim.keymap.set("n", "<M-down>", function()
require("smart-splits").resize_down()
end, { desc = "Resize buffer to the bottom" })
vim.keymap.set("n", "<M-up>", function()
require("smart-splits").resize_up()
end, { desc = "Resize buffer to the top" })
vim.keymap.set("n", "<M-right>", function()
require("smart-splits").resize_right()
end, { desc = "Resize buffer to the right" })
end, end,
} }

View File

@ -4,18 +4,28 @@ local window = require("symbols.window")
--- @type LazySpec --- @type LazySpec
return { return {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
cmd = { "Telescope" },
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
{
"nvim-telescope/telescope-ui-select.nvim", "nvim-telescope/telescope-ui-select.nvim",
config = function()
require("telescope").load_extension("ui-select")
end,
},
{ {
"nvim-telescope/telescope-fzf-native.nvim", "nvim-telescope/telescope-fzf-native.nvim",
build = "make", build = "make",
cond = function() cond = function()
return vim.fn.executable("make") == 1 return vim.fn.executable("make") == 1
end, end,
config = function()
require("telescope").load_extension("fzf")
end,
}, },
}, },
opts = { opts = function()
return {
pickers = { pickers = {
find_files = { find_files = {
hidden = true, hidden = true,
@ -42,13 +52,15 @@ return {
require("telescope.themes").get_dropdown(), require("telescope.themes").get_dropdown(),
}, },
}, },
}, }
end,
init = function() init = function()
require("telescope").load_extension("fzf") vim.keymap.set("n", "<leader>.", function()
require("telescope").load_extension("ui-select") require("telescope.builtin").oldfiles()
end, { desc = "Find recently opened files" })
vim.keymap.set("n", "<leader>.", require("telescope.builtin").oldfiles, { desc = "Find recently opened files" }) vim.keymap.set("n", "<leader>sb", function()
vim.keymap.set("n", "<leader>sb", require("telescope.builtin").buffers, { desc = "Buffers" }) require("telescope.builtin").buffers()
end, { desc = "Buffers" })
vim.keymap.set("n", "<leader>/", function() vim.keymap.set("n", "<leader>/", function()
require("telescope.builtin").current_buffer_fuzzy_find({ require("telescope.builtin").current_buffer_fuzzy_find({
@ -63,18 +75,30 @@ return {
}) })
end, { desc = "Grep in open files" }) end, { desc = "Grep in open files" })
vim.keymap.set("n", "<leader><space>", require("telescope.builtin").find_files, { desc = "Find files" }) vim.keymap.set("n", "<leader><space>", function()
vim.keymap.set("n", "<leader>sh", require("telescope.builtin").help_tags, { desc = "Help" }) require("telescope.builtin").find_files()
end, { desc = "Find files" })
vim.keymap.set("n", "<leader>sh", function()
require("telescope.builtin").help_tags()
end, { desc = "Help" })
vim.keymap.set("n", "<leader>sw", function() vim.keymap.set("n", "<leader>sw", function()
require("telescope.builtin").grep_string({ require("telescope.builtin").grep_string({
-- Show matches in the order they appear in the document -- Show matches in the order they appear in the document
sorting_strategy = "ascending", sorting_strategy = "ascending",
}) })
end, { desc = "Current word" }) end, { desc = "Current word" })
vim.keymap.set("n", "<leader>sg", require("telescope.builtin").live_grep, { desc = "Grep" }) vim.keymap.set("n", "<leader>sg", function()
vim.keymap.set("n", "<leader>sd", require("telescope.builtin").diagnostics, { desc = "Diagnostics" }) require("telescope.builtin").live_grep()
vim.keymap.set("n", "<leader>sr", require("telescope.builtin").resume, { desc = "Resume" }) end, { desc = "Grep" })
vim.keymap.set("n", "<leader>sk", require("telescope.builtin").keymaps, { desc = "Keymaps" }) vim.keymap.set("n", "<leader>sd", function()
require("telescope.builtin").diagnostics()
end, { desc = "Diagnostics" })
vim.keymap.set("n", "<leader>sr", function()
require("telescope.builtin").resume()
end, { desc = "Resume" })
vim.keymap.set("n", "<leader>sk", function()
require("telescope.builtin").keymaps()
end, { desc = "Keymaps" })
vim.keymap.set("n", "<leader>sn", function() vim.keymap.set("n", "<leader>sn", function()
require("telescope.builtin").find_files({ cwd = vim.fn.stdpath("config") }) require("telescope.builtin").find_files({ cwd = vim.fn.stdpath("config") })
end, { desc = "Neovim files" }) end, { desc = "Neovim files" })

View File

@ -8,6 +8,7 @@ return {
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
}, },
event = "VeryLazy",
opts = { opts = {
keywords = { keywords = {
-- FIX: Fix -- FIX: Fix
@ -52,13 +53,12 @@ return {
require("todo-comments").jump_prev() require("todo-comments").jump_prev()
end, { desc = "Previous todo comment" }) end, { desc = "Previous todo comment" })
if pcall(require, "trouble") then -- -- TODO: Use cwd to only show todo's in the current file
-- TODO: Use cwd to only show todo's in the current file -- -- vim.keymap.set("n", "<F4>", "<cmd>TroubleToggle todo cwd=%<cr>", { desc = "Next todo comment" })
-- vim.keymap.set("n", "<F4>", "<cmd>TroubleToggle todo cwd=%<cr>", { desc = "Next todo comment" }) -- vim.keymap.set("n", "<F4>", "<cmd>TroubleToggle todo<cr>", { desc = "Next todo comment" })
vim.keymap.set("n", "<F4>", "<cmd>TroubleToggle todo<cr>", { desc = "Next todo comment" })
end vim.keymap.set("n", "<leader>st", function()
if pcall(require, "telescope") then require("telescope").extensions["todo-comments"].todo()
vim.keymap.set("n", "<leader>st", "<cmd>TodoTelescope<cr>", { desc = "Search todo" }) end, { desc = "Search todo" })
end
end, end,
} }

View File

@ -4,6 +4,7 @@ local window = require("symbols.window")
--- @type LazySpec --- @type LazySpec
return { return {
"folke/which-key.nvim", "folke/which-key.nvim",
event = "VeryLazy",
--- @module "which-key" --- @module "which-key"
--- @type wk.Opts --- @type wk.Opts
opts = { opts = {
@ -48,15 +49,13 @@ return {
}, },
expand = 1, expand = 1,
sort = { "alphanum" }, sort = { "alphanum" },
}, spec = {
init = function()
require("which-key").add({
{ "<leader>b", group = "Buffer" }, { "<leader>b", group = "Buffer" },
{ "<leader>d", group = "Doument" }, { "<leader>d", group = "Doument" },
{ "<leader>g", group = "Git" }, { "<leader>g", group = "Git" },
{ "<leader>t", group = "Toggle" }, { "<leader>t", group = "Toggle" },
{ "<leader>s", group = "Search" }, { "<leader>s", group = "Search" },
{ "gr", group = "LSP" }, { "gr", group = "LSP" },
}) },
end, },
} }