Skip to content

Commit

Permalink
Speed up radically (liuchengxu#242)
Browse files Browse the repository at this point in the history
* Speed up startup radically

* Remove immature menu.vim

* Rename some variables

* Defer python

* Defer better-defaults

* Defer programming

* Do not load all the markdown plugins

The vim-markdown plugins really costs much to load. I can do nothing but
only using timer to load vim-markdown, leaving markdown-down-toc and
markdown-preview.vim on-demand loading.

* Increase markdown timer delay
  • Loading branch information
liuchengxu authored Dec 8, 2017
1 parent 6dd173d commit 51d367f
Show file tree
Hide file tree
Showing 16 changed files with 117 additions and 33 deletions.
1 change: 1 addition & 0 deletions core/autoload/spacevim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ let g:spacevim_layers_dir = '/layers'
let g:spacevim_private_layers_dir = '/private'
let g:spacevim_nvim = has('nvim') && exists('*jobwait') && !g:WINDOWS
let g:spacevim_vim8 = exists('*job_start')
let g:spacevim_timer = exists('*timer_start')
let g:spacevim_gui = has('gui_running')
let g:spacevim_tmux = !empty($TMUX)

Expand Down
30 changes: 27 additions & 3 deletions core/autoload/spacevim/defer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ function! spacevim#defer#git(timer) abort
GitGutterEnable
endfunction

function! spacevim#defer#signature(timer) abort
function! spacevim#defer#defaults(timer) abort
call plug#load('vim-signature')
call plug#load('vim-rsi')
call plug#load('vim-choosewin')
call plug#load('vim_current_word')
endfunction

function! spacevim#defer#programming(timer) abort
call plug#load('rainbow')
call plug#load('vim-polyglot')
endfunction

function! spacevim#defer#motion(timer) abort
Expand All @@ -24,6 +32,22 @@ endfunction

function! spacevim#defer#markdown(timer) abort
call plug#load('vim-markdown')
call plug#load('vim-markdown-toc')
call plug#load('markdown-preview.vim')
endfunction

function! spacevim#defer#fzf(timer) abort
call plug#load('fzf')
call plug#load('fzf.vim')
endfunction

function! spacevim#defer#rust(timer) abort
call plug#load('rust.vim')
endfunction

function! spacevim#defer#go(timer) abort
call plug#load('vim-go')
endfunction

function! spacevim#defer#python(timer) abort
call plug#load('python-mode')
call plug#load('SimpylFold')
endfunction
7 changes: 7 additions & 0 deletions core/ftplugin/go.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
nmap <buffer> <LocalLeader>b :<C-U>call spacevim#lang#go#BuildGoFiles()<CR>
nmap <buffer> <LocalLeader>r <Plug>(go-run)
nmap <buffer> <LocalLeader>t <Plug>(go-test)
if !exists('g:spacevim_go_loaded')
if g:spacevim_timer
call timer_start(300, 'spacevim#defer#go')
endif
let g:spacevim_go_loaded = 1
endif
8 changes: 5 additions & 3 deletions core/ftplugin/markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ if spacevim#LayerLoaded('text-align')
nnoremap <buffer> <LocalLeader>ta :Tabularize /<Bar><CR>
endif

if !has('g:spacevim_markdown')
silent! call timer_start(200, 'spacevim#defer#markdown')
let g:spacevim_markdown = 1
if !has('g:spacevim_markdown_loaded')
if g:spacevim_timer
call timer_start(1300, 'spacevim#defer#markdown')
endif
let g:spacevim_markdown_loaded = 1
endif
7 changes: 7 additions & 0 deletions core/ftplugin/python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ nnoremap <buffer> <F5> :<C-U>call spacevim#lang#python#run()<CR>
nnoremap <buffer> <LocalLeader>= :<C-U>call spacevim#lang#python#fmt()<CR>
nnoremap <buffer> <LocalLeader>cc :<C-U>call spacevim#lang#python#run()<CR>
nnoremap <buffer> <LocalLeader>cs :<C-U>call spacevim#lang#python#stop()<CR>
if !exists('g:spacevim_python_loaded')
if g:spacevim_timer
call timer_start(300, 'spacevim#defer#python')
endif
let g:spacevim_python_loaded = 1
endif
8 changes: 8 additions & 0 deletions core/ftplugin/rust.vim
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
nnoremap <buffer> <LocalLeader>r :<C-U>call spacevim#lang#rust#Run()<CR>
nnoremap <buffer> <LocalLeader>b :<C-U>call spacevim#lang#rust#Build()<CR>
nnoremap <buffer> <LocalLeader>= :RustFmt<CR>
if !exists('g:spacevim_rust_loaded')
if g:spacevim_timer
call timer_start(300, 'spacevim#defer#rust')
endif
let g:spacevim_rust_loaded = 1
endif
24 changes: 12 additions & 12 deletions layers/+distributions/better-defaults/packages.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@
" Plug 'ybian/smartim'
" endif

MP 'tpope/vim-rsi'

MP 't9md/vim-choosewin'
if g:spacevim_timer
MP 'kshenoy/vim-signature' , { 'on': [] }
MP 'tpope/vim-rsi' , { 'on': [] }
MP 't9md/vim-choosewin' , { 'on': [] }
MP 'dominikduda/vim_current_word' , { 'on': [] }
call timer_start(500, 'spacevim#defer#defaults')
else
MP 'tpope/vim-rsi'
MP 't9md/vim-choosewin'
MP 'kshenoy/vim-signature'
MP 'dominikduda/vim_current_word'
endif

MP 'mhinz/vim-startify', { 'on': 'Startify' }
augroup spacevimStart
Expand All @@ -16,8 +25,6 @@ augroup spacevimStart
\| endif
augroup END

MP 'dominikduda/vim_current_word'

" Bug here.
" MP 'kana/vim-operator-user', { 'on': '<Plug>(operator-flashy)' }
" MP 'haya14busa/vim-operator-flashy', { 'on': '<Plug>(operator-flashy)' }
Expand All @@ -42,10 +49,3 @@ else
\ }
endif
endif

