blob: 1632aed2b6082ab3e5acef62f866f47ca5f19769 [file] [log] [blame]
Christian Brabandt4f174f02023-11-04 11:16:23 +01001" Vim runtime support library,
Hirohito Higashifbe4a8f2025-04-27 15:28:30 +02002" runs the Vim9 script version or legacy script version
Christian Brabandt4f174f02023-11-04 11:16:23 +01003" on demand (mostly for Neovim compatability)
4"
5" Maintainer: The Vim Project <https://github.com/vim/vim>
Hirohito Higashifbe4a8f2025-04-27 15:28:30 +02006" Last Change: 2025 Apr 27
D. Ben Knoblecd8a3ea2023-11-04 05:11:17 -04007
D. Ben Knoblecd8a3ea2023-11-04 05:11:17 -04008
Christian Brabandt4f174f02023-11-04 11:16:23 +01009" enable the zip and gzip plugin by default, if not set
10if !exists('g:zip_exec')
11 let g:zip_exec = 1
12endif
D. Ben Knoblecd8a3ea2023-11-04 05:11:17 -040013
Christian Brabandt4f174f02023-11-04 11:16:23 +010014if !exists('g:gzip_exec')
15 let g:gzip_exec = 1
16endif
17
Sean Dewarb2a4c112023-11-05 09:11:37 +000018if !has('vim9script')
19 function dist#vim#IsSafeExecutable(filetype, executable)
Christian Brabandt4f174f02023-11-04 11:16:23 +010020 let cwd = getcwd()
Christian Brabandt8e25d912024-08-17 15:52:11 +020021 if empty(exepath(a:executable))
Christian Brabandt8e25d912024-08-17 15:52:11 +020022 return v:false
23 endif
Christian Brabandt4f174f02023-11-04 11:16:23 +010024 return get(g:, a:filetype .. '_exec', get(g:, 'plugin_exec', 0)) &&
25 \ (fnamemodify(exepath(a:executable), ':p:h') !=# cwd
26 \ || (split($PATH, has('win32') ? ';' : ':')->index(cwd) != -1 &&
27 \ cwd != '.'))
Sean Dewarb2a4c112023-11-05 09:11:37 +000028 endfunction
29
30 finish
Christian Brabandt4f174f02023-11-04 11:16:23 +010031endif
Sean Dewarb2a4c112023-11-05 09:11:37 +000032
33def dist#vim#IsSafeExecutable(filetype: string, executable: string): bool
34 return dist#vim9#IsSafeExecutable(filetype, executable)
35enddef