Skip to content

Commit

Permalink
feat: Use CursorHold* to improve startup time (#502)
Browse files Browse the repository at this point in the history
* feat: Use CursorHold* to improve startup time

* chore(updatetime): Update comment

* fix(load): load `which-key` during initialization

* chore: Remove release note
  • Loading branch information
Jint-lzxy authored Feb 10, 2023
1 parent e722188 commit b1cc5ed
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 23 deletions.
15 changes: 0 additions & 15 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
if not vim.g.vscode then
require("core")

-- Release note
vim.schedule(function()
vim.notify_once(
[[
We've released version v2.0.0!
This is a backward-incompatible release. See the release notes for instructions on how to migrate your configs.
Visit https://github.com/ayamir/nvimdots/releases to see the release notes.
To silence this message, remove it from `init.lua` at root directory!
]],
vim.log.levels.WARN
)
end)
end
3 changes: 2 additions & 1 deletion lua/core/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ local function load_options()
ttimeoutlen = 0,
undodir = global.cache_dir .. "undo/",
undofile = true,
updatetime = 100,
-- Please do NOT set `updatetime` to above 500, otherwise most plugins may not work correctly
updatetime = 200,
viewoptions = "folds,cursor,curdir,slash,unix",
virtualedit = "block",
visualbell = true,
Expand Down
2 changes: 2 additions & 0 deletions lua/modules/plugins/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ completion["neovim/nvim-lspconfig"] = {
},
}
completion["hrsh7th/nvim-cmp"] = {
lazy = true,
event = "InsertEnter",
config = require("completion.cmp"),
dependencies = {
Expand All @@ -46,6 +47,7 @@ completion["hrsh7th/nvim-cmp"] = {
},
}
completion["zbirenbaum/copilot.lua"] = {
lazy = true,
cmd = "Copilot",
event = "InsertEnter",
config = require("completion.copilot"),
Expand Down
10 changes: 5 additions & 5 deletions lua/modules/plugins/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ editor["rmagatti/auto-session"] = {
}
editor["max397574/better-escape.nvim"] = {
lazy = true,
event = "BufReadPost",
event = { "CursorHold", "CursorHoldI" },
config = require("editor.better-escape"),
}
editor["LunarVim/bigfile.nvim"] = {
Expand All @@ -26,12 +26,12 @@ editor["ojroques/nvim-bufdel"] = {
}
editor["rhysd/clever-f.vim"] = {
lazy = true,
event = "BufReadPost",
event = { "BufReadPost", "BufAdd", "BufNewFile" },
config = require("editor.cleverf"),
}
editor["numToStr/Comment.nvim"] = {
lazy = true,
event = { "BufNewFile", "BufReadPre" },
event = { "CursorHold", "CursorHoldI" },
config = require("editor.comment"),
}
editor["sindrets/diffview.nvim"] = {
Expand All @@ -50,7 +50,7 @@ editor["phaazon/hop.nvim"] = {
}
editor["RRethy/vim-illuminate"] = {
lazy = true,
event = "BufReadPost",
event = { "CursorHold", "CursorHoldI" },
config = require("editor.vim-illuminate"),
}
editor["luukvbaal/stabilize.nvim"] = {
Expand All @@ -68,7 +68,7 @@ editor["romainl/vim-cool"] = {
editor["nvim-treesitter/nvim-treesitter"] = {
lazy = true,
build = ":TSUpdate",
event = "BufReadPost",
event = { "CursorHold", "CursorHoldI" },
config = require("editor.treesitter"),
dependencies = {
{ "nvim-treesitter/nvim-treesitter-textobjects" },
Expand Down
10 changes: 9 additions & 1 deletion lua/modules/plugins/tool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tool["tpope/vim-fugitive"] = {
}
-- Please don't remove which-key.nvim otherwise you need to set timeoutlen=300 at `lua/core/options.lua`
tool["folke/which-key.nvim"] = {
lazy = true,
event = "VeryLazy",
config = require("tool.which-key"),
}
Expand Down Expand Up @@ -41,7 +42,14 @@ tool["michaelb/sniprun"] = {
}
tool["akinsho/toggleterm.nvim"] = {
lazy = true,
event = "UIEnter",
cmd = {
"ToggleTerm",
"ToggleTermSetName",
"ToggleTermToggleAll",
"ToggleTermSendVisualLines",
"ToggleTermSendCurrentLine",
"ToggleTermSendVisualSelection",
},
config = require("tool.toggleterm"),
}
tool["folke/trouble.nvim"] = {
Expand Down
2 changes: 1 addition & 1 deletion lua/modules/plugins/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ui["j-hui/fidget.nvim"] = {
}
ui["lewis6991/gitsigns.nvim"] = {
lazy = true,
event = { "BufReadPost", "BufNewFile" },
event = { "CursorHold", "CursorHoldI" },
config = require("ui.gitsigns"),
}
ui["lukas-reineke/indent-blankline.nvim"] = {
Expand Down

0 comments on commit b1cc5ed

Please sign in to comment.