Closed9
Neovim + Packerの起動速度チューニング
チューニング前の起動速度(プラグイン数は73個)
起動速度はvim-startuptimeにて計測
Total Average: 1105.211500 msec
Total Max: 1132.987000 msec
Total Min: 1085.796000 msec
計測結果(大体50ms以上のものだけ)
Extra options: []
Measured: 10 times
Total Average: 1105.211500 msec
Total Max: 1132.987000 msec
Total Min: 1085.796000 msec
AVERAGE MAX MIN
---------------------------------
851.268200 880.493000 837.394000: C:\Users\wagomu\AppData\Local\nvim\plugin\packer_compiled.lua
193.754500 213.645000 187.914000: require('pluginconfig/telescope')
135.137400 143.121000 131.679000: require('pluginconfig/nvim-tree')
122.469000 130.002000 119.332000: require('nvim-tree')
91.007000 95.562000 88.870000: require('nvim-tree.lib')
81.349500 85.430000 78.979000: require('nvim-tree.renderer')
81.244200 101.627000 77.087000: require('telescope.previewers')
66.556600 69.674000 64.422000: require('nvim-tree.core')
65.199100 67.562000 64.313000: require('pluginconfig/gitsigns')
65.155700 67.307000 63.612000: require('pluginconfig/neogit')
64.700400 66.786000 63.170000: require('neogit')
61.520000 77.159000 58.186000: require('telescope.previewers.buffer_previewer')
53.886400 56.312000 52.674000: require('pluginconfig/nvim-cmp')
53.876800 57.186000 52.750000: require('telescope.builtin')
52.685100 55.212000 51.268000: require('cmp')
51.797900 55.122000 50.722000: require('telescope.builtin.__lsp')
51.622800 52.403000 50.923000: C:\Users\wagomu\AppData\Local\nvim-data\site\pack\packer\start\LuaSnip\plugin\luasnip.vim
51.077000 51.856000 50.392000: require('luasnip.config')
50.569500 52.693000 49.505000: require('telescope.actions')
48.189700 50.306000 46.901000: require('cmp.core')
43.725000 47.517000 42.150000: require('pluginconfig/lualine')
導入しているプラグイン
• Comment.nvim
• LuaSnip
• alpha-nvim
• cmp-buffer
• cmp-calc
• cmp-cmdline
• cmp-git
• cmp-mocword
• cmp-nvim-lsp
• cmp-nvim-lsp-document-symbol
• cmp-nvim-lsp-signature-help
• cmp-path
• cmp-spell
• cmp_luasnip
• denops-translate.vim
• denops.vim
• diffview.nvim
• emmet-vim
• fidget.nvim
• filetype.nvim
• fuzzy-motion.vim
• gitsigns.nvim
• iceberg.vim
• impatient.nvim
• indent-blankline.nvim
• lexima.vim
• lir-git-status.nvim
• lir.nvim
• lsp-colors.nvim
• lsp_lines.nvim
• lsp_signature.nvim
• lspkind.nvim
• lspsaga.nvim
• lualine.nvim
• mason-lspconfig.nvim
• mason.nvim
• modes.nvim
• neogit
• nui.nvim
• null-ls.nvim
• nvim-autopairs
• nvim-cmp
• nvim-lspconfig
• nvim-navic
• nvim-notify
• nvim-scrollbar
• nvim-surround
• nvim-tree.lua
• nvim-treesitter
• nvim-ufo
• nvim-web-devicons
• packer.nvim
• pgmnt.vim
• plenary.nvim
• pretty-fold.nvim
• promise-async
• telescope-changes.nvim
• telescope-github.nvim
• telescope-heading.nvim
• telescope-rg.nvim
• telescope-smart-history.nvim
• telescope-symbols.nvim
• telescope-ui-select.nvim
• telescope.nvim
• tint.nvim
• toggleterm.nvim
• trouble.nvim
• vim-edgemotion
• vim-goimports
• vim-sandwich
• vim-sonictemplate
• vimdoc-ja
• which-key.nvim
• winbar.nvim
• winresizer
こちらの記事を参考にimpatient.nvimを導入した。
追記内容は下記
plugins.lua
use {
"lewis6991/impatient.nvim",
config = function()
require('impatient')
require('impatient').enable_profile()
end
}
結果は165msほど短縮された。
Total Average: 940.221500 msec
Total Max: 991.177000 msec
Total Min: 925.551000 msec
計測結果(大体50ms以上のものだけ)
Total Average: 940.221500 msec
Total Max: 991.177000 msec
Total Min: 925.551000 msec
AVERAGE MAX MIN
---------------------------------
766.749000 818.057000 753.931000: C:\Users\wagomu\AppData\Local\nvim\plugin\packer_compiled.lua
159.800300 181.666000 154.480000: require('pluginconfig/telescope')
143.685000 151.662000 140.344000: require('pluginconfig/nvim-tree')
127.633200 135.490000 124.171000: require('nvim-tree')
95.025500 100.691000 92.488000: require('nvim-tree.lib')
92.859400 97.987000 90.079000: require('pluginconfig/neogit')
92.399000 97.644000 89.641000: require('neogit')
84.969400 90.720000 82.573000: require('nvim-tree.renderer')
69.281600 74.816000 67.476000: require('nvim-tree.core')
66.502100 68.721000 65.168000: require('pluginconfig/gitsigns')
60.619000 65.239000 58.068000: require('telescope.previewers')
55.888600 59.054000 54.335000: require('neogit.lib')
51.215700 64.807000 48.837000: require('telescope.actions')
46.691600 47.670000 45.819000: require('pluginconfig/lualine')
さきほどの記事を参考にfiletype.nvimも導入する。
追記内容は下記。
とりあえず上記リンクのexpampleをそのままコピペする
plugins.lua
use {
"nathom/filetype.nvim",
config = function()
-- In init.lua or filetype.nvim's config file
require("filetype").setup({
overrides = {
extensions = {
-- Set the filetype of *.pn files to potion
pn = "potion",
},
literal = {
-- Set the filetype of files named "MyBackupFile" to lua
MyBackupFile = "lua",
},
complex = {
-- Set the filetype of any full filename matching the regex to gitconfig
[".*git/config"] = "gitconfig", -- Included in the plugin
},
-- The same as the ones above except the keys map to functions
function_extensions = {
["cpp"] = function()
vim.bo.filetype = "cpp"
-- Remove annoying indent jumping
vim.bo.cinoptions = vim.bo.cinoptions .. "L0"
end,
["pdf"] = function()
vim.bo.filetype = "pdf"
-- Open in PDF viewer (Skim.app) automatically
vim.fn.jobstart(
"open -a skim " .. '"' .. vim.fn.expand("%") .. '"'
)
end,
},
function_literal = {
Brewfile = function()
vim.cmd("syntax off")
end,
},
function_complex = {
["*.math_notes/%w+"] = function()
vim.cmd("iabbrev $ $$")
end,
},
shebang = {
-- Set the filetype of files with a dash shebang to sh
dash = "sh",
},
},
})
end
結果は更に173msほど短縮された。
が、正直まだ相当遅い。。。。
Total Average: 767.567300 msec
Total Max: 794.601000 msec
Total Min: 751.828000 msec
計測結果(大体50ms以上のものだけ)
Total Average: 767.567300 msec
Total Max: 794.601000 msec
Total Min: 751.828000 msec
AVERAGE MAX MIN
---------------------------------
593.365900 620.574000 580.371000: C:\Users\wagomu\AppData\Local\nvim\plugin\packer_compiled.lua
141.375000 147.213000 138.547000: require('pluginconfig/nvim-tree')
125.449700 130.881000 122.935000: require('nvim-tree')
92.737900 96.914000 90.809000: require('nvim-tree.lib')
82.612000 86.046000 81.000000: require('nvim-tree.renderer')
67.294000 70.187000 66.008000: require('nvim-tree.core')
46.347300 50.243000 45.116000: require('pluginconfig/lir')
44.170400 51.093000 42.734000: require('pluginconfig/lualine')
40.324100 42.063000 39.218000: require('pluginconfig/telescope')
遅延読み込みをしたら相当早くなったので仕事終わってから続き書きます
今日起動すると、
遅くなっていた
Extra options: []
Measured: 50 times
Total Average: 1070.775720 msec
Total Max: 1119.974000 msec
Total Min: 1055.967000 msec
デフォルトプラグインを無効化する。
init.lua
local vim = vim
vim.g.loaded_gzip = 1
vim.g.loaded_tar = 1
vim.g.loaded_tarPlugin = 1
vim.g.loaded_zip = 1
vim.g.loaded_zipPlugin = 1
vim.g.loaded_rrhelper = 1
vim.g.loaded_2html_plugin = 1
vim.g.loaded_vimball = 1
vim.g.loaded_vimballPlugin = 1
vim.g.loaded_getscript = 1
vim.g.loaded_getscriptPlugin = 1
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.g.loaded_netrwSettings = 1
vim.g.loaded_netrwFileHandlers = 1
結果変わらず
Extra options: []
Measured: 50 times
Total Average: 1072.374100 msec
Total Max: 1147.336000 msec
Total Min: 1050.504000 msec
使っていないプラグインの削除
・mvllow/modes.nvim
・kyazdani42/nvim-tree.lua
・machakann/vim-sandwich
を削除
ここにきてえらく早くなった。
Extra options: []
Measured: 50 times
Total Average: 486.727440 msec
Total Max: 536.441000 msec
Total Min: 476.950000 msec
以下略
Extra options: []
Measured: 50 times
Total Average: 486.727440 msec
Total Max: 536.441000 msec
Total Min: 476.950000 msec
AVERAGE MAX MIN
---------------------------------
325.446940 357.614000 318.226000: C:\Users\to6wa\AppData\Local\nvim\plugin\packer_compiled.lua
106.443500 122.770000 103.101000: require('pluginconfig/neogit')
93.090840 103.996000 90.036000: require('neogit')
56.425280 65.400000 54.310000: require('neogit.lib')
46.423940 50.526000 44.298000: require('pluginconfig/telescope')
43.819160 51.959000 42.053000: require('neogit.lib.git')
43.508600 47.296000 42.089000: require('pluginconfig/lualine')
37.165420 41.163000 35.736000: require('telescope.previewers')
31.445120 37.972000 30.175000: require('neogit.lib.git.cli')
コマンドから実行するプラグインを遅延読み込みさせる。
・TimUntersberger/neogit
・sindrets/diffview.nvim
plugins.lua
@@ -239,6 +232,7 @@ return require("packer").startup({ function(use)
config = function()
require("pluginconfig/neogit")
end,
+ cmd = { "Neogit" }
}
use {
@@ -248,7 +242,16 @@ return require("packer").startup({ function(use)
},
config = function()
require("pluginconfig/diffview")
end
end,
+ cmd = {
+ "DiffviewLog",
+ "DiffviewOpen",
+ "DiffviewClose",
+ "DiffviewRefresh",
+ "DiffviewFocusFiles",
+ "DiffviewToggleFiles",
+ "DiffviewFileHistory",
+ },
ちょっと遅くなった?なんで??
Extra options: []
Measured: 50 times
Total Average: 544.263220 msec
Total Max: 598.992000 msec
Total Min: 520.876000 msec
読み込み遅いプラグインに片っ端からevent = { "VimEnter" }
を付ける。
はい。爆速です。
Extra options: []
Measured: 50 times
Total Average: 107.587780 msec
Total Max: 119.844000 msec
Total Min: 104.629000 msec
以下略
Extra options: []
Measured: 50 times
Total Average: 107.587780 msec
Total Max: 119.844000 msec
Total Min: 104.629000 msec
AVERAGE MAX MIN
------------------------------
44.808180 53.081000 43.136000: C:\Users\wagomu\AppData\Local\nvim\plugin\packer_compiled.lua
14.299060 15.618000 13.618000: C:\Users\wagomu\AppData\Local\nvim\init.lua
11.767160 12.820000 11.296000: require('plugins')
9.926100 11.586000 9.651000: locale set
9.077820 11.842000 8.407000: require('impatient')
9.051680 12.437000 8.670000: loading rtp plugins
8.299680 18.588000 0.015000: C:\Users\wagomu\AppData\Local\nvim-data\site\pack\packer\start\denops.vim\plugin\denops.vim
7.344660 8.118000 7.128000: loading packages
7.136700 8.655000 6.845000: require('pluginconfig/iceberg')
5.281580 6.377000 5.017000: require('packer')
4.489680 4.859000 4.360000: sourcing vimrc file(s)
4.391560 4.792000 4.213000: loading after plugins
3.773000 4.411000 3.410000: reading ShaDa
3.012740 3.312000 2.937000: require('packer.plugin_utils')
2.030560 2.360000 1.949000: C:\Program Files\Neovim\share\nvim\runtime\plugin\matchit.vim
1.971300 2.172000 1.882000: C:\Users\wagomu\AppData\Local\nvim-data\site\pack\packer\opt\iceberg.vim\colors\iceberg.vim
1.802840 2.244000 1.694000: require('options')
1.800700 2.343000 1.540000: require('vim.lsp')
1.475300 1.886000 1.362000: C:\Program Files\Neovim\share\nvim\runtime\syntax\syntax.vim
1.437940 1.545000 1.402000: require('packer.jobs')
1.112240 1.365000 1.072000: require('vim._init_packages')
0.865600 1.075000 0.708000: require('pluginconfig/lspkind')
0.850680 1.087000 0.772000: require('packer.log')
0.834400 1.302000 0.670000: require('vim.lsp.handlers')
0.772640 0.890000 0.747000: require('packer.snapshot')
0.766660 0.898000 0.734000: require('packer.util')
0.736320 0.995000 0.707000: require('vim._editor')
0.719680 0.880000 0.693000: require('packer.async')
0.675620 0.791000 0.654000: require('packer.result')
0.645700 0.847000 0.624000: init highlight
0.625440 1.020000 0.483000: require('mapping')
0.597660 0.627000 0.549000: inits 1
0.577960 0.707000 0.519000: init lua interpreter
0.521940 0.686000 0.502000: C:\Program Files\Neovim\share\nvim\runtime\pack\dist\opt\matchit\plugin\matchit.vim
0.521940 0.718000 0.390000: require('vim.lsp.protocol')
0.485480 0.817000 0.364000: require('vim.lsp.util')
0.447800 0.554000 0.426000: C:\Program Files\Neovim\share\nvim\runtime\plugin\rplugin.vim
0.422100 0.572000 0.402000: C:\Users\wagomu\AppData\Local\nvim-data\site\pack\packer\start\vim-sonictemplate\plugin\sonictemplate.vim
0.422060 0.615000 0.354000: require('pluginconfig/alpha-nvim')
0.361360 0.485000 0.328000: require('vim._meta')
0.277160 0.466000 0.247000: require('vim.shared')
0.276800 0.543000 0.214000: require('fidget')
0.249160 0.268000 0.242000: C:\Program Files\Neovim\share\nvim\runtime\plugin\matchparen.vim
0.206100 0.363000 0.160000: require('vim.lsp.log')
0.191520 0.259000 0.145000: require('pluginconfig/fuzzy-motion')
0.175620 0.286000 0.126000: require('vim.lsp.rpc')
0.167080 0.220000 0.156000: init default mappings
0.166900 0.224000 0.153000: C:\Users\wagomu\AppData\Local\nvim-data\site\pack\packer\start\nvim-lspconfig\plugin\lspconfig.lua
0.162300 0.238000 0.145000: require('pluginconfig/nvim-lspconfig')
0.147600 0.190000 0.138000: C:\Users\wagomu\AppData\Local\nvim-data\site\pack\packer\opt\fuzzy-motion.vim\plugin\fuzzy_motion.vim
0.145480 0.280000 0.107000: require('vim.lsp._snippet')
0.137000 0.226000 0.097000: require('fidget.log')
0.131680 0.255000 0.098000: require('alpha')
0.130840 0.329000 0.103000: require('vim.lsp.buf')
0.129620 0.241000 0.086000: require('vim.highlight')
0.129580 0.196000 0.116000: C:\Program Files\Neovim\share\nvim\runtime\syntax\synload.vim
0.127560 0.286000 0.079000: require('vim.lsp.diagnostic')
0.124160 0.170000 0.099000: C:\Users\wagomu\AppData\Local\nvim-data\site\pack\packer\start\denops.vim\autoload\denops.vim
0.124100 0.244000 0.107000: require('impatient.profile')
0.123240 0.209000 0.095000: require('filetype')
0.120740 0.214000 0.111000: C:\Users\wagomu\AppData\Local\nvim-data\site\pack\packer\start\plenary.nvim\plugin\plenary.vim
0.120520 0.189000 0.106000: require('fidget.spinners')
0.117900 0.167000 0.109000: C:\Program Files\Neovim\share\nvim\runtime\plugin\shada.vim
0.114560 0.269000 0.078000: require('vim.lsp.codelens')
0.105260 0.218000 0.077000: require('vim.lsp.sync')
0.102540 0.164000 0.086000: require('alpha.themes.dashboard')
0.101700 0.131000 0.085000: early init
0.096960 0.212000 0.082000: require('lspkind')
0.090760 0.131000 0.087000: C:\Program Files\Neovim\share\nvim\runtime\plugin\man.vim
0.079400 0.181000 0.071000: C:\Program Files\Neovim\share\nvim\runtime\ftplugin.vim
0.077300 0.117000 0.071000: C:\Program Files\Neovim\share\nvim\runtime\filetype.lua
0.069880 0.103000 0.059000: event init
0.069880 0.088000 0.063000: opening buffers
0.066720 0.091000 0.059000: expanding arguments
0.063540 0.114000 0.054000: C:\Program Files\Neovim\share\nvim\runtime\plugin\man.lua
0.059820 0.089000 0.056000: C:\Users\wagomu\AppData\Local\nvim-data\site\pack\packer\start\nvim-web-devicons\plugin\nvim-web-devicons.vim
0.054160 0.059000 0.051000: C:\Program Files\Neovim\share\nvim\runtime\indent.vim
0.050020 0.106000 0.046000: C:\Program Files\Neovim\share\nvim\runtime\plugin\tutor.vim
0.049360 0.119000 0.042000: require('vim.keymap')
0.048820 0.062000 0.046000: C:\Program Files\Neovim\share\nvim\runtime\plugin\spellfile.vim
0.047880 0.085000 0.028000: C:\Users\wagomu\AppData\Local\nvim-data\site\pack\packer\start\pgmnt.vim\plugin\pgmnt.vim
0.046680 0.061000 0.034000: init first window
0.046540 0.157000 0.039000: C:\Users\wagomu\AppData\Local\nvim-data\site\pack\packer\start\filetype.nvim\filetype.vim
0.045040 0.053000 0.043000: inits 3
0.043610 0.088000 0.019000: C:\Users\wagomu\AppData\Local\nvim-data\site\pack\packer\start\denops.vim\plugin\denops\debug.vim
0.039180 0.258000 0.033000: C:\Program Files\Neovim\share\nvim\runtime\plugin\zipPlugin.vim
0.036860 0.053000 0.031000: inits 2
0.032060 0.036000 0.031000: C:\Program Files\Neovim\share\nvim\runtime\plugin\netrwPlugin.vim
0.031040 0.048000 0.028000: C:\Program Files\Neovim\share\nvim\runtime\plugin\health.vim
0.030140 0.034000 0.029000: C:\Program Files\Neovim\share\nvim\runtime\plugin\tarPlugin.vim
0.029320 0.084000 0.025000: C:\Program Files\Neovim\share\nvim\runtime\plugin\gzip.vim
0.026180 0.038000 0.023000: require('vim.F')
0.026100 0.031000 0.025000: C:\Program Files\Neovim\share\nvim\runtime\plugin\tohtml.vim
0.025380 0.030000 0.022000: window checked
0.025300 0.088000 0.022000: C:\Users\wagomu\AppData\Local\nvim-data/rplugin.vim
0.022680 0.049000 0.019000: C:\Program Files\Neovim\share\nvim\runtime\filetype.vim
0.014920 0.020000 0.010000: --- NVIM STARTING ---
0.014440 0.020000 0.012000: init default autocommands
0.013860 0.024000 0.011000: clearing screen
0.010600 0.071000 0.009000: parsing arguments
0.004160 0.005000 0.004000: editing files in windows
0.004060 0.005000 0.004000: BufEnter autocommands
このスクラップは2023/11/07にクローズされました