为什么我的 require 函数在启动 Neovim 时花费如此之长?

huangapple go评论66阅读模式
英文:

Why my require functions takes so long when startup neovim?

问题

我在neovim的启动时间上遇到了严重的问题。我尝试使用--startuptime来查看问题出在哪里,令人惊讶的是,与其他人的结果相比,有如此多的require函数。而且每个过程都需要很长时间。以下是一些结果:

   43 417.518  045.278  014.356: require('colorscheme')
   44 460.586  004.998  004.998: require('nvim-tree.notify')
   45 460.600  009.976  004.978: require('nvim-tree.events')
   46 480.300  004.872  004.872: require('nvim-tree.log')
   47 492.942  007.324  007.324: require('nvim-tree.iterators.node-iterator')
   48 493.028  012.718  005.394: require('nvim-tree.utils')
   49 516.366  023.334  023.334: require('nvim-tree.git.utils')
   50 522.552  006.174  006.174: require('nvim-tree.git.runner')
   51 527.582  005.022  005.022: require('nvim-tree.watcher')
   52 532.882  005.291  005.291: require('nvim-tree.explorer.node')
   53 532.892  065.091  007.679: require('nvim-tree.git')
   54 537.823  004.927  004.927: require('nvim-tree.explorer.watch')
   55 547.688  004.857  004.857: require('nvim-tree.explorer.node-builders')
   56 552.693  004.996  004.996: require('nvim-tree.explorer.sorters')
   57 557.760  005.059  005.059: require('nvim-tree.explorer.filters')
   58 570.921  005.365  005.365: require('nvim-tree.view')
   59 570.933  013.166  007.801: require('nvim-tree.live-filter')
   60 570.938  033.108  005.031: require('nvim-tree.explorer.explore')
   61 576.097  005.157  005.157: require('nvim-tree.explorer.reload')
   62 576.108  115.505  007.221: require('nvim-tree.explorer')
   63 576.114  130.469  004.989: require('nvim-tree.core')
   64 581.400  005.284  005.284: require('nvim-tree.diagnostics')
   65 593.482  004.836  004.836: require('nvim-tree.modified')
   66 593.492  012.083  007.247: require('nvim-tree.renderer.components.modified')
   67 598.521  005.025  005.025: require('nvim-tree.renderer.components.padding')
   68 603.421  004.891  004.891: require('nvim-tree.renderer.components.icons')
   69 608.584  005.156  005.156: require('nvim-tree.renderer.components.full-name')
   70 613.550  004.956  004.956: require('nvim-tree.renderer.components.git')
   71 621.535  007.979  007.979: require('nvim-tree.renderer.builder')
   72 628.986  007.443  007.443: require('nvim-tree.marks')
   73 629.014  190.728  007.442: require('nvim-tree.renderer')
   74 629.022  198.777  008.050: require('nvim-tree.lib')
   75 633.945  004.921  004.921: require('nvim-tree.colors')
   76 666.528  007.269  007.269: require('nvim-tree.actions.finders.find-file')
   77 666.539  016.924  009.655: require('nvim-tree.actions.tree.open')
   78 671.468  004.925  004.925: require('nvim-tree.actions.tree.toggle')
   79 678.888  007.407  007.407: require('nvim-tree.actions.reloaders.reloaders')
   80 686.220  007.322  007.322: require('nvim-tree.actions.root.dir-up')
   81 691.179  004.949  004.949: require('nvim-tree.actions.tree.find-file')
   82 696.790  005.544  005.544: require('nvim-tree.actions.finders.search-node')

总的启动时间可能会达到2秒,没有耐心的插件。是否有人知道为什么会出现这么多的require函数,以及如何减少启动时间?

当其他人运行--startuptime命令时,我并没有看到太多的require函数。我想知道是否有设置错误。

英文:

