From 3ac76a0ca8d1a8ac68b11dae2393e810e2b33265 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Thu, 22 Feb 2018 21:15:46 +0800 Subject: [PATCH] Better default Fix up Fix up Fix up Fix rtp Update project layout Fix colorscheme layer Add colorsheme close #1308 Close #1307 Set default fillchars Move cache to cache Disable lang layer Remove layers Fix crash ref : https://github.com/neovim/neovim/issues/7876 Fix plugin manager Filter same filename:linenumber in flygrep Fix type --- README.md | 12 +- autoload/SpaceVim.vim | 75 +++++++++- autoload/SpaceVim/api/bash/complete.vim | 2 +- autoload/SpaceVim/api/data/list.vim | 17 +++ autoload/SpaceVim/custom.vim | 4 +- autoload/SpaceVim/default.vim | 48 +++--- autoload/SpaceVim/layers/autocomplete.vim | 2 +- autoload/SpaceVim/layers/colorscheme.vim | 66 ++++----- .../SpaceVim/mapping/guide/theme/SpaceVim.vim | 22 +++ autoload/SpaceVim/plugins/flygrep.vim | 6 + autoload/SpaceVim/plugins/highlight.vim | 2 + autoload/zvim/util.vim | 4 +- codecov.yml | 2 +- colors/SpaceVim.vim | 137 ++++++++++++++++++ config/init.vim | 98 +++++++------ config/main.vim | 65 +-------- config/plugins/neosnippet.vim | 2 +- doc/SpaceVim.cnx | 2 +- doc/SpaceVim.txt | 5 +- docs/development.md | 7 + test/init.vader | 2 +- 21 files changed, 393 insertions(+), 187 deletions(-) create mode 100644 autoload/SpaceVim/mapping/guide/theme/SpaceVim.vim create mode 100644 colors/SpaceVim.vim diff --git a/README.md b/README.md index 90e038a9d..299a1bf51 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/autoload/SpaceVim.vim b/autoload/SpaceVim.vim index 74360891f..053ae4a4e 100644 --- a/autoload/SpaceVim.vim +++ b/autoload/SpaceVim.vim @@ -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,10 +688,59 @@ 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 +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#SetOptions() call SpaceVim#default#SetPlugins() call SpaceVim#default#SetMappings() diff --git a/autoload/SpaceVim/api/bash/complete.vim b/autoload/SpaceVim/api/bash/complete.vim index 67cdcccd5..5119a5363 100644 --- a/autoload/SpaceVim/api/bash/complete.vim +++ b/autoload/SpaceVim/api/bash/complete.vim @@ -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') diff --git a/autoload/SpaceVim/api/data/list.vim b/autoload/SpaceVim/api/data/list.vim index 6cf5e3c20..0d7644ad1 100644 --- a/autoload/SpaceVim/api/data/list.vim +++ b/autoload/SpaceVim/api/data/list.vim @@ -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 diff --git a/autoload/SpaceVim/custom.vim b/autoload/SpaceVim/custom.vim index 9212ea833..8124da0af 100644 --- a/autoload/SpaceVim/custom.vim +++ b/autoload/SpaceVim/custom.vim @@ -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 diff --git a/autoload/SpaceVim/default.vim b/autoload/SpaceVim/default.vim index becc15851..4c5a61430 100644 --- a/autoload/SpaceVim/default.vim +++ b/autoload/SpaceVim/default.vim @@ -7,6 +7,7 @@ "============================================================================= scriptencoding utf-8 +" Default options {{{ function! SpaceVim#default#SetOptions() abort " basic vim settiing if has('gui_running') @@ -31,14 +32,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 +59,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 +85,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,21 +107,24 @@ 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 @@ -133,17 +138,6 @@ function! SpaceVim#default#SetPlugins() abort 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') diff --git a/autoload/SpaceVim/layers/autocomplete.vim b/autoload/SpaceVim/layers/autocomplete.vim index f6c005405..23bf2eaa2 100644 --- a/autoload/SpaceVim/layers/autocomplete.vim +++ b/autoload/SpaceVim/layers/autocomplete.vim @@ -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|. " diff --git a/autoload/SpaceVim/layers/colorscheme.vim b/autoload/SpaceVim/layers/colorscheme.vim index 9e95c5e2f..822ba3ad5 100644 --- a/autoload/SpaceVim/layers/colorscheme.vim +++ b/autoload/SpaceVim/layers/colorscheme.vim @@ -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 diff --git a/autoload/SpaceVim/mapping/guide/theme/SpaceVim.vim b/autoload/SpaceVim/mapping/guide/theme/SpaceVim.vim new file mode 100644 index 000000000..0c10f7cd8 --- /dev/null +++ b/autoload/SpaceVim/mapping/guide/theme/SpaceVim.vim @@ -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 diff --git a/autoload/SpaceVim/plugins/flygrep.vim b/autoload/SpaceVim/plugins/flygrep.vim index e84d6e022..a66aab532 100644 --- a/autoload/SpaceVim/plugins/flygrep.vim +++ b/autoload/SpaceVim/plugins/flygrep.vim @@ -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 diff --git a/autoload/SpaceVim/plugins/highlight.vim b/autoload/SpaceVim/plugins/highlight.vim index ab0595949..e5a0f0e15 100644 --- a/autoload/SpaceVim/plugins/highlight.vim +++ b/autoload/SpaceVim/plugins/highlight.vim @@ -347,3 +347,5 @@ function! s:find_func_range() abort return [line, line] endfunction " }}} + +" vim:set et sw=2 cc=80 foldenable: diff --git a/autoload/zvim/util.vim b/autoload/zvim/util.vim index abc0df5cc..0e6cdb1bb 100644 --- a/autoload/zvim/util.vim +++ b/autoload/zvim/util.vim @@ -26,8 +26,8 @@ fu! zvim#util#defineMap(type,key,value,desc,...) abort endf fu! zvim#util#source_rc(file) abort - if filereadable(g:Config_Main_Home. '/' . a:file) - execute 'source ' . g:Config_Main_Home . '/' . a:file + if filereadable(g:_spacevim_root_dir. '/' . a:file) + execute 'source ' . g:_spacevim_root_dir . '/' . a:file endif endf diff --git a/codecov.yml b/codecov.yml index d05a32202..cd6ba3544 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,5 +1,5 @@ coverage: - range: 50..70 + range: 30..60 round: down precision: 2 comment: diff --git a/colors/SpaceVim.vim b/colors/SpaceVim.vim new file mode 100644 index 000000000..086def607 --- /dev/null +++ b/colors/SpaceVim.vim @@ -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 diff --git a/config/init.vim b/config/init.vim index b6381985d..2d26e044f 100644 --- a/config/init.vim +++ b/config/init.vim @@ -1,69 +1,71 @@ +"============================================================================= +" 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 " 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 WINDOWS() + silent exec 'lan mes en_US.UTF-8' + elseif OSX() + 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 + " 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 - - diff --git a/config/main.vim b/config/main.vim index 655a048c7..2eb2c5a79 100644 --- a/config/main.vim +++ b/config/main.vim @@ -6,71 +6,20 @@ " License: GPLv3 "============================================================================= -let g:Config_Main_Home = fnamemodify(expand(''), +" Detect root directory of SpaceVim +let g:_spacevim_root_dir = fnamemodify(expand(''), \ ':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: diff --git a/config/plugins/neosnippet.vim b/config/plugins/neosnippet.vim index a490e3ae8..ff6b94e37 100644 --- a/config/plugins/neosnippet.vim +++ b/config/plugins/neosnippet.vim @@ -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 = diff --git a/doc/SpaceVim.cnx b/doc/SpaceVim.cnx index 7a18e6375..30812e9e5 100644 --- a/doc/SpaceVim.cnx +++ b/doc/SpaceVim.cnx @@ -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|. diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 668a533e0..99f265e2c 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -77,6 +77,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 +588,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|. diff --git a/docs/development.md b/docs/development.md index d83b175e1..5a95e7e38 100644 --- a/docs/development.md +++ b/docs/development.md @@ -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. + + + ### 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. diff --git a/test/init.vader b/test/init.vader index 36d875427..04862e559 100644 --- a/test/init.vader +++ b/test/init.vader @@ -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'