Defer Treesitter setup to improve startup time of nvim {filename}#448
Merged
feoh merged 1 commit intonvim-lua:masterfrom Oct 2, 2023
Merged
Defer Treesitter setup to improve startup time of nvim {filename}#448feoh merged 1 commit intonvim-lua:masterfrom
feoh merged 1 commit intonvim-lua:masterfrom
Conversation
Collaborator
|
@AshrafMichail23 This PR is still marked as a WIP, are you still actually working on it? |
Author
Marked as "ready for review". |
Collaborator
|
OK I just tested this myself. I don't see any downsides here! Merging. Folks please yell if this impacts you in any way, and @AshrafMichail23 thanks for your contribution! |
qiuye2015
pushed a commit
to qiuye2015/fjp.nvim
that referenced
this pull request
Dec 10, 2023
Defer Treesitter setup to improve startup time of nvim {filename}
cbmorrell
pushed a commit
to cbmorrell/kickstart-modular.nvim
that referenced
this pull request
Apr 22, 2024
Defer Treesitter setup to improve startup time of nvim {filename}
s-frick
pushed a commit
to s-frick/kickstart.nvim
that referenced
this pull request
Jul 29, 2024
Defer Treesitter setup to improve startup time of nvim {filename}
melobern
added a commit
to melobern/kickstart.nvim
that referenced
this pull request
Oct 30, 2024
Defer Treesitter setup to improve startup time of nvim {filename}
felixhummel
added a commit
to felixhummel/nvim
that referenced
this pull request
Dec 19, 2024
Defer Treesitter setup to improve startup time of nvim {filename}
restray
added a commit
to restray/kickstart.nvim
that referenced
this pull request
Mar 16, 2025
Defer Treesitter setup to improve startup time of nvim {filename}
tkappedev
pushed a commit
to tkappedev/kickstart.nvim
that referenced
this pull request
Jun 14, 2025
Defer Treesitter setup to improve startup time of nvim {filename}
apriljarosz
pushed a commit
to apriljarosz/kickstart.nvim
that referenced
this pull request
Jun 19, 2025
Defer Treesitter setup to improve startup time of nvim {filename}
eduardofuncao
pushed a commit
to eduardofuncao/config.nvim
that referenced
this pull request
Aug 5, 2025
Defer Treesitter setup to improve startup time of nvim {filename}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wrapping the require('nvim-treesitter.configs').setup block in a vim.defer_fn(function()...end, 0) saves 185ms of startup time when loading a file with an expensive Treesitter parser such as: nvim test.cc.
Default init.lua:
302.407 000.007: --- NVIM STARTED ---
Adding vim.defer_fn around require('nvim-treesitter.configs').setup block:
115.798 000.005: --- NVIM STARTED ---
The 185ms startup delay does not occur when loading a simple .txt file or .lua file.
Changes visual experience:
Before: slower startup + treesitter colors available first frame
After: faster startup + treesitter colors come in after first frame
Closes #435