From 20f478f1a02e7a523283323040e0e335955686b8 Mon Sep 17 00:00:00 2001 From: L3MON4D3 Date: Tue, 22 Mar 2022 12:14:47 +0100 Subject: [PATCH] do fewer refresh_notifies while loading. --- lua/luasnip/loaders/from_lua.lua | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lua/luasnip/loaders/from_lua.lua b/lua/luasnip/loaders/from_lua.lua index 284b3fc8f..801dab369 100644 --- a/lua/luasnip/loaders/from_lua.lua +++ b/lua/luasnip/loaders/from_lua.lua @@ -51,16 +51,17 @@ local function load_files(ft, files) file )) - ls.add_snippets( - ft, - file_snippets, - { type = "snippets", key = "__snippets_" .. file } - ) - ls.add_snippets( - ft, - file_autosnippets, - { type = "autosnippets", key = "__autosnippets_" .. file } - ) + ls.add_snippets(ft, file_snippets, { + type = "snippets", + key = "__snippets_" .. file, + -- prevent refresh here, will be done outside loop. + refresh_notify = false, + }) + ls.add_snippets(ft, file_autosnippets, { + type = "autosnippets", + key = "__autosnippets_" .. file, + refresh_notify = false, + }) end ls.refresh_notify(ft) @@ -205,8 +206,9 @@ function M.edit_snippet_files() end) end --- register during startup so it'll work even if lazy_load is only called after --- the events for some buffers already fired. +-- register during startup (not really startup, as soon as this file is +-- required) so it'll work even if lazy_load is only called after the events +-- for some buffers already fired. vim.cmd([[ augroup _luasnip_lua_lazy_load autocmd!