diff --git a/README.md b/README.md index d7f44195..2439a3db 100644 --- a/README.md +++ b/README.md @@ -85,38 +85,19 @@ If you have been a vimmer for quite a while, just pick out the part you are inte ### Prerequisites -The most recent Vim(NeoVim) version is recommended, for space-vim has been specifically optimized for Vim8 and NeoVim with respect to the startup time. +The most recent Vim(NeoVim) version is recommended. -[chocolatey](https://chocolatey.org/) is an easy way to install software on Windows, tools like `fzf`, `rg`, `ag` are necessary to get you a full-featured space-vim. +space-vim aspires to adhere to the zero-install philosophy, just clone and use. Optional dependencies not installed on the system are downloaded and built from source where possible, and are used embedded within the application. -:exclamation: ~~When layers enabled at the first time, you need to run `:PlugInstall` to install relevant plugins~~. +> In order to make a project zero-install, you must be able to use it as soon as you clone it. -### Linux and macOS +At present there is a lack of the above dependency build feature on Windows. [chocolatey](https://chocolatey.org/) is an easy way to install software on Windows, tools like `fzf`, `rg`, `ag`, `rustc`, `cargo`, `npm` are necessary to get you a full-featured space-vim. -`/path/to/space-vim` may be `~/.vim` (Vim), `~/.config/nvіm` (Neovim), or elsewhere. Installing space-vim to the conventional Vim/Neovim install location mitigates the need for an extra symlink to where space-vim is installed. +### Install location -#### one-line installer +Installing space-vim to the conventional Vim/Neovim install location mitigates the need for an extra symlink to where space-vim is installed. `/path/to/space-vim` may be `~/.vim` (Vim), `~/.config/nvіm` (Neovim), or elsewhere. -```bash -$ bash <(curl -fsSL https://raw.githubusercontent.com/liuchengxu/space-vim/master/install.sh) -``` - -#### Makefile - -```bash -$ git clone https://github.com/liuchengxu/space-vim.git /path/to/space-vim -$ cd /path/to/space-vim -$ make vim # install space-vim for Vim -$ make neovim # install space-vim for NeoVim -``` - -### Windows - -The easist way is to download [`install.cmd`](https://raw.githubusercontent.com/liuchengxu/space-vim/master/install.cmd) and **run it as administrator**, or [install space-vim manually](https://github.com/liuchengxu/space-vim/wiki/install#windows). - -![windows](https://raw.githubusercontent.com/liuchengxu/img/master/space-vim/win-gvim.png) - -### Manual +### Clone 1. Clone [space-vim](https://github.com/liuchengxu/space-vim): @@ -125,18 +106,7 @@ The easist way is to download [`install.cmd`](https://raw.githubusercontent.com/ $ git clone https://github.com/liuchengxu/space-vim.git --single-branch /path/to/space-vim ``` -2. Install [vim-plug](https://github.com/junegunn/vim-plug#installation), refer to vim-plug installation section for more information: - ```bash - # For Vim - $ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ - https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - - # For NeoVim - sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ - https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' - ``` - -3. Create the symlinks and install plugins: +2. Create the symlink(s): **Linux and macOS** @@ -144,54 +114,23 @@ The easist way is to download [`install.cmd`](https://raw.githubusercontent.com/ # **For Vim** # If space-vim not installed to ~/.vim/: $ ln -s /path/to/space-vim/init.vim ~/.vimrc - # Copy init.spacevim for local customization - $ cp /path/to/space-vim/init.spacevim ~/.spacevim - $ vim -es +'PlugInstall' +qall # **For NeoVim** # If space-vim not installed to ~/.config/nvim/: $ ln -s /path/to/space-vim/init.vim ~/.config/nvim/init.vim - # Copy init.spacevim for local customization - $ cp /path/to/space-vim/init.spacevim ~/.spacevim - $ nvim +'PlugInstall' +qall - ``` - -## Customize - -You can use `.spacevim` in your home directory to customize space-vim, where you can enable the existing layers, add your extra plugins and private configurations. -If `.spacevim` does not exist, vanilla vim will be loaded! Refer to [init.spacevim](init.spacevim) as an example. -### Presetting -```vim -" Comment the following line if you don't want Vim and NeoVim to share the -" same plugin download directory. -let g:spacevim_plug_home = '~/.vim/plugged' - -" Uncomment the following line to override the leader key. The default value is space key "<\Space>". -" let g:spacevim_leader = "<\Space>" - -" Uncomment the following line to override the local leader key. The default value is comma ','. -" let g:spacevim_localleader = ',' +## Customize -" Enable the existing layers in space-vim -" Refer to https://github.com/liuchengxu/space-vim/blob/master/layers/LAYERS.md for all available layers. -let g:spacevim_layers = [ - \ 'fzf', 'better-defaults', 'which-key', - \ ] + ```bash + # Copy init.spacevim for local customization, or symlink it + $ cp /path/to/space-vim/init.spacevim ~/.spacevim + ``` -" Uncomment the following line if your terminal(-emulator) supports true colors. -" let g:spacevim_enable_true_color = 1 +You can use `.spacevim` in your home directory to customize space-vim, where you can enable the existing layers, add your extra plugins and private configurations. -" Uncomment the following if you have some nerd font installed. -" let g:spacevim_nerd_fonts = 1 - -" If you want to have more control over the layer, try using Layer command. -" if g:spacevim.gui -" Layer 'airline' -" endif -``` +### .spacevim details Please refer to [LAYERS.md](layers/LAYERS.md) to take a look at the whole shipped layers. @@ -199,12 +138,14 @@ Basically, `g:spacevim_layers` almost takes the place of `Layer` command. As far ### `UserInit()` +`UserInit()` may be used to add plugins that are not within a layer. + ```vim " Manage your own plugins. -" Refer to https://github.com/junegunn/vim-plug for more detials. +" Refer to https://github.com/Shougo/dein.vim for more detials. function! UserInit() - " Add your own plugin via Plug command. + " Add your own plugin via Plug command (wrapper around dein#add) Plug 'junegunn/seoul256.vim' endfunction @@ -212,6 +153,8 @@ endfunction ### `UserConfig()` +Configuration may be placed in `UserConfig()`, and/or in a `plugin/` folder on the runtime path. E.g. `~/.vim/plugin/.vim` for each local plugin configuration. + ```vim " Override the default settings as well as adding extras function! UserConfig() @@ -289,15 +232,6 @@ Second, since console Vim uses whatever font the console/terminal is using, you' ## Update -Run `make update`: - -```bash -$ cd path/to/space-vim -$ make update -``` - -Alternatively, you can manually perform the following steps. If anything has changed with the structure of the configuration, you will have to create the appropriate symlinks. - ```bash $ cd path/to/space-vim $ git pull origin master diff --git a/core/autoload/spacevim.vim b/core/autoload/spacevim.vim index 92d98bf1..39119265 100644 --- a/core/autoload/spacevim.vim +++ b/core/autoload/spacevim.vim @@ -3,6 +3,9 @@ scriptencoding utf-8 let g:spacevim.info = g:spacevim.base. '/core/autoload/spacevim/info.vim' let g:spacevim.layers_base = '/layers' let g:spacevim.private_base = '/private' +let g:spacevim.state_base = fnamemodify(exists('*stdpath') ? stdpath('state') : + \ (g:spacevim.os.windows ? '~/AppData/Local/vim-data' : + \ (exists('$XDG_STATE_HOME') ? $XDG_STATE_HOME : '~/.local/state').'/vim'), ':p') let g:spacevim.nvim = has('nvim') && exists('*jobwait') && !g:spacevim.os.windows let g:spacevim.vim8 = exists('*job_start') let g:spacevim.timer = exists('*timer_start') @@ -12,6 +15,7 @@ let g:spacevim.tmux = !empty($TMUX) let g:spacevim.loaded = ['spacevim'] " Enable spacevim layer by default let g:spacevim.excluded = [] let g:spacevim.plugins = [] +let g:spacevim.enable_dein_recache = v:false let s:plug_options = {} let s:dot_spacevim = $HOME.'/.spacevim' @@ -30,18 +34,16 @@ function! spacevim#bootstrap() abort endfunction function! spacevim#begin() abort - " Download vim-plug if unavailable - if !g:spacevim.os.windows - call s:check_vim_plug() - endif call s:define_command() call s:cache() call s:check_dot_spacevim() + call s:check_dein_vim() endfunction -function! s:check_vim_plug() abort - let l:plug_path = g:spacevim.nvim ? '~/.local/share/nvim/site/autoload/plug.vim' : '~/.vim/autoload/plug.vim' - if empty(glob(l:plug_path)) | call spacevim#vim#plug#download(l:plug_path) | endif +function! s:check_dein_vim() abort + let s:dein_path = g:spacevim_plug_home.'/repos/github.com/Shougo/dein.vim' + if empty(glob(s:dein_path.'/.git')) | call spacevim#vim#plug#download(s:dein_path) | endif + let &runtimepath .= ','.fnamemodify(s:dein_path, ':p:h') endfunction function! s:define_command() abort @@ -51,19 +53,45 @@ function! s:define_command() abort command! -nargs=0 -bar SpaceInfo call spacevim#debugging#Info() command! -nargs=0 -bar LayerCache call spacevim#cache#init() command! -nargs=0 -bar LayerStatus call spacevim#layer#status() + command! -nargs=+ -bar Plug call spacevim#vim#plug#Plug() endfunction function! s:check_dot_spacevim() abort if filereadable(expand(s:dot_spacevim)) + call s:check_dot_spacevim_preset_variables() call s:Source(s:dot_spacevim) call extend(g:spacevim.loaded, get(g:, 'spacevim_layers', [])) - let g:mapleader = get(g:, 'spacevim_leader', "\") - let g:maplocalleader = get(g:, 'spacevim_localleader', ',') + call s:check_dot_spacevim_postset_variables() + if(getftype(g:spacevim.state_base) !~# '\(dir\|link\)') + call mkdir(g:spacevim.state_base, 'p') + endif + call spacevim#util#CheckFileTimestamp( + \ s:dot_spacevim, + \ g:spacevim.state_base.'/.dot_spacevim_last_changed', + \ {-> execute('let g:spacevim.enable_dein_recache = v:true')}) else call spacevim#util#err('.spacevim does not exist! Exiting...') endif endfunction +function! s:check_dot_spacevim_preset_variables() abort + let g:dein#types#git#clone_depth = 1 + let g:dein#enable_hook_function_cache = v:true + let g:dein#install_process_timeout = 6000 +endfunction + +function! s:check_dot_spacevim_postset_variables() abort + let g:mapleader = get(g:, 'spacevim_leader', "\") + let g:maplocalleader = get(g:, 'spacevim_localleader', ',') + let g:spacevim_plug_home = get(g:, 'spacevim_plug_home', + \ g:spacevim.nvim ? '~/.local/share/nvim/plugged' : '~/.vim/plugged') + let g:spacevim_enable_plug_cache = get(g:, 'spacevim_enable_plug_cache', 1) + let g:spacevim_enable_plug_merge = get(g:, 'spacevim_enable_plug_merge', 1) + let g:spacevim_enable_temp_build = get(g:, 'spacevim_enable_temp_build', 0) + let g:spacevim_lsp_engine = get(g:, 'spacevim_lsp_engine', 'lcn') + let g:spacevim.speed_up_via_timer = get(g:, 'spacevim_speed_up_via_timer', g:spacevim.timer) +endfunction + function! s:cache() abort let l:info = g:spacevim.info if filereadable(l:info) @@ -108,16 +136,6 @@ function! s:my_plugin(plugin, ...) abort endif if a:0 == 1 let s:plug_options[a:plugin] = a:1 - if has_key(a:1, 'on_event') - let l:group = 'load/'.a:plugin - let l:name = split(a:plugin, '/')[1] - let l:events = join(s:to_a(a:1.on_event), ',') - let l:load = printf("call plug#load('%s')", l:name) - execute "augroup" l:group - autocmd! - execute 'autocmd' l:events '*' l:load '|' 'autocmd!' l:group - execute 'augroup END' - endif endif endfunction @@ -125,7 +143,7 @@ function! s:Source(file) abort try execute 'source ' . fnameescape(a:file) catch - echom v:exception + call spacevim#util#err(v:exception) call spacevim#cache#init() endtry endfunction @@ -138,6 +156,8 @@ function! spacevim#end() abort " Backward compatibility if exists('*Layers') | call Layers() | endif + call s:validate_manifest() + call s:register_plugin() " Make vim-better-default settings can be overrided silent! runtime! plugin/default.vim @@ -145,45 +165,70 @@ function! spacevim#end() abort call s:config() if exists('*UserConfig') | call UserConfig() | endif - call s:spacevim_helptags() + call spacevim#util#CheckFileTimestamp( + \ g:spacevim.base.'/core/doc/spacevim.txt', + \ g:spacevim.base.'/core/doc/.spacevim_last_helptags_run', + \ {-> execute('helptags '.g:spacevim.base.'/core/doc')}) call s:check_missing_plugins() silent doautocmd User SpacevimAfterUserConfig endfunction -" Initialize vim-plug system +function! s:validate_manifest() abort + if !empty(filter(copy(g:spacevim.loaded), {_,v -> !has_key(g:spacevim.manifest, v)})) + call spacevim#util#info('.spacevim specifies layer(s) not in info.vim: trying to rebuild info.vim') + call spacevim#cache#init() + let bad_layers = filter(copy(g:spacevim.loaded), {_,v -> !has_key(g:spacevim.manifest, v)}) + if !empty(bad_layers) + call spacevim#util#info('.spacevim specifies the following invalid layers: '.string(bad_layers)) + call filter(g:spacevim.loaded, {_,v -> has_key(g:spacevim.manifest, v)}) + endif + endif +endfunction + +" Initialize dein system function! s:register_plugin() abort - " https://github.com/junegunn/vim-plug/issues/559 - call plug#begin(get(g:, 'spacevim_plug_home', - \ g:spacevim.nvim ? '~/.local/share/nvim/plugged' : '~/.vim/plugged/')) - call s:packages() - " Register non-excluded plugins - function! s:filter_and_register(val) abort - if index(g:spacevim.excluded, a:val) < 0 + if g:spacevim_enable_plug_merge == 0 + let g:dein#default_options = { 'merged': v:false } + endif + + call spacevim#vim#plug#dein_cache_setup() + + if !g:spacevim_enable_plug_cache || g:spacevim.enable_dein_recache || dein#load_state(g:spacevim_plug_home) + call dein#begin(g:spacevim_plug_home) + call dein#add(s:dein_path) + call s:packages() + function! s:register(val) abort if has_key(s:plug_options, a:val) - call plug#(a:val, s:plug_options[a:val]) + call dein#add(a:val, s:plug_options[a:val]) else - call plug#(a:val) + call dein#add(a:val) endif + endfunction + call extend(g:spacevim.excluded, get(g:, 'spacevim_excluded', [])) + call dein#disable(g:spacevim.excluded) + call map(copy(g:spacevim.plugins), {_,v -> s:register(v)}) + if exists('*UserInit') | call UserInit() | endif + if g:spacevim_enable_plug_cache + call spacevim#vim#plug#dein_cache_clear() + endif + if g:spacevim.enable_dein_recache && g:spacevim_enable_plug_merge + call dein#recache_runtimepath() endif - endfunction - call extend(g:spacevim.excluded, get(g:, 'spacevim_excluded', [])) - call map(copy(g:spacevim.plugins), 's:filter_and_register(v:val)') - if exists('*UserInit') | call UserInit() | endif - call plug#end() + call dein#end() + if g:spacevim_enable_plug_cache + call dein#save_state() + endif + endif + filetype plugin indent on + syntax enable + delcommand Plug + delcommand MP endfunction function! s:packages() abort - let g:spacevim.speed_up_via_timer = get(g:, 'spacevim_speed_up_via_timer', g:spacevim.timer) " Load Layer packages - for l:layer in g:spacevim.loaded - try - let l:layer_packages = g:spacevim.manifest[l:layer].dir . '/packages.vim' - catch - call spacevim#cache#init() - endtry - call s:Source(l:layer_packages) - endfor + call map(copy(g:spacevim.loaded), {_,v -> s:Source(g:spacevim.manifest[v].dir.'/packages.vim')}) " Try private Layer packages if exists('g:spacevim.private') @@ -207,21 +252,6 @@ function! s:config() abort if filereadable(expand(s:private_config)) | call s:Source(s:private_config) | endif endfunction -function! s:spacevim_helptags() abort - let helptag_file = g:spacevim.base . '/core/doc/spacevim.txt' - let helptag_time = getftime(helptag_file) - let helptag_lastrun_file = g:spacevim.base . '/core/doc/.spacevim_last_helptags_run' - let helptag_lastrun_time = filereadable(helptag_lastrun_file) ? readfile(helptag_lastrun_file) : [] - if (len(helptag_lastrun_time) != 1) || (helptag_lastrun_time[0] != helptag_time) - try - execute 'helptags' g:spacevim.base . '/core/doc' - call writefile([helptag_time], helptag_lastrun_file) - catch - echom v:exception - endtry - endif -endfunction - function! s:check_missing_plugins() abort if g:spacevim.timer call timer_start(1500, 'spacevim#vim#plug#check') @@ -247,11 +277,3 @@ function! spacevim#load_any(...) abort endfor return 0 endfunction - -function! spacevim#VimPlugPostUpdateHook(make, cmd, info) abort - if spacevim#load('programming') - execute('AsyncRun -mode=term -pos=tab '.(a:make?'-program=make ':'').'@ '.a:cmd) - else - call system(a:cmd) - endif -endfunction diff --git a/core/autoload/spacevim/autocmd/go.vim b/core/autoload/spacevim/autocmd/go.vim index 3e84fa4c..c5dae905 100644 --- a/core/autoload/spacevim/autocmd/go.vim +++ b/core/autoload/spacevim/autocmd/go.vim @@ -1,7 +1,7 @@ function s:ctagsbin() if spacevim#load('go') if !exists('*go#path#CheckBinPath') - call plug#load('vim-go') + call dein#source('vim-go') endif if exists('*go#path#CheckBinPath') return go#path#CheckBinPath(get(g:, 'go_gotags_bin', 'gotags')) diff --git a/core/autoload/spacevim/autocmd/unite.vim b/core/autoload/spacevim/autocmd/unite.vim index 68347fc7..5ce3d102 100644 --- a/core/autoload/spacevim/autocmd/unite.vim +++ b/core/autoload/spacevim/autocmd/unite.vim @@ -54,14 +54,14 @@ let s:menus.p = { \ 'description' : ' plugins ⌘ [menu]s', \} let s:menus.p.command_candidates = [ - \['► install-plugin (vim-plug)', - \'PlugInstall'], - \['► clean-plugin (vim-plug)', - \'PlugClean'], - \['► update-plugin (vim-plug)', - \'PlugUpdate'], - \['► show-plugin-status (vim-plug)', - \'PlugStatus'], + \['► install-plugin (dein)', + \'call dein#install()'], + \['► clean-plugin (dein)', + \'call map(dein#check_clean(), { _, val -> delete(val, "rf") }) | call dein#recache_runtimepath()'], + \['► update-plugin (dein)', + \'call dein#update()'], + \['► show-plugin-status (dein)', + \'Unite dein-unite-source-dein!'], \['► ycm-restart-server (ycmd)', \'YcmRestartServer'], \['► generate-markdown-toc (markdown-toc)', diff --git a/core/autoload/spacevim/cache.vim b/core/autoload/spacevim/cache.vim index ed1af387..9f08ca2b 100644 --- a/core/autoload/spacevim/cache.vim +++ b/core/autoload/spacevim/cache.vim @@ -9,6 +9,7 @@ function! spacevim#cache#init() abort else call s:init() endif + let g:spacevim.enable_dein_recache = v:true endfunction function! s:init() diff --git a/core/autoload/spacevim/defer.vim b/core/autoload/spacevim/defer.vim index bd29e9b6..2a57136b 100644 --- a/core/autoload/spacevim/defer.vim +++ b/core/autoload/spacevim/defer.vim @@ -1,7 +1,6 @@ function! s:lod(...) - " Ignore unknown plugins from vim-plug due to the excluded plugins for l:plug in a:000 - silent! call plug#load(l:plug) + silent! call dein#source(l:plug) endfor endfunction diff --git a/core/autoload/spacevim/lang/python.vim b/core/autoload/spacevim/lang/python.vim index 5c93049a..465df93e 100644 --- a/core/autoload/spacevim/lang/python.vim +++ b/core/autoload/spacevim/lang/python.vim @@ -1,5 +1,5 @@ function! spacevim#lang#python#run() - let l:cmd = has_key(g:plugs, 'asyncrun.vim') ? 'AsyncRun!' : '!' + let l:cmd = dein#is_available('asyncrun.vim') ? 'AsyncRun!' : '!' let l:exe = spacevim#lang#util#InferExecutable() let l:py = l:exe != '' ? l:exe : get(g:, 'spacevim_python_run', 'python') let l:fname = shellescape(@%, 1) diff --git a/core/autoload/spacevim/lang/rust.vim b/core/autoload/spacevim/lang/rust.vim index 05640fe8..3c9f457b 100644 --- a/core/autoload/spacevim/lang/rust.vim +++ b/core/autoload/spacevim/lang/rust.vim @@ -1,5 +1,5 @@ function! spacevim#lang#rust#Run() abort - if has_key(g:plugs, 'asyncrun.vim') + if dein#is_available('asyncrun.vim') AsyncRun cargo run else !cargo run @@ -9,7 +9,7 @@ endfunction function! spacevim#lang#rust#Build() abort if has('terminal') call spacevim#vim#term#Run('cargo', 'build') - elseif has_key(g:plugs, 'asyncrun.vim') + elseif dein#is_available('asyncrun.vim') AsyncRun cargo build else !cargo build diff --git a/core/autoload/spacevim/map/manager.vim b/core/autoload/spacevim/map/manager.vim index 9cfd888c..75005bbc 100644 --- a/core/autoload/spacevim/map/manager.vim +++ b/core/autoload/spacevim/map/manager.vim @@ -31,8 +31,11 @@ function! spacevim#map#manager#BufTags() abort " fzf elseif exists(':BTags') - if !exists('g:loaded_fzf') - call plug#load('fzf', 'fzf.vim') + if !dein#is_sourced('fzf') + call dein#source('fzf') + endif + if !dein#is_sourced('fzf.vim') + call dein#source('fzf.vim') endif BTags diff --git a/core/autoload/spacevim/plug/youcompleteme.vim b/core/autoload/spacevim/plug/youcompleteme.vim index eb6752fc..4dc061e9 100644 --- a/core/autoload/spacevim/plug/youcompleteme.vim +++ b/core/autoload/spacevim/plug/youcompleteme.vim @@ -1,4 +1,4 @@ -function! spacevim#plug#youcompleteme#build(info) +function! spacevim#plug#youcompleteme#build() abort let args = ['install.py', '--clang-completer'] call system('go version') @@ -11,15 +11,9 @@ function! spacevim#plug#youcompleteme#build(info) call add(args, '--rust-completer') endif - " info is a dictionary with 3 fields - " - name: name of the plugin - " - status: 'installed', 'updated', or 'unchanged' - " - force: set on PlugInstall! or PlugUpdate! - if a:info.status ==# 'installed' || a:info.force - " Prefer python3 - call insert(args, executable('python3') ? '!python3' : '!python') - call spacevim#VimPlugPostUpdateHook(v:false, join(args, ' '), a:info) - endif + " Prefer python3 + call insert(args, executable('python3') ? '!python3' : '!python') + call spacevim#vim#plug#post_update('YouCompleteMe', join(args, ' ')) endfunction " Load YCM for specific filetypes @@ -35,14 +29,14 @@ function! s:load_ycm() \ ] let l:cur_ft = &filetype if index(l:supported, l:cur_ft) > -1 - call plug#load('YouCompleteMe') + call dein#source('YouCompleteMe') endif endfunction " Load for supported types when loading via timer function! spacevim#plug#youcompleteme#invoke(timer) abort if !exists('g:loaded_youcompleteme') - call plug#load('YouCompleteMe') + call dein#source('YouCompleteMe') endif endfunction diff --git a/core/autoload/spacevim/util.vim b/core/autoload/spacevim/util.vim index 6d15414d..fb0dcdf4 100644 --- a/core/autoload/spacevim/util.vim +++ b/core/autoload/spacevim/util.vim @@ -19,7 +19,7 @@ endfunction " argument plugin is the vim plugin's name function! spacevim#util#IsDir(plugin) abort - return isdirectory(expand(g:my_plug_home.a:plugin)) ? 1 : 0 + return getftype(expand(g:spacevim_plug_home.'/'.a:plugin)) =~# '\(dir\|link\)' endfunction """"""""""""""""""""""""""""""""""""""""""""""""""" @@ -140,6 +140,22 @@ function! spacevim#util#Getfsize(fname) abort return size endfunction +" call OnChanged if checkf was changed, by compare checkf timestamp to ftimef +function! spacevim#util#CheckFileTimestamp(checkf, ftimef, OnChanged) abort + let checkf_time = getftime(a:checkf) + let ftimef_time = filereadable(a:ftimef) ? readfile(a:ftimef) : [] + if (len(ftimef_time) != 1) || (ftimef_time[0] != checkf_time) + try + call a:OnChanged() + call writefile([checkf_time], a:ftimef, 'S') + catch + echom v:exception + endtry + endif +endfunction + + + function! spacevim#util#FloatingWin() abort let height = &lines - 3 let width = float2nr(&columns - (&columns * 2 / 10)) @@ -182,6 +198,33 @@ function! spacevim#util#PathSep() abort return g:spacevim.os.windows ? '\' : '/' endfunction +function! spacevim#util#PathEnvSep() abort + return g:spacevim.os.windows ? ';' : ':' +endfunction + +function! spacevim#util#PrefixPATH(p) abort + let pathsep = spacevim#util#PathEnvSep() + if index(split($PATH, pathsep), a:p) == -1 + let $PATH = a:p.pathsep.$PATH + endif +endfunction + +function! spacevim#util#PostfixPATH(p) abort + let pathsep = spacevim#util#PathEnvSep() + if index(split($PATH, pathsep), a:p) == -1 + let $PATH = $PATH.pathsep.a:p + endif +endfunction + +function! spacevim#util#SymbolicLink(target, linkname) abort + if g:spacevim.os.windows + call system('mklink '.(isdirectory(a:target) ? '/D ' : ''). + \ a:linkname.' '.a:target) + else + call system('ln -s '.a:target.' '.a:linkname) + endif +endfunction + " command! ProfileStart call spacevim#util#ProfileStart() " command! ProfileStop call spacevim#util#ProfileStop() " @@ -213,3 +256,40 @@ function! spacevim#util#CycleQuickfix(action, fallback) abort normal! zz endtry endfunction + +" Params: +" [in] file: to call `--version` on +" [in] vregex: regex to extract v_req components +" [in] v_req: list containing required version components +" [in] f_req: a list either empty or containing argument to +" query features, and pattern to detect if feature is present, e.g. +" ['--list-features', '\V\nyaml'] +" Returns [v:true, [v_maj, v_min, ...]], [v:false, [v_maj, v_min, ...]], or [v:false] +function! spacevim#util#IsVersionSufficient(file, vregex, v_req, f_req) abort + if executable(a:file) == 1 + let fversion = system(a:file.' --version') + if !v:shell_error + let version_parts = matchlist(fversion, a:vregex) + if !empty(version_parts) + let isVersionSufficient = v:true + for i in range(1, len(version_parts)) + if empty(version_parts[i]) + let version_parts = version_parts[1:i-1] + break + elseif version_parts[i] < a:v_req[i-1] + let isVersionSufficient = v:false + endif + let version_parts[i] = str2nr(version_parts[i]) + endfor + if !empty(a:f_req) + let fquery = system(a:file.' '.a:f_req[0]) + if v:shell_error || -1 == match(fquery, a:f_req[1]) + return [v:false, version_parts] + endif + endif + return [isVersionSufficient, version_parts] + endif + endif + endif + return [v:false] +endfunction diff --git a/core/autoload/spacevim/vim/autocmd.vim b/core/autoload/spacevim/vim/autocmd.vim index fe59d869..f47eac60 100644 --- a/core/autoload/spacevim/vim/autocmd.vim +++ b/core/autoload/spacevim/vim/autocmd.vim @@ -38,7 +38,7 @@ endfunction function! spacevim#vim#autocmd#AsyncRunStart() let l:qf_height = float2nr(round(winheight('%') * 0.3)) if !exists('*asyncrun#quickfix_toggle') - call plug#load('asyncrun.vim') + call dein#source('asyncrun.vim') endif call asyncrun#quickfix_toggle(l:qf_height, 1) endfunction diff --git a/core/autoload/spacevim/vim/plug.vim b/core/autoload/spacevim/vim/plug.vim index dfb976a1..aa3c204c 100644 --- a/core/autoload/spacevim/vim/plug.vim +++ b/core/autoload/spacevim/vim/plug.vim @@ -1,7 +1,56 @@ -function! spacevim#vim#plug#download(plug_path) abort - echo '==> Downloading vim-plug ......' - execute '!curl -fLo' a:plug_path '--create-dirs' - \ 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' +function! spacevim#vim#plug#download(dein_path) abort + echo '==> Downloading Shougo/dein.vim ......' + execute '!git clone --depth=1 https://github.com/Shougo/dein.vim '.a:dein_path +endfunction + +" Store dein merged rtp and/or cache in tmpfs +function! spacevim#vim#plug#dein_cache_setup() abort + let s:dein_cache = { 'dir': + \ fnamemodify(g:spacevim_plug_home.'/.cache', ':p'), + \ 'target': fnamemodify(tempname(), ':h:h'). + \ '/.vimcache'.(g:spacevim.os.windows ? '' : $USER) } + let dc = s:dein_cache + let dc.statefile = { 'name': '/state_'.v:progname.'.vim' } + let dc.statefile.linkname = fnamemodify( + \ g:spacevim_plug_home.dc.statefile.name, ':p') + let dc.cachefile = { 'name': '/cache_'.v:progname } + let dc.cachefile.linkname = fnamemodify( + \ g:spacevim_plug_home.dc.cachefile.name, ':p') + if !isdirectory(dc.dir) + if !isdirectory(dc.target) + call mkdir(dc.target, 'p', '0o700') + endif + let dc.type = getftype(dc.dir) + if dc.type !=# 'link' + let ret = empty(dc.type) ? v:false : delete(dc.dir) + if ret == v:false + call spacevim#util#SymbolicLink(dc.target, dc.dir) + endif + endif + endif + + if g:spacevim_enable_plug_merge && !isdirectory(dc.target.'/vimrc/.dein') + let g:spacevim.enable_dein_recache = v:true + endif + + if g:spacevim_enable_plug_cache + for i in [dc.statefile, dc.cachefile] + if getftype(i.linkname) !=# 'link' + call spacevim#util#SymbolicLink(dc.target.i.name, i.linkname) + endif + endfor + endif + + let g:spacevim#vim#plug#native_dependency = {} +endfunction + +function! spacevim#vim#plug#dein_cache_clear() abort + " dein#clear_state() doesn't work with symlinks + for i in [s:dein_cache.statefile, s:dein_cache.cachefile] + if filereadable(i.linkname) + call delete(s:dein_cache.target.i.name) + endif + endfor endfunction " Avoid hit-enter prompt when the message being echoed is too long. @@ -12,33 +61,106 @@ function! s:truncate(msg) abort return len(a:msg) < maxlen ? a:msg : a:msg[:maxlen-3].'...' endfunction -" https://github.com/junegunn/vim-plug/wiki/extra#automatically-install-missing-plugins-on-startup +" Backwards compatibility for vim-plug Plug command using Dein.vim +function! spacevim#vim#plug#Plug(repo, ...) abort + if a:0 > 1 + return spacevim#util#err('Invalid number of arguments (1..2)') + endif + + try + let repo = substitute(a:repo, '[\/]\+$', '', '') + let opts = a:0 == 1 ? a:1 : {} + let opts.merged = v:false + let local = fnamemodify(g:spacevim_plug_home.'/'.repo, ':p:h') + call dein#add(isdirectory(local) ? local : repo, opts) + catch + return spacevim#util#err(repo . ' ' . v:exception) + endtry +endfunction + +function! s:setup_vim_plug_links() abort + " This is how dein appears to queue up plugins to update internally: + "let plugins = dein#util#_get_plugins(a:plugins) + "let plugins = filter(plugins, { _, val -> !isdirectory(val.path) }) + + " s:missing is calculated differently, maybe it will work + for [k,v] in items(s:missing) + let vim_plug_dir = fnamemodify(g:spacevim_plug_home.'/'.k, ':p:h') + let dein_dir = fnamemodify(v.path, ':p') + let relative = dein_dir[len(fnamemodify(g:spacevim_plug_home, ':p')):] + call spacevim#util#SymbolicLink(relative, vim_plug_dir) + endfor +endfunction + +" Automatically install missing plugins on startup function! spacevim#vim#plug#check(...) abort - let l:msg = '[space-vim] Need to install the missing plugins: ' - let missing = filter(values(g:plugs), '!isdirectory(v:val.dir)') - if len(missing) - let plugs = map(missing, 'split(v:val.dir, "/")[-1]') - let l:msg .= string(plugs).' (y/N): ' - let l:msg = s:truncate(l:msg) + " First migrate from vim-plug to dein structure + let dein_status = copy(dein#get()) + let s:missing = filter(dein_status, {k,v -> !dein#is_available(k)}) + let migration_notice = 0 + if len(s:missing) + for [k,v] in items(s:missing) + let vim_plug_dir = fnamemodify(g:spacevim_plug_home.'/'.k, ':p') + let dein_parent_dir = fnamemodify(v.path, ':p:h') + let dein_dir = fnamemodify(v.path, ':p') + if v.type ==# 'git' && getftype(vim_plug_dir) ==# 'dir' + if !isdirectory(dein_parent_dir) + call mkdir(dein_parent_dir, 'p') + endif + call rename(vim_plug_dir, dein_dir) + let relative = dein_dir[len(fnamemodify(g:spacevim_plug_home, ':p')):] + let vim_plug_dir = fnamemodify(vim_plug_dir, ':h') + call spacevim#util#SymbolicLink(relative, vim_plug_dir) + let migration_notice = v:true + endif + endfor + if migration_notice + let vim_plug_file = g:spacevim.base.'/autoload/plug.vim' + let msg_renamed = '' + if filereadable(vim_plug_file) + call rename(vim_plug_file, vim_plug_file.'.old') + let msg_renamed = ' ''autoload/plug.vim'' renamed to '. + \ '''autoload/plug.vim.old''.' + endif + call spacevim#util#info('Migrated some vim-plug packages to dein.'. + \ ' Notice vim-plug''s ''on'', ''for'', ''do'', ''dir'' package'. + \ ' options are silently ignored. Replace them with dein''s '. + \ 'options: ''on_cmd'', ''on_func'', ''on_ft'', ''build'', '. + \ '''hook_done_update'', ''path'', and others.'.msg_renamed) + endif + let g:spacevim.enable_dein_recache = v:true + endif + " Now check for missing plugins after migration + if migration_notice + call filter(s:missing, {k,v -> !dein#is_available(k)}) + endif + if len(s:missing) + let l:msg = '[space-vim] Need to install the missing plugins: ' + let l:msg .= join(keys(s:missing), ',').' (y/N): ' if a:0 == 1 if exists('*popup_dialog') call s:popup_dialog(l:msg) - return - endif - if s:ask(l:msg) - silent PlugInstall --sync | q + elseif s:ask(l:msg) + call s:setup_vim_plug_links() + silent call dein#install() + let g:spacevim.enable_dein_recache = v:true endif else echom l:msg - PlugInstall --sync | q + call s:setup_vim_plug_links() + call dein#install() + let g:spacevim.enable_dein_recache = v:true endif endif + unlet s:missing endfunction function! s:dialog_handler(id, result) abort if a:result call popup_close(a:id) - silent PlugInstall --sync | q + call s:setup_vim_plug_links() + silent call dein#install() + let g:spacevim.enable_dein_recache = v:true endif endfunction @@ -58,3 +180,181 @@ function! s:ask(message) abort echo "\r" return (answer =~? '^y') ? 1 : 0 endfunction + +function! spacevim#vim#plug#post_update(name, cmd) abort + if !empty(a:name) + let cwd = getcwd() + let plugpath = dein#get(a:name).path + execute 'tcd' plugpath + endif + let make = a:cmd =~# '^make' + let cmd = make ? strcharpart(a:cmd, 4) : a:cmd + if dein#is_available('asyncrun.vim') + execute('AsyncRun -mode=term -pos=tab '.(make?'-program=make ':'').'@ '.cmd) + else + call system(a:cmd) + endif + if !empty(a:name) + execute 'tcd' cwd + endif +endfunction + +" Params: +" [in] plugname: e.g. 'rust', 'node', 'ctags' +" Returns list [location, [v_maj, v_min, ...], binpath], location may be +" 'override', 'plugin', 'system', or 'none'. Note ['none'] case. +function! spacevim#vim#plug#LocateDependency(plugname) abort + let c = g:spacevim#vim#plug#native_dependency[a:plugname] + " To speedup startuptime try cached `--version` rather than wait: + let f = g:spacevim.state_base.'version_'.a:plugname + let v = filereadable(f) ? readfile(f) : [] + if len(v) >= 2 + if v[0][0] > c.v_req[0] || (v[0][0] == c.v_req[0] && v[0][1] >= c.v_req[1]) + if len(v) == 3 + call spacevim#util#PrefixPATH(v[2]) + endif + return [v[1], v[0], v[2]] + endif + endif + function! Update(l, f) abort + try + call writefile(a:l, a:f, 'S') + catch + call spacevim#util#err('Failed to write cache file: "'.a:f. + \ '" exception: "'.v:exception.'"') + endtry + endfunction + let fr = has_key(c, 'feature_req') ? c.feature_req : [] + if has_key(c, 'override') && exists(c.override) + let v = spacevim#util#IsVersionSufficient(c.override, c.vregex, c.v_req, fr) + if v[0] + let binpath = fnamemodify(c.override, ':h') + call spacevim#util#PrefixPATH(binpath) + call Update([string(v[1]), 'override', binpath], f) + return ['override', v[1], binpath] + endif + endif + " dein might install 'node' into e.g. 'node_v16.16.0' if 'rev' is set. + let globs = reverse(glob(g:spacevim_plug_home.'/repos/github.com/'. + \ c.repo.'*/install/bin', v:true, v:true)) + for binpath in globs + let v = spacevim#util#IsVersionSufficient(binpath.'/'.c.bin, + \ c.vregex, c.v_req, fr) + if v[0] + call spacevim#util#PrefixPATH(binpath) + call Update([string(v[1]), 'plugin', binpath], f) + return ['plugin', v[1], binpath] + endif + endfor + let v = spacevim#util#IsVersionSufficient(c.bin, c.vregex, c.v_req, fr) + if v[0] + call Update([string(v[1]), 'system'], f) + return ['system', v[1]] + endif + return ['none'] +endfunction + +" plugname is e.g. 'rust', 'node', 'ctags' +function! spacevim#vim#plug#Build(plugname) abort + let c = g:spacevim#vim#plug#native_dependency[a:plugname] + if !dein#is_available('asyncrun.vim') + call spacevim#util#info(a:plugname.' requires asyncrun.vim to '. + \ 'build. Add "programming" layer to .spacevim') + return + endif + + let c.posix_compiler = v:true + if (!exists('$CC') && executable('gcc') != 1) || + \ executable('make') != 1 || executable('python3') != 1 || + \ executable('ninja') != 1 + let c.posix_compiler = v:false + if !g:spacevim.os.windows + call spacevim#util#info('Unable to build '.a:plugname.', requires'. + \ ' a C++ compiler, make, python3, and ninja. After rectifying '. + \ 'try `:call dein#get('.a:plugname.').hook_post_update()`') + return + endif + endif + + if g:spacevim.os.windows + if executable('python') != 1 + call spacevim#util#info('Requires python on PATH. After '. + \ 'rectifying try `:call dein#get('.a:plugname.').hook_post_update()`') + return + endif + if !c.posix_compiler && !exists('$VCINSTALLDIR') + call spacevim#util#info('Suitable Cygwin, MSYS2, or MSVC '. + \ 'environment not detected. Per desired ABI run '. + \ 'msys2_shell.cmd in the case of MSYS2, or vcvars64.bat in '. + \ 'the Vim Shell in the case of MSVC. After rectifying try '. + \ '`:call dein#get('.a:plugname.').hook_post_update()`') + return + endif + endif + + if c.posix_compiler + let c.ninja_flag = '' + let c.jobs_flag = '' + if executable('ninja') + let c.ninja_flag=' --ninja' + else + " Determine number of cores/threads for make -j, ninja autodetects + let num_threads = 4 + if executable('lscpu') + let result = system("lscpu | grep -E '?^(CPU\\(s\\):|Thread\\(s\\) per core:)' | tr -s ' ' | cut -f 2 -d:") + if !v:shell_error + let num_threads = join(split(result), '*') + endif + endif + let c.jobs_flag = ' -j '.num_threads + endif + endif + + call spacevim#util#info('Building '.a:plugname.'...') + + let plugpath = dein#get(a:plugname).path + call extend(c, {'cwd': getcwd(), 'plugpath': plugpath, + \ 'temppath': fnamemodify(tempname(), ':p:h')}) + execute 'tcd' plugpath + + if g:spacevim_enable_temp_build && getftype('build') !=# 'dir' + let temppath = c.temppath.'/build' + call mkdir(temppath, 'p') + call delete('build') + call spacevim#util#SymbolicLink(temppath, 'build') + endif + + execute 'tcd build' + call c.Build(c) + execute 'tcd' c.cwd +endfunction + +function! spacevim#vim#plug#PostBuild(exit_code, plugname) abort + let c = g:spacevim#vim#plug#native_dependency[a:plugname] + execute 'tcd' c.plugpath + if a:exit_code != 0 + call spacevim#util#info(a:plugname.' build failure exit code:'.a:exit_code) + else + " Delete the repo we have the build product + call system('git read-tree -u --reset $(git hash-object -t tree '. + \ (g:spacevim.os.windows ? 'NUL' : '/dev/null').')') + call delete('.git', 'rf') + + call delete((g:spacevim_enable_temp_build ? c.temppath.'/' : ''). + \ 'build', 'rf') + + let c.binpath = fnamemodify(c.plugpath.'/install/bin', ':p:h') + if isdirectory(c.binpath) + call spacevim#util#PrefixPATH(c.binpath) + endif + + call c.PostBuild(c) + + call dein#disable(a:plugname) + call spacevim#vim#plug#dein_cache_clear() + endif + if g:spacevim_enable_temp_build && getftype(c.plugpath.'/build') ==# 'link' + call delete(c.plugpath.'/build') + endif + execute 'tcd' c.cwd +endfunction diff --git a/core/autoload/spacevim/wrap/fzf.vim b/core/autoload/spacevim/wrap/fzf.vim index 36a4f72d..86542fb4 100644 --- a/core/autoload/spacevim/wrap/fzf.vim +++ b/core/autoload/spacevim/wrap/fzf.vim @@ -3,7 +3,7 @@ " ---------------------------------------------- function! s:dispatch(...) abort if !exists('g:loaded_fzf') - call plug#load('fzf', 'fzf.vim') + call dein#source('fzf', 'fzf.vim') endif if a:0 == 2 " FIXME better configurable diff --git a/core/doc/spacevim.txt b/core/doc/spacevim.txt index efb576c7..456c4163 100644 --- a/core/doc/spacevim.txt +++ b/core/doc/spacevim.txt @@ -116,3 +116,41 @@ g:spacevim_enable_clap *g:spacevim_enable_cl Default: `0` Use https://github.com/liuchengxu/vim-clap as the plugin of fzf layer. + +g:spacevim_plug_home *g:spacevim_plug_home* + Type: |Path| + Default: Vim: `~/.vim/plugged` NeoVim: `~/.local/share/nvim/plugged` + + In .spacevim is set to `~/.vim/plugged` as stock configuration for Vim and + NeoVim to share the same plugin download directory. + +g:spacevim_enable_plug_cache *g:spacevim_enable_plug_cache* + Type: |Number| + Default: `1` + + Dein caches the plugin list for better startup performance. + Set this to 0 disable that cache. + Note: To force the regeneration of this cache, delete + `g:spacevim_plug_home/state_{v:progname}` and restart Vim. + Note: This cache is inflexible, changes are not detected in layers and + should be disabled while changing layer packages.vim. + +g:spacevim_enable_plug_merge *g:spacevim_enable_plug_merge* + Type: |Number| + Default: `1` + + Dein merges the layer plugins together into one folder for better startup and + runtime performance. + Set this to 0 disable that merging, with possible filename conflicts. + Note: Private plugins in .spacevim UserInit() are not merged. + Note: If set to 0 dein does not generate plugin helptags. + +g:spacevim_enable_temp_build *g:spacevim_enable_temp_build* + Type: |Number| + Default: `0` + + Following the zero-install build-from-source philosophy, dependency builds + will occur within a `tempfile` directory, likely on RAM depending on system + configuration. The intermediate files take up space and only the output is + required. The tempfile directory is deleted when Vim exits. The largest + dependency, rustc, requires about 14GiB. Others are a 4GiB or less. diff --git a/core/ftplugin/go.vim b/core/ftplugin/go.vim index 3bb00d6b..c1548aa7 100644 --- a/core/ftplugin/go.vim +++ b/core/ftplugin/go.vim @@ -11,6 +11,6 @@ nmap t (go-test) nmap i :GoImports nmap gi (go-implements) -if g:spacevim.timer +if g:spacevim.speed_up_via_timer call timer_start(300, 'spacevim#defer#go') endif diff --git a/core/ftplugin/java.vim b/core/ftplugin/java.vim index f1041d96..7d25ef6b 100644 --- a/core/ftplugin/java.vim +++ b/core/ftplugin/java.vim @@ -3,6 +3,13 @@ if exists('b:did_spacevim_java_ftplugin') || !spacevim#load('java') endif let b:did_spacevim_java_ftplugin = 1 +if dein#is_available('vim-javacomplete2') + augroup spacevimONCE + autocmd! + autocmd InsertEnter * ++once call dein#source('vim-javacomplete2') + augroup END +endif + setlocal omnifunc=javacomplete#Complete " The commented key mappings are the defaults by vim-javacomplete2. diff --git a/core/ftplugin/markdown.vim b/core/ftplugin/markdown.vim index e83b15a0..e2cf7eab 100644 --- a/core/ftplugin/markdown.vim +++ b/core/ftplugin/markdown.vim @@ -37,7 +37,7 @@ let g:tagbar_type_markdown = { \ ] \ } -if g:spacevim.timer +if g:spacevim.speed_up_via_timer call timer_start(1300, 'spacevim#defer#markdown') endif diff --git a/core/ftplugin/python.vim b/core/ftplugin/python.vim index d8a1c02c..9fc54f46 100644 --- a/core/ftplugin/python.vim +++ b/core/ftplugin/python.vim @@ -5,7 +5,7 @@ let b:did_spacevim_py_ftplugin = 1 setlocal foldmethod=indent tabstop=4 textwidth=79 -if g:spacevim.timer +if g:spacevim.speed_up_via_timer call timer_start(300, 'spacevim#defer#python') endif diff --git a/core/ftplugin/rust.vim b/core/ftplugin/rust.vim index 1b657a3f..70906219 100644 --- a/core/ftplugin/rust.vim +++ b/core/ftplugin/rust.vim @@ -16,6 +16,6 @@ let b:ale_fixers = [ \ 'rustfmt', \ ] -if g:spacevim.timer +if g:spacevim.speed_up_via_timer call timer_start(300, 'spacevim#defer#rust') endif diff --git a/core/ftplugin/vim.vim b/core/ftplugin/vim.vim index ca7e9ecb..e0399b02 100644 --- a/core/ftplugin/vim.vim +++ b/core/ftplugin/vim.vim @@ -9,6 +9,9 @@ let b:ale_linters = ['vint'] nnoremap gh :call spacevim#util#OpenPluginHomepage() -if has_key(g:plugs, 'coc-neco') && !exists('g:did_coc_neco_loaded') - call plug#load('neco-vim', 'coc-neco') +if dein#is_available('coc-neco') + call dein#source('coc-neco') +endif +if dein#is_available('neco-vim') + call dein#source('neco-vim') endif diff --git a/init.spacevim b/init.spacevim index 8f34bec5..edeeb0f2 100644 --- a/init.spacevim +++ b/init.spacevim @@ -2,8 +2,13 @@ " same plugin download directory. let g:spacevim_plug_home = '~/.vim/plugged' -" Uncomment the following line to override the leader key. The default value is space key "<\Space>". -" let g:spacevim_leader = "<\Space>" +" Set any of the following to 0 to change dein behaviour, see help: +let g:spacevim_enable_plug_merge = 1 +let g:spacevim_enable_plug_cache = 1 +let g:spacevim_enable_temp_build = 1 + +" Uncomment the following line to override the leader key. The default value is space key "\". +" let g:spacevim_leader = "\" " Uncomment the following line to override the local leader key. The default value is comma ','. " let g:spacevim_localleader = ',' @@ -12,7 +17,19 @@ let g:spacevim_plug_home = '~/.vim/plugged' " Refer to https://github.com/liuchengxu/space-vim/blob/master/layers/LAYERS.md for all available layers. let g:spacevim_layers = [ \ 'fzf', 'better-defaults', 'which-key', - \ ] + \ 'programming', 'file-manager', 'lsp',] + "\ 'rustc', + "\ 'denops', + "\ 'tree-sitter', + "\ 'ddc', + "\ 'ddu', + "\ ] + +" Uncomment to use clap instead of fzf in the fzf layer: +" let g:spacevim_enable_clap = 1 + +" Uncomment to use vim-lsp instead of the default LSP engine in the lsp layer: +" let g:spacevim_lsp_engine = 'vim_lsp' " Uncomment the following line if your terminal(-emulator) supports true colors. " let g:spacevim_enable_true_color = 1 @@ -30,7 +47,7 @@ let g:spacevim_layers = [ function! UserInit() " Add your own plugin via Plug command. - Plug 'junegunn/seoul256.vim' + " Plug 'junegunn/seoul256.vim' endfunction diff --git a/layers/+checkers/syntax-checking/config.vim b/layers/+checkers/syntax-checking/config.vim index 5d147c7e..75fc2dc2 100644 --- a/layers/+checkers/syntax-checking/config.vim +++ b/layers/+checkers/syntax-checking/config.vim @@ -2,6 +2,10 @@ scriptencoding utf-8 if g:spacevim.vim8 || g:spacevim.nvim " ale { + if g:spacevim.speed_up_via_timer + call timer_start(200, 'spacevim#defer#ale') + endif + let g:ale_set_highlights = 0 let g:ale_fix_on_save = 1 let g:ale_echo_msg_format = '[#%linter%#] %s [%severity%]' diff --git a/layers/+checkers/syntax-checking/packages.vim b/layers/+checkers/syntax-checking/packages.vim index 20cada4e..e2742c29 100644 --- a/layers/+checkers/syntax-checking/packages.vim +++ b/layers/+checkers/syntax-checking/packages.vim @@ -1,6 +1,5 @@ if g:spacevim.vim8 || g:spacevim.nvim - MP 'w0rp/ale', { 'on': [] } - call timer_start(200, 'spacevim#defer#ale') + MP 'w0rp/ale', { 'lazy': g:spacevim.speed_up_via_timer } else - MP 'vim-syntastic/syntastic', { 'on': 'SyntasticCheck' } + MP 'vim-syntastic/syntastic', { 'on_cmd': 'SyntasticCheck' } endif diff --git a/layers/+completion/auto-completion/config.vim b/layers/+completion/auto-completion/config.vim index 2b36297a..f4f8e4ce 100644 --- a/layers/+completion/auto-completion/config.vim +++ b/layers/+completion/auto-completion/config.vim @@ -1,6 +1,15 @@ scriptencoding utf-8 -if has_key(g:plugs, 'vim-mucomplete') +if exists('g:spacevim_use_ncm2') || has('nvim-0.2.2') && has('python3') + " Enable ncm2 for all buffer + augroup spacevimNcm2 + autocmd! + autocmd CursorHold,InsertEnter * call ncm2#enable_for_buffer() + augroup END + let g:ncm2#matcher = 'abbrfuzzy' +endif + +if dein#is_available('vim-mucomplete') let g:mucomplete#enable_auto_at_startup = 1 let g:mucomplete#no_mappings = 1 inoremap mucomplete#popup_exit("\") diff --git a/layers/+completion/auto-completion/packages.vim b/layers/+completion/auto-completion/packages.vim index fc022d8d..7bee1903 100644 --- a/layers/+completion/auto-completion/packages.vim +++ b/layers/+completion/auto-completion/packages.vim @@ -24,9 +24,6 @@ if exists('g:spacevim_use_ncm2') || has("nvim-0.2.2") && has('python3') if spacevim#load('code-snippets') call add(s:plugins, 'ncm2/ncm2-ultisnips') endif - " Enable ncm2 for all buffer - autocmd CursorHold,InsertEnter * call ncm2#enable_for_buffer() - let g:ncm2#matcher = 'abbrfuzzy' elseif g:spacevim.vim8 let s:plugins = [ diff --git a/layers/+completion/deoplete/packages.vim b/layers/+completion/deoplete/packages.vim index 2eca38af..8b008048 100644 --- a/layers/+completion/deoplete/packages.vim +++ b/layers/+completion/deoplete/packages.vim @@ -1,5 +1,5 @@ if g:spacevim.nvim - MP 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } + MP 'Shougo/deoplete.nvim', { 'hook_post_update': ':UpdateRemotePlugins' } else MP 'Shougo/deoplete.nvim' MP 'roxma/nvim-yarp' @@ -10,4 +10,5 @@ endif MP 'eagletmt/neco-ghc' MP 'Shougo/neco-vim' MP 'sebastianmarkow/deoplete-rust' -MP 'zchee/deoplete-go', { 'do': function('spacevim#VimPlugPostUpdateHook', [v:true, '']) } +MP 'zchee/deoplete-go', { 'hook_post_update': + \ function('spacevim#vim#plug#post_update', ['deoplete-go', 'make']) } diff --git a/layers/+completion/unite/config.vim b/layers/+completion/unite/config.vim index 6b316eac..320afd13 100644 --- a/layers/+completion/unite/config.vim +++ b/layers/+completion/unite/config.vim @@ -1,4 +1,8 @@ " unite.vim { + if g:spacevim.speed_up_via_timer + call timer_start(500, 'spacevim#defer#unite') + endif + " menu prefix key (for all Unite menus) nnoremap [menu] nmap [menu] @@ -16,8 +20,4 @@ nnoremap [menu]u :Unite -silent menu:u nnoremap [menu]v :call spacevim#map#manager#QuickOpen() - - if !g:spacevim.timer - call spacevim#autocmd#unite#Init() - endif " } diff --git a/layers/+completion/unite/packages.vim b/layers/+completion/unite/packages.vim index 5d357e78..88f4b2d9 100644 --- a/layers/+completion/unite/packages.vim +++ b/layers/+completion/unite/packages.vim @@ -1,9 +1,5 @@ " temporarily disabled " MP 'Shougo/denite.nvim' -if g:spacevim.speed_up_via_timer - MP 'Shougo/unite.vim', { 'on': [] } - autocmd! User unite.vim call spacevim#autocmd#unite#Init() - call timer_start(500, 'spacevim#defer#unite') -else - MP 'Shougo/unite.vim' +MP 'Shougo/unite.vim', { 'lazy': g:spacevim.speed_up_via_timer, + \ 'hook_source': function('spacevim#autocmd#unite#Init') } endif diff --git a/layers/+distributions/better-defaults/config.vim b/layers/+distributions/better-defaults/config.vim index 9a04713a..82cc13ee 100644 --- a/layers/+distributions/better-defaults/config.vim +++ b/layers/+distributions/better-defaults/config.vim @@ -1,5 +1,9 @@ scriptencoding utf-8 +if g:spacevim.speed_up_via_timer + call timer_start(500, 'spacevim#defer#defaults') +endif + " Smarter cursorline { augroup spacevimCursorline autocmd! @@ -33,4 +37,19 @@ endif let g:choosewin_overlay_enable = 1 " } +" vim-startify { +if get(g:, 'spacevim_enable_startify', 1) + function! s:LoadStartifyIfNoArgs() abort + if !argc() && v:progname =~# 'vim$' && !dein#is_sourced('vim-startify') + call dein#source('vim-startify') + endif + endfunction + + augroup spacevimStart + autocmd! + autocmd VimEnter * call s:LoadStartifyIfNoArgs() + augroup END +endif +" } + execute 'source' fnamemodify(expand(''), ':h') . '/keybindings.vim' diff --git a/layers/+distributions/better-defaults/packages.vim b/layers/+distributions/better-defaults/packages.vim index 6e04db01..52af075a 100644 --- a/layers/+distributions/better-defaults/packages.vim +++ b/layers/+distributions/better-defaults/packages.vim @@ -2,57 +2,40 @@ " Plug 'ybian/smartim' " endif -if g:spacevim.speed_up_via_timer - MP 'kshenoy/vim-signature' , { 'on': [] } - MP 'tpope/vim-rsi' , { 'on': [] } - MP 'markonm/traces.vim' , { 'on': [] } - MP 'dominikduda/vim_current_word' , { 'on': [] } - call timer_start(500, 'spacevim#defer#defaults') -else - MP 'tpope/vim-rsi' - MP 'kshenoy/vim-signature' - MP 'dominikduda/vim_current_word' +MP 'kshenoy/vim-signature', { 'lazy': g:spacevim.speed_up_via_timer } +MP 'tpope/vim-rsi', { 'lazy': g:spacevim.speed_up_via_timer } +MP 'dominikduda/vim_current_word', { 'lazy': g:spacevim.speed_up_via_timer } +if has('patch-8.0.1206') || has('nvim-0.2.3') + MP 'markonm/traces.vim', { 'lazy': g:spacevim.speed_up_via_timer } endif -MP 't9md/vim-choosewin', { 'on': '(choosewin)' } +MP 't9md/vim-choosewin', { 'on_map': '(choosewin)' } if get(g:, 'spacevim_enable_startify', 1) - MP 'mhinz/vim-startify', { 'on': 'Startify' } - autocmd! User vim-startify call spacevim#autocmd#startify#Init() - - function! s:LoadStartifyIfNoArgs() abort - if !argc() && v:progname =~ "vim$" - call plug#load('vim-startify') - silent! Startify - endif - endfunction - - augroup spacevimStart - autocmd! - autocmd VimEnter * call s:LoadStartifyIfNoArgs() - augroup END + MP 'mhinz/vim-startify', { 'on_cmd': 'Startify', + \ 'hook_source': function('spacevim#autocmd#startify#Init') } endif " Bug here. -" MP 'kana/vim-operator-user', { 'on': '(operator-flashy)' } -" MP 'haya14busa/vim-operator-flashy', { 'on': '(operator-flashy)' } +" MP 'kana/vim-operator-user', { 'on_map': '(operator-flashy)' } +" MP 'haya14busa/vim-operator-flashy', { 'on_map': '(operator-flashy)' } -MP 'ntpeters/vim-better-whitespace', { 'on': 'StripWhitespace' } +MP 'ntpeters/vim-better-whitespace', { 'on_cmd': 'StripWhitespace' } if has('patch-8.0.1238') MP 'haya14busa/is.vim' - MP 'osyo-manga/vim-anzu', { 'on': ['(anzu-n-with-echo)', '(anzu-N-with-echo)'] } + MP 'osyo-manga/vim-anzu', { 'on_map': ['(anzu-n-with-echo)', '(anzu-N-with-echo)'] } else MP 'google/vim-searchindex' if !g:spacevim.nvim - MP 'haya14busa/incsearch.vim', { 'on': [ + MP 'haya14busa/incsearch.vim', { 'on_map': [ \ '(incsearch-forward)', \ '(incsearch-backward)', \ '(incsearch-stay)' ] \ } - MP 'haya14busa/incsearch-fuzzy.vim', { 'on': [ - \ '(incsearch-fuzzy-/)', - \ '(incsearch-fuzzy-?)', - \ '(incsearch-fuzzy-stay)' ] + MP 'haya14busa/incsearch-fuzzy.vim', { 'on_map': [ + \ '(incsearch-fuzzyspell-/)', + \ '(incsearch-fuzzyspell-?)', + \ '(incsearch-fuzzyspell-stay)' ] \ } endif endif diff --git a/layers/+fun/emoji/packages.vim b/layers/+fun/emoji/packages.vim index 6bfd6aaa..1a1e9eab 100644 --- a/layers/+fun/emoji/packages.vim +++ b/layers/+fun/emoji/packages.vim @@ -1,2 +1,2 @@ -MP 'junegunn/vim-emoji', { 'for': 'markdown' } +MP 'junegunn/vim-emoji', { 'on_ft': 'markdown' } diff --git a/layers/+fun/goyo/packages.vim b/layers/+fun/goyo/packages.vim index 1418caae..6fe1d95e 100644 --- a/layers/+fun/goyo/packages.vim +++ b/layers/+fun/goyo/packages.vim @@ -1,3 +1,3 @@ -MP 'junegunn/goyo.vim', { 'on' : 'Goyo' } -MP 'junegunn/limelight.vim', { 'on' : 'Limelight' } +MP 'junegunn/goyo.vim', { 'on_cmd' : 'Goyo' } +MP 'junegunn/limelight.vim', { 'on_cmd' : 'Limelight' } diff --git a/layers/+lang/c-c++/packages.vim b/layers/+lang/c-c++/packages.vim index ced4823b..83dd140d 100644 --- a/layers/+lang/c-c++/packages.vim +++ b/layers/+lang/c-c++/packages.vim @@ -1,2 +1,2 @@ -MP 'rhysd/vim-clang-format', { 'for': [ 'c', 'cpp' ] } -MP 'octol/vim-cpp-enhanced-highlight', { 'for': [ 'c', 'cpp' ] } +MP 'rhysd/vim-clang-format', { 'on_ft': [ 'c', 'cpp' ] } +MP 'octol/vim-cpp-enhanced-highlight', { 'on_ft': [ 'c', 'cpp' ] } diff --git a/layers/+lang/clojure/packages.vim b/layers/+lang/clojure/packages.vim index 687ca54f..50928a22 100644 --- a/layers/+lang/clojure/packages.vim +++ b/layers/+lang/clojure/packages.vim @@ -1,5 +1,5 @@ -MP 'kovisoft/paredit' , { 'for': 'clojure' } -MP 'tpope/vim-fireplace' , { 'for': 'clojure' } +MP 'kovisoft/paredit' , { 'on_ft': 'clojure' } +MP 'tpope/vim-fireplace' , { 'on_ft': 'clojure' } MP 'guns/vim-clojure-static' MP 'guns/vim-clojure-highlight' MP 'guns/vim-slamhound' diff --git a/layers/+lang/erlang/packages.vim b/layers/+lang/erlang/packages.vim index b1cf87d7..2e2d526d 100644 --- a/layers/+lang/erlang/packages.vim +++ b/layers/+lang/erlang/packages.vim @@ -1,16 +1,16 @@ -MP 'vim-erlang/vim-erlang-omnicomplete', { 'for': 'erlang' } +MP 'vim-erlang/vim-erlang-omnicomplete', { 'on_ft': 'erlang' } " Generate tags -MP 'vim-erlang/vim-erlang-tags', { 'on': 'ErlangTags' } +MP 'vim-erlang/vim-erlang-tags', { 'on_cmd': 'ErlangTags' } " Syntax checking and compiler on save -MP 'vim-erlang/vim-erlang-compiler', { 'for': 'erlang' } +MP 'vim-erlang/vim-erlang-compiler', { 'on_ft': 'erlang' } " Indentation and syntax (included in vim-polyglot) "MP 'vim-erlang/vim-erlang-runtime' " Generic templates -MP 'vim-erlang/vim-erlang-skeletons', { 'for': 'erlang' } +MP 'vim-erlang/vim-erlang-skeletons', { 'on_ft': 'erlang' } " Motions and text objects -MP 'vim-erlang/erlang-motions.vim', { 'for': 'erlang' } +MP 'vim-erlang/erlang-motions.vim', { 'on_ft': 'erlang' } diff --git a/layers/+lang/go/packages.vim b/layers/+lang/go/packages.vim index 398c1543..dbbeb4cc 100644 --- a/layers/+lang/go/packages.vim +++ b/layers/+lang/go/packages.vim @@ -1,6 +1,7 @@ if g:spacevim.speed_up_via_timer - MP 'fatih/vim-go', { 'on': [], 'do': ':GoInstallBinaries' } + MP 'fatih/vim-go', { 'hook_post_update': ':GoInstallBinaries', + \ 'hook_source': function('spacevim#autocmd#go#Init'), 'lazy': 1 } else - MP 'fatih/vim-go', { 'for': 'go', 'do': ':GoInstallBinaries' } + MP 'fatih/vim-go', { 'hook_post_update': ':GoInstallBinaries', + \ 'hook_source': function('spacevim#autocmd#go#Init'), 'on_ft': 'go' } endif -autocmd! User vim-go call spacevim#autocmd#go#Init() diff --git a/layers/+lang/html/packages.vim b/layers/+lang/html/packages.vim index 365e7111..575b02c6 100644 --- a/layers/+lang/html/packages.vim +++ b/layers/+lang/html/packages.vim @@ -1,3 +1,3 @@ -MP 'othree/html5.vim', { 'for': 'html' } -MP 'hail2u/vim-css3-syntax', { 'for': 'css' } -MP 'mattn/emmet-vim', { 'for': [ 'html', 'vue', 'css' ] } +MP 'othree/html5.vim', { 'on_ft': 'html' } +MP 'hail2u/vim-css3-syntax', { 'on_ft': 'css' } +MP 'mattn/emmet-vim', { 'on_ft': [ 'html', 'vue', 'css' ] } diff --git a/layers/+lang/java/packages.vim b/layers/+lang/java/packages.vim index f7e7fab5..b404ff92 100644 --- a/layers/+lang/java/packages.vim +++ b/layers/+lang/java/packages.vim @@ -1,13 +1 @@ -MP 'artur-shaik/vim-javacomplete2', { 'on': [] } - -" Load vim-javacomplete2 for java -function! s:invoke_javacomplete() - if &filetype ==# 'java' - call plug#load('vim-javacomplete2') - endif -endfunction - -augroup loadJava - autocmd! - autocmd InsertEnter * call s:invoke_javacomplete() -augroup END +MP 'artur-shaik/vim-javacomplete2', { 'lazy': 1 } diff --git a/layers/+lang/javascript/packages.vim b/layers/+lang/javascript/packages.vim index caf5abe2..ea564266 100644 --- a/layers/+lang/javascript/packages.vim +++ b/layers/+lang/javascript/packages.vim @@ -1,2 +1,2 @@ -MP 'pangloss/vim-javascript', { 'for': ['javascript'] } -MP 'neoclide/vim-jsx-improve', { 'for': ['javascript', 'javascript.jsx'] } +MP 'pangloss/vim-javascript', { 'on_ft': ['javascript'] } +MP 'neoclide/vim-jsx-improve', { 'on_ft': ['javascript', 'javascript.jsx'] } diff --git a/layers/+lang/latex/packages.vim b/layers/+lang/latex/packages.vim index b811596a..77eecb4b 100644 --- a/layers/+lang/latex/packages.vim +++ b/layers/+lang/latex/packages.vim @@ -1,2 +1,2 @@ -MP 'xuhdev/vim-latex-live-preview', { 'for': 'tex' } -autocmd! User vim-latex-live-preview call spacevim#autocmd#latex#Init() +MP 'xuhdev/vim-latex-live-preview', { 'on_ft': 'tex', + \ 'hook_source': function('spacevim#autocmd#latex#Init') } diff --git a/layers/+lang/markdown/packages.vim b/layers/+lang/markdown/packages.vim index 9cb33f8a..92c7f91c 100644 --- a/layers/+lang/markdown/packages.vim +++ b/layers/+lang/markdown/packages.vim @@ -1,9 +1,13 @@ if g:spacevim.speed_up_via_timer - MP 'plasticboy/vim-markdown', { 'on': [] } + MP 'plasticboy/vim-markdown', { 'lazy': 1, + \ 'hook_source': function('spacevim#autocmd#markdown#Init') } else - MP 'plasticboy/vim-markdown', { 'for': 'markdown' } + MP 'plasticboy/vim-markdown', { 'on_ft': 'markdown', + \ 'hook_source': function('spacevim#autocmd#markdown#Init') } endif -MP 'mzlogin/vim-markdown-toc', { 'on': ['GenTocGFM', 'GenTocRedcarpet', 'GenTocGitLab', 'UpdateToc', 'RemoveToc'] } -MP 'previm/previm', { 'for': 'markdown', 'on': 'PrevimOpen' } -autocmd! User vim-markdown,vim-markdown-toc,previm call spacevim#autocmd#markdown#Init() +MP 'mzlogin/vim-markdown-toc', { 'on_cmd': + \ ['GenTocGFM', 'GenTocRedcarpet', 'GenTocGitLab', 'UpdateToc', 'RemoveToc'], + \ 'hook_source': function('spacevim#autocmd#markdown#Init') } +MP 'previm/previm', { 'on_ft': 'markdown', 'on_cmd': 'PrevimOpen', + \ 'hook_source': function('spacevim#autocmd#markdown#Init') } diff --git a/layers/+lang/python/packages.vim b/layers/+lang/python/packages.vim index 6aa218c3..e1c72818 100644 --- a/layers/+lang/python/packages.vim +++ b/layers/+lang/python/packages.vim @@ -1,6 +1,6 @@ MP 'jeetsukumaran/vim-pythonsense' if g:spacevim.speed_up_via_timer - MP 'python-mode/python-mode', { 'on': [] } + MP 'python-mode/python-mode', { 'rev': 'develop', 'lazy': 1 } else - MP 'python-mode/python-mode', { 'for': 'python', 'branch': 'develop' } + MP 'python-mode/python-mode', { 'rev': 'develop', 'on_ft': 'python' } endif diff --git a/layers/+lang/ruby/packages.vim b/layers/+lang/ruby/packages.vim index 978468c0..587da7f1 100644 --- a/layers/+lang/ruby/packages.vim +++ b/layers/+lang/ruby/packages.vim @@ -1 +1 @@ -MP 'vim-ruby/vim-ruby', { 'for': 'ruby' } +MP 'vim-ruby/vim-ruby', { 'on_ft': 'ruby' } diff --git a/layers/+lang/rust/packages.vim b/layers/+lang/rust/packages.vim index bdb2c6d8..3208068f 100644 --- a/layers/+lang/rust/packages.vim +++ b/layers/+lang/rust/packages.vim @@ -2,8 +2,9 @@ MP 'cespare/vim-toml' if g:spacevim.speed_up_via_timer - MP 'rust-lang/rust.vim', { 'on': [] } + MP 'rust-lang/rust.vim', { 'lazy': 1, + \ 'hook_source': function('spacevim#autocmd#rust#Init') } else - MP 'rust-lang/rust.vim', { 'for': 'rust' } + MP 'rust-lang/rust.vim', { 'on_ft': 'rust', + \ 'hook_source': function('spacevim#autocmd#rust#Init') } endif -autocmd! User rust.vim call spacevim#autocmd#rust#Init() diff --git a/layers/+lang/scala/packages.vim b/layers/+lang/scala/packages.vim index 0bbbc2a7..44acae73 100644 --- a/layers/+lang/scala/packages.vim +++ b/layers/+lang/scala/packages.vim @@ -1 +1 @@ -MP 'derekwyatt/vim-scala', { 'for': 'scala' } +MP 'derekwyatt/vim-scala', { 'on_ft': 'scala' } diff --git a/layers/+lang/typescript/packages.vim b/layers/+lang/typescript/packages.vim index 8d3a1cad..205b4f4b 100644 --- a/layers/+lang/typescript/packages.vim +++ b/layers/+lang/typescript/packages.vim @@ -1,4 +1,4 @@ -MP 'Quramy/tsuquyomi', { 'for': 'typescript' } -MP 'Shougo/vimproc.vim', { 'for': 'typescript', 'do' : 'make' } -MP 'leafgarland/typescript-vim', { 'for': 'typescript' } -MP 'ianks/vim-tsx', { 'for': 'typescript.tsx' } +MP 'Quramy/tsuquyomi', { 'on_ft': 'typescript' } +MP 'Shougo/vimproc.vim', { 'on_ft': 'typescript', 'build' : 'make' } +MP 'leafgarland/typescript-vim', { 'on_ft': 'typescript' } +MP 'ianks/vim-tsx', { 'on_ft': 'typescript.tsx' } diff --git a/layers/+lang/vue/packages.vim b/layers/+lang/vue/packages.vim index 16afff05..fb14c048 100644 --- a/layers/+lang/vue/packages.vim +++ b/layers/+lang/vue/packages.vim @@ -1 +1 @@ -MP 'posva/vim-vue', { 'for': 'vue' } +MP 'posva/vim-vue', { 'on_ft': 'vue' } diff --git a/layers/+programming/code-snippets/config.vim b/layers/+programming/code-snippets/config.vim index 040c9d98..d0e44d70 100644 --- a/layers/+programming/code-snippets/config.vim +++ b/layers/+programming/code-snippets/config.vim @@ -10,7 +10,7 @@ scriptencoding utf-8 let g:UltiSnipsJumpForwardTrigger = "" let g:UltiSnipsJumpBackwardTrigger = "" - if has_key(g:plugs, 'ncm2-ultisnips') + if dein#is_available('ncm2-ultisnips') " is used to expand snippets inoremap ((pumvisible() && empty(v:completed_item)) ? "\\" : (!empty(v:completed_item) ? ncm2_ultisnips#expand_or("", 'n') : "\" )) imap ncm2_ultisnips#expand_or("\(ultisnips_expand)", 'm') diff --git a/layers/+programming/code-snippets/packages.vim b/layers/+programming/code-snippets/packages.vim index b453fac3..56e358ee 100644 --- a/layers/+programming/code-snippets/packages.vim +++ b/layers/+programming/code-snippets/packages.vim @@ -1,4 +1,2 @@ -" Refer to https://github.com/junegunn/vim-plug/wiki/faq -" Load on nothing -MP 'SirVer/ultisnips', { 'on': [], 'on_event': 'InsertEnter' } -MP 'honza/vim-snippets', { 'on': [], 'on_event': 'InsertEnter' } +MP 'SirVer/ultisnips', { 'on_event': 'InsertEnter' } +MP 'honza/vim-snippets', { 'on_event': 'InsertEnter' } diff --git a/layers/+programming/editing/config.vim b/layers/+programming/editing/config.vim index 06e13685..5f9c7409 100644 --- a/layers/+programming/editing/config.vim +++ b/layers/+programming/editing/config.vim @@ -26,3 +26,23 @@ scriptencoding utf-8 nnoremap ss :call Swoop() nnoremap sm :call SwoopMulti() " } + +" auto-pairs { + function! s:TryInitAutoPairs() abort + if !dein#is_available('auto-pairs') + return + endif + if !exists('g:AutoPairsLoaded') + call dein#source('auto-pairs') + endif + if exists('*AutoPairsTryInit') + call AutoPairsTryInit() + endif + autocmd! spacevimAutoPairs + endfunction + + augroup spacevimAutoPairs + autocmd! + autocmd CursorHold,CursorHoldI,InsertEnter * call TryInitAutoPairs() + augroup END +" } diff --git a/layers/+programming/editing/packages.vim b/layers/+programming/editing/packages.vim index 4c1ad497..146f8d3c 100644 --- a/layers/+programming/editing/packages.vim +++ b/layers/+programming/editing/packages.vim @@ -2,26 +2,8 @@ MP 'tpope/vim-surround' MP 'pelodelfuego/vim-swoop' MP 'terryma/vim-multiple-cursors' -MP 'scrooloose/nerdcommenter', { 'on': 'NERDCommenterToggle' } +MP 'scrooloose/nerdcommenter', { 'on_map': 'NERDCommenterToggle' } " auto-pairs may interfere with vim-clap. You can disable auto-pairs and use " the other alternatives, e.g., coc-pairs. -MP 'jiangmiao/auto-pairs', { 'on': [] } - -function! s:TryInitAutoPairs() abort - if !has_key(g:plugs, 'auto-pairs') - return - endif - if !exists('g:AutoPairsLoaded') - call plug#load('auto-pairs') - endif - if exists('*AutoPairsTryInit') - call AutoPairsTryInit() - endif - autocmd! spacevimAutoPairs -endfunction - -augroup spacevimAutoPairs - autocmd! - autocmd CursorHold,CursorHoldI,InsertEnter * call TryInitAutoPairs() -augroup END +MP 'jiangmiao/auto-pairs', { 'lazy': 1 } diff --git a/layers/+programming/formatting/packages.vim b/layers/+programming/formatting/packages.vim index dc1063aa..f29535a0 100644 --- a/layers/+programming/formatting/packages.vim +++ b/layers/+programming/formatting/packages.vim @@ -1 +1 @@ -MP 'Chiel92/vim-autoformat', { 'on': 'Autoformat' } +MP 'Chiel92/vim-autoformat', { 'on_cmd': 'Autoformat' } diff --git a/layers/+programming/programming/config.vim b/layers/+programming/programming/config.vim index 80ca0721..f1405076 100644 --- a/layers/+programming/programming/config.vim +++ b/layers/+programming/programming/config.vim @@ -1,5 +1,9 @@ scriptencoding utf-8 +if g:spacevim.speed_up_via_timer + call timer_start(400, 'spacevim#defer#programming') +endif + augroup spacevimNewFile autocmd! " Add title automatically when new files and move cursor to the end of file diff --git a/layers/+programming/programming/packages.vim b/layers/+programming/programming/packages.vim index 6648e5b3..a1c37470 100644 --- a/layers/+programming/programming/packages.vim +++ b/layers/+programming/programming/packages.vim @@ -1,33 +1,28 @@ -if g:spacevim.speed_up_via_timer - MP 'luochen1990/rainbow' , { 'on': [] } - MP 'sheerun/vim-polyglot' , { 'on': [] } - MP 'airblade/vim-rooter' , { 'on': []} - MP 'editorconfig/editorconfig-vim', { 'on': []} - call timer_start(400, 'spacevim#defer#programming') -else - MP 'luochen1990/rainbow' - MP 'sheerun/vim-polyglot' - MP 'airblade/vim-rooter' - MP 'editorconfig/editorconfig-vim' -endif +MP 'luochen1990/rainbow' , { 'lazy': g:spacevim.speed_up_via_timer } +MP 'sheerun/vim-polyglot' , { 'lazy': g:spacevim.speed_up_via_timer } +MP 'airblade/vim-rooter' , { 'lazy': g:spacevim.speed_up_via_timer } +MP 'editorconfig/editorconfig-vim', { 'lazy': g:spacevim.speed_up_via_timer } -MP 'matze/vim-move', { 'on': [ +MP 'matze/vim-move', { 'on_map': [ \ 'MoveBlockDown', \ 'MoveBlockUp', \ 'MoveLineDown', \ 'MoveLineUp', + \ 'MoveCharLeft', + \ 'MoveCharRight', \ ]} -MP 'junegunn/rainbow_parentheses.vim', { 'for': ['lisp', 'clojure', 'scheme'] } +MP 'junegunn/rainbow_parentheses.vim', { 'on_ft': ['lisp', 'clojure', 'scheme'] } " Need to disable airline extension for tagbar, see vim-airline issue 1313. " -MP 'majutsushi/tagbar', { 'on': 'TagbarToggle' } +MP 'majutsushi/tagbar', { 'on_cmd': 'TagbarToggle' } MP 'liuchengxu/vista.vim' -MP 'Yggdroot/indentLine', { 'on': 'IndentLinesToggle' } -MP 'nathanaelkane/vim-indent-guides', { 'on': 'IndentGuidesToggle' } -autocmd! User indentLine,vim-indent-guides call spacevim#autocmd#indent#Init() +MP 'Yggdroot/indentLine', { 'on_cmd': 'IndentLinesToggle', + \ 'hook_source': function('spacevim#autocmd#indent#Init') } +MP 'nathanaelkane/vim-indent-guides', { 'on_cmd': 'IndentGuidesToggle', + \ 'hook_source': function('spacevim#autocmd#indent#Init') } -MP 'skywind3000/asyncrun.vim', { 'on': ['AsyncRun!', 'AsyncRun'] } +MP 'skywind3000/asyncrun.vim', { 'on_cmd': ['AsyncRun'] } diff --git a/layers/+themes/airline/config.vim b/layers/+themes/airline/config.vim index 8b4a2c4b..0b8b60e3 100644 --- a/layers/+themes/airline/config.vim +++ b/layers/+themes/airline/config.vim @@ -1,6 +1,12 @@ scriptencoding=utf-8 " vim-airline { + if g:spacevim.speed_up_via_timer + " The waiting time for airline should be longer than the one for + " fugitive and ale. + call timer_start(250, 'spacevim#defer#airline') + endif + let g:airline_theme='violet' let g:Powerline_symbols='fancy' let g:airline#extensions#branch#enabled = 1 diff --git a/layers/+themes/airline/packages.vim b/layers/+themes/airline/packages.vim index 12f3876f..ae43a288 100644 --- a/layers/+themes/airline/packages.vim +++ b/layers/+themes/airline/packages.vim @@ -1,10 +1,2 @@ -if g:spacevim.speed_up_via_timer - MP 'vim-airline/vim-airline-themes' , { 'on': [] } - MP 'vim-airline/vim-airline' , { 'on': [] } - " The waiting time for airline should be longer than the one for fugitive - " and ale. - call timer_start(250, 'spacevim#defer#airline') -else - MP 'vim-airline/vim-airline-themes' - MP 'vim-airline/vim-airline' -endif +MP 'vim-airline/vim-airline-themes', { 'lazy': g:spacevim.speed_up_via_timer } +MP 'vim-airline/vim-airline', { 'lazy': g:spacevim.speed_up_via_timer } diff --git a/layers/+tools/ctags/packages.vim b/layers/+tools/ctags/packages.vim index 99b15e22..ab7f1fad 100644 --- a/layers/+tools/ctags/packages.vim +++ b/layers/+tools/ctags/packages.vim @@ -1,2 +1,2 @@ -MP 'ludovicchabant/vim-gutentags', { 'for': ['c', 'cpp'] } -autocmd! User vim-gutentags call spacevim#autocmd#gutentags#Init() +MP 'ludovicchabant/vim-gutentags', { 'on_ft': ['c', 'cpp'], + \ 'hook_source': function('spacevim#autocmd#gutentags#Init') } diff --git a/layers/+tools/docker/packages.vim b/layers/+tools/docker/packages.vim index 0ef8f957..e4c5cb8f 100644 --- a/layers/+tools/docker/packages.vim +++ b/layers/+tools/docker/packages.vim @@ -1 +1 @@ -MP 'ekalinin/Dockerfile.vim', { 'for': ['Dockerfile', 'docker-compose'] } +MP 'ekalinin/Dockerfile.vim', { 'on_ft': ['Dockerfile', 'docker-compose'] } diff --git a/layers/+tools/file-manager/config.vim b/layers/+tools/file-manager/config.vim index b8f59540..0e7fa640 100644 --- a/layers/+tools/file-manager/config.vim +++ b/layers/+tools/file-manager/config.vim @@ -1,7 +1,6 @@ scriptencoding utf-8 if exists('g:coc_global_extensions') && index(g:coc_global_extensions, 'coc-explorer') > -1 - function! s:CocExplorerFind() abort " Workaround for coc-explorer let coc_explorer = filter(range(1, bufnr('$')), 'getbufvar(v:val, "&filetype") ==# "coc-explorer"') @@ -22,8 +21,19 @@ if exists('g:coc_global_extensions') && index(g:coc_global_extensions, 'coc-expl nnoremap ft :call CocExplorerToggle() nnoremap fd :call CocExplorerFind() else - nnoremap :NERDTreeToggle - inoremap :NERDTreeToggle - nnoremap ft :NERDTreeToggle - nnoremap fd :NERDTreeFind + " nerdtree { + augroup loadNerdtree + autocmd! + autocmd VimEnter * silent! autocmd! FileExplorer + autocmd BufEnter,BufNew * + \ if isdirectory(expand('')) + \| call dein#source('nerdtree') + \| call nerdtree#checkForBrowse(expand("")) + \| endif + augroup END + nnoremap :NERDTreeToggle + inoremap :NERDTreeToggle + nnoremap ft :NERDTreeToggle + nnoremap fd :NERDTreeFind + " } endif diff --git a/layers/+tools/file-manager/packages.vim b/layers/+tools/file-manager/packages.vim index 54e253fc..0a7739bb 100644 --- a/layers/+tools/file-manager/packages.vim +++ b/layers/+tools/file-manager/packages.vim @@ -1,28 +1,20 @@ -MP 'danro/rename.vim', { 'on' : 'Rename' } +MP 'danro/rename.vim', { 'on_cmd' : 'Rename' } if exists('g:coc_global_extensions') && index(g:coc_global_extensions, 'coc-explorer') > -1 " coc.nvim will handle this automatically. else " Refer to https://github.com/junegunn/dotfiles vimrc - MP 'scrooloose/nerdtree', { 'on': ['NERDTreeToggle', 'NERDTreeFind'] } - autocmd! User nerdtree call spacevim#autocmd#nerdtree#Init() - augroup loadNerdtree - autocmd! - autocmd VimEnter * silent! autocmd! FileExplorer - autocmd BufEnter,BufNew * - \ if isdirectory(expand('')) - \| call plug#load('nerdtree') - \| call nerdtree#checkForBrowse(expand("")) - \| endif - augroup END - + MP 'scrooloose/nerdtree', { 'on_cmd': ['NERDTreeToggle', 'NERDTreeFind'], + \ 'hook_source': function('spacevim#autocmd#nerdtree#Init'), + \ 'hook_post_source': 'call dein#source(\"nerdtree-git-plugin\")' } + "\ .'| call dein#source(\"vim-nerdtree-syntax-highlight\")' } if get(g:, 'spacevim_nerd_fonts', 0) MP 'ryanoasis/vim-devicons' endif MP 'liuchengxu/nerdtree-dash' - MP 'Xuyuanp/nerdtree-git-plugin', { 'on': ['NERDTreeToggle', 'NERDTreeFind'] } + MP 'Xuyuanp/nerdtree-git-plugin', { 'lazy': 1 } " Disable vim-nerdtree-syntax-highlight for the performance consideration, see #237 - " MP 'tiagofumo/vim-nerdtree-syntax-highlight', { 'on': ['NERDTreeToggle', 'NERDTreeFind'] } + " MP 'tiagofumo/vim-nerdtree-syntax-highlight', { 'lazy': 1 } endif diff --git a/layers/+tools/fzf/README.md b/layers/+tools/fzf/README.md index 32acdf28..149efc40 100644 --- a/layers/+tools/fzf/README.md +++ b/layers/+tools/fzf/README.md @@ -27,6 +27,8 @@ choco install ag choco install ripgrep ``` +Alternatively ripgrep, fd, git-delta, bat will be built from source if using the 'rustc' layer. fzf and ag are not rust and can't be built with the 'rustc' layer. + ## Install To use this configuration layer, add it to your `~/.spacevim`. *It has been enabled as one of the default layers*. diff --git a/layers/+tools/fzf/config.vim b/layers/+tools/fzf/config.vim index ce39b88a..50166a99 100644 --- a/layers/+tools/fzf/config.vim +++ b/layers/+tools/fzf/config.vim @@ -18,6 +18,10 @@ if g:spacevim.gui && !has('terminal') " } else " fzf.vim { + if g:spacevim.speed_up_via_timer + call timer_start(700, 'spacevim#defer#fzf') + endif + " Refer to https://github.com/liuchengxu/space-vim/issues/364 let $LANG = 'en_US.UTF-8' diff --git a/layers/+tools/fzf/packages.vim b/layers/+tools/fzf/packages.vim index 914acd2a..c7454adf 100644 --- a/layers/+tools/fzf/packages.vim +++ b/layers/+tools/fzf/packages.vim @@ -1,15 +1,11 @@ if get(g:, 'spacevim_enable_clap', 0) - MP 'liuchengxu/vim-clap', { 'do': ':Clap install-binary!' } + MP 'liuchengxu/vim-clap', { 'hook_post_update': ':Clap install-binary!' } MP 'vn-ki/coc-clap' elseif g:spacevim.gui && !has('terminal') MP 'Yggdroot/LeaderF' else - if g:spacevim.speed_up_via_timer - MP 'junegunn/fzf', { 'dir': '~/.fzf', 'do': function('spacevim#VimPlugPostUpdateHook', [v:false, './install --all']), 'on': [] } - MP 'junegunn/fzf.vim', { 'on': [] } - call timer_start(700, 'spacevim#defer#fzf') - else - MP 'junegunn/fzf', { 'dir': '~/.fzf', 'do': function('spacevim#VimPlugPostUpdateHook', [v:false, './install --all']) } - MP 'junegunn/fzf.vim' - endif + MP 'junegunn/fzf', { 'path': '~/.fzf', 'hook_post_update': + \ function('spacevim#vim#plug#post_update', ['fzf', './install --all']), + \ 'lazy': g:spacevim.speed_up_via_timer } + MP 'junegunn/fzf.vim', { 'lazy': g:spacevim.speed_up_via_timer } endif diff --git a/layers/+tools/lsp/config.vim b/layers/+tools/lsp/config.vim index e345f78f..2b08fb4b 100644 --- a/layers/+tools/lsp/config.vim +++ b/layers/+tools/lsp/config.vim @@ -14,6 +14,8 @@ function! s:try_show_signature_help() abort endfunction function! s:coc() abort + call timer_start(200, function('spacevim#plug#coc#Init')) + " Better display for messages set cmdheight=2 diff --git a/layers/+tools/lsp/packages.vim b/layers/+tools/lsp/packages.vim index 09f4659b..3e7a74a2 100644 --- a/layers/+tools/lsp/packages.vim +++ b/layers/+tools/lsp/packages.vim @@ -1,29 +1,20 @@ -function! s:coc() abort - MP 'neoclide/coc.nvim', { 'branch': 'release' } - - call timer_start(200, function('spacevim#plug#coc#Init')) +if g:spacevim_lsp_engine ==# 'coc' + MP 'neoclide/coc.nvim', { 'rev': 'release' } " Load these two plugins in core/ftplugin/vim.vim - MP 'Shougo/neco-vim', { 'on': [] } - MP 'neoclide/coc-neco', { 'on': [] } -endfunction - -function! s:vim_lsp() abort + MP 'Shougo/neco-vim', { 'lazy': 1 } + MP 'neoclide/coc-neco', { 'lazy': 1 } +elseif g:spacevim_lsp_engine ==# 'vim_lsp' MP 'prabirshrestha/async.vim' MP 'prabirshrestha/vim-lsp' MP 'mattn/vim-lsp-settings' if spacevim#load('ale') MP 'rhysd/vim-lsp-ale' endif -endfunction - -function! s:lcn() abort +elseif g:spacevim_lsp_engine ==# 'lcn' MP 'autozimu/LanguageClient-neovim', { - \ 'branch': 'next', - \ 'do': function('spacevim#VimPlugPostUpdateHook', [v:false, 'bash install.sh']), + \ 'rev': 'next', + \ 'hook_post_update': function('spacevim#vim#plug#post_update', + \ ['LanguageClient-neovim', 'bash install.sh']), \ } -endfunction - -let g:spacevim_lsp_engine = get(g:, 'spacevim_lsp_engine', 'lcn') - -call s:{g:spacevim_lsp_engine}() +endif diff --git a/layers/+tools/rustc/README.md b/layers/+tools/rustc/README.md new file mode 100644 index 00000000..5c22d976 --- /dev/null +++ b/layers/+tools/rustc/README.md @@ -0,0 +1,43 @@ +# Rust tool layer + +## Table of Contents + + + +* [Description](#description) +* [Install](#install) + * [Building](#building) + * [Prerequisite](#prerequisite) + * [MS Windows](#ms-windows) + + + +## Description + +Folowing the zero-install philosophy, this layer adds the Rust compiler, standard library, documentation, and default extensions including Cargo. All built from source. + +If `rustc` is found on $PATH, or $RUSTC points to `rustc`, and either is of sufficient version, that will be used instead of building from source. + +Cargo will be added to $PATH for use by Vim plugins and for a LSP plugin/engine to install language servers. + +A convenience feature of this layer is that the binaries installed by cargo will be added to $PATH, e.g. deno, tree-sitter, and language servers. + +## Install + +To use this layer, add it to your `~/.spacevim`. + +### Building + +On building from source, around 600MiB is іnstalled into the prefix `./install` relative to the plugin directory. The building process requires around 17GiB, which will be deleted on completion. + +If the automated building doesn't work, you may navigate to the plugin directory and build manually, into the prefix `./install`; installing system-wide isn't required. Or install prebuilt binaries and set $PATH or $RUSTC accordingly. + +#### Prerequisite + +See [Unix](https://github.com/rust-lang/rust#building-on-a-unix-like-system) or [Windows](https://github.com/rust-lang/rust#building-on-windows) prerequisites. + +#### MS Windows + +At present rust supports building under two ABIs: GNU and MSVC (comes with Visual Studio Tools). Your choice depends on the C/C++ libraries you want to interoperate with. + +Automated building from source isn't tested. However it should work in Cygwin or with the environmental variables as defined by `msys2_shell.cmd` or `vcvars64.bat` per the desired ABI. diff --git a/layers/+tools/rustc/config.vim b/layers/+tools/rustc/config.vim new file mode 100644 index 00000000..d1ef3f08 --- /dev/null +++ b/layers/+tools/rustc/config.vim @@ -0,0 +1,17 @@ +execute 'source '.fnamemodify(expand(''), ':h').'/native-dependency.vim' + +if spacevim#vim#plug#LocateDependency('rust')[0] ==# 'none' + call spacevim#util#warn('rustc layer failure, try ":call dein#get('. + \ '"rust").hook_post_update()" to build as plugin, or set $RUSTC/'. + \ '$PATH to existing build, or install system-wide with version >= '. + \ join(g:spacevim#vim#plug#native_dependency['rust'].v_req, '.').'.') +else + " Add cargo installed binaries to PATH, e.g. deno, tree-sitter + if exists('$CARGO_INSTALL_ROOT') + call spacevim#util#PostfixPATH(expand('$CARGO_INSTALL_ROOT/bin')) + elseif exists('$CARGO_HOME') + call spacevim#util#PostfixPATH(expand('$CARGO_HOME/bin')) + else + call spacevim#util#PostfixPATH(expand('$HOME/.cargo/bin')) + endif +endif diff --git a/layers/+tools/rustc/native-dependency.vim b/layers/+tools/rustc/native-dependency.vim new file mode 100644 index 00000000..d97d0ffe --- /dev/null +++ b/layers/+tools/rustc/native-dependency.vim @@ -0,0 +1,48 @@ +function! Build(native) abort + let python = (g:spacevim.os.windows ? 'python ' : './') + call system(python.a:native.plugpath.'/src/bootstrap/configure.py '. + \ '--prefix='.a:native.plugpath.'/install --bindir=bin --libdir=lib'. + \ ' --sysconfdir=. --disable-docs') + + if filereadable('config.toml') + " profile=user setting unsupported through configure.py interface + execute ':tabnew +%s/\\V\#profile\ \=\ \/profile\ \=\ \"user\"/e|up config.toml' + call spacevim#util#info('Edit config.toml rustc configuration if desired...') + endif + + call execute('AsyncRun -cwd='.a:native.plugpath.'/build -mode=term '. + \ '-pos=tab -post='. + \ 'call\ spacevim\#vim\#plug\#PostBuild(code,\ ''rust'') @ '. + \ python.'x.py build && '.python.'x.py install') +endfunction + +function! PostBuild(native) abort + "TODO: Comment? + "call delete('library', 'rf') + "call delete('Makefile') + "call delete('src', 'rf') + " Install rg and fd tools if not on system + if executable('rg') != 1 + call spacevim#vim#plug#post_update('', 'cargo install --locked ripgrep') + endif + if executable('fd') != 1 + call spacevim#vim#plug#post_update('', 'cargo install --locked fd-find') + endif + if executable('delta') != 1 + call spacevim#vim#plug#post_update('', 'cargo install --locked git-delta') + endif + if executable('bat') != 1 + call spacevim#vim#plug#post_update('', 'cargo install --locked bat') + endif +endfunction + +let g:spacevim#vim#plug#native_dependency = get(g:, 'spacevim#vim#plug#native_dependency', {}) +let g:spacevim#vim#plug#native_dependency['rust'] = { + \ 'bin': 'rustc', + \ 'override': '$RUSTC', + \ 'repo': 'rust-lang/rust', + \ 'vregex': '\Vrustc \(\[0-9]\+\).\(\[0-9]\+\).\(\[0-9]\+\)', + \ 'v_req': [1, 56, 0], + \ 'Build': function('Build'), + \ 'PostBuild': function('PostBuild'), +\ } diff --git a/layers/+tools/rustc/packages.vim b/layers/+tools/rustc/packages.vim new file mode 100644 index 00000000..06ee08a0 --- /dev/null +++ b/layers/+tools/rustc/packages.vim @@ -0,0 +1,6 @@ +execute 'source '.fnamemodify(expand(''), ':h').'/native-dependency.vim' + +if spacevim#vim#plug#LocateDependency('rust')[0] ==# 'none' + MP 'rust-lang/rust', { 'merged': v:false, 'rtp': '', + \ 'hook_post_update': function('spacevim#vim#plug#Build', ['rust']) } +endif diff --git a/layers/+tools/tmux/packages.vim b/layers/+tools/tmux/packages.vim index 011915cf..eb89a0b1 100644 --- a/layers/+tools/tmux/packages.vim +++ b/layers/+tools/tmux/packages.vim @@ -1,7 +1,7 @@ MP 'christoomey/vim-tmux-navigator' if g:spacevim.tmux if spacevim#load('unite') - MP 'lucidstack/ctrlp-tmux.vim',{'on': 'CtrlPTmux'} + MP 'lucidstack/ctrlp-tmux.vim',{'on_cmd': 'CtrlPTmux'} endif MP 'jebaum/vim-tmuxify' endif diff --git a/layers/+tools/vimspector/config.vim b/layers/+tools/vimspector/config.vim index e69de29b..5124fbb1 100644 --- a/layers/+tools/vimspector/config.vim +++ b/layers/+tools/vimspector/config.vim @@ -0,0 +1,3 @@ +if g:spacevim.speed_up_via_timer + call timer_start(900, 'spacevim#defer#vimspector') +endif diff --git a/layers/+tools/vimspector/packages.vim b/layers/+tools/vimspector/packages.vim index 13a1996f..e522aef2 100644 --- a/layers/+tools/vimspector/packages.vim +++ b/layers/+tools/vimspector/packages.vim @@ -1,6 +1 @@ -if g:spacevim.speed_up_via_timer - MP 'puremourning/vimspector', { 'on': [] } - call timer_start(900, 'spacevim#defer#vimspector') -else - MP 'puremourning/vimspector' -endif +MP 'puremourning/vimspector', { 'lazy': g:spacevim.speed_up_via_timer } diff --git a/layers/+tools/ycmd/config.vim b/layers/+tools/ycmd/config.vim index d9516249..eb7e133f 100644 --- a/layers/+tools/ycmd/config.vim +++ b/layers/+tools/ycmd/config.vim @@ -1 +1,7 @@ -let g:ycm_global_ycm_extra_conf = fnamemodify(expand(''), ':h') . '/global_conf.py' +" YouCompleteMe { + if g:spacevim.speed_up_via_timer + call timer_start(1000, 'spacevim#plug#youcompleteme#invoke') + endif + + let g:ycm_global_ycm_extra_conf = fnamemodify(expand(''), ':h') . '/global_conf.py' +" } diff --git a/layers/+tools/ycmd/packages.vim b/layers/+tools/ycmd/packages.vim index 271a61db..b6a1777e 100644 --- a/layers/+tools/ycmd/packages.vim +++ b/layers/+tools/ycmd/packages.vim @@ -1,10 +1,8 @@ +MP 'rdnetto/YCM-Generator', { + \ 'on_cmd': ['YcmGenerateConfig', 'CCGenerateConfig'], + \ 'rev': 'stable' } -MP 'rdnetto/YCM-Generator', { 'on': ['YcmGenerateConfig', 'CCGenerateConfig'], 'branch': 'stable' } - -MP 'ycm-core/YouCompleteMe', { 'do': function('spacevim#plug#youcompleteme#build'), 'on': [], - \ 'on_event': ['CursorHold', 'CursorHoldI', 'InsertEnter'] } -autocmd! User YouCompleteMe call spacevim#autocmd#youcompleteme#Init() - -if g:spacevim.speed_up_via_timer - call timer_start(1000, 'spacevim#plug#youcompleteme#invoke') -endif +MP 'ycm-core/YouCompleteMe', { + \ 'hook_post_update': function('spacevim#plug#youcompleteme#build'), + \ 'on_event': ['CursorHold', 'CursorHoldI', 'InsertEnter'], 'lazy': 1, + \ 'hook_source': function('spacevim#autocmd#youcompleteme#Init') } diff --git a/layers/+version-control/git/config.vim b/layers/+version-control/git/config.vim index 317102d9..94152586 100644 --- a/layers/+version-control/git/config.vim +++ b/layers/+version-control/git/config.vim @@ -1,5 +1,10 @@ scriptencoding utf-8 +if g:spacevim.speed_up_via_timer + call timer_start(300, 'spacevim#defer#git') + call timer_start(800, 'spacevim#defer#fugitive') +endif + " vim-fugitive { nnoremap gs :Git nnoremap gd :Gdiffsplit diff --git a/layers/+version-control/git/packages.vim b/layers/+version-control/git/packages.vim index 6bf25546..3c4ddaf8 100644 --- a/layers/+version-control/git/packages.vim +++ b/layers/+version-control/git/packages.vim @@ -1,11 +1,4 @@ -MP 'junegunn/gv.vim', { 'on': ['GV', 'GV!'] } +MP 'junegunn/gv.vim', { 'on_cmd': ['GV'] } -if g:spacevim.speed_up_via_timer - MP 'tpope/vim-fugitive' , { 'on': [] } - MP 'mhinz/vim-signify' , { 'on': [] } - call timer_start(300, 'spacevim#defer#git') - call timer_start(800, 'spacevim#defer#fugitive') -else - MP 'tpope/vim-fugitive' - MP 'mhinz/vim-signify' -endif +MP 'tpope/vim-fugitive' , { 'lazy': g:spacevim.speed_up_via_timer } +MP 'mhinz/vim-signify' , { 'lazy': g:spacevim.speed_up_via_timer } diff --git a/layers/+version-control/github/packages.vim b/layers/+version-control/github/packages.vim index fe73d342..290c7761 100644 --- a/layers/+version-control/github/packages.vim +++ b/layers/+version-control/github/packages.vim @@ -1,3 +1,4 @@ -MP 'junegunn/vim-github-dashboard', { 'on': ['GHDashboard', 'GHActivity'] } -MP 'mattn/webapi-vim', { 'on': 'Gist' } -MP 'mattn/gist-vim', { 'on': 'Gist' } +MP 'junegunn/vim-github-dashboard', { 'on_cmd': ['GHDashboard', 'GHActivity'] } +MP 'mattn/webapi-vim', { 'lazy': 1 } +MP 'mattn/gist-vim', { 'on_cmd': 'Gist', + \ 'hook_post_source': 'call dein#source(\"webapi-vim\")' } diff --git a/layers/+vim/better-motion/config.vim b/layers/+vim/better-motion/config.vim index 889a4f16..53bc77f8 100644 --- a/layers/+vim/better-motion/config.vim +++ b/layers/+vim/better-motion/config.vim @@ -1,4 +1,8 @@ " easy-motion +if g:spacevim.speed_up_via_timer + call timer_start(600, 'spacevim#defer#motion') +endif + " Default key bindings: " w : word " b : back diff --git a/layers/+vim/better-motion/packages.vim b/layers/+vim/better-motion/packages.vim index 3d41367a..ebf03a0f 100644 --- a/layers/+vim/better-motion/packages.vim +++ b/layers/+vim/better-motion/packages.vim @@ -1,21 +1,16 @@ MP 'unblevable/quick-scope' -if g:spacevim.speed_up_via_timer - MP 'justinmk/vim-sneak' , { 'on': [] } - MP 'easymotion/vim-easymotion' , { 'on': [] } - MP 'haya14busa/incsearch-easymotion.vim' , { 'on': [] } - call timer_start(600, 'spacevim#defer#motion') -else - MP 'justinmk/vim-sneak' - MP 'easymotion/vim-easymotion' - MP 'haya14busa/incsearch-easymotion.vim', { 'on': [ - \ '(easymotion-prefix)', - \ '(easymotion-bd-f)', - \ '(easymotion-overwin-f)', - \ '(easymotion-overwin-f2)', - \ '(easymotion-bd-jk)', - \ '(easymotion-overwin-line)', - \ '(easymotion-bd-w)', - \ '(easymotion-overwin-w)', - \ ] } -endif +MP 'justinmk/vim-sneak', { 'lazy': g:spacevim.speed_up_via_timer } +MP 'easymotion/vim-easymotion', { 'lazy': g:spacevim.speed_up_via_timer } +MP 'haya14busa/incsearch-easymotion.vim', { + \ 'lazy': g:spacevim.speed_up_via_timer, 'on_map': [ + \ '(easymotion-prefix)', + \ '(easymotion-bd-f)', + \ '(easymotion-overwin-f)', + \ '(easymotion-overwin-f2)', + \ '(easymotion-bd-jk)', + \ '(easymotion-overwin-line)', + \ '(easymotion-bd-w)', + \ '(easymotion-overwin-w)', + \ ] + \ } diff --git a/layers/+vim/ctrlp/packages.vim b/layers/+vim/ctrlp/packages.vim index 80f7151d..2a88d3d2 100644 --- a/layers/+vim/ctrlp/packages.vim +++ b/layers/+vim/ctrlp/packages.vim @@ -2,6 +2,7 @@ if spacevim#load('tmux') MP 'ctrlpvim/ctrlp.vim' MP 'FelikZ/ctrlp-py-matcher' else - MP 'ctrlpvim/ctrlp.vim', { 'on': ['CtrlP', 'CtrlPMRU'] } - MP 'FelikZ/ctrlp-py-matcher', { 'on': ['CtrlP', 'CtrlPMRU'] } + MP 'ctrlpvim/ctrlp.vim', { 'on_cmd': ['CtrlP', 'CtrlPMRU'], + \ 'hook_post_source': 'call dein#source(\"ctrlp-py-matcher\")' } + MP 'FelikZ/ctrlp-py-matcher', { 'lazy': 1 } endif diff --git a/layers/+vim/text-align/packages.vim b/layers/+vim/text-align/packages.vim index add95e92..08ddcfd9 100644 --- a/layers/+vim/text-align/packages.vim +++ b/layers/+vim/text-align/packages.vim @@ -1,2 +1,2 @@ -MP 'godlygeek/tabular', { 'on': 'Tabularize' } -MP 'junegunn/vim-easy-align', { 'on': [ '(EasyAlign)', 'EasyAlign' ] } +MP 'godlygeek/tabular', { 'on_cmd': 'Tabularize' } +MP 'junegunn/vim-easy-align', { 'on_map': '(EasyAlign)', 'on_cmd': 'EasyAlign' } diff --git a/layers/+vim/which-key/packages.vim b/layers/+vim/which-key/packages.vim index 43676962..2ad2da92 100644 --- a/layers/+vim/which-key/packages.vim +++ b/layers/+vim/which-key/packages.vim @@ -1,2 +1,2 @@ -MP 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!', 'WhichKeyVisual', 'WhichKeyVisual!'] } -autocmd! User vim-which-key call spacevim#autocmd#which_key#Init() +MP 'liuchengxu/vim-which-key', { 'on_cmd': ['WhichKey', 'WhichKeyVisual'], + \ 'hook_source': function('spacevim#autocmd#which_key#Init') } diff --git a/layers/LAYERS.md b/layers/LAYERS.md index 934a76e5..1ea1680e 100644 --- a/layers/LAYERS.md +++ b/layers/LAYERS.md @@ -1,7 +1,7 @@ Layer Manifest ============== -Last updated: 2022-09-29 12:39:45 +Last updated: 2022-09-29 16:25:03 Default layers: `fzf`, `better-defaults` and `which-key`. @@ -52,6 +52,7 @@ Topic | Layer | Plugins +tools | [file-manager](https://github.com/liuchengxu/space-vim/tree/master/layers/+tools/file-manager) |
  • [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin)
  • [danro/rename.vim](https://github.com/danro/rename.vim)
  • [liuchengxu/nerdtree-dash](https://github.com/liuchengxu/nerdtree-dash)
  • [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons)
  • [scrooloose/nerdtree](https://github.com/scrooloose/nerdtree)
  • [tiagofumo/vim-nerdtree-syntax-highlight](https://github.com/tiagofumo/vim-nerdtree-syntax-highlight)
+tools | [fzf](https://github.com/liuchengxu/space-vim/tree/master/layers/+tools/fzf) |
  • [Yggdroot/LeaderF](https://github.com/Yggdroot/LeaderF)
  • [junegunn/fzf](https://github.com/junegunn/fzf)
  • [junegunn/fzf.vim](https://github.com/junegunn/fzf.vim)
  • [liuchengxu/vim-clap](https://github.com/liuchengxu/vim-clap)
  • [vn-ki/coc-clap](https://github.com/vn-ki/coc-clap)
+tools | [lsp](https://github.com/liuchengxu/space-vim/tree/master/layers/+tools/lsp) |
  • [autozimu/LanguageClient-neovim](https://github.com/autozimu/LanguageClient-neovim)
  • [mattn/vim-lsp-settings](https://github.com/mattn/vim-lsp-settings)
  • [neoclide/coc-neco](https://github.com/neoclide/coc-neco)
  • [neoclide/coc.nvim](https://github.com/neoclide/coc.nvim)
  • [prabirshrestha/async.vim](https://github.com/prabirshrestha/async.vim)
  • [prabirshrestha/vim-lsp](https://github.com/prabirshrestha/vim-lsp)
  • [rhysd/vim-lsp-ale](https://github.com/rhysd/vim-lsp-ale)
++tools | [rustc](https://github.com/liuchengxu/space-vim/tree/master/layers/+tools/rustc) |
  • [rust-lang/rust](https://github.com/rust-lang/rust)
+tools | [tmux](https://github.com/liuchengxu/space-vim/tree/master/layers/+tools/tmux) |
  • [christoomey/vim-tmux-navigator](https://github.com/christoomey/vim-tmux-navigator)
  • [jebaum/vim-tmuxify](https://github.com/jebaum/vim-tmuxify)
  • [lucidstack/ctrlp-tmux.vim](https://github.com/lucidstack/ctrlp-tmux.vim)
+tools | [vimspector](https://github.com/liuchengxu/space-vim/tree/master/layers/+tools/vimspector) |
  • [puremourning/vimspector](https://github.com/puremourning/vimspector)
+tools | [ycmd](https://github.com/liuchengxu/space-vim/tree/master/layers/+tools/ycmd) |
  • [rdnetto/YCM-Generator](https://github.com/rdnetto/YCM-Generator)
  • [ycm-core/YouCompleteMe](https://github.com/ycm-core/YouCompleteMe)