1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 05:20:04 +08:00

Merge pull request #1438 from wsdjeg/default

Better default
This commit is contained in:
Wang Shidong 2018-02-25 22:46:36 +08:00 committed by GitHub
commit 43f7914364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 730 additions and 505 deletions

View File

@ -104,11 +104,15 @@ The easist way is to download [install.cmd](https://spacevim.org/install.cmd) an
### Project layout
```txt
├─ autoload/SpaceVim/api/ APIs
├─ autoload/SpaceVim/layers/ layers
├─ autoload/SpaceVim/plugins/ plugins
├─ .ci/ build automation
├─ .github/ issue/PR templates
├─ .SpaceVim.d/ project specific configuration
├─ autoload/SpaceVim.vim SpaceVim core file
├─ autoload/SpaceVim/api/ Public APIs
├─ autoload/SpaceVim/layers/ available layers
├─ autoload/SpaceVim/plugins/ buildin plugins
├─ autoload/SpaceVim/mapping/ mapping guide
├─ doc/SpaceVim.txt help
├─ doc/ help(cn/en)
├─ docs/ website(cn/en)
├─ wiki/ wiki(cn/en)
├─ bin/ executeable

View File

@ -24,11 +24,14 @@
" settings in `.SpaceVim.d/init.vim` in the root directory of your project.
" `.SpaceVim.d/` will also be added to runtimepath.
" Public SpaceVim Options {{{
scriptencoding utf-8
""
" Version of SpaceVim , this value can not be changed.
scriptencoding utf-8
let g:spacevim_version = '0.7.0-dev'
lockvar g:spacevim_version
""
" Change the default indentation of SpaceVim. Default is 2.
" >
@ -480,9 +483,12 @@ let g:spacevim_wildignore
\ = '*/tmp/*,*.so,*.swp,*.zip,*.class,tags,*.jpg,
\*.ttf,*.TTF,*.png,*/target/*,
\.git,.svn,.hg,.DS_Store,*.svg'
" privite options
" }}}
" Privite SpaceVim options
let g:_spacevim_mappings = {}
" TODO merge leader guide
let g:_spacevim_mappings_space_custom = []
let g:_spacevim_mappings_space_custom_group_name = []
@ -597,6 +603,8 @@ endfunction
function! SpaceVim#end() abort
call SpaceVim#server#connect()
if g:spacevim_enable_neocomplcache
let g:spacevim_autocomplete_method = 'neocomplcache'
endif
@ -649,8 +657,12 @@ function! SpaceVim#end() abort
endif
""
" generate tags for SpaceVim
let help = fnamemodify(g:Config_Main_Home, ':p:h:h') . '/doc'
exe 'helptags ' . help
let help = fnamemodify(g:_spacevim_root_dir, ':p:h:h') . '/doc'
try
exe 'helptags ' . help
catch
call SpaceVim#logger#warn('Failed to generate helptags for SpaceVim')
endtry
""
" set language
@ -664,6 +676,8 @@ function! SpaceVim#end() abort
if !g:spacevim_relativenumber
set norelativenumber
else
set relativenumber
endif
let &shiftwidth = g:spacevim_default_indent
@ -674,20 +688,65 @@ function! SpaceVim#end() abort
endif
let g:leaderGuide_max_size = 15
call SpaceVim#plugins#load()
call SpaceVim#plugins#projectmanager#RootchandgeCallback()
call zvim#util#source_rc('general.vim')
call SpaceVim#autocmds#init()
if has('nvim')
call zvim#util#source_rc('neovim.vim')
endif
call zvim#util#source_rc('commands.vim')
filetype plugin indent on
syntax on
endfunction
function! SpaceVim#default() abort
call SpaceVim#default#SetOptions()
call SpaceVim#default#SetPlugins()
call SpaceVim#default#SetMappings()
function! SpaceVim#begin() abort
call zvim#util#source_rc('functions.vim')
call zvim#util#source_rc('init.vim')
" Before loading SpaceVim, We need to parser argvs.
function! s:parser_argv() abort
if !argc()
return [1, getcwd()]
elseif argv(0) =~# '/$'
let f = expand(argv(0))
if isdirectory(f)
return [1, f]
else
return [1, getcwd()]
endif
elseif argv(0) ==# '.'
return [1, getcwd()]
elseif isdirectory(expand(argv(0)))
return [1, expand(argv(0)) ]
else
return [0]
endif
endfunction
let s:status = s:parser_argv()
" If do not start Vim with filename, Define autocmd for opening welcome page
if s:status[0]
let g:_spacevim_enter_dir = s:status[1]
augroup SPwelcome
au!
autocmd VimEnter * call SpaceVim#welcome()
augroup END
endif
call SpaceVim#default#options()
call SpaceVim#default#layers()
call SpaceVim#default#keyBindings()
call SpaceVim#commands#load()
endfunction
function! SpaceVim#defindFuncs() abort
endfunction
function! SpaceVim#welcome() abort
if get(g:, '_spacevim_session_loaded', 0) == 1
return

View File

@ -8,7 +8,7 @@
let s:self = {}
let s:completer = fnamemodify(g:Config_Main_Home, ':p:h:h') . '/autoload/SpaceVim/bin/get_complete'
let s:completer = fnamemodify(g:_spacevim_root_dir, ':p:h:h') . '/autoload/SpaceVim/bin/get_complete'
let s:COP = SpaceVim#api#import('vim#compatible')

View File

@ -12,6 +12,7 @@ function! SpaceVim#api#data#list#get() abort
\ 'unshift' : '',
\ 'uniq' : '',
\ 'uniq_by' : '',
\ 'uniq_by_func' : '',
\ 'clear' : '',
\ 'char_range' : '',
\ 'has' : '',
@ -71,6 +72,22 @@ function! s:uniq(list) abort
return s:uniq_by(a:list, 'v:val')
endfunction
function! s:uniq_by_func(list, func) abort
let list = map(copy(a:list), '[v:val, call(a:func, [v:val])]')
let i = 0
let seen = {}
while i < len(list)
let key = string(list[i][1])
if has_key(seen, key)
call remove(list, i)
else
let seen[key] = 1
let i += 1
endif
endwhile
return map(list, 'v:val[0]')
endfunction
function! s:uniq_by(list, f) abort
let list = map(copy(a:list), printf('[v:val, %s]', a:f))
let i = 0

View File

@ -40,14 +40,14 @@ endfunction
function! s:awesome_mode() abort
let sep = SpaceVim#api#import('file').separator
let f = fnamemodify(g:Config_Main_Home, ':h') . join(['', 'mode', 'dark_powered.vim'], sep)
let f = fnamemodify(g:_spacevim_root_dir, ':h') . join(['', 'mode', 'dark_powered.vim'], sep)
let config = readfile(f, '')
call s:write_to_config(config)
endfunction
function! s:basic_mode() abort
let sep = SpaceVim#api#import('file').separator
let f = fnamemodify(g:Config_Main_Home, ':h') . join(['', 'mode', 'basic.vim'], sep)
let f = fnamemodify(g:_spacevim_root_dir, ':h') . join(['', 'mode', 'basic.vim'], sep)
let config = readfile(f, '')
call s:write_to_config(config)
endfunction

View File

@ -7,7 +7,10 @@
"=============================================================================
scriptencoding utf-8
function! SpaceVim#default#SetOptions() abort
let s:SYSTEM = SpaceVim#api#import('system')
" Default options {{{
function! SpaceVim#default#options() abort
" basic vim settiing
if has('gui_running')
set guioptions-=m " Hide menu bar.
@ -17,10 +20,10 @@ function! SpaceVim#default#SetOptions() abort
set guioptions-=b " Hide bottom scrollbar
set showtabline=0 " Hide tabline
set guioptions-=e " Hide tab
if WINDOWS()
if s:SYSTEM.isWindows
" please install the font in 'Dotfiles\font'
set guifont=DejaVu_Sans_Mono_for_Powerline:h11:cANSI:qDRAFT
elseif OSX()
elseif s:SYSTEM.isOSX
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h11
else
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 11
@ -31,14 +34,12 @@ function! SpaceVim#default#SetOptions() abort
" begining start delete the char you just typed in if you do not use set
" nocompatible ,you need this
set backspace=indent,eol,start
set smarttab
set nrformats-=octal
set listchars=tab:→\ ,eol:↵,trail,extends:↷,precedes:↶
set fillchars=vert:│,fold
" Shou number and relativenumber
set relativenumber
set number
" set fillchar
hi VertSplit ctermbg=NONE guibg=NONE
set fillchars+=vert:│
set laststatus=2
" hide cmd
set noshowcmd
@ -60,14 +61,17 @@ function! SpaceVim#default#SetOptions() abort
set softtabstop=4
set shiftwidth=4
" autoread
" Enable line number
set number
" Automatically read a file changed outside of vim
set autoread
" backup
set backup
set undofile
set undolevels=1000
let g:data_dir = $HOME . '/.data/'
let g:data_dir = $HOME . '/.cache/SpaceVim/'
let g:backup_dir = g:data_dir . 'backup'
let g:swap_dir = g:data_dir . 'swap'
let g:undo_dir = g:data_dir . 'undofile'
@ -83,13 +87,13 @@ function! SpaceVim#default#SetOptions() abort
if finddir(g:undo_dir) ==# ''
silent call mkdir(g:undo_dir)
endif
unlet g:data_dir
unlet g:backup_dir
unlet g:swap_dir
unlet g:data_dir
unlet g:undo_dir
set undodir=$HOME/.data/undofile
set backupdir=$HOME/.data/backup
set directory=$HOME/.data/swap
set undodir=$HOME/.cache/SpaceVim/undofile
set backupdir=$HOME/.cache/SpaceVim/backup
set directory=$HOME/.cache/SpaceVim/swap
" no fold enable
set nofoldenable
@ -105,45 +109,36 @@ function! SpaceVim#default#SetOptions() abort
set complete=.,w,b,u,t
" limit completion menu height
set pumheight=15
set scrolloff=3
set scrolloff=1
set sidescrolloff=5
set display+=lastline
set incsearch
set hlsearch
set laststatus=2
set wildignorecase
set mouse=nv
set hidden
set ttimeout
set ttimeoutlen=50
set lazyredraw
if has('patch-7.4.314')
" don't give ins-completion-menu messages.
set shortmess+=c
endif
" Do not wrap lone lines
set nowrap
endfunction
"}}}
function! SpaceVim#default#SetPlugins() abort
function! SpaceVim#default#layers() abort
call add(g:spacevim_plugin_groups, 'web')
call add(g:spacevim_plugin_groups, 'lang')
call add(g:spacevim_plugin_groups, 'edit')
call SpaceVim#layers#load('autocomplete')
call SpaceVim#layers#load('checkers')
call SpaceVim#layers#load('format')
call SpaceVim#layers#load('edit')
call SpaceVim#layers#load('ui')
call add(g:spacevim_plugin_groups, 'ui')
call add(g:spacevim_plugin_groups, 'tools')
call add(g:spacevim_plugin_groups, 'checkers')
call add(g:spacevim_plugin_groups, 'format')
call add(g:spacevim_plugin_groups, 'chat')
call add(g:spacevim_plugin_groups, 'git')
call add(g:spacevim_plugin_groups, 'VersionControl')
call add(g:spacevim_plugin_groups, 'javascript')
call add(g:spacevim_plugin_groups, 'ruby')
call add(g:spacevim_plugin_groups, 'python')
call add(g:spacevim_plugin_groups, 'scala')
call add(g:spacevim_plugin_groups, 'lang#go')
call add(g:spacevim_plugin_groups, 'lang#markdown')
call add(g:spacevim_plugin_groups, 'scm')
call add(g:spacevim_plugin_groups, 'editing')
call add(g:spacevim_plugin_groups, 'indents')
call add(g:spacevim_plugin_groups, 'navigation')
call add(g:spacevim_plugin_groups, 'misc')
call add(g:spacevim_plugin_groups, 'core')
call SpaceVim#layers#load('core#banner')
@ -154,26 +149,13 @@ function! SpaceVim#default#SetPlugins() abort
call add(g:spacevim_plugin_groups, 'github')
if has('python3')
call add(g:spacevim_plugin_groups, 'denite')
endif
call add(g:spacevim_plugin_groups, 'ctrlp')
call add(g:spacevim_plugin_groups, 'autocomplete')
if ! has('nvim')
call add(g:spacevim_plugin_groups, 'vim')
elseif has('python')
else
call add(g:spacevim_plugin_groups, 'nvim')
endif
if OSX()
call add(g:spacevim_plugin_groups, 'osx')
endif
if WINDOWS()
call add(g:spacevim_plugin_groups, 'windows')
endif
if LINUX()
call add(g:spacevim_plugin_groups, 'linux')
call add(g:spacevim_plugin_groups, 'ctrlp')
endif
endfunction
function! SpaceVim#default#SetMappings() abort
function! SpaceVim#default#keyBindings() abort
" Save a file with sudo
" http://forrst.com/posts/Use_w_to_sudo_write_a_file_with_Vim-uAN

View File

@ -5,6 +5,9 @@
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
let s:SYSTEM = SpaceVim#api#import('system')
function! SpaceVim#health#python#check() abort
let result = ['SpaceVim python support check report:']
if has('nvim')
@ -25,7 +28,7 @@ function! SpaceVim#health#python#check() abort
if has('python3')
call add(result, ' SUCCEED!')
else
if !WINDOWS()
if !s:SYSTEM.isWindows
call add(result, ' Failed : to support +python3, Please install vim-gik, or build from sources.')
else
call add(result, ' Failed : to support +python3, install vim from https://github.com/vim/vim-win32-installer/releases')
@ -36,7 +39,7 @@ function! SpaceVim#health#python#check() abort
if has('python')
call add(result, ' SUCCEED!')
else
if !WINDOWS()
if !s:SYSTEM.isWindows
call add(result, ' Failed : to support +python, Please install vim-gik, or build from sources.')
else
call add(result, ' Failed : to support +python3, install vim from https://github.com/vim/vim-win32-installer/releases')

View File

@ -12,7 +12,7 @@
" @subsection code completion
" SpaceVim uses neocomplete as the default completion engine if vim has lua
" support. If there is no lua support, neocomplcache will be used for the
" completion engine. Spacevim uses deoplete as the default completion engine
" completion engine. SpaceVim uses deoplete as the default completion engine
" for neovim. Deoplete requires neovim to be compiled with python support. For
" more information on python support, please read neovim's |provider-python|.
"
@ -161,6 +161,7 @@ function! SpaceVim#layers#autocomplete#config() abort
\ neosnippet#expandable() ?
\ "\<Plug>(neosnippet_expand)" : ""
let g:_spacevim_mappings_space.i = {'name' : '+Insertion'}
if g:spacevim_snippet_engine ==# 'neosnippet'
call SpaceVim#mapping#space#def('nnoremap', ['i', 's'], 'Unite neosnippet', 'insert snippets', 1)
elseif g:spacevim_snippet_engine ==# 'ultisnips'

View File

@ -149,39 +149,39 @@
function! SpaceVim#layers#colorscheme#plugins() abort
return [
\ ['morhetz/gruvbox', {'loadconf' : 1}],
\ ['kristijanhusak/vim-hybrid-material'],
\ ['altercation/vim-colors-solarized'],
\ ['nanotech/jellybeans.vim'],
\ ['mhartington/oceanic-next'],
\ ['mhinz/vim-janah'],
\ ['Gabirel/molokai'],
\ ['kabbamine/yowish.vim'],
\ ['vim-scripts/wombat256.vim'],
\ ['vim-scripts/twilight256.vim'],
\ ['junegunn/seoul256.vim'],
\ ['vim-scripts/rdark-terminal2.vim'],
\ ['vim-scripts/pyte'],
\ ['joshdick/onedark.vim'],
\ ['fmoralesc/molokayo'],
\ ['jonathanfilip/vim-lucius'],
\ ['wimstefan/Lightning'],
\ ['w0ng/vim-hybrid'],
\ ['scheakur/vim-scheakur'],
\ ['keith/parsec.vim'],
\ ['NLKNguyen/papercolor-theme'],
\ ['romainl/flattened'],
\ ['MaxSt/FlatColor'],
\ ['chase/focuspoint-vim'],
\ ['chriskempson/base16-vim'],
\ ['gregsexton/Atom'],
\ ['gilgigilgil/anderson.vim'],
\ ['romainl/Apprentice'],
\ ['icymind/NeoSolarized'],
\ ['jacoborus/tender'],
\ ['wsdjeg/vim-one'],
\ ['arcticicestudio/nord-vim'],
\ ['KeitaNakamura/neodark.vim'],
\ ['morhetz/gruvbox', {'loadconf' : 1, 'merged' : 0}],
\ ['kristijanhusak/vim-hybrid-material', { 'merged' : 0 }],
\ ['altercation/vim-colors-solarized', { 'merged' : 0 }],
\ ['nanotech/jellybeans.vim', { 'merged' : 0 }],
\ ['mhartington/oceanic-next', { 'merged' : 0 }],
\ ['mhinz/vim-janah', { 'merged' : 0 }],
\ ['Gabirel/molokai', { 'merged' : 0 }],
\ ['kabbamine/yowish.vim', { 'merged' : 0 }],
\ ['vim-scripts/wombat256.vim', { 'merged' : 0 }],
\ ['vim-scripts/twilight256.vim', { 'merged' : 0 }],
\ ['junegunn/seoul256.vim', { 'merged' : 0 }],
\ ['vim-scripts/rdark-terminal2.vim', { 'merged' : 0 }],
\ ['vim-scripts/pyte', { 'merged' : 0 }],
\ ['joshdick/onedark.vim', { 'merged' : 0 }],
\ ['fmoralesc/molokayo', { 'merged' : 0 }],
\ ['jonathanfilip/vim-lucius', { 'merged' : 0 }],
\ ['wimstefan/Lightning', { 'merged' : 0 }],
\ ['w0ng/vim-hybrid', { 'merged' : 0 }],
\ ['scheakur/vim-scheakur', { 'merged' : 0 }],
\ ['keith/parsec.vim', { 'merged' : 0 }],
\ ['NLKNguyen/papercolor-theme', { 'merged' : 0 }],
\ ['romainl/flattened', { 'merged' : 0 }],
\ ['SpaceVim/FlatColor', { 'merged' : 0 }],
\ ['chase/focuspoint-vim', { 'merged' : 0 }],
\ ['chriskempson/base16-vim', { 'merged' : 0 }],
\ ['gregsexton/Atom', { 'merged' : 0 }],
\ ['gilgigilgil/anderson.vim', { 'merged' : 0 }],
\ ['romainl/Apprentice', { 'merged' : 0 }],
\ ['icymind/NeoSolarized', { 'merged' : 0 }],
\ ['jacoborus/tender', { 'merged' : 0 }],
\ ['wsdjeg/vim-one', { 'merged' : 0 }],
\ ['arcticicestudio/nord-vim', { 'merged' : 0 }],
\ ['KeitaNakamura/neodark.vim', { 'merged' : 0 }]
\ ]
endfunction

View File

@ -0,0 +1,22 @@
" the theme colors should be
" [
" \ [ a_guifg, a_guibg, a_ctermfg, a_ctermbg],
" \ [ b_guifg, b_guibg, b_ctermfg, b_ctermbg],
" \ [ c_guifg, c_guibg, c_ctermfg, c_ctermbg],
" \ [ z_guibg, z_ctermbg],
" \ [ i_guifg, i_guibg, i_ctermfg, i_ctermbg],
" \ [ v_guifg, v_guibg, v_ctermfg, v_ctermbg],
" \ [ r_guifg, r_guibg, r_ctermfg, r_ctermbg],
" \ ]
function! SpaceVim#mapping#guide#theme#SpaceVim#palette() abort
return [
\ ['#282828' , '#FFA500' , 250, 97],
\ ['#d75fd7' , '#4e4e4e' , 170 , 239],
\ ['#c6c6c6' , '#3a3a3a' , 251 , 237],
\ ['#2c323c', 16],
\ ['#282828', '#00BFFF', 114, 152],
\ ['#2c323c', '#ff8787', 114, 210],
\ ['#2c323c', '#d75f5f', 114, 167],
\ ]
endfunction

View File

@ -12,6 +12,7 @@ let s:MPT = SpaceVim#api#import('prompt')
let s:JOB = SpaceVim#api#import('job')
let s:SYS = SpaceVim#api#import('system')
let s:BUFFER = SpaceVim#api#import('vim#buffer')
let s:LIST = SpaceVim#api#import('data#list')
"}}}
" Init local options: {{{
@ -189,12 +190,17 @@ endfunction
let s:MPT._oninputpro = function('s:close_grep_job')
" }}}
function! s:file_line(line) abort
return matchstr(a:line, '[^:]*:\d\+:')
endfunction
" FlyGrep job handles: {{{
" @vimlint(EVL103, 1, a:data)
" @vimlint(EVL103, 1, a:id)
" @vimlint(EVL103, 1, a:event)
function! s:grep_stdout(id, data, event) abort
let datas =filter(a:data, '!empty(v:val)')
let datas = s:LIST.uniq_by_func(datas, function('s:file_line'))
if getline(1) ==# ''
call setline(1, datas)
else

View File

@ -347,3 +347,5 @@ function! s:find_func_range() abort
return [line, line]
endfunction
" }}}
" vim:set et sw=2 cc=80 foldenable:

View File

@ -1,295 +1,296 @@
scriptencoding utf-8
let s:SYSTEM = SpaceVim#api#import('system')
let s:save_cpo = &cpo
set cpo&vim
let g:unite_source_menu_menus =
\ get(g:,'unite_source_menu_menus',{})
\ get(g:,'unite_source_menu_menus',{})
let g:unite_source_menu_menus.CustomKeyMaps = {'description':
\ 'Custom mapped keyboard shortcuts [unite]<SPACE>'}
\ 'Custom mapped keyboard shortcuts [unite]<SPACE>'}
let g:unite_source_menu_menus.CustomKeyMaps.command_candidates =
\ get(g:unite_source_menu_menus.CustomKeyMaps,'command_candidates', [])
\ get(g:unite_source_menu_menus.CustomKeyMaps,'command_candidates', [])
let g:unite_source_menu_menus.MyStarredrepos = {'description':
\ 'All github repos starred by me <leader>ls'}
\ 'All github repos starred by me <leader>ls'}
let g:unite_source_menu_menus.MyStarredrepos.command_candidates =
\ get(g:unite_source_menu_menus.MyStarredrepos,'command_candidates', [])
\ get(g:unite_source_menu_menus.MyStarredrepos,'command_candidates', [])
let g:unite_source_menu_menus.MpvPlayer = {'description':
\ 'Musics list <leader>lm'}
\ 'Musics list <leader>lm'}
let g:unite_source_menu_menus.MpvPlayer.command_candidates =
\ get(g:unite_source_menu_menus.MpvPlayer,'command_candidates', [])
\ get(g:unite_source_menu_menus.MpvPlayer,'command_candidates', [])
fu! zvim#util#defineMap(type,key,value,desc,...) abort
exec a:type . ' ' . a:key . ' ' . a:value
let description = '➤ '
\. a:desc
\. repeat(' ', 80 - len(a:desc) - len(a:key))
\. a:key
let cmd = len(a:000) > 0 ? a:000[0] : a:value
call add(g:unite_source_menu_menus.CustomKeyMaps.command_candidates, [description,cmd])
exec a:type . ' ' . a:key . ' ' . a:value
let description = '➤ '
\. a:desc
\. repeat(' ', 80 - len(a:desc) - len(a:key))
\. a:key
let cmd = len(a:000) > 0 ? a:000[0] : a:value
call add(g:unite_source_menu_menus.CustomKeyMaps.command_candidates, [description,cmd])
endf
fu! zvim#util#source_rc(file) abort
if filereadable(g:Config_Main_Home. '/' . a:file)
execute 'source ' . g:Config_Main_Home . '/' . a:file
endif
if filereadable(g:_spacevim_root_dir. '/' . a:file)
execute 'source ' . g:_spacevim_root_dir . '/' . a:file
endif
endf
fu! zvim#util#SmartClose() abort
let ignorewin = get(g:,'spacevim_smartcloseignorewin',[])
let ignoreft = get(g:, 'spacevim_smartcloseignoreft',[])
let win_count = winnr('$')
let num = win_count
for i in range(1,win_count)
if index(ignorewin , bufname(winbufnr(i))) != -1 || index(ignoreft, getbufvar(bufname(winbufnr(i)),'&filetype')) != -1
let num = num - 1
endif
if getbufvar(winbufnr(i),'&buftype') ==# 'quickfix'
let num = num - 1
endif
endfor
if num == 1
else
quit
let ignorewin = get(g:,'spacevim_smartcloseignorewin',[])
let ignoreft = get(g:, 'spacevim_smartcloseignoreft',[])
let win_count = winnr('$')
let num = win_count
for i in range(1,win_count)
if index(ignorewin , bufname(winbufnr(i))) != -1 || index(ignoreft, getbufvar(bufname(winbufnr(i)),'&filetype')) != -1
let num = num - 1
endif
if getbufvar(winbufnr(i),'&buftype') ==# 'quickfix'
let num = num - 1
endif
endfor
if num == 1
else
quit
endif
endf
fu! s:findFileInParent(what, where) abort " {{{2
let old_suffixesadd = &suffixesadd
let &suffixesadd = ''
let file = findfile(a:what, escape(a:where, ' ') . ';')
let &suffixesadd = old_suffixesadd
return file
let old_suffixesadd = &suffixesadd
let &suffixesadd = ''
let file = findfile(a:what, escape(a:where, ' ') . ';')
let &suffixesadd = old_suffixesadd
return file
endf " }}}2
fu! s:findDirInParent(what, where) abort " {{{2
let old_suffixesadd = &suffixesadd
let &suffixesadd = ''
let dir = finddir(a:what, escape(a:where, ' ') . ';')
let &suffixesadd = old_suffixesadd
return dir
let old_suffixesadd = &suffixesadd
let &suffixesadd = ''
let dir = finddir(a:what, escape(a:where, ' ') . ';')
let &suffixesadd = old_suffixesadd
return dir
endf " }}}2
fu! zvim#util#CopyToClipboard(...) abort
if a:0
if executable('git')
let repo_home = fnamemodify(s:findDirInParent('.git', expand('%:p')), ':p:h:h')
if repo_home !=# '' || !isdirectory(repo_home)
let branch = split(systemlist('git -C '. repo_home. ' branch -a |grep "*"')[0],' ')[1]
let remotes = filter(systemlist('git -C '. repo_home. ' remote -v'),"match(v:val,'^origin') >= 0 && match(v:val,'fetch') > 0")
if len(remotes) > 0
let remote = remotes[0]
if stridx(remote, '@') > -1
let repo_url = 'https://github.com/'. split(split(remote,' ')[0],':')[1]
let repo_url = strpart(repo_url, 0, len(repo_url) - 4)
else
let repo_url = split(remote,' ')[0]
let repo_url = strpart(repo_url, stridx(repo_url, 'http'),len(repo_url) - 4 - stridx(repo_url, 'http'))
endif
let f_url =repo_url. '/blob/'. branch. '/'. strpart(expand('%:p'), len(repo_home) + 1, len(expand('%:p')))
if WINDOWS()
let f_url = substitute(f_url, '\', '/', 'g')
endif
if a:1 == 2
let current_line = line('.')
let f_url .= '#L' . current_line
elseif a:1 == 3
let f_url .= '#L' . getpos("'<")[1] . '-L' . getpos("'>")[1]
endif
try
let @+=f_url
echo 'Copied to clipboard'
catch /^Vim\%((\a\+)\)\=:E354/
if has('nvim')
echohl WarningMsg | echom 'Can not find clipboard, for more info see :h clipboard' | echohl None
else
echohl WarningMsg | echom 'You need compile you vim with +clipboard feature' | echohl None
endif
endtry
else
echohl WarningMsg | echom 'This git repo has no remote host' | echohl None
endif
else
echohl WarningMsg | echom 'This file is not in a git repo' | echohl None
endif
else
echohl WarningMsg | echom 'You need install git!' | echohl None
endif
else
try
let @+=expand('%:p')
echo 'Copied to clipboard ' . @+
catch /^Vim\%((\a\+)\)\=:E354/
if a:0
if executable('git')
let repo_home = fnamemodify(s:findDirInParent('.git', expand('%:p')), ':p:h:h')
if repo_home !=# '' || !isdirectory(repo_home)
let branch = split(systemlist('git -C '. repo_home. ' branch -a |grep "*"')[0],' ')[1]
let remotes = filter(systemlist('git -C '. repo_home. ' remote -v'),"match(v:val,'^origin') >= 0 && match(v:val,'fetch') > 0")
if len(remotes) > 0
let remote = remotes[0]
if stridx(remote, '@') > -1
let repo_url = 'https://github.com/'. split(split(remote,' ')[0],':')[1]
let repo_url = strpart(repo_url, 0, len(repo_url) - 4)
else
let repo_url = split(remote,' ')[0]
let repo_url = strpart(repo_url, stridx(repo_url, 'http'),len(repo_url) - 4 - stridx(repo_url, 'http'))
endif
let f_url =repo_url. '/blob/'. branch. '/'. strpart(expand('%:p'), len(repo_home) + 1, len(expand('%:p')))
if s:SYSTEM.isWindows
let f_url = substitute(f_url, '\', '/', 'g')
endif
if a:1 == 2
let current_line = line('.')
let f_url .= '#L' . current_line
elseif a:1 == 3
let f_url .= '#L' . getpos("'<")[1] . '-L' . getpos("'>")[1]
endif
try
let @+=f_url
echo 'Copied to clipboard'
catch /^Vim\%((\a\+)\)\=:E354/
if has('nvim')
echohl WarningMsg | echom 'Can not find clipboard, for more info see :h clipboard' | echohl None
echohl WarningMsg | echom 'Can not find clipboard, for more info see :h clipboard' | echohl None
else
echohl WarningMsg | echom 'You need compile you vim with +clipboard feature' | echohl None
echohl WarningMsg | echom 'You need compile you vim with +clipboard feature' | echohl None
endif
endtry
endtry
else
echohl WarningMsg | echom 'This git repo has no remote host' | echohl None
endif
else
echohl WarningMsg | echom 'This file is not in a git repo' | echohl None
endif
else
echohl WarningMsg | echom 'You need install git!' | echohl None
endif
else
try
let @+=expand('%:p')
echo 'Copied to clipboard ' . @+
catch /^Vim\%((\a\+)\)\=:E354/
if has('nvim')
echohl WarningMsg | echom 'Can not find clipboard, for more info see :h clipboard' | echohl None
else
echohl WarningMsg | echom 'You need compile you vim with +clipboard feature' | echohl None
endif
endtry
endif
endf
fu! zvim#util#check_if_expand_tab() abort
let has_noexpandtab = search('^\t','wn')
let has_expandtab = search('^ ','wn')
if has_noexpandtab && has_expandtab
let idx = inputlist ( ['ERROR: current file exists both expand and noexpand TAB, python can only use one of these two mode in one file.\nSelect Tab Expand Type:',
\ '1. expand (tab=space, recommended)',
\ '2. noexpand (tab=\t, currently have risk)',
\ '3. do nothing (I will handle it by myself)'])
let tab_space = printf('%*s',&tabstop,'')
if idx == 1
let has_noexpandtab = 0
let has_expandtab = 1
silent exec '%s/\t/' . tab_space . '/g'
elseif idx == 2
let has_noexpandtab = 1
let has_expandtab = 0
silent exec '%s/' . tab_space . '/\t/g'
else
return
endif
endif
if has_noexpandtab == 1 && has_expandtab == 0
echomsg 'substitute space to TAB...'
set noexpandtab
echomsg 'done!'
elseif has_noexpandtab == 0 && has_expandtab == 1
echomsg 'substitute TAB to space...'
set expandtab
echomsg 'done!'
let has_noexpandtab = search('^\t','wn')
let has_expandtab = search('^ ','wn')
if has_noexpandtab && has_expandtab
let idx = inputlist ( ['ERROR: current file exists both expand and noexpand TAB, python can only use one of these two mode in one file.\nSelect Tab Expand Type:',
\ '1. expand (tab=space, recommended)',
\ '2. noexpand (tab=\t, currently have risk)',
\ '3. do nothing (I will handle it by myself)'])
let tab_space = printf('%*s',&tabstop,'')
if idx == 1
let has_noexpandtab = 0
let has_expandtab = 1
silent exec '%s/\t/' . tab_space . '/g'
elseif idx == 2
let has_noexpandtab = 1
let has_expandtab = 0
silent exec '%s/' . tab_space . '/\t/g'
else
" it may be a new file
" we use original vim setting
return
endif
endif
if has_noexpandtab == 1 && has_expandtab == 0
echomsg 'substitute space to TAB...'
set noexpandtab
echomsg 'done!'
elseif has_noexpandtab == 0 && has_expandtab == 1
echomsg 'substitute TAB to space...'
set expandtab
echomsg 'done!'
else
" it may be a new file
" we use original vim setting
endif
endf
function! zvim#util#BufferEmpty() abort
let l:current = bufnr('%')
if ! getbufvar(l:current, '&modified')
enew
silent! execute 'bdelete '.l:current
endif
let l:current = bufnr('%')
if ! getbufvar(l:current, '&modified')
enew
silent! execute 'bdelete '.l:current
endif
endfunction
function! zvim#util#loadMusics() abort
let musics = SpaceVim#util#globpath('~/Musics', '*.mp3')
let g:unite_source_menu_menus.MpvPlayer.command_candidates = []
for m in musics
call add(g:unite_source_menu_menus.MpvPlayer.command_candidates,
\ [fnamemodify(m, ':t'),
\ "call zvim#mpv#play('" . m . "')"])
endfor
let musics = SpaceVim#util#globpath('~/Musics', '*.mp3')
let g:unite_source_menu_menus.MpvPlayer.command_candidates = []
for m in musics
call add(g:unite_source_menu_menus.MpvPlayer.command_candidates,
\ [fnamemodify(m, ':t'),
\ "call zvim#mpv#play('" . m . "')"])
endfor
endfunction
function! zvim#util#listDirs(dir) abort
let dir = fnamemodify(a:dir, ':p')
if isdirectory(dir)
let cmd = printf('ls -F %s | grep /$', dir)
return map(systemlist(cmd), 'v:val[:-2]')
endif
return []
let dir = fnamemodify(a:dir, ':p')
if isdirectory(dir)
let cmd = printf('ls -F %s | grep /$', dir)
return map(systemlist(cmd), 'v:val[:-2]')
endif
return []
endfunction
function! zvim#util#OpenVimfiler() abort
if bufnr('vimfiler') == -1
silent VimFiler
if exists(':AirlineRefresh')
AirlineRefresh
endif
wincmd p
if &filetype !=# 'startify'
IndentLinesToggle
IndentLinesToggle
endif
wincmd p
else
silent VimFiler
doautocmd WinEnter
if exists(':AirlineRefresh')
AirlineRefresh
endif
if bufnr('vimfiler') == -1
silent VimFiler
if exists(':AirlineRefresh')
AirlineRefresh
endif
wincmd p
if &filetype !=# 'startify'
IndentLinesToggle
IndentLinesToggle
endif
wincmd p
else
silent VimFiler
doautocmd WinEnter
if exists(':AirlineRefresh')
AirlineRefresh
endif
endif
endfunction
let s:plugins_argv = ['-update', '-openurl']
function! zvim#util#complete_plugs(ArgLead, CmdLine, CursorPos) abort
call zvim#debug#completion_debug(a:ArgLead, a:CmdLine, a:CursorPos)
if a:CmdLine =~# 'Plugin\s*$' || a:ArgLead =~# '^-[a-zA-Z]*'
return join(s:plugins_argv, "\n")
endif
return join(plugins#list(), "\n")
call zvim#debug#completion_debug(a:ArgLead, a:CmdLine, a:CursorPos)
if a:CmdLine =~# 'Plugin\s*$' || a:ArgLead =~# '^-[a-zA-Z]*'
return join(s:plugins_argv, "\n")
endif
return join(plugins#list(), "\n")
endfunction
function! zvim#util#Plugin(...) abort
let adds = []
let updates = []
let flag = 0
for a in a:000
if flag == 1
call add(adds, a)
elseif flag == 2
call add(updates, a)
endif
if a ==# '-update'
let flag = 1
elseif a ==# '-openurl'
let flag = 2
endif
endfor
echo string(adds) . "\n" . string(updates)
let adds = []
let updates = []
let flag = 0
for a in a:000
if flag == 1
call add(adds, a)
elseif flag == 2
call add(updates, a)
endif
if a ==# '-update'
let flag = 1
elseif a ==# '-openurl'
let flag = 2
endif
endfor
echo string(adds) . "\n" . string(updates)
endfunction
function! zvim#util#complete_project(ArgLead, CmdLine, CursorPos) abort
call zvim#debug#completion_debug(a:ArgLead, a:CmdLine, a:CursorPos)
let dir = get(g:,'spacevim_src_root', '~')
"return globpath(dir, '*')
let result = split(globpath(dir, '*'), "\n")
let ps = []
for p in result
if isdirectory(p) && isdirectory(p. '\' . '.git')
call add(ps, fnamemodify(p, ':t'))
endif
endfor
return join(ps, "\n")
call zvim#debug#completion_debug(a:ArgLead, a:CmdLine, a:CursorPos)
let dir = get(g:,'spacevim_src_root', '~')
"return globpath(dir, '*')
let result = split(globpath(dir, '*'), "\n")
let ps = []
for p in result
if isdirectory(p) && isdirectory(p. '\' . '.git')
call add(ps, fnamemodify(p, ':t'))
endif
endfor
return join(ps, "\n")
endfunction
function! zvim#util#OpenProject(p) abort
let dir = get(g:, 'spacevim_src_root', '~') . a:p
exe 'CtrlP '. dir
let dir = get(g:, 'spacevim_src_root', '~') . a:p
exe 'CtrlP '. dir
endfunction
function! zvim#util#UpdateHosts(...) abort
if len(a:000) == 0
let url = get(g:,'spacevim_hosts_url', '')
else
let url = a:1
endif
let hosts = systemlist('curl -s ' . url)
if WINDOWS()
let local_hosts = $SystemRoot . expand('\System32\drivers\etc\hosts')
else
let local_hosts = '/etc/hosts'
endif
if writefile(hosts, local_hosts, 'a') == -1
echo 'failed!'
else
echo 'successfully!'
endif
if len(a:000) == 0
let url = get(g:,'spacevim_hosts_url', '')
else
let url = a:1
endif
let hosts = systemlist('curl -s ' . url)
if s:SYSTEM.isWindows
let local_hosts = $SystemRoot . expand('\System32\drivers\etc\hosts')
else
let local_hosts = '/etc/hosts'
endif
if writefile(hosts, local_hosts, 'a') == -1
echo 'failed!'
else
echo 'successfully!'
endif
endfunction
fu! zvim#util#Generate_ignore(ignore,tool, ...) abort
let ignore = []
if a:tool ==# 'ag'
for ig in split(a:ignore,',')
call add(ignore, '--ignore')
call add(ignore, "'" . ig . "'")
endfor
elseif a:tool ==# 'rg'
for ig in split(a:ignore,',')
call add(ignore, '-g')
if a:0 > 0
call add(ignore, "'!" . ig . "'")
else
call add(ignore, '!' . ig)
endif
endfor
endif
return ignore
let ignore = []
if a:tool ==# 'ag'
for ig in split(a:ignore,',')
call add(ignore, '--ignore')
call add(ignore, "'" . ig . "'")
endfor
elseif a:tool ==# 'rg'
for ig in split(a:ignore,',')
call add(ignore, '-g')
if a:0 > 0
call add(ignore, "'!" . ig . "'")
else
call add(ignore, '!' . ig)
endif
endfor
endif
return ignore
endf
let &cpo = s:save_cpo

View File

@ -1,5 +1,5 @@
coverage:
range: 50..70
range: 30..60
round: down
precision: 2
comment:

137
colors/SpaceVim.vim Normal file
View File

@ -0,0 +1,137 @@
"=============================================================================
" SpaceVim.vim --- SpaceVim colorscheme
" Copyright (c) 2016-2017 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg at 163.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
if version > 580
hi clear
if exists("syntax_on")
syntax reset
endif
endif
if !(has('termguicolors') && &termguicolors) && !has('gui_running') && &t_Co != 256
" prevent change statuslines
finish
else
let g:colors_name='SpaceVim'
endif
let s:HIAPI = SpaceVim#api#import('vim#highlight')
let s:COLOR = SpaceVim#api#import('color')
let s:is_dark=(&background == 'dark')
function! s:hi(items) abort
for [item, fg, bg, cterm, gui] in a:items
call s:HIAPI.hi(
\ {
\ 'name' : item,
\ 'ctermbg' : bg,
\ 'ctermfg' : fg,
\ 'guifg' : s:COLOR.nr2str(fg),
\ 'guibg' : s:COLOR.nr2str(bg),
\ 'cterm' : cterm,
\ 'gui' : gui,
\ }
\ )
endfor
endfunction
" color palette
let s:palette = {
\ 'dark' : [
\ ['Boolean' , 178 , '' , 'None' , 'None'] ,
\ ['Character' , 75 , '' , 'None' , 'None'] ,
\ ['ColorColumn' , '' , 236 , 'None' , 'None'] ,
\ ['Comment' , 30 , '' , 'None' , 'italic'] ,
\ ['Conditional' , 68 , '' , 'bold' , 'bold'] ,
\ ['Constant' , 218 , '' , 'None' , 'None'] ,
\ ['Cursor' , 235 , 178 , 'bold' , 'bold'] ,
\ ['CursorColumn' , '' , 236 , 'None' , 'None'] ,
\ ['CursorLine' , '' , 236 , 'None' , 'None'] ,
\ ['CursorLineNr' , 134 , 236 , 'None' , 'None'] ,
\ ['Debug' , 225 , '' , 'None' , 'None'] ,
\ ['Define' , 177 , '' , 'None' , 'None'] ,
\ ['Delimiter' , 151 , '' , 'None' , 'None'] ,
\ ['DiffAdd' , '' , 24 , 'None' , 'None'] ,
\ ['DiffChange' , 181 , 239 , 'None' , 'None'] ,
\ ['DiffDelete' , 162 , 53 , 'None' , 'None'] ,
\ ['DiffText' , '' , 102 , 'None' , 'None'] ,
\ ['Directory' , 67 , '' , 'bold' , 'bold'] ,
\ ['Error' , 160 , 235 , 'bold' , 'bold'] ,
\ ['ErrorMsg' , 196 , 235 , 'bold' , 'bold'] ,
\ ['Exception' , 204 , '' , 'bold' , 'bold'] ,
\ ['Float' , 135 , '' , 'None' , 'None'] ,
\ ['FoldColumn' , 67 , 236 , 'None' , 'None'] ,
\ ['Folded' , 133 , 236 , 'bold' , 'bold'] ,
\ ['Function' , 169 , '' , 'bold' , 'bold'] ,
\ ['Identifier' , 167 , '' , 'None' , 'None'] ,
\ ['Ignore' , 244 , '' , 'None' , 'None'] ,
\ ['IncSearch' , 16 , 76 , 'bold' , 'bold'] ,
\ ['Keyword' , 68 , '' , 'bold' , 'bold'] ,
\ ['Label' , 104 , '' , 'None' , 'None'] ,
\ ['LineNr' , 238 , 235 , 'None' , 'None'] ,
\ ['Macro' , 140 , '' , 'None' , 'None'] ,
\ ['MatchParen' , 40 , 234 , 'bold , underline' , 'bold , underline'] ,
\ ['ModeMsg' , 229 , '' , 'None' , 'None'] ,
\ ['NonText' , 241 , '' , 'None' , 'None'] ,
\ ['Normal' , 249 , 235 , 'None' , 'None'] ,
\ ['Number' , 176 , '' , 'None' , 'None'] ,
\ ['Operator' , 111 , '' , 'None' , 'None'] ,
\ ['Pmenu' , 141 , 236 , 'None' , 'None'] ,
\ ['PmenuSbar' , 28 , 233 , 'None' , 'None'] ,
\ ['PmenuSel' , 251 , 97 , 'None' , 'None'] ,
\ ['PmenuThumb' , 160 , 97 , 'None' , 'None'] ,
\ ['PreCondit' , 139 , '' , 'None' , 'None'] ,
\ ['PreProc' , 176 , '' , 'None' , 'None'] ,
\ ['Question' , 81 , '' , 'None' , 'None'] ,
\ ['Repeat' , 68 , '' , 'bold' , 'bold'] ,
\ ['Search' , 16 , 76 , 'bold' , 'bold'] ,
\ ['SignColumn' , 118 , 235 , 'None' , 'None'] ,
\ ['Special' , 169 , '' , 'None' , 'None'] ,
\ ['SpecialChar' , 171 , '' , 'bold' , 'bold'] ,
\ ['SpecialComment' , 24 , '' , 'None' , 'None'] ,
\ ['SpecialKey' , 59 , '' , 'None' , 'None'] ,
\ ['SpellBad' , 168 , '' , 'underline' , 'undercurl'] ,
\ ['SpellCap' , 110 , '' , 'underline' , 'undercurl'] ,
\ ['SpellLocal' , 253 , '' , 'underline' , 'undercurl'] ,
\ ['SpellRare' , 218 , '' , 'underline' , 'undercurl'] ,
\ ['Statement' , 68 , '' , 'None' , 'None'] ,
\ ['StatusLine' , 140 , 238 , 'None' , 'None'] ,
\ ['StatusLineNC' , 242 , 237 , 'None' , 'None'] ,
\ ['StatusLineTerm' , 140 , 238 , 'bold' , 'bold'] ,
\ ['StatusLineTermNC' , 244 , 237 , 'bold' , 'bold'] ,
\ ['StorageClass' , 178 , '' , 'bold' , 'bold'] ,
\ ['String' , 36 , '' , 'None' , 'None'] ,
\ ['Structure' , 68 , '' , 'bold' , 'bold'] ,
\ ['TabLine' , 66 , 239 , 'None' , 'None'] ,
\ ['TabLineFill' , 145 , 238 , 'None' , 'None'] ,
\ ['TabLineSel' , 178 , 240 , 'None' , 'None'] ,
\ ['Tag' , 161 , '' , 'None' , 'None'] ,
\ ['Title' , 176 , '' , 'None' , 'None'] ,
\ ['Todo' , 172 , 235 , 'bold' , 'bold'] ,
\ ['Type' , 68 , '' , 'None' , 'None'] ,
\ ['Typedef' , 68 , '' , 'None' , 'None'] ,
\ ['VertSplit' , 234 , '' , 'None' , 'None'] ,
\ ['Visual' , '' , 238 , 'None' , 'None'] ,
\ ['VisualNOS' , '' , 238 , 'None' , 'None'] ,
\ ['Warning' , 136 , '' , 'bold' , 'bold'] ,
\ ['WarningMsg' , 136 , '' , 'bold' , 'bold'] ,
\ ['WildMenu' , 214 , 239 , 'None' , 'None'] ,
\ ['VertSplit' , 235 , 238 , 'None' , 'None'] ,
\ ] ,
\ 'light' : [
\ ],
\ }
call s:hi(s:palette[s:is_dark ? 'dark' : 'light'])
if s:is_dark
set background=dark
endif

View File

@ -1,69 +1,73 @@
"=============================================================================
" init.vim --- Language && encoding in SpaceVim
" Copyright (c) 2016-2017 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg at 163.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
scriptencoding utf-8
" Enable nocompatible
if has('vim_starting')
if &compatible
set nocompatible
endif
if &compatible
set nocompatible
endif
endif
let s:SYSTEM = SpaceVim#api#import('system')
" Fsep && Psep
if has('win16') || has('win32') || has('win64')
let s:Psep = ';'
let s:Fsep = '\'
let s:Psep = ';'
let s:Fsep = '\'
else
let s:Psep = ':'
let s:Fsep = '/'
let s:Psep = ':'
let s:Fsep = '/'
endif
"Use English for anything in vim
try
if WINDOWS()
silent exec 'lan mes en_US.UTF-8'
elseif OSX()
silent exec 'language en_US'
if s:SYSTEM.isWindows
silent exec 'lan mes en_US.UTF-8'
elseif s:SYSTEM.isOSX
silent exec 'language en_US'
else
let s:uname = system('uname -s')
if s:uname ==# "Darwin\n"
" in mac-terminal
silent exec 'language en_US'
elseif s:uname ==# "SunOS\n"
" in Sun-OS terminal
silent exec 'lan en_US.UTF-8'
else
let s:uname = system('uname -s')
if s:uname ==# "Darwin\n"
" in mac-terminal
silent exec 'language en_US'
elseif s:uname ==# "SunOS\n"
" in Sun-OS terminal
silent exec 'lan en_US.UTF-8'
else
" in linux-terminal
silent exec 'lan en_US.utf8'
endif
" in linux-terminal
silent exec 'lan en_US.utf8'
endif
endif
catch /^Vim\%((\a\+)\)\=:E197/
call SpaceVim#logger#error('Can not set language to en_US.utf8')
call SpaceVim#logger#error('Can not set language to en_US.utf8')
endtry
" try to set encoding to utf-8
if WINDOWS()
" 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
set termencoding=cp850
" Let Vim use utf-8 internally, because many scripts require this
set encoding=utf-8
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.
set fileencodings=ucs-bom,utf-8,gbk,utf-16le,cp1252,iso-8859-15
endif
if s:SYSTEM.isWindows
" 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
set termencoding=cp850
" Let Vim use utf-8 internally, because many scripts require this
set encoding=utf-8
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.
set fileencodings=ucs-bom,utf-8,gbk,utf-16le,cp1252,iso-8859-15
endif
else
" set default encoding to utf-8
set encoding=utf-8
set termencoding=utf-8
" set default encoding to utf-8
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
endif
" Enable 256 colors
if $COLORTERM ==# 'gnome-terminal'
set t_Co=256
endif

View File

@ -6,71 +6,20 @@
" License: GPLv3
"=============================================================================
let g:Config_Main_Home = fnamemodify(expand('<sfile>'),
" Detect root directory of SpaceVim
let g:_spacevim_root_dir = fnamemodify(expand('<sfile>'),
\ ':p:h:gs?\\?'.((has('win16') || has('win32')
\ || has('win64'))?'\':'/') . '?')
" [dir?, path]
function! s:parser_argv() abort
if !argc()
return [1, getcwd()]
elseif argv(0) =~# '/$'
let f = expand(argv(0))
if isdirectory(f)
return [1, f]
else
return [1, getcwd()]
endif
elseif argv(0) ==# '.'
return [1, getcwd()]
elseif isdirectory(expand(argv(0)))
return [1, expand(argv(0)) ]
else
return [0]
endif
endfunction
let s:status = s:parser_argv()
if s:status[0]
let g:_spacevim_enter_dir = s:status[1]
augroup SPwelcome
au!
autocmd VimEnter * call SpaceVim#welcome()
augroup END
endif
lockvar g:_spacevim_root_dir
try
call zvim#util#source_rc('functions.vim')
call SpaceVim#begin()
catch
execute 'set rtp +=' . fnamemodify(g:Config_Main_Home, ':p:h:h')
call zvim#util#source_rc('functions.vim')
" Update the rtp only when SpaceVim is not contained in runtimepath.
execute 'set rtp +=' . fnamemodify(g:_spacevim_root_dir, ':p:h:h')
call SpaceVim#begin()
endtry
call zvim#util#source_rc('init.vim')
call SpaceVim#default()
call SpaceVim#loadCustomConfig()
call SpaceVim#server#connect()
call SpaceVim#end()
call SpaceVim#plugins#projectmanager#RootchandgeCallback()
call zvim#util#source_rc('general.vim')
call SpaceVim#autocmds#init()
if has('nvim')
call zvim#util#source_rc('neovim.vim')
endif
call zvim#util#source_rc('commands.vim')
filetype plugin indent on
syntax on
" vim:set et sw=2 cc=80:

View File

@ -15,7 +15,7 @@ elseif type(g:spacevim_force_global_config) == type([])
endif
if g:spacevim_force_global_config == 0
let g:neosnippet#snippets_directory = [getcwd() . '/.Spacevim.d/snippets'] +
let g:neosnippet#snippets_directory = [getcwd() . '/.SpaceVim.d/snippets'] +
\ g:neosnippet#snippets_directory
endif
let g:neosnippet#enable_snipmate_compatibility =

View File

@ -558,7 +558,7 @@ AUTOCOMPLETE *SpaceVim-autocomplete*
CODE COMPLETION
SpaceVim uses neocomplete as the default completion engine if vim has lua
support. If there is no lua support, neocomplcache will be used for the
completion engine. Spacevim uses deoplete as the default completion engine for
completion engine. SpaceVim uses deoplete as the default completion engine for
neovim. Deoplete requires neovim to be compiled with python support. For more
information on python support, please read neovim's |provider-python|.

View File

@ -33,25 +33,26 @@ CONTENTS *SpaceVim-contents*
10. indentmove...............................|SpaceVim-layer-indentmove|
11. lang#c.......................................|SpaceVim-layer-lang-c|
12. lang#crystal...........................|SpaceVim-layer-lang-crystal|
13. lang#elixir.............................|SpaceVim-layer-lang-elixir|
14. lang#go.....................................|SpaceVim-layer-lang-go|
15. lang#java.................................|SpaceVim-layer-lang-java|
16. lang#julia...............................|SpaceVim-layer-lang-julia|
17. lang#kotlin.............................|SpaceVim-layer-lang-kotlin|
18. lang#lua...................................|SpaceVim-layer-lang-lua|
19. lang#ocaml...............................|SpaceVim-layer-lang-ocaml|
20. lang#php...................................|SpaceVim-layer-lang-php|
21. lang#pony.................................|SpaceVim-layer-lang-pony|
22. lang#puppet.............................|SpaceVim-layer-lang-puppet|
23. lang#python.............................|SpaceVim-layer-lang-python|
24. lang#rust.................................|SpaceVim-layer-lang-rust|
25. lang#scala...............................|SpaceVim-layer-lang-scala|
26. lang#tmux.................................|SpaceVim-layer-lang-tmux|
27. lang#xml...................................|SpaceVim-layer-lang-xml|
28. operator...................................|SpaceVim-layer-operator|
29. shell.........................................|SpaceVim-layer-shell|
30. tmux...........................................|SpaceVim-layer-tmux|
31. tools#dash...............................|SpaceVim-layer-tools-dash|
13. lang#csharp.............................|SpaceVim-layer-lang-csharp|
14. lang#elixir.............................|SpaceVim-layer-lang-elixir|
15. lang#go.....................................|SpaceVim-layer-lang-go|
16. lang#java.................................|SpaceVim-layer-lang-java|
17. lang#julia...............................|SpaceVim-layer-lang-julia|
18. lang#kotlin.............................|SpaceVim-layer-lang-kotlin|
19. lang#lua...................................|SpaceVim-layer-lang-lua|
20. lang#ocaml...............................|SpaceVim-layer-lang-ocaml|
21. lang#php...................................|SpaceVim-layer-lang-php|
22. lang#pony.................................|SpaceVim-layer-lang-pony|
23. lang#puppet.............................|SpaceVim-layer-lang-puppet|
24. lang#python.............................|SpaceVim-layer-lang-python|
25. lang#rust.................................|SpaceVim-layer-lang-rust|
26. lang#scala...............................|SpaceVim-layer-lang-scala|
27. lang#tmux.................................|SpaceVim-layer-lang-tmux|
28. lang#xml...................................|SpaceVim-layer-lang-xml|
29. operator...................................|SpaceVim-layer-operator|
30. shell.........................................|SpaceVim-layer-shell|
31. tmux...........................................|SpaceVim-layer-tmux|
32. tools#dash...............................|SpaceVim-layer-tools-dash|
6. API........................................................|SpaceVim-api|
1. cmdlinemenu................................|SpaceVim-api-cmdlinemenu|
2. data#list....................................|SpaceVim-api-data-list|
@ -77,6 +78,9 @@ also supports local config for each project. Place local config settings in
`.SpaceVim.d/init.vim` in the root directory of your project. `.SpaceVim.d/`
will also be added to runtimepath.
*g:spacevim_version*
Version of SpaceVim , this value can not be changed.
*g:spacevim_default_indent*
Change the default indentation of SpaceVim. Default is 2.
>
@ -585,7 +589,7 @@ AUTOCOMPLETE *SpaceVim-autocomplete*
CODE COMPLETION
SpaceVim uses neocomplete as the default completion engine if vim has lua
support. If there is no lua support, neocomplcache will be used for the
completion engine. Spacevim uses deoplete as the default completion engine for
completion engine. SpaceVim uses deoplete as the default completion engine for
neovim. Deoplete requires neovim to be compiled with python support. For more
information on python support, please read neovim's |provider-python|.
@ -881,6 +885,32 @@ INTRO
The lang#crystal layer provides crystal filetype detection and syntax
highlight, crystal tool and crystal spec integration.
==============================================================================
LANG#CSHARP *SpaceVim-layer-lang-csharp*
This layer includes utilities and language-specific mappings for csharp
development.
KEY MAPPINGS
>
Mode Key Function
---------------------------------------------
normal SPC l b compile the project
normal SPC l f format current file
normal SPC l d show doc
normal SPC l e rename symbol under cursor
normal SPC l g g go to definition
normal SPC l g i find implementations
normal SPC l g t find type
normal SPC l g s find symbols
normal SPC l g u find usages of symbol under cursor
normal SPC l g m find members in the current buffer
normal SPC l s r reload the solution
normal SPC l s s start the OmniSharp server
normal SPC l s S stop the OmniSharp server
<
==============================================================================
LANG#ELIXIR *SpaceVim-layer-lang-elixir*

View File

@ -260,7 +260,8 @@ autocommand BufEnter <buffer>
#### Naming
In general, use plugin-names-like-this, FunctionNamesLikeThis, CommandNamesLikeThis, augroup_names_like_this, variable_names_like_this.
In general, use `plugin-names-like-this`, `FunctionNamesLikeThis`,
`CommandNamesLikeThis`, `augroup_names_like_this`, `variable_names_like_this`.
Always prefix variables with their scope.

View File

@ -11,6 +11,7 @@ description: "General contributing guidelines and changelog of SpaceVim, includi
- [Reporting issues](#reporting-issues)
- [Contributing code](#contributing-code)
- [License](#license)
- [Bootstrap](#bootstrap)
- [Conventions](#conventions)
- [Pull Request](#pull-request)
- [Rebase your pr Branch on top of upstream master:](#rebase-your-pr-branch-on-top-of-upstream-master)
@ -71,6 +72,12 @@ The license is GPLv3 for all the parts of SpaceVim. this includes:
For files not belonging to SpaceVim like local packages and libraries, refer to the header file. Those files should not have an empty header, we may not accept code without a proper header file.
### Bootstrap
Before contributing to SpaceVim, you should know how does SpaceVim bootstrap, here is the logic of the bootstrap when SpaceVim startup.
<!-- TODO -->
### Conventions
SpaceVim is based on conventions, mainly for naming functions, keybindings definition and writing documentation. Please read the [conventions](https://spacevim.org/conventions/) before your first contribution to get to know them.

View File

@ -45,44 +45,44 @@ call SpaceVim#layers#disable('shell')
## Available layers
| Name | Description |
| ---------- | ------------ |
| [autocomplete](https://spacevim.org/layers/autocomplete/) | This layer provides auto-completion to SpaceVim |
| [chat](https://spacevim.org/layers/chat/) | SpaceVim chatting layer provide chatting with qq and weixin in vim. |
| [checkers](https://spacevim.org/layers/checkers/) | This layer provides syntax checking feature |
| [chinese](https://spacevim.org/layers/chinese/) | Layer for chinese users, include chinese docs and runtime messages |
| [colorscheme](https://spacevim.org/layers/colorscheme/) | colorscheme provides a list of colorscheme for SpaceVim, default colorscheme is gruvbox with dark theme. |
| [cscope](https://spacevim.org/layers/cscope/) | This layer provide cscope manager for project |
| [ctrlp](https://spacevim.org/layers/ctrlp/) | This layers adds extensive support for git |
| [debug](https://spacevim.org/layers/debug/) | This layer provide debug workflow support in SpaceVim |
| [default](https://spacevim.org/layers/default/) | lt layer contains none plugins, but it has some better default config for vim and neovim |
| [denite](https://spacevim.org/layers/denite/) | Another Unite centric work-flow which use denite |
| [git](https://spacevim.org/layers/git/) | This layers adds extensive support for git |
| [github](https://spacevim.org/layers/github/) | This layer provides GitHub integration for SpaceVim |
| [index](https://spacevim.org/layers/index/) | list of available layers in SpaceVim |
| [lang#c](https://spacevim.org/layers/lang/c/) | This layer is for c/c++/object-c development |
| [lang#csharp](https://spacevim.org/layers/lang/csharp/) | This layer is for csharp development |
| [lang#dart](https://spacevim.org/layers/lang/dart/) | This layer is for dart development, provide autocompletion, syntax checking, code format for dart file. |
| [lang#elixir](https://spacevim.org/layers/lang/elixir/) | This layer is for elixir development, provide autocompletion, syntax checking, code format for elixir file. |
| [lang#go](https://spacevim.org/layers/lang/go/) | This layer is for golang development. It also provides additional language-specific key mappings. |
| [lang#haskell](https://spacevim.org/layers/lang/haskell/) | This layer is for haskell development |
| [lang#html](https://spacevim.org/layers/lang/html/) | Edit html in SpaceVim, with this layer, this layer provides code completion, syntax checking and code formatting for html. |
| [lang#java](https://spacevim.org/layers/lang/java/) | This layer is for Java development. All the features such as code completion, formatting, syntax checking, REPL and debug have be done in this layer. |
| [lang#javascript](https://spacevim.org/layers/lang/javascript/) | This layer is for JaveScript development |
| [lang#lisp](https://spacevim.org/layers/lang/lisp/) | for lisp development |
| [lang#lua](https://spacevim.org/layers/lang/lua/) | This layer is for lua development, provide autocompletion, syntax checking, code format for lua file. |
| [lang#markdown](https://spacevim.org/layers/lang/markdown/) | Edit markdown within vim, autopreview markdown in the default browser, with this layer you can also format markdown file. |
| [lang#ocaml](https://spacevim.org/layers/lang/ocaml/) | This layer is for Python development, provide autocompletion, syntax checking, code format for ocaml file. |
| [lang#php](https://spacevim.org/layers/lang/php/) | This layer adds PHP language support to SpaceVim |
| [lang#python](https://spacevim.org/layers/lang/python/) | This layer is for Python development, provide autocompletion, syntax checking, code format for python file. |
| [lang#ruby](https://spacevim.org/layers/lang/ruby/) | This layer is for ruby development, provide autocompletion, syntax checking, code format for ruby file. |
| [lang#typescript](https://spacevim.org/layers/lang/typescript/) | This layer is for TypeScript development |
| [lang#vim](https://spacevim.org/layers/lang/vim/) | This layer is for writting vim script, including code completion, syntax checking and buffer formatting |
| [language-server-protocol](https://spacevim.org/layers/language-server-protocol/) | This layers provides language server protocol for vim and neovim |
| [shell](https://spacevim.org/layers/shell/) | This layer provide shell support in SpaceVim |
| [tags](https://spacevim.org/layers/tags/) | This layer provide tags manager for project |
| [tools#dash](https://spacevim.org/layers/tools/dash/) | This layer provides Dash integration for SpaceVim |
| [ui](https://spacevim.org/layers/ui/) | Awesome UI layer for SpaceVim, provide IDE-like UI for neovim and vim in both TUI and GUI |
| Name | Description |
| --------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| [autocomplete](https://spacevim.org/layers/autocomplete/) | This layer provides auto-completion to SpaceVim |
| [chat](https://spacevim.org/layers/chat/) | SpaceVim chatting layer provide chatting with qq and weixin in vim. |
| [checkers](https://spacevim.org/layers/checkers/) | This layer provides syntax checking feature |
| [chinese](https://spacevim.org/layers/chinese/) | Layer for chinese users, include chinese docs and runtime messages |
| [colorscheme](https://spacevim.org/layers/colorscheme/) | colorscheme provides a list of colorscheme for SpaceVim, default colorscheme is gruvbox with dark theme. |
| [cscope](https://spacevim.org/layers/cscope/) | This layer provide cscope manager for project |
| [ctrlp](https://spacevim.org/layers/ctrlp/) | This layers adds extensive support for git |
| [debug](https://spacevim.org/layers/debug/) | This layer provide debug workflow support in SpaceVim |
| [default](https://spacevim.org/layers/default/) | lt layer contains none plugins, but it has some better default config for vim and neovim |
| [denite](https://spacevim.org/layers/denite/) | Another Unite centric work-flow which use denite |
| [git](https://spacevim.org/layers/git/) | This layers adds extensive support for git |
| [github](https://spacevim.org/layers/github/) | This layer provides GitHub integration for SpaceVim |
| [index](https://spacevim.org/layers/index/) | list of available layers in SpaceVim |
| [lang#c](https://spacevim.org/layers/lang/c/) | This layer is for c/c++/object-c development |
| [lang#csharp](https://spacevim.org/layers/lang/csharp/) | This layer is for csharp development |
| [lang#dart](https://spacevim.org/layers/lang/dart/) | This layer is for dart development, provide autocompletion, syntax checking, code format for dart file. |
| [lang#elixir](https://spacevim.org/layers/lang/elixir/) | This layer is for elixir development, provide autocompletion, syntax checking, code format for elixir file. |
| [lang#go](https://spacevim.org/layers/lang/go/) | This layer is for golang development. It also provides additional language-specific key mappings. |
| [lang#haskell](https://spacevim.org/layers/lang/haskell/) | This layer is for haskell development |
| [lang#html](https://spacevim.org/layers/lang/html/) | Edit html in SpaceVim, with this layer, this layer provides code completion, syntax checking and code formatting for html. |
| [lang#java](https://spacevim.org/layers/lang/java/) | This layer is for Java development. All the features such as code completion, formatting, syntax checking, REPL and debug have be done in this layer. |
| [lang#javascript](https://spacevim.org/layers/lang/javascript/) | This layer is for JaveScript development |
| [lang#lisp](https://spacevim.org/layers/lang/lisp/) | for lisp development |
| [lang#lua](https://spacevim.org/layers/lang/lua/) | This layer is for lua development, provide autocompletion, syntax checking, code format for lua file. |
| [lang#markdown](https://spacevim.org/layers/lang/markdown/) | Edit markdown within vim, autopreview markdown in the default browser, with this layer you can also format markdown file. |
| [lang#ocaml](https://spacevim.org/layers/lang/ocaml/) | This layer is for Python development, provide autocompletion, syntax checking, code format for ocaml file. |
| [lang#php](https://spacevim.org/layers/lang/php/) | This layer adds PHP language support to SpaceVim |
| [lang#python](https://spacevim.org/layers/lang/python/) | This layer is for Python development, provide autocompletion, syntax checking, code format for python file. |
| [lang#ruby](https://spacevim.org/layers/lang/ruby/) | This layer is for ruby development, provide autocompletion, syntax checking, code format for ruby file. |
| [lang#typescript](https://spacevim.org/layers/lang/typescript/) | This layer is for TypeScript development |
| [lang#vim](https://spacevim.org/layers/lang/vim/) | This layer is for writting vim script, including code completion, syntax checking and buffer formatting |
| [language-server-protocol](https://spacevim.org/layers/language-server-protocol/) | This layers provides language server protocol for vim and neovim |
| [shell](https://spacevim.org/layers/shell/) | This layer provide shell support in SpaceVim |
| [tags](https://spacevim.org/layers/tags/) | This layer provide tags manager for project |
| [tools#dash](https://spacevim.org/layers/tools/dash/) | This layer provides Dash integration for SpaceVim |
| [ui](https://spacevim.org/layers/ui/) | Awesome UI layer for SpaceVim, provide IDE-like UI for neovim and vim in both TUI and GUI |
<!-- SpaceVim layer list end -->

View File

@ -3,4 +3,4 @@ Execute ( SpaceVim api: SpaceVim main code ):
SPInstall
exe "func! Close() \n qa! \n endf"
call timer_start(2000, 'Close')
AssertEqual fnamemodify(g:Config_Main_Home, ':.'), 'config'
AssertEqual fnamemodify(g:_spacevim_root_dir, ':.'), 'config'