

GitHub - lewis6991/impatient.nvim: Improve startup time for Neovim
source link: https://github.com/lewis6991/impatient.nvim
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

WIP
Speed up loading Lua modules in Neovim to improve startup time.
Optimisations include:
- Cache for compiled lua modules.
- Improved default package loader for uncached module loads
- Restoring the preloader
The expectation is that a form of this plugin will eventually be merged into Neovim core via this PR. This plugin serves as a way for impatient users to speed up there Neovim 0.5 until the PR is merged and included in a following Neovim release at which point this plugin will be redundant.
Optimisations
This plugin does several things to speed up require
in Lua.
Implements cache for all loaded Lua modules
This is done by using loadstring
to compile the Lua modules to bytecode and stores them in a cache file. This also has the benefit of avoiding Neovim's expensive module loader which uses nvim_get_runtime_file()
. The cache is invalidated using the modified time of each modules file path.
The cache file is located in $XDG_CACHE_HOME/nvim/luacache
.
Reduces runtimepath
during require
runtimepath
contains directories for many things used by Neovim including Lua modules; the full list of what it is used for can be found using :help 'runtimepath'
. When require
is called, Neovim searches through every directory in runtimepath
until it finds a match. This means it ends up searching in every plugin that doesn't have a Lua directory, which can be a lot and makes require
much more expensive to run. To mitigate this, Impatient reduces runtimepath
during require
to only contain directories that have a Lua directory.
Restores the preloader
Neovim currently places its own loader for searching runtime files at the front of package.loaders
. This prevents any preloaders in package.preload
from being used. This plugin fixes that by moving the default package preloader to run before Neovim's loader. For example, LuaJIT provides preloaders for the built-in modules ffi
and bit
, so this optimisation will improve the loading of those.
Installation
-- Is using a standard Neovim install, i.e. built from source or using a -- provided appimage. use 'lewis6991/impatient.nvim'
Setup
impatient needs to be setup before any other lua plugin is loaded so it is recommended you add the following near the start of your init.vim
.
lua require('impatient')
Commands
:LuaCacheClear
:
Remove the loaded cache and delete the cache file. A new cache file will be created the next time you load Neovim.
:LuaCacheLog
:
View log of impatient.
:LuaCacheProfile
:
View profiling data. To enable, Impatient must be setup with:
lua require'impatient'.enable_profile()
Performance Example
Measured on a M1 MacBook Air.
Standard
Total resolve: 68.108365ms, total load: 56.954069ms
With reduced runtimepath
Total resolve: 39.302892ms, total load: 58.602757ms
With cache
Cache load: 3.414473ms
Total resolve: 2.122016ms, total load: 4.539859ms
Relevent Neovim PR's
libs: vendor libmpack and libmpack-lua [merged]
Credit
All credit goes to @bfredl who implemented the majority of this plugin in https://github.com/neovim/neovim/pull/15436.
Recommend
-
53
GitHub is where people build software. More than 28 million people use GitHub to discover, fork, and contribute to over 85 million projects.
-
89
Make your vim/neovim smart as VSCode. Coc is an intellisense engine for vim8 & neovim. It works on vim &g...
-
54
NVIM v0.4.0 · neovim/neovim@e2cc5fe · GitHub
-
21
Files Permalink Latest commit message Commit time
-
68
配置nvim-lspconfig和clangd的注意事项 clangd可以通过homebrew安装 brew install llvm clangd一定要在PATH环境变量下,否则neovim找不到它,LSP也就不能生效。在Apple M1安装llvm后,它的路径在/o...
-
163
nvim-lspconfig A collection of common configurations for Neovim's built-in language server client. This repo handles automatically launching and initializing language servers t...
-
1610
nvim-cmp A completion plugin for neovim coded by Lua. Status can be used. feedbacks are wanted. Concept Support pairs-wise plugin automatically Fully customizable via Lua functions
-
10
tmux.nvim This plugin still under development This plugin provides a framework to turns Neovim into terminal multiplexer (heavily based on
-
11
Install provider-* for Neovim (nvim) in Windows :h provider-python First, add those lines in your %LocalAppData%\nvim\init.vim: " Source local init.vim {{{1 let s:local_vimrc = expand('$LOCALAPPDATA\nv...
-
9
Walt Woods Programming, Electrical Engineering, and Whatever Else ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK