diff --git a/autoload/SpaceVim.vim b/autoload/SpaceVim.vim index 659644a4a..bf3ca6a9b 100644 --- a/autoload/SpaceVim.vim +++ b/autoload/SpaceVim.vim @@ -186,6 +186,9 @@ let g:spacevim_buffer_index_type = 0 " Enable/Disable tabline filetype icon. default is 0. let g:spacevim_enable_tabline_filetype_icon = 0 "" +" Enable/Disable os fileformat icon. default is 0. +let g:spacevim_enable_os_fileformat_icon = 0 +"" " Plugin groups to be loaded. " > " let g:spacevim_plugin_groups = ['core', 'lang'] diff --git a/autoload/SpaceVim/api/system.vim b/autoload/SpaceVim/api/system.vim index ec767f308..b3388cace 100644 --- a/autoload/SpaceVim/api/system.vim +++ b/autoload/SpaceVim/api/system.vim @@ -1,3 +1,4 @@ +scriptencoding utf-8 let s:system = {} let s:system['isWindows'] = has('win16') || has('win32') || has('win64') @@ -6,6 +7,52 @@ let s:system['isLinux'] = has('unix') && !has('macunix') && !has('win32unix') let s:system['isOSX'] = has('macunix') +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) diff --git a/config/plugins/vim-airline.vim b/config/plugins/vim-airline.vim index 3b2979edd..a0c89da41 100644 --- a/config/plugins/vim-airline.vim +++ b/config/plugins/vim-airline.vim @@ -79,3 +79,7 @@ let g:airline#extensions#tabline#tab_nr_type= 2 let g:airline#extensions#tabline#show_tab_type = 1 let g:airline#extensions#tabline#buffers_label = 'BUFFERS' let g:airline#extensions#tabline#tabs_label = 'TABS' +if g:spacevim_enable_os_fileformat_icon + let s:sys = SpaceVim#api#import('system') + let g:airline_section_y = " %{&fenc . ' ' . SpaceVim#api#import('system').fileformat()} " +endif diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 286d223e2..f7145b610 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -213,6 +213,9 @@ Set SpaceVim buffer index type, default is 0. *g:spacevim_enable_tabline_filetype_icon* Enable/Disable tabline filetype icon. default is 0. + *g:spacevim_enable_os_fileformat_icon* +Enable/Disable os fileformat icon. default is 0. + *g:spacevim_plugin_groups* Plugin groups to be loaded. >