" MNV runtime support library,
" runs the MNV9 script version or legacy script version
" on demand (mostly for Neomnv compatibility)
"
" Maintainer:	The MNV Project <https://github.com/Project-Tick/Project-Tick>
" Last Change:	2026 Jan 11


" enable the zip and gzip plugin by default, if not set
if !exists('g:zip_exec')
  let g:zip_exec = 1
endif

if !exists('g:gzip_exec')
  let g:gzip_exec = 1
endif

if !has('mnv9script')
  function dist#mnv#IsSafeExecutable(filetype, executable)
    let cwd = getcwd()
    if empty(exepath(a:executable))
      return v:false
    endif
    return get(g:, a:filetype .. '_exec', get(g:, 'plugin_exec', 0)) &&
          \ (fnamemodify(exepath(a:executable), ':p:h') !=# cwd
          \ || (split($PATH, has('win32') ? ';' : ':')->index(cwd) != -1 &&
          \  cwd != '.'))
  endfunction

  finish
endif

def dist#mnv#IsSafeExecutable(filetype: string, executable: string): bool
  return dist#mnv9#IsSafeExecutable(filetype, executable)
enddef