if g:spacevim_vim8 || g:spacevim_nvim
MP 'kshenoy/vim-signature', { 'on': [] }
call timer_start(500, 'spacevim#defer#signature')
else
MP 'kshenoy/vim-signature'
endif
6 changes: 5 additions & 1 deletion layers/+lang/go/packages.vim
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
MP 'fatih/vim-go', { 'for': 'go', 'do': ':GoInstallBinaries' }
if g:spacevim_timer
MP 'fatih/vim-go', { 'on': [], 'do': ':GoInstallBinaries' }
else
MP 'fatih/vim-go', { 'for': 'go', 'do': ':GoInstallBinaries' }
endif
9 changes: 4 additions & 5 deletions layers/+lang/markdown/packages.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
if g:spacevim_vim8 || g:spacevim_nvim
if g:spacevim_timer
MP 'plasticboy/vim-markdown', { 'on': [] }
MP 'mzlogin/vim-markdown-toc', { 'on': [] }
MP 'iamcco/markdown-preview.vim', { 'on': [] }
else
MP 'plasticboy/vim-markdown', { 'for': 'markdown' }
MP 'mzlogin/vim-markdown-toc', { 'for': 'markdown' }
MP 'iamcco/markdown-preview.vim', { 'on': 'MarkdownPreview' }
endif

MP 'mzlogin/vim-markdown-toc', { 'on': ['GenTocGFM', 'GenTocRedcarpet', 'GenTocGitLab'] }
MP 'iamcco/markdown-preview.vim', { 'on': ['MarkdownPreview'] }
9 changes: 7 additions & 2 deletions layers/+lang/python/packages.vim
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
MP 'tmhedberg/SimpylFold', { 'for': 'python' }
MP 'python-mode/python-mode', { 'for': 'python' }
if g:spacevim_timer
MP 'tmhedberg/SimpylFold', { 'on': [] }
MP 'python-mode/python-mode', { 'on': [] }
else
MP 'tmhedberg/SimpylFold', { 'for': 'python' }
MP 'python-mode/python-mode', { 'for': 'python' }
endif
6 changes: 5 additions & 1 deletion layers/+lang/rust/packages.vim
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
MP 'rust-lang/rust.vim'
if g:spacevim_timer
MP 'rust-lang/rust.vim', { 'on': [] }
else
MP 'rust-lang/rust.vim', { 'for': 'rust' }
endif
10 changes: 10 additions & 0 deletions layers/+programming/editing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
## Table of Contents

<!-- vim-markdown-toc GFM -->

* [Description](#description)
* [Install](#install)
* [Related Projects](#related-projects)
* [Comment](#comment)

<!-- vim-markdown-toc -->

Expand All @@ -15,3 +18,10 @@ This layer adds support for more effective editing.
## Install

To use this configuration layer, add it to your `~/.spacevim`.

## Related Projects

### Comment

- [caw.vim](https://github.com/tyru/caw.vim)
- [nerdcommenter](https://github.com/scrooloose/nerdcommenter)
12 changes: 9 additions & 3 deletions layers/+programming/programming/packages.vim
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
MP 'luochen1990/rainbow'
if g:spacevim_timer
MP 'luochen1990/rainbow', { 'on': [] }
MP 'sheerun/vim-polyglot', { 'on': [] }
call timer_start(300, 'spacevim#defer#programming')
else
MP 'luochen1990/rainbow'
MP 'sheerun/vim-polyglot'
endif

MP 'editorconfig/editorconfig-vim', { 'on': 'EditorConfigReload' }

MP 'matze/vim-move', { 'on': [
Expand All @@ -19,5 +27,3 @@ MP 'Yggdroot/indentLine', { 'on': 'IndentLinesToggle' }
MP 'nathanaelkane/vim-indent-guides', { 'on': 'IndentGuidesToggle' }

MP 'skywind3000/asyncrun.vim', { 'on': ['AsyncRun!', 'AsyncRun'] }

MP 'sheerun/vim-polyglot'
9 changes: 8 additions & 1 deletion layers/+tools/fzf/packages.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
if g:spacevim_gui && !has('terminal')
MP 'Yggdroot/LeaderF'
else
MP 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | MP 'junegunn/fzf.vim'
if g:spacevim_timer
MP 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all', 'on': [] }
MP 'junegunn/fzf.vim', { 'on': [] }
call timer_start(700, 'spacevim#defer#fzf')
else
MP 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
MP 'junegunn/fzf.vim'
endif
MP 'tweekmonster/fzf-filemru', { 'on': 'ProjectMru' }
endif
2 changes: 1 addition & 1 deletion layers/+version-control/git/packages.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MP 'junegunn/gv.vim', { 'on': ['GV', 'GV!'] }

if g:spacevim_vim8 || g:spacevim_nvim
if g:spacevim_timer
MP 'tpope/vim-fugitive' , { 'on': [] }
MP 'airblade/vim-gitgutter' , { 'on': [] }
call timer_start(500, 'spacevim#defer#git')
Expand Down
2 changes: 1 addition & 1 deletion layers/+vim/better-motion/packages.vim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if g:spacevim_vim8 || g:spacevim_nvim
if g:spacevim_timer
MP 'justinmk/vim-sneak' , { 'on': [] }
MP 'easymotion/vim-easymotion' , { 'on': [] }
MP 'haya14busa/incsearch-easymotion.vim' , { 'on': [] }
Expand Down

0 comments on commit 51d367f

Please sign in to comment.