From 921382735480153a6348a1c680fe2e917613c3ad Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Thu, 29 Dec 2016 18:53:29 +0800 Subject: [PATCH] Fix #4 --- README.md | 186 +++++++++++++++++++------------------ autoload/SpaceVim.vim | 111 +++++++++++++++++++++- autoload/SpaceVim/util.vim | 7 ++ config/functions.vim | 31 ------- config/init.vim | 101 -------------------- config/main.vim | 2 + 6 files changed, 210 insertions(+), 228 deletions(-) create mode 100644 autoload/SpaceVim/util.vim diff --git a/README.md b/README.md index 51a56205f..833311148 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Like spacemacs, but for vim. ## Features - Neovim-centric -- Robust, yet light weight +- [Modular configuration](#modular-configuration) - Lazy-load 90% of plugins with [dein.vim] -- Modular configuration +- Robust, yet light weight - Unite centric work-flow - Extensive Neocomplete setup - Central location for tags @@ -192,96 +192,6 @@ Name | Description [textobj-user] | Create your own text objects [textobj-multiblock] | Handle multiple brackets objects -[dein.vim]: https://github.com/Shougo/dein.vim -[vimproc]: https://github.com/Shougo/vimproc.vim -[colorschemes]: https://github.com/rafi/awesome-vim-colorschemes -[file-line]: https://github.com/bogado/file-line -[neomru]: https://github.com/Shougo/neomru.vim -[cursorword]: https://github.com/itchyny/vim-cursorword -[gitbranch]: https://github.com/itchyny/vim-gitbranch -[gitgutter]: https://github.com/airblade/vim-gitgutter -[bookmarks]: https://github.com/MattesGroeger/vim-bookmarks -[tmux-navigator]: https://github.com/christoomey/vim-tmux-navigator -[tinyline]: https://github.com/rafi/vim-tinyline -[tagabana]: https://github.com/rafi/vim-tagabana - -[html5]: https://github.com/othree/html5.vim -[mustache]: https://github.com/mustache/vim-mustache-handlebars -[markdown]: https://github.com/rcmdnk/vim-markdown -[ansible-yaml]: https://github.com/chase/vim-ansible-yaml -[jinja]: https://github.com/mitsuhiko/vim-jinja -[less]: https://github.com/groenewege/vim-less -[css3-syntax]: https://github.com/hail2u/vim-css3-syntax -[csv]: https://github.com/chrisbra/csv.vim -[pep8-indent]: https://github.com/hynek/vim-python-pep8-indent -[logstash]: https://github.com/robbles/logstash.vim -[tmux]: https://github.com/tmux-plugins/vim-tmux -[json]: https://github.com/elzr/vim-json -[toml]: https://github.com/cespare/vim-toml -[i3]: https://github.com/PotatoesMaster/i3-vim-syntax -[Dockerfile]: https://github.com/ekalinin/Dockerfile.vim -[go]: https://github.com/fatih/vim-go -[jedi-vim]: https://github.com/davidhalter/jedi-vim -[ruby]: https://github.com/vim-ruby/vim-ruby -[portfile]: https://github.com/jstrater/mpvim - -[javascript]: https://github.com/jelera/vim-javascript-syntax -[javascript-indent]: https://github.com/jiangmiao/simple-javascript-indenter -[tern]: https://github.com/marijnh/tern_for_vim - -[php]: https://github.com/StanAngeloff/php.vim -[phpfold]: https://github.com/rayburgemeestre/phpfolding.vim -[phpcomplete]: https://github.com/shawncplus/phpcomplete.vim -[phpindent]: https://github.com/2072/PHP-Indenting-for-VIm -[phpspec]: https://github.com/rafi/vim-phpspec - -[vimfiler]: https://github.com/Shougo/vimfiler.vim -[tinycomment]: https://github.com/rafi/vim-tinycomment -[vinarise]: https://github.com/Shougo/vinarise.vim -[syntastic]: https://github.com/scrooloose/syntastic -[gita]: https://github.com/lambdalisue/vim-gita -[gista]: https://github.com/lambdalisue/vim-gista -[undotree]: https://github.com/mbbill/undotree -[incsearch]: https://github.com/haya14busa/incsearch.vim -[expand-region]: https://github.com/terryma/vim-expand-region -[open-browser]: https://github.com/tyru/open-browser.vim -[prettyprint]: https://github.com/thinca/vim-prettyprint -[quickrun]: https://github.com/thinca/vim-quickrun -[ref]: https://github.com/thinca/vim-ref -[dictionary]: https://github.com/itchyny/dictionary.vim -[vimwiki]: https://github.com/vimwiki/vimwiki -[thesaurus]: https://github.com/beloglazov/vim-online-thesaurus - -[goyo]: https://github.com/junegunn/goyo.vim -[limelight]: https://github.com/junegunn/limelight.vim -[matchit]: http://www.vim.org/scripts/script.php?script_id=39 -[indentline]: https://github.com/Yggdroot/indentLine -[choosewin]: https://github.com/t9md/vim-choosewin - -[delimitmate]: https://github.com/Raimondi/delimitMate -[echodoc]: https://github.com/Shougo/echodoc.vim -[deoplete]: https://github.com/Shougo/deoplete.nvim -[neocomplete]: https://github.com/Shougo/neocomplete.vim -[neosnippet]: https://github.com/Shougo/neosnippet.vim - -[unite]: https://github.com/Shougo/unite.vim -[unite-colorscheme]: https://github.com/ujihisa/unite-colorscheme -[unite-filetype]: https://github.com/osyo-manga/unite-filetype -[unite-history]: https://github.com/thinca/vim-unite-history -[unite-build]: https://github.com/Shougo/unite-build -[unite-outline]: https://github.com/h1mesuke/unite-outline -[unite-tag]: https://github.com/tsukkee/unite-tag -[unite-quickfix]: https://github.com/osyo-manga/unite-quickfix -[neossh]: https://github.com/Shougo/neossh.vim -[unite-pull-request]: https://github.com/joker1007/unite-pull-request -[junkfile]: https://github.com/Shougo/junkfile.vim -[unite-issue]: https://github.com/rafi/vim-unite-issue - -[operator-user]: https://github.com/kana/vim-operator-user -[operator-replace]: https://github.com/kana/vim-operator-replace -[operator-surround]: https://github.com/rhysd/vim-operator-surround -[textobj-user]: https://github.com/kana/vim-textobj-user -[textobj-multiblock]: https://github.com/osyo-manga/vim-textobj-multiblock ## Custom Key bindings @@ -501,3 +411,95 @@ Key | Mode | Action ``+`K` | Normal | Thesaurus ## Enjoy! + + +[dein.vim]: https://github.com/Shougo/dein.vim +[vimproc]: https://github.com/Shougo/vimproc.vim +[colorschemes]: https://github.com/rafi/awesome-vim-colorschemes +[file-line]: https://github.com/bogado/file-line +[neomru]: https://github.com/Shougo/neomru.vim +[cursorword]: https://github.com/itchyny/vim-cursorword +[gitbranch]: https://github.com/itchyny/vim-gitbranch +[gitgutter]: https://github.com/airblade/vim-gitgutter +[bookmarks]: https://github.com/MattesGroeger/vim-bookmarks +[tmux-navigator]: https://github.com/christoomey/vim-tmux-navigator +[tinyline]: https://github.com/rafi/vim-tinyline +[tagabana]: https://github.com/rafi/vim-tagabana + +[html5]: https://github.com/othree/html5.vim +[mustache]: https://github.com/mustache/vim-mustache-handlebars +[markdown]: https://github.com/rcmdnk/vim-markdown +[ansible-yaml]: https://github.com/chase/vim-ansible-yaml +[jinja]: https://github.com/mitsuhiko/vim-jinja +[less]: https://github.com/groenewege/vim-less +[css3-syntax]: https://github.com/hail2u/vim-css3-syntax +[csv]: https://github.com/chrisbra/csv.vim +[pep8-indent]: https://github.com/hynek/vim-python-pep8-indent +[logstash]: https://github.com/robbles/logstash.vim +[tmux]: https://github.com/tmux-plugins/vim-tmux +[json]: https://github.com/elzr/vim-json +[toml]: https://github.com/cespare/vim-toml +[i3]: https://github.com/PotatoesMaster/i3-vim-syntax +[Dockerfile]: https://github.com/ekalinin/Dockerfile.vim +[go]: https://github.com/fatih/vim-go +[jedi-vim]: https://github.com/davidhalter/jedi-vim +[ruby]: https://github.com/vim-ruby/vim-ruby +[portfile]: https://github.com/jstrater/mpvim + +[javascript]: https://github.com/jelera/vim-javascript-syntax +[javascript-indent]: https://github.com/jiangmiao/simple-javascript-indenter +[tern]: https://github.com/marijnh/tern_for_vim + +[php]: https://github.com/StanAngeloff/php.vim +[phpfold]: https://github.com/rayburgemeestre/phpfolding.vim +[phpcomplete]: https://github.com/shawncplus/phpcomplete.vim +[phpindent]: https://github.com/2072/PHP-Indenting-for-VIm +[phpspec]: https://github.com/rafi/vim-phpspec + +[vimfiler]: https://github.com/Shougo/vimfiler.vim +[tinycomment]: https://github.com/rafi/vim-tinycomment +[vinarise]: https://github.com/Shougo/vinarise.vim +[syntastic]: https://github.com/scrooloose/syntastic +[gita]: https://github.com/lambdalisue/vim-gita +[gista]: https://github.com/lambdalisue/vim-gista +[undotree]: https://github.com/mbbill/undotree +[incsearch]: https://github.com/haya14busa/incsearch.vim +[expand-region]: https://github.com/terryma/vim-expand-region +[open-browser]: https://github.com/tyru/open-browser.vim +[prettyprint]: https://github.com/thinca/vim-prettyprint +[quickrun]: https://github.com/thinca/vim-quickrun +[ref]: https://github.com/thinca/vim-ref +[dictionary]: https://github.com/itchyny/dictionary.vim +[vimwiki]: https://github.com/vimwiki/vimwiki +[thesaurus]: https://github.com/beloglazov/vim-online-thesaurus + +[goyo]: https://github.com/junegunn/goyo.vim +[limelight]: https://github.com/junegunn/limelight.vim +[matchit]: http://www.vim.org/scripts/script.php?script_id=39 +[indentline]: https://github.com/Yggdroot/indentLine +[choosewin]: https://github.com/t9md/vim-choosewin + +[delimitmate]: https://github.com/Raimondi/delimitMate +[echodoc]: https://github.com/Shougo/echodoc.vim +[deoplete]: https://github.com/Shougo/deoplete.nvim +[neocomplete]: https://github.com/Shougo/neocomplete.vim +[neosnippet]: https://github.com/Shougo/neosnippet.vim + +[unite]: https://github.com/Shougo/unite.vim +[unite-colorscheme]: https://github.com/ujihisa/unite-colorscheme +[unite-filetype]: https://github.com/osyo-manga/unite-filetype +[unite-history]: https://github.com/thinca/vim-unite-history +[unite-build]: https://github.com/Shougo/unite-build +[unite-outline]: https://github.com/h1mesuke/unite-outline +[unite-tag]: https://github.com/tsukkee/unite-tag +[unite-quickfix]: https://github.com/osyo-manga/unite-quickfix +[neossh]: https://github.com/Shougo/neossh.vim +[unite-pull-request]: https://github.com/joker1007/unite-pull-request +[junkfile]: https://github.com/Shougo/junkfile.vim +[unite-issue]: https://github.com/rafi/vim-unite-issue + +[operator-user]: https://github.com/kana/vim-operator-user +[operator-replace]: https://github.com/kana/vim-operator-replace +[operator-surround]: https://github.com/rhysd/vim-operator-surround +[textobj-user]: https://github.com/kana/vim-textobj-user +[textobj-multiblock]: https://github.com/osyo-manga/vim-textobj-multiblock diff --git a/autoload/SpaceVim.vim b/autoload/SpaceVim.vim index 9be753983..210064a9d 100644 --- a/autoload/SpaceVim.vim +++ b/autoload/SpaceVim.vim @@ -1,18 +1,121 @@ +scriptencoding utf-8 function! SpaceVim#init() abort - + "Vim settings + let g:settings = get(g:, 'settings', {}) + let g:settings.default_indent = 2 + let g:settings.max_column = 120 + let g:settings.enable_googlesuggest = 0 + let g:settings.auto_download_neobundle = 0 + let g:settings.neobundle_installed = 0 + let g:settings.dein_installed = 0 + let g:settings.vim_plug_installed = 0 + let g:settings.plugin_bundle_dir = $HOME. join(['', '.cache', 'vimfiles', ''], '/') + let g:settings.autocomplete_method = '' + let g:settings.enable_cursorcolumn = 0 + let g:settings.enable_neomake = 1 + let g:settings.enable_ycm = 0 + let g:settings.enable_neocomplcache = 0 + let g:settings.enable_cursorline = 0 + let g:settings.error_symbol = '✖' + let g:settings.warning_symbol = '⚠' + let g:settings.use_colorscheme = 1 + let g:settings.vim_help_language = 'en' + let g:settings.colorscheme = 'gruvbox' + let g:settings.colorscheme_default = 'desert' + let g:settings.filemanager = 'vimfiler' + let g:settings.plugin_manager = 'dein' " neobundle or dein or vim-plug + let g:settings.checkinstall = 0 + let g:settings.hiddenfileinfo = 1 + let g:settings.plugin_groups_exclude = [] + let g:settings.plugin_groups = [] + let g:settings.smartcloseignorewin = ['__Tagbar__' , 'vimfiler:default'] + let g:settings.smartcloseignoreft = ['help'] + let g:settings.altmoveignoreft = ['Tagbar' , 'vimfiler'] + let g:settings.enable_javacomplete2_py = 0 + let g:settings.src_root = 'E:\sources\' + let g:settings.hosts_url = 'https://raw.githubusercontent.com/racaljk/hosts/master/hosts' + let g:settings.wildignore = '*/tmp/*,*.so,*.swp,*.zip,*.class,tags,*.jpg, + \*.ttf,*.TTF,*.png,*/target/*, + \.git,.svn,.hg,.DS_Store' + endfunction function! SpaceVim#loadCustomConfig() abort - let custom_confs = globpath(getcwd(), '.local.vim', 1,1) + let custom_confs = SpaceVim#util#globpath(getcwd(), '.local.vim') if !empty(custom_confs) exe 'source ' . custom_confs[0] endif endfunction function! SpaceVim#Layer(layer, opt) abort - + endfunction function! SpaceVim#end() abort - + for s:group in g:settings.plugin_groups_exclude + let s:i = index(g:settings.plugin_groups, s:group) + if s:i != -1 + call remove(g:settings.plugin_groups, s:i) + endif + endfor + if g:settings.vim_help_language ==# 'cn' + call add(g:settings.plugin_groups, 'chinese') + endif + if g:settings.use_colorscheme==1 + call add(g:settings.plugin_groups, 'colorscheme') + endif + + if has('nvim') + let g:settings.autocomplete_method = 'deoplete' + elseif has('lua') + let g:settings.autocomplete_method = 'neocomplete' + else + let g:settings.autocomplete_method = 'neocomplcache' + endif + if g:settings.enable_ycm + let g:settings.autocomplete_method = 'ycm' + endif + if g:settings.enable_neocomplcache + let g:settings.autocomplete_method = 'neocomplcache' + endif +endfunction + + +function! SpaceVim#default() abort + call add(g:settings.plugin_groups, 'web') + call add(g:settings.plugin_groups, 'javascript') + call add(g:settings.plugin_groups, 'ruby') + call add(g:settings.plugin_groups, 'python') + call add(g:settings.plugin_groups, 'scala') + call add(g:settings.plugin_groups, 'go') + call add(g:settings.plugin_groups, 'scm') + call add(g:settings.plugin_groups, 'editing') + call add(g:settings.plugin_groups, 'indents') + call add(g:settings.plugin_groups, 'navigation') + call add(g:settings.plugin_groups, 'misc') + + call add(g:settings.plugin_groups, 'core') + call add(g:settings.plugin_groups, 'unite') + if has('python3') + call add(g:settings.plugin_groups, 'denite') + endif + call add(g:settings.plugin_groups, 'ctrlp') + call add(g:settings.plugin_groups, 'autocomplete') + if ! has('nvim') + call add(g:settings.plugin_groups, 'vim') + else + call add(g:settings.plugin_groups, 'nvim') + endif + if OSX() + call add(g:settings.plugin_groups, 'osx') + endif + if WINDOWS() + call add(g:settings.plugin_groups, 'windows') + endif + if LINUX() + call add(g:settings.plugin_groups, 'linux') + endif +endfunction + +function! SpaceVim#defindFuncs() abort endfunction diff --git a/autoload/SpaceVim/util.vim b/autoload/SpaceVim/util.vim new file mode 100644 index 000000000..b6bfad708 --- /dev/null +++ b/autoload/SpaceVim/util.vim @@ -0,0 +1,7 @@ +function! SpaceVim#util#globpath(path, expr) abort + if has('patch-7.4.279') + return globpath(a:path, a:expr, 1, 1) + else + return split(globpath(a:path, a:expr), '\n') + endif +endfunction diff --git a/config/functions.vim b/config/functions.vim index 38424ac05..a2c7077e7 100644 --- a/config/functions.vim +++ b/config/functions.vim @@ -144,21 +144,6 @@ function! MyTagfuncBack() abort endif endfunction -function! MyEnterfunc() abort - if pumvisible() - if getline('.')[col('.') - 2]=="{" - return "\" - elseif g:settings.autocomplete_method == 'neocomplete'||g:settings.autocomplete_method == 'deoplete' - return "\" - else - return "\a" - endif - elseif getline('.')[col('.') - 2]=="{"&&getline('.')[col('.')-1]=="}" - return "\\ko" - else - return "\" - endif -endf function! MyLeaderTabfunc() abort if g:settings.autocomplete_method == 'deoplete' @@ -172,22 +157,6 @@ function! MyLeaderTabfunc() abort endif endfunction -function! MyTabfunc() abort - if getline('.')[col('.')-2] =='{'&& pumvisible() - return "\" - endif - if neosnippet#expandable() && getline('.')[col('.')-2] =='(' && !pumvisible() - return "\(neosnippet_expand)" - elseif neosnippet#jumpable() && getline('.')[col('.')-2] =='(' && !pumvisible() && !neosnippet#expandable() - return "\(neosnippet_jump)" - elseif neosnippet#expandable_or_jumpable() && getline('.')[col('.')-2] !='(' - return "\(neosnippet_expand_or_jump)" - elseif pumvisible() - return "\" - else - return "\" - endif -endfunction func! Openpluginrepo() try exec "normal! ".'"ayi'."'" diff --git a/config/init.vim b/config/init.vim index 0c3a4d007..1d4e986b7 100644 --- a/config/init.vim +++ b/config/init.vim @@ -59,107 +59,6 @@ if $COLORTERM ==# 'gnome-terminal' set t_Co=256 endif -"Vim settings -let g:settings = get(g:, 'settings', {}) -let g:settings.default_indent = 2 -let g:settings.max_column = 120 -let g:settings.enable_googlesuggest = 0 -let g:settings.auto_download_neobundle = 0 -let g:settings.neobundle_installed = 0 -let g:settings.dein_installed = 0 -let g:settings.vim_plug_installed = 0 -let g:settings.plugin_bundle_dir = $HOME. join(['', '.cache', 'vimfiles', ''],s:Fsep) -let g:settings.autocomplete_method = '' -let g:settings.enable_cursorcolumn = 0 -let g:settings.enable_neomake = 1 -let g:settings.enable_ycm = 0 -let g:settings.enable_neocomplcache = 0 -let g:settings.enable_cursorline = 0 -let g:settings.error_symbol = '✖' -let g:settings.warning_symbol = '⚠' -let g:settings.use_colorscheme = 1 -let g:settings.vim_help_language = 'en' -let g:settings.colorscheme = 'gruvbox' -let g:settings.colorscheme_default = 'desert' -let g:settings.filemanager = 'vimfiler' -let g:settings.plugin_manager = 'dein' " neobundle or dein or vim-plug -let g:settings.checkinstall = 0 -let g:settings.hiddenfileinfo = 1 -let g:settings.plugin_groups_exclude = [] -let g:settings.smartcloseignorewin = ['__Tagbar__' , 'vimfiler:default'] -let g:settings.smartcloseignoreft = ['help'] -let g:settings.altmoveignoreft = ['Tagbar' , 'vimfiler'] -let g:settings.enable_javacomplete2_py = 0 -let g:settings.src_root = 'E:\sources\' -let g:settings.hosts_url = 'https://raw.githubusercontent.com/racaljk/hosts/master/hosts' -let g:settings.wildignore = '*/tmp/*,*.so,*.swp,*.zip,*.class,tags,*.jpg, - \*.ttf,*.TTF,*.png,*/target/*, - \.git,.svn,.hg,.DS_Store' - -"core vimrc -let g:settings.plugin_groups = [] -call add(g:settings.plugin_groups, 'web') -call add(g:settings.plugin_groups, 'javascript') -call add(g:settings.plugin_groups, 'ruby') -call add(g:settings.plugin_groups, 'python') -call add(g:settings.plugin_groups, 'scala') -call add(g:settings.plugin_groups, 'go') -call add(g:settings.plugin_groups, 'scm') -call add(g:settings.plugin_groups, 'editing') -call add(g:settings.plugin_groups, 'indents') -call add(g:settings.plugin_groups, 'navigation') -call add(g:settings.plugin_groups, 'misc') - -call add(g:settings.plugin_groups, 'core') -call add(g:settings.plugin_groups, 'unite') -if has('python3') - call add(g:settings.plugin_groups, 'denite') -endif -call add(g:settings.plugin_groups, 'ctrlp') -call add(g:settings.plugin_groups, 'autocomplete') -if ! has('nvim') - call add(g:settings.plugin_groups, 'vim') -else - call add(g:settings.plugin_groups, 'nvim') -endif - - -if g:settings.vim_help_language ==# 'cn' - call add(g:settings.plugin_groups, 'chinese') -endif -if g:settings.use_colorscheme==1 - call add(g:settings.plugin_groups, 'colorscheme') -endif -if OSX() - call add(g:settings.plugin_groups, 'osx') -endif -if WINDOWS() - call add(g:settings.plugin_groups, 'windows') -endif -if LINUX() - call add(g:settings.plugin_groups, 'linux') -endif - -if has('nvim') - let g:settings.autocomplete_method = 'deoplete' -elseif has('lua') - let g:settings.autocomplete_method = 'neocomplete' -else - let g:settings.autocomplete_method = 'neocomplcache' -endif -if g:settings.enable_ycm - let g:settings.autocomplete_method = 'ycm' -endif -if g:settings.enable_neocomplcache - let g:settings.autocomplete_method = 'neocomplcache' -endif - -for s:group in g:settings.plugin_groups_exclude - let s:i = index(g:settings.plugin_groups, s:group) - if s:i != -1 - call remove(g:settings.plugin_groups, s:i) - endif -endfor " python host for neovim let g:python_host_prog = '/usr/bin/python2' diff --git a/config/main.vim b/config/main.vim index 6fddd5042..df321c8a1 100644 --- a/config/main.vim +++ b/config/main.vim @@ -1,4 +1,5 @@ let g:Config_Main_Home = fnamemodify(expand(''), ':p:h:gs?\\?'.((has('win16') || has('win32') || has('win64'))?'\':'/') . '?') + try call zvim#util#source_rc('functions.vim') catch @@ -10,6 +11,7 @@ call SpaceVim#init() call zvim#util#source_rc('init.vim') +call SpaceVim#default() call SpaceVim#loadCustomConfig()