I suffer from a terrible startup time for neovim. I tried using --startuptime to see what's wrong and surprisingly found that there are so many require functions compared with other's result. And each process will take a very long time. Here is some of the result:

   43 417.518  045.278  014.356: require('colorscheme')
   44 460.586  004.998  004.998: require('nvim-tree.notify')
   45 460.600  009.976  004.978: require('nvim-tree.events')
   46 480.300  004.872  004.872: require('nvim-tree.log')
   47 492.942  007.324  007.324: require('nvim-tree.iterators.node-iterator')
   48 493.028  012.718  005.394: require('nvim-tree.utils')
   49 516.366  023.334  023.334: require('nvim-tree.git.utils')
   50 522.552  006.174  006.174: require('nvim-tree.git.runner')
   51 527.582  005.022  005.022: require('nvim-tree.watcher')
   52 532.882  005.291  005.291: require('nvim-tree.explorer.node')
   53 532.892  065.091  007.679: require('nvim-tree.git')
   54 537.823  004.927  004.927: require('nvim-tree.explorer.watch')
   55 547.688  004.857  004.857: require('nvim-tree.explorer.node-builders')
   56 552.693  004.996  004.996: require('nvim-tree.explorer.sorters')
   57 557.760  005.059  005.059: require('nvim-tree.explorer.filters')
   58 570.921  005.365  005.365: require('nvim-tree.view')
   59 570.933  013.166  007.801: require('nvim-tree.live-filter')
   60 570.938  033.108  005.031: require('nvim-tree.explorer.explore')
   61 576.097  005.157  005.157: require('nvim-tree.explorer.reload')
   62 576.108  115.505  007.221: require('nvim-tree.explorer')
   63 576.114  130.469  004.989: require('nvim-tree.core')
   64 581.400  005.284  005.284: require('nvim-tree.diagnostics')
   65 593.482  004.836  004.836: require('nvim-tree.modified')
   66 593.492  012.083  007.247: require('nvim-tree.renderer.components.modified')
   67 598.521  005.025  005.025: require('nvim-tree.renderer.components.padding')
   68 603.421  004.891  004.891: require('nvim-tree.renderer.components.icons')
   69 608.584  005.156  005.156: require('nvim-tree.renderer.components.full-name')
   70 613.550  004.956  004.956: require('nvim-tree.renderer.components.git')
   71 621.535  007.979  007.979: require('nvim-tree.renderer.builder')
   72 628.986  007.443  007.443: require('nvim-tree.marks')
   73 629.014  190.728  007.442: require('nvim-tree.renderer')
   74 629.022  198.777  008.050: require('nvim-tree.lib')
   75 633.945  004.921  004.921: require('nvim-tree.colors')
   76 666.528  007.269  007.269: require('nvim-tree.actions.finders.find-file')
   77 666.539  016.924  009.655: require('nvim-tree.actions.tree.open')
   78 671.468  004.925  004.925: require('nvim-tree.actions.tree.toggle')
   79 678.888  007.407  007.407: require('nvim-tree.actions.reloaders.reloaders')
   80 686.220  007.322  007.322: require('nvim-tree.actions.root.dir-up')
   81 691.179  004.949  004.949: require('nvim-tree.actions.tree.find-file')
   82 696.790  005.544  005.544: require('nvim-tree.actions.finders.search-node')

The total startup time may reach 2 seconds without impatient plugin. Does anyone know why there are so many require functions appeared and how to reduce the time?

I don't see too many require functions when other people run --startuptime command. I am wondering if I set something wrong.

答案1

得分: 1

nvim-tree 在启动时非常占资源,但自从 neovim 0.9.0 版本以后,有一个选项可以使用新的加载器来加载 Lua 模块,尽量在你的 init.lua 中尽早使用 vim.loader.enable()

英文:

nvim-tree is really heavy on startup, but since neovim 0.9.0 there is an option to use new loader for lua try to put it in in your init.lua vim.loader.enable() as early as possible.

huangapple
  • 本文由 发表于 2023年6月2日 04:08:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76385363.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定