2018-02-22 21:15:46 +08:00
|
|
|
"=============================================================================
|
|
|
|
" init.vim --- Language && encoding in SpaceVim
|
2020-08-31 21:24:27 +08:00
|
|
|
" Copyright (c) 2016-2020 Wang Shidong & Contributors
|
2018-02-22 21:15:46 +08:00
|
|
|
" Author: Wang Shidong < wsdjeg at 163.com >
|
|
|
|
" URL: https://spacevim.org
|
|
|
|
" License: GPLv3
|
|
|
|
"=============================================================================
|
|
|
|
|
2018-02-25 22:14:26 +08:00
|
|
|
let s:SYSTEM = SpaceVim#api#import('system')
|
|
|
|
|
2016-12-26 21:11:19 +08:00
|
|
|
"Use English for anything in vim
|
2017-04-15 20:00:28 +08:00
|
|
|
try
|
2018-02-25 22:14:26 +08:00
|
|
|
if s:SYSTEM.isWindows
|
2018-02-22 21:15:46 +08:00
|
|
|
silent exec 'lan mes en_US.UTF-8'
|
2018-02-25 22:14:26 +08:00
|
|
|
elseif s:SYSTEM.isOSX
|
2019-01-23 05:27:56 +08:00
|
|
|
silent exec 'language en_US.UTF-8'
|
2018-02-22 21:15:46 +08:00
|
|
|
else
|
|
|
|
let s:uname = system('uname -s')
|
|
|
|
if s:uname ==# "Darwin\n"
|
|
|
|
" in mac-terminal
|
2019-01-23 05:27:56 +08:00
|
|
|
silent exec 'language en_US.UTF-8'
|
2018-02-22 21:15:46 +08:00
|
|
|
elseif s:uname ==# "SunOS\n"
|
|
|
|
" in Sun-OS terminal
|
|
|
|
silent exec 'lan en_US.UTF-8'
|
2018-03-21 18:25:59 +08:00
|
|
|
elseif s:uname ==# "FreeBSD\n"
|
|
|
|
" in FreeBSD terminal
|
|
|
|
silent exec 'lan en_US.UTF-8'
|
2016-12-26 21:11:19 +08:00
|
|
|
else
|
2018-02-22 21:15:46 +08:00
|
|
|
" in linux-terminal
|
2018-05-11 19:25:50 +08:00
|
|
|
silent exec 'lan en_US.UTF-8'
|
2016-12-26 21:11:19 +08:00
|
|
|
endif
|
2018-02-22 21:15:46 +08:00
|
|
|
endif
|
2017-04-15 20:00:28 +08:00
|
|
|
catch /^Vim\%((\a\+)\)\=:E197/
|
2018-02-22 21:15:46 +08:00
|
|
|
call SpaceVim#logger#error('Can not set language to en_US.utf8')
|
2017-04-15 20:00:28 +08:00
|
|
|
endtry
|
2016-12-26 21:11:19 +08:00
|
|
|
|
|
|
|
" try to set encoding to utf-8
|
2018-02-25 22:14:26 +08:00
|
|
|
if s:SYSTEM.isWindows
|
2018-02-22 21:15:46 +08:00
|
|
|
" Be nice and check for multi_byte even if the config requires
|
|
|
|
" multi_byte support most of the time
|
|
|
|
if has('multi_byte')
|
|
|
|
" Windows cmd.exe still uses cp850. If Windows ever moved to
|
|
|
|
" Powershell as the primary terminal, this would be utf-8
|
2020-01-19 18:35:50 +08:00
|
|
|
if exists('&termencoding') && !has('nvim')
|
|
|
|
set termencoding=cp850
|
|
|
|
endif
|
2018-02-22 21:15:46 +08:00
|
|
|
setglobal fileencoding=utf-8
|
|
|
|
" Windows has traditionally used cp1252, so it's probably wise to
|
|
|
|
" fallback into cp1252 instead of eg. iso-8859-15.
|
|
|
|
" Newer Windows files might contain utf-8 or utf-16 LE so we might
|
|
|
|
" want to try them first.
|
2019-07-18 22:36:59 +08:00
|
|
|
set fileencodings=ucs-bom,utf-8,gbk,utf-16le,cp1252,iso-8859-15,cp936
|
2018-02-22 21:15:46 +08:00
|
|
|
endif
|
2016-12-26 21:11:19 +08:00
|
|
|
|
2018-02-22 21:15:46 +08:00
|
|
|
else
|
2020-01-19 18:35:50 +08:00
|
|
|
if exists('&termencoding') && !has('nvim')
|
|
|
|
set termencoding=utf-8
|
|
|
|
endif
|
2018-02-22 21:15:46 +08:00
|
|
|
set fileencoding=utf-8
|
|
|
|
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
|
2016-12-26 21:11:19 +08:00
|
|
|
endif
|
2018-05-10 21:39:04 +08:00
|
|
|
scriptencoding utf-8
|