Skip to content

Commit a2559e1

Browse files
smancilllpil
authored andcommitted
Do not call external processes during plugin initialization
Having the plugin initialization calling Git commands increases the startup time by orders of magnitude. The plugin was very fast before (output of --startuptime): 000.047 000.047: sourcing .../vim-snippets/plugin/vimsnippets.vim And this is the result of adding those external Git command calls: 039.083 039.083: sourcing .../vim-snippets/plugin/vimsnippets.vim It could be argued that it is still fast, but a lot of users care about Vim startup time and those 40 ms in this case are too much, and others have reported worst. In my case, it is taking a fifth of the total startup time now with almost 50 plugins, and it takes more than 2.5x longer than any other. Specially when the plugin initialization was barely noticed originally. Having `system()` calls on a `<rtp>/plugin/*.vim` file is just bad for the users, when a plugin should try to load as fast as possible, lazy-loading as much as possible. This commit reverts `plugin/vimsnippets.vim` to the state it was before PR honza#1252, effectively reverting the PR and all the subsequent commits trying to fix it: - 730443a (trim() not exist in old version of Vim., 2020-09-26) - a044188 (Remove command, 2020-09-25) - db91ad4 (Update logic using honza#1257, 2020-09-25) - 06fbadd (Speed up the startup time, 2020-09-24) - 5b5cc36 (Correct syntax, 2020-09-23) - d4c285e (Set author, email and GitHub address automatically from git config., 2020-09-19) The variables `g:snips_author` and `g:snips_author_email` are not really widely used to justify having them set automatically from Git at the cost of increasing the startup time (the workaround for this was having to op-out of it by defining them in the .vimrc, but that's still not ideal compared to the opt-in behaviour restored by this commit). Also, they have been in use with empty/dummy default values since the initial commit almost 10 years ago, without being an inconvenience to users. Fixes honza#1267.
1 parent 87dbbc6 commit a2559e1

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

plugin/vimsnippets.vim

+3-24
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,18 @@ endif
44
let b:done_vimsnippets = 1
55

66
" Some variables need default value
7-
let s:has_git = executable('git')
8-
97
if !exists("g:snips_author")
10-
if s:has_git
11-
let s:author = substitute(system('git config --global user.name'), '\n', '', 'g')
12-
if s:author == ''
13-
let g:snips_author = "yourname"
14-
else
15-
let g:snips_author = s:author
16-
endif
17-
else
18-
let g:snips_author = "yourname"
19-
endif
8+
let g:snips_author = "yourname"
209
endif
2110

2211
if !exists("g:snips_email")
23-
if s:has_git
24-
let s:email = substitute(system('git config --global user.email'), '\n', '', 'g')
25-
if s:email == ''
26-
let g:snips_email = "[email protected]"
27-
else
28-
let g:snips_email = s:email
29-
endif
30-
else
31-
let g:snips_email = "[email protected]"
32-
endif
12+
let g:snips_email = "[email protected]"
3313
endif
3414

3515
if !exists("g:snips_github")
36-
let g:snips_github = "https://github.com/" . g:snips_author
16+
let g:snips_github = "https://github.com/yourname"
3717
endif
3818

39-
4019
" Expanding the path is not needed on Vim 7.4
4120
if &cp || version >= 704
4221
finish

0 commit comments

Comments
 (0)