Christian Brabandt | 4f174f0 | 2023-11-04 11:16:23 +0100 | [diff] [blame] | 1 | " Vim runtime support library, |
Hirohito Higashi | fbe4a8f | 2025-04-27 15:28:30 +0200 | [diff] [blame] | 2 | " runs the Vim9 script version or legacy script version |
Christian Brabandt | 4f174f0 | 2023-11-04 11:16:23 +0100 | [diff] [blame] | 3 | " on demand (mostly for Neovim compatability) |
| 4 | " |
| 5 | " Maintainer: The Vim Project <https://github.com/vim/vim> |
Hirohito Higashi | fbe4a8f | 2025-04-27 15:28:30 +0200 | [diff] [blame] | 6 | " Last Change: 2025 Apr 27 |
D. Ben Knoble | cd8a3ea | 2023-11-04 05:11:17 -0400 | [diff] [blame] | 7 | |
D. Ben Knoble | cd8a3ea | 2023-11-04 05:11:17 -0400 | [diff] [blame] | 8 | |
Christian Brabandt | 4f174f0 | 2023-11-04 11:16:23 +0100 | [diff] [blame] | 9 | " enable the zip and gzip plugin by default, if not set |
| 10 | if !exists('g:zip_exec') |
| 11 | let g:zip_exec = 1 |
| 12 | endif |
D. Ben Knoble | cd8a3ea | 2023-11-04 05:11:17 -0400 | [diff] [blame] | 13 | |
Christian Brabandt | 4f174f0 | 2023-11-04 11:16:23 +0100 | [diff] [blame] | 14 | if !exists('g:gzip_exec') |
| 15 | let g:gzip_exec = 1 |
| 16 | endif |
| 17 | |
Sean Dewar | b2a4c11 | 2023-11-05 09:11:37 +0000 | [diff] [blame] | 18 | if !has('vim9script') |
| 19 | function dist#vim#IsSafeExecutable(filetype, executable) |
Christian Brabandt | 4f174f0 | 2023-11-04 11:16:23 +0100 | [diff] [blame] | 20 | let cwd = getcwd() |
Christian Brabandt | 8e25d91 | 2024-08-17 15:52:11 +0200 | [diff] [blame] | 21 | if empty(exepath(a:executable)) |
Christian Brabandt | 8e25d91 | 2024-08-17 15:52:11 +0200 | [diff] [blame] | 22 | return v:false |
| 23 | endif |
Christian Brabandt | 4f174f0 | 2023-11-04 11:16:23 +0100 | [diff] [blame] | 24 | 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 Dewar | b2a4c11 | 2023-11-05 09:11:37 +0000 | [diff] [blame] | 28 | endfunction |
| 29 | |
| 30 | finish |
Christian Brabandt | 4f174f0 | 2023-11-04 11:16:23 +0100 | [diff] [blame] | 31 | endif |
Sean Dewar | b2a4c11 | 2023-11-05 09:11:37 +0000 | [diff] [blame] | 32 | |
| 33 | def dist#vim#IsSafeExecutable(filetype: string, executable: string): bool |
| 34 | return dist#vim9#IsSafeExecutable(filetype, executable) |
| 35 | enddef |