1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-22 00:35:42 +08:00
2023-03-26 13:44:47 +08:00

96 lines
1.9 KiB
VimL

"=============================================================================
" system.vim --- SpaceVim system API
" Copyright (c) 2016-2023 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
""
" @section system, api-system
" @parentsection api
" name()
"
" Return the name of current os, availibel value is: linux, cygwin, windows
" and mac.
scriptencoding utf-8
let s:system = {}
let s:system['isWindows'] = has('win16') || has('win32') || has('win64')
let s:system['isLinux'] = has('unix') && !has('macunix') && !has('win32unix')
let s:system['isOSX'] = has('macunix')
" windows, unix, cygwin, mac, linux
function! s:name() abort
if s:system.isLinux
return 'linux'
elseif s:system.isWindows
if has('win32unix')
return 'cygwin'
else
return 'windows'
endif
else
return 'mac'
endif
endfunction
let s:system['name'] = function('s:name')
function! s:isDarwin() abort
if exists('s:is_darwin')
return s:is_darwin
endif
if has('macunix')
let s:is_darwin = 1
return s:is_darwin
endif
if ! has('unix')
let s:is_darwin = 0
return s:is_darwin
endif
if system('uname -s') ==# "Darwin\n"
let s:is_darwin = 1
else
let s:is_darwin = 0
endif
return s:is_darwin
endfunction
let s:system['isDarwin'] = function('s:isDarwin')
function! s:fileformat() abort
let fileformat = ''
if &fileformat ==? 'dos'
let fileformat = ''
elseif &fileformat ==? 'unix'
if s:isDarwin()
let fileformat = ''
else
let fileformat = ''
endif
elseif &fileformat ==? 'mac'
let fileformat = ''
endif
return fileformat
endfunction
let s:system['fileformat'] = function('s:fileformat')
function! SpaceVim#api#system#get() abort
return deepcopy(s:system)
endfunction
" vim:set et sw=2: