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",
-- optional: provides snippets for the snippet source
dependencies = { "rafamadriz/friendly-snippets" },
event = "InsertEnter",
-- use a release tag to download pre-built binaries
version = "1.*",
@ -117,6 +118,10 @@ return {
},
},
cmdline = {
enabled = false,
},
-- (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,
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,6 +3,9 @@
--- @type LazySpec
return {
"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"
--- @type inc_rename.UserConfig
opts = {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,6 +8,7 @@ return {
dependencies = {
"nvim-lua/plenary.nvim",
},
event = "VeryLazy",
opts = {
keywords = {
-- FIX: Fix
@ -52,13 +53,12 @@ return {
require("todo-comments").jump_prev()
end, { desc = "Previous todo comment" })
if pcall(require, "trouble") then
-- 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<cr>", { desc = "Next todo comment" })
end
if pcall(require, "telescope") then
vim.keymap.set("n", "<leader>st", "<cmd>TodoTelescope<cr>", { desc = "Search todo" })
end
-- -- 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<cr>", { desc = "Next todo comment" })
vim.keymap.set("n", "<leader>st", function()
require("telescope").extensions["todo-comments"].todo()
end, { desc = "Search todo" })
end,
}

View File

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