From 95db7ccfc8da242550e498c51f6dd173c1adbf53 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 30 Jul 2017 05:12:51 +0800 Subject: [PATCH 01/46] Add java debug mappings --- autoload/SpaceVim/layers/lang/java.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/autoload/SpaceVim/layers/lang/java.vim b/autoload/SpaceVim/layers/lang/java.vim index 632834a8f..95e4338dd 100644 --- a/autoload/SpaceVim/layers/lang/java.vim +++ b/autoload/SpaceVim/layers/lang/java.vim @@ -138,6 +138,9 @@ function! s:language_specified_mappings() abort " debug let g:_spacevim_mappings_space.l.d = {'name' : '+Debug'} + call SpaceVim#mapping#space#langSPC('nmap', ['l','d', 's'], ':VBGstartJDB', 'start jdb', 0) + call SpaceVim#mapping#space#langSPC('nmap', ['l','d', 't'], 'VBGtoggleBreakpointThisLine', 'toggle breakpoint at this line', 1) + " maven let g:_spacevim_mappings_space.l.m = {'name' : '+Maven'} call SpaceVim#mapping#space#langSPC('nnoremap', ['l','m', 'i'], 'call call(' From de7e68a5ebe990d233225996eb2726928d4e6f60 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 27 Aug 2017 20:40:37 +0000 Subject: [PATCH 02/46] Update php layer --- autoload/SpaceVim/layers/lang/php.vim | 9 ++++++++ docs/layers/lang/php.md | 30 +++++++++++++++++++-------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/autoload/SpaceVim/layers/lang/php.vim b/autoload/SpaceVim/layers/lang/php.vim index 93bda2072..775120e03 100644 --- a/autoload/SpaceVim/layers/lang/php.vim +++ b/autoload/SpaceVim/layers/lang/php.vim @@ -1,3 +1,12 @@ +"============================================================================= +" php.vim --- lang#php layer +" Copyright (c) 2016-2017 Shidong Wang & Contributors +" Author: Shidong Wang < wsdjeg at 163.com > +" URL: https://spacevim.org +" License: MIT license +"============================================================================= + + "" " @section lang#php, layer-lang-php " @parentsection layers diff --git a/docs/layers/lang/php.md b/docs/layers/lang/php.md index 21f98403c..6a31233f6 100644 --- a/docs/layers/lang/php.md +++ b/docs/layers/lang/php.md @@ -1,15 +1,27 @@ -# [Layers](https://spacevim.org/layers) > lang#php +--- +title: "SpaceVim lang#php layer" +--- -This layer is for php development. +# [SpaceVim Layers:](https://spacevim.org/layers) lang#php -## Install + +* [Description](#description) +* [Layer Installation](#layer-installation) + * [Requirement](#requirement) -To include this layer, add `SPLayer 'lang#php'` to your custom configuration file. + +## Description -## Requirement +This layer adds PHP language support to SpaceVim. - 1. [PHP 5.3+](http://php.net/) - 2. [PCNTL](http://php.net/manual/en/book.pcntl.php) Extension - 3. [Msgpack 0.5.7+(for NeoVim)](https://github.com/msgpack/msgpack-php) Extension or [JSON(for Vim 7.4+)](http://php.net/manual/en/intro.json.php) Extension - 4. [Composer](https://getcomposer.org/) Project +## Layer Installation + +To use this configuration layer, add `SPLayer 'lang#php'` to your custom configuration file. + +### Requirement + +1. [PHP 5.3+](http://php.net/) +2. [PCNTL](http://php.net/manual/en/book.pcntl.php) Extension +3. [Msgpack 0.5.7+(for NeoVim)](https://github.com/msgpack/msgpack-php) Extension or [JSON(for Vim 7.4+)](http://php.net/manual/en/intro.json.php) Extension +4. [Composer](https://getcomposer.org/) Project From 3bc5e5e4df753914c472065432eddf58a5233885 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 26 Sep 2017 22:49:11 +0800 Subject: [PATCH 03/46] Hide curosr when guide buffer is open --- autoload/SpaceVim/mapping/guide.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/autoload/SpaceVim/mapping/guide.vim b/autoload/SpaceVim/mapping/guide.vim index d41165901..d7eb9f634 100644 --- a/autoload/SpaceVim/mapping/guide.vim +++ b/autoload/SpaceVim/mapping/guide.vim @@ -401,6 +401,7 @@ function! s:winopen() " {{{ setlocal nocursorline nocursorcolumn colorcolumn= setlocal winfixwidth winfixheight call s:updateStatusline() + call s:toggle_hide_cursor() endfunction " }}} function! s:updateStatusline() abort @@ -428,7 +429,16 @@ function! s:guide_help_msg() abort return substitute(msg,' ', '\\ ', 'g') endfunction +let s:t_ve = '' +function! s:toggle_hide_cursor() abort + let t_ve = &t_ve + let &t_ve = s:t_ve + let s:t_ve = t_ve +endfunction + + function! s:winclose() " {{{ + call s:toggle_hide_cursor() noautocmd execute s:gwin.'wincmd w' if s:gwin == winnr() noautocmd close From 7c0bbd671bb639588be32c9423fab8436f19d984 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Thu, 28 Sep 2017 21:17:46 +0800 Subject: [PATCH 04/46] Add lang#ruby --- autoload/SpaceVim/layers/lang/ruby.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/lang/ruby.vim b/autoload/SpaceVim/layers/lang/ruby.vim index ec832d5bc..13060223b 100644 --- a/autoload/SpaceVim/layers/lang/ruby.vim +++ b/autoload/SpaceVim/layers/lang/ruby.vim @@ -8,7 +8,7 @@ function! SpaceVim#layers#lang#ruby#plugins() abort let plugins = [] - + call add(plugins, ['vim-ruby/vim-ruby', { 'on_ft' : 'ruby'}]) return plugins endfunction From 34fa2a9a49cd7065aee5fe2cd992bd9564065eea Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Thu, 28 Sep 2017 21:36:54 +0800 Subject: [PATCH 05/46] Add SPReinstall command for reinstall plugins close #866 --- autoload/SpaceVim/commands.vim | 15 +++++++++++++++ autoload/SpaceVim/plugins/manager.vim | 6 ++++++ doc/SpaceVim.txt | 3 +++ 3 files changed, 24 insertions(+) diff --git a/autoload/SpaceVim/commands.vim b/autoload/SpaceVim/commands.vim index 79fb6d82a..79fada09f 100644 --- a/autoload/SpaceVim/commands.vim +++ b/autoload/SpaceVim/commands.vim @@ -35,6 +35,13 @@ function! SpaceVim#commands#load() abort command! -nargs=* \ -complete=custom,SpaceVim#commands#complete_plugin \ SPUpdate call SpaceVim#commands#update_plugin() + + "" + " Command for reinstall plugin, support completion of plugin anme. + command! -nargs=+ + \ -complete=custom,SpaceVim#commands#complete_plugin + \ SPReinstall call SpaceVim#commands#reinstall_plugin() + "" " Command for install plugins. command! -nargs=* SPInstall call SpaceVim#commands#install_plugin() @@ -80,6 +87,14 @@ function! SpaceVim#commands#update_plugin(...) abort endif endfunction +function! SpaceVim#commands#reinstall_plugin(...) + if g:spacevim_plugin_manager ==# 'dein' + call SpaceVim#plugins#manager#reinstall(a:000) + elseif g:spacevim_plugin_manager ==# 'neobundle' + elseif g:spacevim_plugin_manager ==# 'vim-plug' + endif +endfunction + function! SpaceVim#commands#install_plugin(...) abort if g:spacevim_plugin_manager ==# 'neobundle' elseif g:spacevim_plugin_manager ==# 'dein' diff --git a/autoload/SpaceVim/plugins/manager.vim b/autoload/SpaceVim/plugins/manager.vim index 9f49cce21..22c3b45cd 100644 --- a/autoload/SpaceVim/plugins/manager.vim +++ b/autoload/SpaceVim/plugins/manager.vim @@ -111,6 +111,12 @@ function! s:get_uninstalled_plugins() abort return filter(values(dein#get()), '!isdirectory(v:val.path)') endfunction + +function! SpaceVim#plugins#manager#reinstall(...) + call dein#reinstall(a:1) +endfunction + + " @vimlint(EVL102, 1, l:i) function! SpaceVim#plugins#manager#install(...) abort if !s:JOB.vim_job && !s:JOB.nvim_job diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 3666dcb49..af01b2ffa 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -412,6 +412,9 @@ COMMANDS *SpaceVim-commands* :SPUpdate vim-airline < +:SPReinstall *:SPReinstall* + Command for reinstall plugin, support completion of plugin anme. + :SPInstall *:SPInstall* Command for install plugins. From d78cd78dac5fef8d631365dfc6c258ff8394d6bf Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Thu, 28 Sep 2017 23:31:50 +0800 Subject: [PATCH 06/46] Update doc for git layer --- docs/layers/git.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 docs/layers/git.md diff --git a/docs/layers/git.md b/docs/layers/git.md new file mode 100644 index 000000000..06abb5061 --- /dev/null +++ b/docs/layers/git.md @@ -0,0 +1,37 @@ +--- +title: "SpaceVim git layer" +--- + +# [SpaceVim Layers:](https://spacevim.org/layers) git + + + +- [Description](#description) + - [Features](#features) +- [Install](#install) + - [Layer](#layer) +- [Key bindings](#key-bindings) + + + +## Description + +This layers adds extensive support for [git](http://git-scm.com/). + +### Features + +## Install + +### Layer + +To use this configuration layer, add `call SpaceVim#layers#load('git')` to your custom configuration file. + +## Key bindings + +| Key Binding | Description | +| -------------- | ---------------------- | +| ` g a` | git add current file | +| ` g A` | git add All files | +| ` g b` | open git blame window | +| ` g s` | open git status window | +| ` g c` | open git commit window | From 8ceaa387d67d04051e35b46df2505bcd0f58da7f Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 1 Oct 2017 19:31:43 +0800 Subject: [PATCH 07/46] Fix bug with mapleader Fix #847 --- autoload/SpaceVim/mapping/space.vim | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index a20d90b26..2b6db1a0a 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -1,12 +1,5 @@ let s:file = expand(':~') function! SpaceVim#mapping#space#init() abort - if s:has_map_to_spc() - return - endif - nnoremap [SPC] :LeaderGuide " " - vnoremap [SPC] :LeaderGuideVisual " " - nmap [SPC] - vmap [SPC] let g:_spacevim_mappings_space = {} let g:_spacevim_mappings_prefixs['[SPC]'] = {'name' : '+SPC prefix'} let g:_spacevim_mappings_space['?'] = ['Unite menu:CustomKeyMaps -input=[SPC]', 'show mappings'] @@ -26,6 +19,13 @@ function! SpaceVim#mapping#space#init() abort let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'} let g:_spacevim_mappings_space.s = {'name' : '+Searching'} let g:_spacevim_mappings_space.r = {'name' : '+Registers/rings/resume'} + if s:has_map_to_spc() + return + endif + nnoremap [SPC] :LeaderGuide " " + vnoremap [SPC] :LeaderGuideVisual " " + nmap [SPC] + vmap [SPC] " Windows for i in range(1, 9) exe "call SpaceVim#mapping#space#def('nnoremap', [" . i . "], 'call SpaceVim#layers#core#statusline#jump(" . i . ")', 'window " . i . "', 1)" From 352fc4f691f28fc6ed4f1c11d847650524acda7d Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 1 Oct 2017 20:32:36 +0800 Subject: [PATCH 08/46] Update readme --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 01d9e8fbf..2e567f8bc 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,7 @@ [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/SpaceVim/SpaceVim.svg)](http://isitmaintained.com/project/SpaceVim/SpaceVim "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/SpaceVim/SpaceVim.svg)](http://isitmaintained.com/project/SpaceVim/SpaceVim "Percentage of issues still open") -SpaceVim is a community-driven vim distribution that seeks to provide layer feature, especially for neovim. It offers a variety of layers to choose from. to create a suitable vim development environment, you just need to select the required layers. If you use SpaceVim, -please star it on github. It's a great way of getting feedback and gives me the kick to -put more time into development. +SpaceVim is a community-driven vim distribution that seeks to provide layer feature, compatible with vim and neoVim. Layers help collect related packages together to provide features. For example, the [lang#java layer](http://spacevim.org/layers/lang/java/) provides auto-completion, syntax checking, and debug support for java files. This approach helps keep configuration organized and reduces overhead for the user by keeping them from having to think about what packages to install. To install all the java features the user has just to add the `lang#java` layer to their dotfile. If you use SpaceVim, please star it on github. It's a great way of getting feedback and gives me the kick to put more time into development. ![welcome-page](https://cloud.githubusercontent.com/assets/13142418/26402270/28ad72b8-40bc-11e7-945e-003f41e057be.png) @@ -28,6 +26,10 @@ Here is a throughput graph of the repository for the last few weeks: [![Throughput Graph](https://graphs.waffle.io/SpaceVim/SpaceVim/throughput.svg)](https://waffle.io/SpaceVim/SpaceVim/metrics/throughput) +### Requirements + +SpaceVim's basic mode only requests `git` comamnd in your `$PATH`, but if you want to get better user experience, you need to install [nerd-font](https://github.com/ryanoasis/nerd-fonts). And make sure your terminal support [true colors](https://gist.github.com/XVilka/8346728). + ### Install ```bash From 280a0d7fcd969e4652218ba76c189174a9e69670 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 1 Oct 2017 20:53:57 +0800 Subject: [PATCH 09/46] Update intro --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2e567f8bc..ae6ccf955 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/SpaceVim/SpaceVim.svg)](http://isitmaintained.com/project/SpaceVim/SpaceVim "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/SpaceVim/SpaceVim.svg)](http://isitmaintained.com/project/SpaceVim/SpaceVim "Percentage of issues still open") -SpaceVim is a community-driven vim distribution that seeks to provide layer feature, compatible with vim and neoVim. Layers help collect related packages together to provide features. For example, the [lang#java layer](http://spacevim.org/layers/lang/java/) provides auto-completion, syntax checking, and debug support for java files. This approach helps keep configuration organized and reduces overhead for the user by keeping them from having to think about what packages to install. To install all the java features the user has just to add the `lang#java` layer to their dotfile. If you use SpaceVim, please star it on github. It's a great way of getting feedback and gives me the kick to put more time into development. +SpaceVim is a community-driven vim distribution that seeks to provide layer feature, compatible with vim and neoVim. Layers help collect related plugins together to provide features. Also help keep configuration organized and reduces overhead for the user by keeping them from having to think about what plugins to install. star it on github is a great way of getting feedback and gives me the kick to put more time into development. ![welcome-page](https://cloud.githubusercontent.com/assets/13142418/26402270/28ad72b8-40bc-11e7-945e-003f41e057be.png) @@ -64,6 +64,7 @@ If you want to show your support financially you can buy a drink for the mainta ### Credits & Thanks - [![GitHub contributors](https://img.shields.io/github/contributors/SpaceVim/SpaceVim.svg)](https://github.com/SpaceVim/SpaceVim/graphs/contributors) +- [@Gabirel](https://github.com/Gabirel) and his [Hack-SpaceVim](https://github.com/Gabirel/Hack-SpaceVim) - [vimdoc](https://github.com/google/vimdoc) generate doc file for SpaceVim - [Rafael Bodill](https://github.com/rafi) and his vim-config - [Bailey Ling](https://github.com/bling) and his dotvim From 8189e70695c4cd8efd946ba32ce0be350ed201b8 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 1 Oct 2017 21:23:20 +0800 Subject: [PATCH 10/46] Add coveragerc --- .coveragerc | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..02c2f4205 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +plugins = covimerage From 9c14723486a8d0891162ce9e7122ef6717b56e04 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 1 Oct 2017 21:24:42 +0800 Subject: [PATCH 11/46] Add coverage badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ae6ccf955..77f8cd200 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ [中文文档](http://spacevim.org/README_zh_cn/) [![Build Status](https://travis-ci.org/SpaceVim/SpaceVim.svg?branch=dev)](https://travis-ci.org/SpaceVim/SpaceVim) +[![codecov](https://codecov.io/gh/SpaceVim/SpaceVim/branch/master/graph/badge.svg)](https://codecov.io/gh/SpaceVim/SpaceVim) ![Version](https://img.shields.io/badge/version-0.5.0--dev-FF00CC.svg) [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![Doc](https://img.shields.io/badge/doc-%3Ah%20SpaceVim-orange.svg)](doc/SpaceVim.txt) From 45e26cdc1dce00781645c7aaedb768e54b5572c4 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 1 Oct 2017 21:35:49 +0800 Subject: [PATCH 12/46] Use codecov.yml --- .coveragerc => codecov.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .coveragerc => codecov.yml (100%) diff --git a/.coveragerc b/codecov.yml similarity index 100% rename from .coveragerc rename to codecov.yml From 7ba7ca34553e560cccaf9eb0a6d65e4cc1212526 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 4 Oct 2017 10:02:38 +0800 Subject: [PATCH 13/46] Add server support --- autoload/SpaceVim/server.vim | 21 +++++++++++++++++++++ config/main.vim | 4 ++++ 2 files changed, 25 insertions(+) create mode 100644 autoload/SpaceVim/server.vim diff --git a/autoload/SpaceVim/server.vim b/autoload/SpaceVim/server.vim new file mode 100644 index 000000000..08a0ab034 --- /dev/null +++ b/autoload/SpaceVim/server.vim @@ -0,0 +1,21 @@ +"============================================================================= +" server.vim --- server manager for SpaceVim +" Copyright (c) 2016-2017 Shidong Wang & Contributors +" Author: Shidong Wang < wsdjeg at 163.com > +" URL: https://spacevim.org +" License: MIT license +"============================================================================= + + +function! SpaceVim#server#connect() + if empty($SPACEVIM_SERVER_ADDRESS) + let $SPACEVIM_SERVER_ADDRESS = serverlist()[0] + return 0 + else + call sockconnect('pipe', $SPACEVIM_SERVER_ADDRESS, {'rpc' : 1}) + return 1 + endif +endfunction + + + diff --git a/config/main.vim b/config/main.vim index 6abcba9a0..947589258 100644 --- a/config/main.vim +++ b/config/main.vim @@ -1,3 +1,7 @@ +if SpaceVim#server#connect() + finish +endif + let g:Config_Main_Home = fnamemodify(expand(''), \ ':p:h:gs?\\?'.((has('win16') || has('win32') \ || has('win64'))?'\':'/') . '?') From 63c7705a0b9f1c25c5a7feae235cc2d87df0fcd0 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 4 Oct 2017 13:49:14 +0800 Subject: [PATCH 14/46] Update server func --- autoload/SpaceVim.vim | 7 +++++++ autoload/SpaceVim/server.vim | 20 ++++++++++++++++++++ doc/SpaceVim.txt | 3 +++ 3 files changed, 30 insertions(+) diff --git a/autoload/SpaceVim.vim b/autoload/SpaceVim.vim index ce0e64108..11ef17a47 100644 --- a/autoload/SpaceVim.vim +++ b/autoload/SpaceVim.vim @@ -200,6 +200,9 @@ let g:spacevim_vim_help_language = 'en' " < let g:spacevim_language = '' "" +" Option for keep the spacevim server ailive +let g:spacevim_keep_server_alive = 1 +"" " The colorscheme of SpaceVim. Default is 'gruvbox'. let g:spacevim_colorscheme = 'gruvbox' "" @@ -467,6 +470,10 @@ endfunction function! SpaceVim#end() abort + + if g:spacevim_keep_server_alive + call SpaceVim#server#export_server() + endif if !empty(g:spacevim_windows_leader) call SpaceVim#mapping#leader#defindWindowsLeader(g:spacevim_windows_leader) endif diff --git a/autoload/SpaceVim/server.vim b/autoload/SpaceVim/server.vim index 08a0ab034..7b15b0a73 100644 --- a/autoload/SpaceVim/server.vim +++ b/autoload/SpaceVim/server.vim @@ -7,6 +7,8 @@ "============================================================================= + + function! SpaceVim#server#connect() if empty($SPACEVIM_SERVER_ADDRESS) let $SPACEVIM_SERVER_ADDRESS = serverlist()[0] @@ -18,4 +20,22 @@ function! SpaceVim#server#connect() endfunction +function! SpaceVim#server#export_server() + + call system('export $TEST_SPACEVIM="test"') + +endfunction + +function! SpaceVim#server#terminate() + +endfunction + +function! SpaceVim#server#list() + if has('nvim') + return join(serverlist(), "\n") + else + endif +endfunction + + diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index af01b2ffa..a76a6c70f 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -234,6 +234,9 @@ Set the message language of vim. Default is 'en_US.UTF-8'. let g:spacevim_language = 'en_CA.utf8' < + *g:spacevim_keep_server_alive* +Option for keep the spacevim server ailive + *g:spacevim_colorscheme* The colorscheme of SpaceVim. Default is 'gruvbox'. From c83c74830ca2c88cdf2333467a7e7ae8335e4b39 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 4 Oct 2017 14:31:01 +0800 Subject: [PATCH 15/46] Add quit mappings for spacevim --- autoload/SpaceVim/layers/core.vim | 5 +++++ autoload/SpaceVim/layers/core/tabline.vim | 4 ++-- autoload/SpaceVim/mapping/space.vim | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/autoload/SpaceVim/layers/core.vim b/autoload/SpaceVim/layers/core.vim index bccf68b5b..f2c7fc2e6 100644 --- a/autoload/SpaceVim/layers/core.vim +++ b/autoload/SpaceVim/layers/core.vim @@ -15,4 +15,9 @@ function! SpaceVim#layers#core#config() abort call SpaceVim#mapping#space#def('nnoremap', ['p', 'k'], 'call SpaceVim#plugins#projectmanager#kill_project()', 'kill all project buffers', 1) call SpaceVim#mapping#space#def('nnoremap', ['p', 'f'], 'CtrlP', 'find files in current project', 1) call SpaceVim#mapping#space#def('nnoremap', ['p', '/'], 'Grepper', 'fuzzy search for text in current project', 1) + call SpaceVim#mapping#space#def('nnoremap', ['q', 'q'], 'qa', 'prompt-kill-vim', 1) + call SpaceVim#mapping#space#def('nnoremap', ['q', 'Q'], 'qa!', 'kill-vim', 1) + call SpaceVim#mapping#space#def('nnoremap', ['q', 'R'], '', 'restart-vim(TODO)', 1) + call SpaceVim#mapping#space#def('nnoremap', ['q', 'r'], '', 'restart-vim-resume-layouts(TODO)', 1) + call SpaceVim#mapping#space#def('nnoremap', ['q', 't'], 'tabclose!', 'kill current tab', 1) endfunction diff --git a/autoload/SpaceVim/layers/core/tabline.vim b/autoload/SpaceVim/layers/core/tabline.vim index 6519e1827..21c67fe35 100644 --- a/autoload/SpaceVim/layers/core/tabline.vim +++ b/autoload/SpaceVim/layers/core/tabline.vim @@ -101,7 +101,7 @@ function! SpaceVim#layers#core#tabline#get() abort endif endfor let t .= '%=%#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:rsep - let t .= '%#SpaceVim_tabline_a# Tabs' + let t .= '%#SpaceVim_tabline_a# Tabs ' else let s:buffers = s:BUFFER.listed_buffers() let g:_spacevim_list_buffers = s:buffers @@ -146,7 +146,7 @@ function! SpaceVim#layers#core#tabline#get() abort endif endfor let t .= '%=%#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:rsep - let t .= '%#SpaceVim_tabline_a# Buffers' + let t .= '%#SpaceVim_tabline_a# Buffers ' endif return t endfunction diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 2b6db1a0a..81efbdb31 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -16,6 +16,7 @@ function! SpaceVim#mapping#space#init() abort let g:_spacevim_mappings_space.w = {'name' : '+Windows'} let g:_spacevim_mappings_space.p = {'name' : '+Projects'} let g:_spacevim_mappings_space.h = {'name' : '+Help'} + let g:_spacevim_mappings_space.q = {'name' : '+Quit'} let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'} let g:_spacevim_mappings_space.s = {'name' : '+Searching'} let g:_spacevim_mappings_space.r = {'name' : '+Registers/rings/resume'} From d617c2338be62c56e6e6d24be0d1cc83428a08cf Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 4 Oct 2017 15:17:06 +0800 Subject: [PATCH 16/46] Show buffer name when there are dup buf --- autoload/SpaceVim/api/vim/statusline.vim | 6 +++--- autoload/SpaceVim/layers/core/statusline.vim | 18 ++++++++++++++---- autoload/SpaceVim/layers/core/tabline.vim | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/autoload/SpaceVim/api/vim/statusline.vim b/autoload/SpaceVim/api/vim/statusline.vim index 47d8acb1f..019da8572 100644 --- a/autoload/SpaceVim/api/vim/statusline.vim +++ b/autoload/SpaceVim/api/vim/statusline.vim @@ -1,7 +1,7 @@ let s:self = {} -function! s:self.build(left_sections, right_sections, lsep, rsep, hi_a, hi_b, hi_c, hi_z) abort +function! s:self.build(left_sections, right_sections, lsep, rsep, fname, hi_a, hi_b, hi_c, hi_z) abort let l = '%#' . a:hi_a . '#' . a:left_sections[0] let l .= '%#' . a:hi_a . '_' . a:hi_b . '#' . a:lsep let flag = 1 @@ -24,9 +24,9 @@ function! s:self.build(left_sections, right_sections, lsep, rsep, hi_a, hi_b, hi endif endif if flag == 1 - let l .= '%#' . a:hi_c . '_' . a:hi_z . '#' . a:lsep . '%=' + let l .= '%#' . a:hi_c . '_' . a:hi_z . '#' . a:lsep . a:fname . '%=' else - let l .= '%#' . a:hi_b . '_' . a:hi_z . '#' . a:lsep . '%=' + let l .= '%#' . a:hi_b . '_' . a:hi_z . '#' . a:lsep . a:fname . '%=' endif let l .= '%#' . a:hi_b . '_' . a:hi_z . '#' . a:rsep let flag = 1 diff --git a/autoload/SpaceVim/layers/core/statusline.vim b/autoload/SpaceVim/layers/core/statusline.vim index abc112325..3b6b1879f 100644 --- a/autoload/SpaceVim/layers/core/statusline.vim +++ b/autoload/SpaceVim/layers/core/statusline.vim @@ -86,6 +86,15 @@ function! s:check_mode() abort endif endfunction +" only when there are more than two buffers have same name. +function! s:buffer_name() abort + if get(b:, '_spacevim_statusline_showbfname', 0) == 1 + return ' ' . bufname('%') + else + return '' + endif +endfunction + function! s:search_status() abort let ct = 0 let tt = 0 @@ -285,7 +294,8 @@ function! s:active() abort if index(s:loaded_sections, 'whitespace') != -1 call add(rsec, s:whitespace()) endif - return s:STATUSLINE.build(lsec, rsec, s:lsep, s:rsep, + let fname = s:buffer_name() + return s:STATUSLINE.build(lsec, rsec, s:lsep, s:rsep, fname, \ 'SpaceVim_statusline_a', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z') endfunction @@ -386,7 +396,7 @@ function! SpaceVim#layers#core#statusline#config() abort \ 'toggle the statuline itself', 1) function! TagbarStatusline(...) abort let name = (strwidth(a:3) > (g:spacevim_sidebar_width - 15)) ? a:3[:g:spacevim_sidebar_width - 20] . '..' : a:3 - return s:STATUSLINE.build([s:winnr(),' Tagbar ', ' ' . name . ' '], [], s:lsep, s:rsep, + return s:STATUSLINE.build([s:winnr(),' Tagbar ', ' ' . name . ' '], [], s:lsep, s:rsep, '', \ 'SpaceVim_statusline_ia', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z') endfunction let g:tagbar_status_func = 'TagbarStatusline' @@ -415,7 +425,7 @@ endfunction " the marked filenames. function! SpaceVim#layers#core#statusline#ctrlp(focus, byfname, regex, prev, item, next, marked) abort return s:STATUSLINE.build([' Ctrlp ', ' ' . a:prev . ' ', ' ' . a:item . ' ', ' ' . a:next . ' '], - \ [' ' . a:focus . ' ', ' ' . a:byfname . ' ', ' ' . getcwd() . ' '], s:lsep, s:rsep, + \ [' ' . a:focus . ' ', ' ' . a:byfname . ' ', ' ' . getcwd() . ' '], s:lsep, s:rsep, '', \ 'SpaceVim_statusline_a_bold', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z') endfunction @@ -423,7 +433,7 @@ endfunction " the current directory is being scanned with a user_command. function! SpaceVim#layers#core#statusline#ctrlp_status(str) abort return s:STATUSLINE.build([' Ctrlp ', ' ' . a:str . ' '], - \ [' ' . getcwd() . ' '], s:lsep, s:rsep, + \ [' ' . getcwd() . ' '], s:lsep, s:rsep, '', \ 'SpaceVim_statusline_a', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z') endfunction diff --git a/autoload/SpaceVim/layers/core/tabline.vim b/autoload/SpaceVim/layers/core/tabline.vim index 21c67fe35..bb32ce357 100644 --- a/autoload/SpaceVim/layers/core/tabline.vim +++ b/autoload/SpaceVim/layers/core/tabline.vim @@ -58,9 +58,20 @@ function! s:tabname(id) abort endif endfunction +function! s:need_show_bfname(stack, nr) abort + let dupbufs = filter(a:stack, "fnamemodify(bufname(v:val), ':t') ==# fnamemodify(bufname(a:nr), ':t')") + if len(dupbufs) >= 2 + for i in dupbufs + call setbufvar(i, '_spacevim_statusline_showbfname', 1) + endfor + endif +endfunction + function! SpaceVim#layers#core#tabline#get() abort let nr = tabpagenr('$') let t = '' + " the stack should be the bufnr stack of tabline + let stack = [] if nr > 1 let ct = tabpagenr() if ct == 1 @@ -78,6 +89,8 @@ function! SpaceVim#layers#core#tabline#get() abort if empty(name) let name = 'No Name' endif + call add(stack, buflist[winnr - 1]) + call s:need_show_bfname(stack, buflist[winnr - 1]) if g:spacevim_buffer_index_type == 3 let id = s:messletters.index_num(i) elseif g:spacevim_buffer_index_type == 4 @@ -123,6 +136,8 @@ function! SpaceVim#layers#core#tabline#get() abort if empty(name) let name = 'No Name' endif + call add(stack, i) + call s:need_show_bfname(stack, i) if g:spacevim_buffer_index_type == 3 let id = s:messletters.index_num(index(s:buffers, i) + 1) elseif g:spacevim_buffer_index_type == 4 From b16837623df76b8cc15aca7f34bc40b63a09da74 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 4 Oct 2017 15:33:52 +0800 Subject: [PATCH 17/46] Silent open tagbar problem: when open tagbar buffer, you will see message like: "autoload/SpaceVim/layers/core/tabline.vim" 205 lines --36%-- which is not needed. --- autoload/SpaceVim/layers/ui.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/ui.vim b/autoload/SpaceVim/layers/ui.vim index 6cb538498..510c25467 100644 --- a/autoload/SpaceVim/layers/ui.vim +++ b/autoload/SpaceVim/layers/ui.vim @@ -30,7 +30,7 @@ function! SpaceVim#layers#ui#config() abort let g:indentLine_fileTypeExclude = ['help', 'startify', 'vimfiler'] let g:signify_disable_by_default = 0 let g:signify_line_highlight = 0 - noremap :TagbarToggle + noremap :silent TagbarToggle " Ui toggles call SpaceVim#mapping#space#def('nnoremap', ['t', '8'], 'call call(' \ . string(s:_function('s:toggle_fill_column')) . ', [])', From d61a5118e773cb130ad87ab6e70242cb860246c3 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 4 Oct 2017 15:46:45 +0800 Subject: [PATCH 18/46] Silent jump to buffer --- autoload/SpaceVim/layers/core/tabline.vim | 2 +- autoload/SpaceVim/layers/shell.vim | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/core/tabline.vim b/autoload/SpaceVim/layers/core/tabline.vim index bb32ce357..04cfe0362 100644 --- a/autoload/SpaceVim/layers/core/tabline.vim +++ b/autoload/SpaceVim/layers/core/tabline.vim @@ -188,7 +188,7 @@ endfunction function! SpaceVim#layers#core#tabline#jump(id) abort if len(s:buffers) >= a:id let bid = s:buffers[a:id - 1] - exe 'b' . bid + exe 'silent b' . bid endif endfunction diff --git a/autoload/SpaceVim/layers/shell.vim b/autoload/SpaceVim/layers/shell.vim index 387b01e94..89404510f 100644 --- a/autoload/SpaceVim/layers/shell.vim +++ b/autoload/SpaceVim/layers/shell.vim @@ -42,6 +42,7 @@ let s:shell_win_nr = 0 function! s:open_default_shell() abort if s:shell_win_nr != 0 && getwinvar(s:shell_win_nr, '&buftype') ==# 'terminal' && &buftype !=# 'terminal' exe s:shell_win_nr . 'wincmd w' + startinsert return endif if &buftype ==# 'terminal' @@ -64,6 +65,7 @@ function! s:open_default_shell() abort exe 'te' let s:shell_win_nr = winnr() let w:shell_layer_win = 1 + startinsert else echo ':terminal is not supported in this version' endif From d620550a581c4d200922d9db2bbb3f698bea9648 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 4 Oct 2017 19:19:08 +0800 Subject: [PATCH 19/46] Add support for editorconfig --- .editorconfig | 9 +++ autoload/SpaceVim/layers/edit.vim | 2 +- autoload/SpaceVim/mapping/space.vim | 90 +++++++++++++++++++---------- 3 files changed, 70 insertions(+), 31 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..c080a004c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*.vim] +indent_style = space +indent_size = 2 +end_of_line = 1f +insert_final_newline = true +charset = utf_8 + diff --git a/autoload/SpaceVim/layers/edit.vim b/autoload/SpaceVim/layers/edit.vim index 2914bfd2b..95c7a6570 100644 --- a/autoload/SpaceVim/layers/edit.vim +++ b/autoload/SpaceVim/layers/edit.vim @@ -19,7 +19,7 @@ function! SpaceVim#layers#edit#plugins() abort \ ['gcmt/wildfire.vim',{'on_map' : '(wildfire-'}], \ ['easymotion/vim-easymotion'], \ ['haya14busa/vim-easyoperator-line'], - \ ['editorconfig/editorconfig-vim', { 'on_cmd' : 'EditorConfigReload'}], + \ ['editorconfig/editorconfig-vim', { 'merged' : 0}], \ ['floobits/floobits-neovim', { 'on_cmd' : ['FlooJoinWorkspace','FlooShareDirPublic','FlooShareDirPrivate']}], \ ] if executable('fcitx') diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 81efbdb31..82653fdca 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -2,7 +2,8 @@ let s:file = expand(':~') function! SpaceVim#mapping#space#init() abort let g:_spacevim_mappings_space = {} let g:_spacevim_mappings_prefixs['[SPC]'] = {'name' : '+SPC prefix'} - let g:_spacevim_mappings_space['?'] = ['Unite menu:CustomKeyMaps -input=[SPC]', 'show mappings'] + let g:_spacevim_mappings_space['?'] = + \ ['Unite menu:CustomKeyMaps -input=[SPC]', 'show mappings'] let g:_spacevim_mappings_space.t = {'name' : '+Toggles'} let g:_spacevim_mappings_space.t.h = {'name' : '+Toggles highlight'} let g:_spacevim_mappings_space.t.m = {'name' : '+modeline'} @@ -29,7 +30,9 @@ function! SpaceVim#mapping#space#init() abort vmap [SPC] " Windows for i in range(1, 9) - exe "call SpaceVim#mapping#space#def('nnoremap', [" . i . "], 'call SpaceVim#layers#core#statusline#jump(" . i . ")', 'window " . i . "', 1)" + exe "call SpaceVim#mapping#space#def('nnoremap', [" + \ . i . "], 'call SpaceVim#layers#core#statusline#jump(" + \ . i . ")', 'window " . i . "', 1)" endfor let g:_spacevim_mappings_space.w[''] = ['wincmd w', 'alternate-window'] nnoremap [SPC]w :wincmd w @@ -38,33 +41,60 @@ function! SpaceVim#mapping#space#init() abort \ 'call call(' \ . string(function('s:windows_layout_toggle')) \ . ', [])', 'windows-layout-toggle', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'c'], 'Goyo', 'centered-buffer-mode', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'C'], 'ChooseWin | Goyo', 'centered-buffer-mode(other windows)', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'd'], 'close', 'delete window', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'D'], 'ChooseWin | close | wincmd w', 'delete window (other windows)', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'F'], 'tabnew', 'create new tab', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'h'], 'wincmd h', 'window-left', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'j'], 'wincmd j', 'window-down', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'k'], 'wincmd k', 'window-up', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'l'], 'wincmd l', 'window-right', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'H'], 'wincmd H', 'window-far-left', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'J'], 'wincmd J', 'window-far-down', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'K'], 'wincmd K', 'window-far-up', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'L'], 'wincmd L', 'window-far-right', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'm'], 'only', 'maximize/minimize window', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'M'], 'ChooseWinSwap', 'swap window', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'o'], 'tabnext', 'other tabs', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', '/'], 'bel vs | wincmd w', 'split-window-right', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'v'], 'bel vs | wincmd w', 'split-window-right', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', '-'], 'bel split | wincmd w', 'split-window-below', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 's'], 'bel split | wincmd w', 'split-window-below', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'S'], 'bel split', 'split-focus-window-below', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', '2'], 'silent only | vs | wincmd w', 'layout-double-columns', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', '3'], 'silent only | vs | vs | wincmd H', 'split-window-below', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'V'], 'bel vs', 'split-window-right-focus', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', '='], 'wincmd =', 'balance-windows', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'w'], 'wincmd w', 'cycle and focus between windows', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'W'], 'ChooseWin', 'select window', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'c'], + \ 'Goyo', 'centered-buffer-mode', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'C'], + \ 'ChooseWin | Goyo', 'centered-buffer-mode(other windows)', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'd'], + \ 'close', 'delete window', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'D'], + \ 'ChooseWin | close | wincmd w', 'delete window (other windows)', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'F'], + \ 'tabnew', 'create new tab', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'h'], + \ 'wincmd h', 'window-left', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'j'], + \ 'wincmd j', 'window-down', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'k'], + \ 'wincmd k', 'window-up', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'l'], + \ 'wincmd l', 'window-right', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'H'], + \ 'wincmd H', 'window-far-left', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'J'], + \ 'wincmd J', 'window-far-down', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'K'], + \ 'wincmd K', 'window-far-up', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'L'], + \ 'wincmd L', 'window-far-right', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'm'], + \ 'only', 'maximize/minimize window', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'M'], + \ 'ChooseWinSwap', 'swap window', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'o'], + \ 'tabnext', 'other tabs', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', '/'], + \ 'bel vs | wincmd w', 'split-window-right', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'v'], + \ 'bel vs | wincmd w', 'split-window-right', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', '-'], + \ 'bel split | wincmd w', 'split-window-below', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 's'], + \ 'bel split | wincmd w', 'split-window-below', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'S'], + \ 'bel split', 'split-focus-window-below', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', '2'], + \ 'silent only | vs | wincmd w', 'layout-double-columns', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', '3'], + \ 'silent only | vs | vs | wincmd H', 'split-window-below', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'V'], + \ 'bel vs', 'split-window-right-focus', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', '='], + \ 'wincmd =', 'balance-windows', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'w'], + \ 'wincmd w', 'cycle and focus between windows', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'W'], + \ 'ChooseWin', 'select window', 1) call SpaceVim#mapping#space#def('nnoremap', ['w', 'u'], 'call SpaceVim#plugins#windowsmanager#UndoQuitWin()', 'undo quieted window', 1) call SpaceVim#mapping#space#def('nnoremap', ['w', 'U'], 'call SpaceVim#plugins#windowsmanager#RedoQuitWin()', 'redo quieted window', 1) let s:lnum = expand('') + 3 @@ -417,4 +447,4 @@ function! s:comment_to_line(invert) abort endif endfunction -" vim:set et sw=2 cc=80: +" vim:set et nowrap sw=2 cc=80: From 81920749c0d9edc7d8ffa0fe0fdfb86b0d27eefe Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 4 Oct 2017 20:08:19 +0800 Subject: [PATCH 20/46] Update shell layer --- autoload/SpaceVim/layers/shell.vim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/autoload/SpaceVim/layers/shell.vim b/autoload/SpaceVim/layers/shell.vim index 89404510f..0500d54d0 100644 --- a/autoload/SpaceVim/layers/shell.vim +++ b/autoload/SpaceVim/layers/shell.vim @@ -33,7 +33,7 @@ function! SpaceVim#layers#shell#config() abort endfunction function! SpaceVim#layers#shell#set_variable(var) abort - let s:default_shell = get(a:var, 'defaut_shell', 'terminal') + let s:default_shell = get(a:var, 'default_shell', 'terminal') let s:default_position = get(a:var, 'default_position', 'top') let s:default_height = get(a:var, 'default_height', 30) endfunction @@ -61,8 +61,12 @@ function! s:open_default_shell() abort exe 'resize ' . lines endif if s:default_shell ==# 'terminal' - if exists(':te') - exe 'te' + if exists(':terminal') + if has('nvim') + exe 'terminal' + else + call term_start('bash', {'curwin' : 1, 'term_finish' : 'close'}) + endif let s:shell_win_nr = winnr() let w:shell_layer_win = 1 startinsert From c10d144b0f26c4b88b978439c2939e13bae9e41b Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 4 Oct 2017 21:20:52 +0800 Subject: [PATCH 21/46] Update shell layer --- autoload/SpaceVim/layers/shell.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/SpaceVim/layers/shell.vim b/autoload/SpaceVim/layers/shell.vim index 0500d54d0..914f7ec0f 100644 --- a/autoload/SpaceVim/layers/shell.vim +++ b/autoload/SpaceVim/layers/shell.vim @@ -11,9 +11,8 @@ function! SpaceVim#layers#shell#plugins() abort let plugins = [] if has('nvim') call add(plugins,['Shougo/deol.nvim']) - else - call add(plugins,['Shougo/vimshell.vim', { 'on_cmd':['VimShell']}]) endif + call add(plugins,['Shougo/vimshell.vim', { 'on_cmd':['VimShell']}]) return plugins endfunction @@ -75,5 +74,6 @@ function! s:open_default_shell() abort endif elseif s:default_shell ==# 'VimShell' VimShell + imap exit(vimshell_enter) endif endfunction From 89d7e5324d54ddada02925ca19871801421a29b2 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Thu, 5 Oct 2017 19:10:01 +0800 Subject: [PATCH 22/46] Add language specified mappings for python --- autoload/SpaceVim/layers/lang/python.vim | 40 ++++++++++++++---------- autoload/SpaceVim/plugins/runner.vim | 33 +++++++++++++++++++ 2 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 autoload/SpaceVim/plugins/runner.vim diff --git a/autoload/SpaceVim/layers/lang/python.vim b/autoload/SpaceVim/layers/lang/python.vim index 0709a578c..e42ae85cc 100644 --- a/autoload/SpaceVim/layers/lang/python.vim +++ b/autoload/SpaceVim/layers/lang/python.vim @@ -8,25 +8,33 @@ " < function! SpaceVim#layers#lang#python#plugins() abort - let plugins = [] - " python - if has('nvim') - call add(plugins, ['zchee/deoplete-jedi', { 'on_ft' : 'python'}]) - else - call add(plugins, ['davidhalter/jedi-vim', { 'on_ft' : 'python', - \ 'if' : has('python') || has('python3')}]) - endif - call add(plugins, ['Vimjas/vim-python-pep8-indent', - \ { 'on_ft' : 'python'}]) - return plugins + let plugins = [] + " python + if has('nvim') + call add(plugins, ['zchee/deoplete-jedi', { 'on_ft' : 'python'}]) + else + call add(plugins, ['davidhalter/jedi-vim', { 'on_ft' : 'python', + \ 'if' : has('python') || has('python3')}]) + endif + call add(plugins, ['Vimjas/vim-python-pep8-indent', + \ { 'on_ft' : 'python'}]) + return plugins endfunction function! SpaceVim#layers#lang#python#config() abort - call SpaceVim#layers#edit#add_ft_head_tamplate('python', - \ ['#!/usr/bin/env python', - \ '# -*- coding: utf-8 -*-', - \ ''] - \ ) + call SpaceVim#mapping#space#regesit_lang_mappings('python', funcref('s:language_specified_mappings')) + call SpaceVim#layers#edit#add_ft_head_tamplate('python', + \ ['#!/usr/bin/env python', + \ '# -*- coding: utf-8 -*-', + \ ''] + \ ) endfunction + +function! s:language_specified_mappings() abort + + call SpaceVim#mapping#space#langSPC('nmap', ['l','r'], + \ 'call SpaceVim#plugins#runner#open()', + \ 'execute current file', 1) +endfunction diff --git a/autoload/SpaceVim/plugins/runner.vim b/autoload/SpaceVim/plugins/runner.vim new file mode 100644 index 000000000..1d01094c2 --- /dev/null +++ b/autoload/SpaceVim/plugins/runner.vim @@ -0,0 +1,33 @@ +"============================================================================= +" runner.vim --- code runner for SpaceVim +" Copyright (c) 2016-2017 Shidong Wang & Contributors +" Author: Shidong Wang < wsdjeg at 163.com > +" URL: https://spacevim.org +" License: MIT license +"============================================================================= + +let s:runners = {} + +function! s:open_win() abort + +endfunction + + +function! s:async_run(runner) abort + +endfunction + + +function! s:update_statusline() abort + +endfunction + + +function! SpaceVim#plugins#runner#open() + let runner = get(s:runners, &filetype, '') + if !empty(runner) + call s:open_win() + call s:async_run(runner) + call s:update_statusline() + endif +endfunction From 228beb038dec9513c996bff7e0c8ab6f166950ae Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Thu, 5 Oct 2017 20:26:17 +0800 Subject: [PATCH 23/46] Add SpaceVimRunner --- autoload/SpaceVim/api/vim/buffer.vim | 60 +++++++++++--------- autoload/SpaceVim/layers/core/statusline.vim | 2 + autoload/SpaceVim/layers/lang/python.vim | 2 +- autoload/SpaceVim/plugins/runner.vim | 57 ++++++++++++++++++- 4 files changed, 91 insertions(+), 30 deletions(-) diff --git a/autoload/SpaceVim/api/vim/buffer.vim b/autoload/SpaceVim/api/vim/buffer.vim index 2642bdf79..e70ff3a95 100644 --- a/autoload/SpaceVim/api/vim/buffer.vim +++ b/autoload/SpaceVim/api/vim/buffer.vim @@ -12,46 +12,54 @@ else endif function! s:self.open(opts) abort - let buf = get(a:opts, 'bufname', '') - let mode = get(a:opts, 'mode', 'vertical topleft split') - let Initfunc = get(a:opts, 'initfunc', '') - let cmd = get(a:opts, 'cmd', '') - if empty(buf) - exe mode | enew - else - exe mode buf - endif - if !empty(Initfunc) - call call(Initfunc, []) - endif + let buf = get(a:opts, 'bufname', '') + let mode = get(a:opts, 'mode', 'vertical topleft split') + let Initfunc = get(a:opts, 'initfunc', '') + let cmd = get(a:opts, 'cmd', '') + if empty(buf) + exe mode | enew + else + exe mode buf + endif + if !empty(Initfunc) + call call(Initfunc, []) + endif - if !empty(cmd) - exe cmd - endif + if !empty(cmd) + exe cmd + endif endfunction func! s:self.resize(size, ...) abort - let cmd = get(a:000, 0, 'vertical') - exe cmd 'resize' a:size + let cmd = get(a:000, 0, 'vertical') + exe cmd 'resize' a:size endf function! s:self.listed_buffers() abort - return filter(range(1, bufnr('$')), 'buflisted(v:val)') + return filter(range(1, bufnr('$')), 'buflisted(v:val)') endfunction function! s:self.filter_do(expr) abort - let buffers = range(1, bufnr('$')) - for f_expr in a:expr.expr - let buffers = filter(buffers, f_expr) - endfor - for b in buffers - exe printf(a:expr.do, b) - endfor + let buffers = range(1, bufnr('$')) + for f_expr in a:expr.expr + let buffers = filter(buffers, f_expr) + endfor + for b in buffers + exe printf(a:expr.do, b) + endfor +endfunction + + +" just same as nvim_buf_set_lines +function! s:self.buf_set_lines(buffer, start, end, strict_indexing, replacement) abort + if exists('*nvim_buf_set_lines') + call nvim_buf_set_lines(a:buffer, a:start, a:end, a:strict_indexing, a:replacement) + endif endfunction fu! SpaceVim#api#vim#buffer#get() abort - return deepcopy(s:self) + return deepcopy(s:self) endf diff --git a/autoload/SpaceVim/layers/core/statusline.vim b/autoload/SpaceVim/layers/core/statusline.vim index 3b6b1879f..59248cbca 100644 --- a/autoload/SpaceVim/layers/core/statusline.vim +++ b/autoload/SpaceVim/layers/core/statusline.vim @@ -251,6 +251,8 @@ function! SpaceVim#layers#core#statusline#get(...) abort return '%#SpaceVim_statusline_a# Transient State %#SpaceVim_statusline_a_SpaceVim_statusline_b#' elseif &filetype ==# 'HelpDescribe' return '%#SpaceVim_statusline_a# HelpDescribe %#SpaceVim_statusline_a_SpaceVim_statusline_b#' + elseif &filetype ==# 'SpaceVimRunner' + return '%#SpaceVim_statusline_a# Runner %#SpaceVim_statusline_a_SpaceVim_statusline_b# %{SpaceVim#plugins#runner#status()}' endif if a:0 > 0 return s:active() diff --git a/autoload/SpaceVim/layers/lang/python.vim b/autoload/SpaceVim/layers/lang/python.vim index e42ae85cc..3cf3634b7 100644 --- a/autoload/SpaceVim/layers/lang/python.vim +++ b/autoload/SpaceVim/layers/lang/python.vim @@ -22,7 +22,7 @@ function! SpaceVim#layers#lang#python#plugins() abort endfunction function! SpaceVim#layers#lang#python#config() abort - + call SpaceVim#plugins#runner#reg_runner('python', 'python %s') call SpaceVim#mapping#space#regesit_lang_mappings('python', funcref('s:language_specified_mappings')) call SpaceVim#layers#edit#add_ft_head_tamplate('python', \ ['#!/usr/bin/env python', diff --git a/autoload/SpaceVim/plugins/runner.vim b/autoload/SpaceVim/plugins/runner.vim index 1d01094c2..708fa8b13 100644 --- a/autoload/SpaceVim/plugins/runner.vim +++ b/autoload/SpaceVim/plugins/runner.vim @@ -6,24 +6,49 @@ " License: MIT license "============================================================================= +let s:JOB = SpaceVim#api#import('job') +let s:BUFFER = SpaceVim#api#import('vim#buffer') + let s:runners = {} +let s:bufnr = 0 + function! s:open_win() abort - + botright split __runner__ + let lines = &lines * 30 / 100 + exe 'resize ' . lines + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber + set filetype=SpaceVimRunner + let s:bufnr = bufnr('%') endfunction function! s:async_run(runner) abort - + let cmd = printf(a:runner, bufname('#')) + call s:JOB.start(cmd,{ + \ 'on_stdout' : function('s:on_stdout'), + \ 'on_stderr' : function('s:on_stderr'), + \ 'on_exit' : function('s:on_exit'), + \ }) endfunction function! s:update_statusline() abort - + redrawstatus endfunction +function! SpaceVim#plugins#runner#reg_runner(ft, runner) + let s:runners[a:ft] = a:runner +endfunction function! SpaceVim#plugins#runner#open() + let s:lines = 0 + let s:status = { + \ 'is_running' : 0, + \ 'is_exit' : 0, + \ 'has_errors' : 0, + \ 'exit_code' : 0 + \ } let runner = get(s:runners, &filetype, '') if !empty(runner) call s:open_win() @@ -31,3 +56,29 @@ function! SpaceVim#plugins#runner#open() call s:update_statusline() endif endfunction + +function! s:on_stdout(job_id, data, event) abort + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, a:data) + let s:lines += len(a:data) + call s:update_statusline() +endfunction + +function! s:on_stderr(job_id, data, event) abort + let s:status.has_errors = 1 + call s:update_statusline() +endfunction + +function! s:on_exit(job_id, data, event) abort + let s:status.is_exit = 1 + let s:status.exit_code = a:data + call s:update_statusline() + +endfunction + + +function! SpaceVim#plugins#runner#status() + if s:status.is_running == 1 + elseif s:status.is_exit == 1 + return 'exit code : ' . s:status.exit_code + endif +endfunction From eb7d940de883646f25be71af230d149b64dad420 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Thu, 5 Oct 2017 20:50:38 +0800 Subject: [PATCH 24/46] Fix runner --- autoload/SpaceVim.vim | 2 +- autoload/SpaceVim/plugins/runner.vim | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/autoload/SpaceVim.vim b/autoload/SpaceVim.vim index 11ef17a47..987d98d49 100644 --- a/autoload/SpaceVim.vim +++ b/autoload/SpaceVim.vim @@ -348,7 +348,7 @@ let g:spacevim_enable_vimfiler_gitstatus = 0 " Enable/Disable filetypeicon colum in vimfiler buffer, default is 0. let g:spacevim_enable_vimfiler_filetypeicon = 0 let g:spacevim_smartcloseignorewin = ['__Tagbar__' , 'vimfiler:default'] -let g:spacevim_smartcloseignoreft = ['help', 'tagbar', 'vimfiler'] +let g:spacevim_smartcloseignoreft = ['help', 'tagbar', 'vimfiler', 'SpaceVimRunner'] let g:spacevim_altmoveignoreft = ['Tagbar' , 'vimfiler'] let g:spacevim_enable_javacomplete2_py = 0 let g:spacevim_src_root = 'E:\sources\' diff --git a/autoload/SpaceVim/plugins/runner.vim b/autoload/SpaceVim/plugins/runner.vim index 708fa8b13..e5c5705bb 100644 --- a/autoload/SpaceVim/plugins/runner.vim +++ b/autoload/SpaceVim/plugins/runner.vim @@ -14,17 +14,22 @@ let s:runners = {} let s:bufnr = 0 function! s:open_win() abort + if s:bufnr != 0 && bufexists(s:bufnr) + exe 'bd ' . s:bufnr + endif botright split __runner__ let lines = &lines * 30 / 100 exe 'resize ' . lines setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber set filetype=SpaceVimRunner + nnoremap q :bd let s:bufnr = bufnr('%') + wincmd p endfunction function! s:async_run(runner) abort - let cmd = printf(a:runner, bufname('#')) + let cmd = printf(a:runner, bufname('%')) call s:JOB.start(cmd,{ \ 'on_stdout' : function('s:on_stdout'), \ 'on_stderr' : function('s:on_stderr'), @@ -34,7 +39,7 @@ endfunction function! s:update_statusline() abort - redrawstatus + redrawstatus! endfunction function! SpaceVim#plugins#runner#reg_runner(ft, runner) @@ -65,6 +70,8 @@ endfunction function! s:on_stderr(job_id, data, event) abort let s:status.has_errors = 1 + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, a:data) + let s:lines += len(a:data) call s:update_statusline() endfunction @@ -75,10 +82,15 @@ function! s:on_exit(job_id, data, event) abort endfunction +function! s:debug_info() abort + return [] +endfunction + function! SpaceVim#plugins#runner#status() if s:status.is_running == 1 elseif s:status.is_exit == 1 return 'exit code : ' . s:status.exit_code endif + return '' endfunction From c5aee19c89335fd7ff240b58ab9262ba18bcef07 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Thu, 5 Oct 2017 21:26:24 +0800 Subject: [PATCH 25/46] Fix lint --- autoload/SpaceVim/plugins/runner.vim | 29 ++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/autoload/SpaceVim/plugins/runner.vim b/autoload/SpaceVim/plugins/runner.vim index e5c5705bb..c9d90eeca 100644 --- a/autoload/SpaceVim/plugins/runner.vim +++ b/autoload/SpaceVim/plugins/runner.vim @@ -8,6 +8,7 @@ let s:JOB = SpaceVim#api#import('job') let s:BUFFER = SpaceVim#api#import('vim#buffer') +let s:STRING = SpaceVim#api#import('data#string') let s:runners = {} @@ -22,7 +23,7 @@ function! s:open_win() abort exe 'resize ' . lines setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber set filetype=SpaceVimRunner - nnoremap q :bd + nnoremap q :call SpaceVim#plugins#runner#close() let s:bufnr = bufnr('%') wincmd p endfunction @@ -30,7 +31,8 @@ endfunction function! s:async_run(runner) abort let cmd = printf(a:runner, bufname('%')) - call s:JOB.start(cmd,{ + let s:start_time = reltime() + let s:job_id = s:JOB.start(cmd,{ \ 'on_stdout' : function('s:on_stdout'), \ 'on_stderr' : function('s:on_stderr'), \ 'on_exit' : function('s:on_exit'), @@ -42,11 +44,11 @@ function! s:update_statusline() abort redrawstatus! endfunction -function! SpaceVim#plugins#runner#reg_runner(ft, runner) +function! SpaceVim#plugins#runner#reg_runner(ft, runner) abort let s:runners[a:ft] = a:runner endfunction -function! SpaceVim#plugins#runner#open() +function! SpaceVim#plugins#runner#open() abort let s:lines = 0 let s:status = { \ 'is_running' : 0, @@ -62,6 +64,9 @@ function! SpaceVim#plugins#runner#open() endif endfunction +" @vimlint(EVL103, 1, a:job_id) +" @vimlint(EVL103, 1, a:data) +" @vimlint(EVL103, 1, a:event) function! s:on_stdout(job_id, data, event) abort call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, a:data) let s:lines += len(a:data) @@ -76,21 +81,33 @@ function! s:on_stderr(job_id, data, event) abort endfunction function! s:on_exit(job_id, data, event) abort + let s:end_time = reltime(s:start_time) let s:status.is_exit = 1 let s:status.exit_code = a:data call s:update_statusline() endfunction +" @vimlint(EVL103, 0, a:job_id) +" @vimlint(EVL103, 0, a:data) +" @vimlint(EVL103, 0, a:event) function! s:debug_info() abort return [] endfunction -function! SpaceVim#plugins#runner#status() +function! SpaceVim#plugins#runner#status() abort if s:status.is_running == 1 elseif s:status.is_exit == 1 - return 'exit code : ' . s:status.exit_code + return 'exit code : ' . s:status.exit_code + \ . ' time: ' . s:STRING.trim(reltimestr(s:end_time)) endif return '' endfunction + +function! SpaceVim#plugins#runner#close() abort + if s:status.is_exit == 0 + call s:JOB.close(s:job_id) + endif + exe 'bd' s:bufnr +endfunction From 44ebec2fe85d592ccee090d55ec54905e4af49f8 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Thu, 5 Oct 2017 22:27:10 +0800 Subject: [PATCH 26/46] Add test for buf_set_lines --- autoload/SpaceVim/api/vim/buffer.vim | 21 +++++++++++++++++++++ test/api/vim/buffer.vader | 10 +++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/api/vim/buffer.vim b/autoload/SpaceVim/api/vim/buffer.vim index e70ff3a95..4dcfbe5e9 100644 --- a/autoload/SpaceVim/api/vim/buffer.vim +++ b/autoload/SpaceVim/api/vim/buffer.vim @@ -56,6 +56,27 @@ endfunction function! s:self.buf_set_lines(buffer, start, end, strict_indexing, replacement) abort if exists('*nvim_buf_set_lines') call nvim_buf_set_lines(a:buffer, a:start, a:end, a:strict_indexing, a:replacement) + elseif has('python') + py import vim + py import string + if bufexists(a:buffer) + py bufnr = string.atoi(vim.eval("a:buffer")) + py start_line = string.atoi(vim.eval("a:start")) + py end_line = string.atoi(vim.eval("a:end")) + py lines = vim.eval("a:replacement") + py vim.buffers[bufnr][start_line:end_line] = lines + endif + elseif has('python3') + py3 import vim + py3 import string + if bufexists(a:buffer) + py3 bufnr = string.atoi(vim.eval("a:buffer")) + py3 start_line = string.atoi(vim.eval("a:start")) + py3 end_line = string.atoi(vim.eval("a:end")) + py3 lines = vim.eval("a:replacement") + py3 vim.buffers[bufnr][start_line:end_line] = lines + endif + else endif endfunction diff --git a/test/api/vim/buffer.vader b/test/api/vim/buffer.vader index c60f19aa2..5bd1cc405 100644 --- a/test/api/vim/buffer.vader +++ b/test/api/vim/buffer.vader @@ -1,6 +1,14 @@ -Execute ( SpaceVim api: vim#buffer ): +Execute ( SpaceVim api: vim#buffer open ): new let buffer = SpaceVim#api#import('vim#buffer') call buffer.open({'bufname':'foo', 'cmd' : 'setl buftype=nofile bufhidden=wipe'}) AssertEqual bufname('%'), 'foo' AssertEqual &buftype, 'nofile' + +Execute ( SpaceVim api: vim#buffer buf_set_lines): + new + let buffer = SpaceVim#api#import('vim#buffer') + let nr = bufnr('%') + new + call buffer.buf_set_lines(nr, 0, 1, 0, ['line 1', 'line 2', 'line 3']) + AssertEqual getbufline(nr, 1, '$'), ['line 1', 'line 2', 'line 3'] From ef3ad4ccb3818b0cd6e7800dbadfef757462a92a Mon Sep 17 00:00:00 2001 From: techgaun Date: Thu, 5 Oct 2017 13:25:35 -0500 Subject: [PATCH 27/46] update spell checking --- autoload/SpaceVim/layers/ui.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/SpaceVim/layers/ui.vim b/autoload/SpaceVim/layers/ui.vim index 510c25467..52d64ff32 100644 --- a/autoload/SpaceVim/layers/ui.vim +++ b/autoload/SpaceVim/layers/ui.vim @@ -76,7 +76,7 @@ function! SpaceVim#layers#ui#config() abort \ 'toggle syntax checker', 1) call SpaceVim#mapping#space#def('nnoremap', ['t', 'S'], 'call call(' \ . string(s:_function('s:toggle_spell_check')) . ', [])', - \ 'toggle syntax checker', 1) + \ 'toggle spell checker', 1) call SpaceVim#mapping#space#def('nnoremap', ['t', 'w'], 'call call(' \ . string(s:_function('s:toggle_whitespace')) . ', [])', \ 'toggle the whitespace', 1) @@ -202,9 +202,9 @@ function! s:toggle_syntax_checker() abort call SpaceVim#layers#core#statusline#toggle_mode('syntax-checking') let g:_spacevim_toggle_syntax_flag = g:_spacevim_toggle_syntax_flag * -1 if g:_spacevim_toggle_syntax_flag == 1 - echo "syntax-checking enabled." + echo 'syntax-checking enabled.' else - echo "syntax-checking disabled." + echo 'syntax-checking disabled.' endif endfunction From 28a5554b1930b53dd923260868fc49d3fcaa86df Mon Sep 17 00:00:00 2001 From: Samar Dhwoj Acharya Date: Thu, 5 Oct 2017 13:49:59 -0500 Subject: [PATCH 28/46] improve documentation --- docs/documentation.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/documentation.md b/docs/documentation.md index 2073b851a..826448122 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -407,7 +407,7 @@ Reminder of the color codes for the states: | Mode | Color | | ------- | ------ | | Normal | Grey | -| Insert | Blus | +| Insert | Blue | | Visual | Orange | | Replace | Aqua | @@ -461,7 +461,7 @@ all the colors based on the current colorscheme **Statusline separators:** -It is possible to easily customize the statusline separator by setting the `g:spacevim_statusline_separator` variable in your custon configration file and then redraw the statusline. For instance if you want to set back the separator to the well-known arrow separator add the following snippet to your configuration file: +It is possible to easily customize the statusline separator by setting the `g:spacevim_statusline_separator` variable in your custom configration file and then redraw the statusline. For instance if you want to set back the separator to the well-known arrow separator add the following snippet to your configuration file: ```vim let g:spacevim_statusline_separator = 'arrow' @@ -809,7 +809,7 @@ Buffer manipulation commands (start with `b`): ##### Special Buffers -In SpaceVim, there are many special buffers, these buffers are created by plugins or SpaceVim isself. and all of this buffers are not listed. +In SpaceVim, there are many special buffers, these buffers are created by plugins or SpaceVim itself. And these buffers are not listed. ##### Files manipulations key bindings @@ -969,7 +969,7 @@ after pressing prefix `z` in normal mode, if you do not remember the mappings, y | `zO` | open folds recursively | | `zR` | set `foldlevel` to deepest fold | | `zW` | mark wrong spelled | -| `zX` | re-apply `foldleve` | +| `zX` | re-apply `foldlevel` | | `z^` | cursor to screen bottom line N | | `za` | toggle a fold | | `zb` | redraw, cursor line at bottom | From cde8f1b12ca12d7ce0db365c5d842fc9c9fdb080 Mon Sep 17 00:00:00 2001 From: techgaun Date: Thu, 5 Oct 2017 14:03:28 -0500 Subject: [PATCH 29/46] msg about spell-checking (en|dis)abled --- autoload/SpaceVim/layers/ui.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autoload/SpaceVim/layers/ui.vim b/autoload/SpaceVim/layers/ui.vim index 52d64ff32..e37c263c7 100644 --- a/autoload/SpaceVim/layers/ui.vim +++ b/autoload/SpaceVim/layers/ui.vim @@ -215,6 +215,11 @@ function! s:toggle_spell_check() abort let &l:spell = 1 endif call SpaceVim#layers#core#statusline#toggle_mode('spell-checking') + if &l:spell == 1 + echo 'spell-checking enabled.' + else + echo 'spell-checking disabled.' + endif endfunction function! s:toggle_whitespace() abort From 4053622d5ca4fdfa11a6bb12274e9b3cf8bcb64d Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 6 Oct 2017 00:26:24 +0200 Subject: [PATCH 30/46] Travis: set -e with script blocks This makes it fail actually if there are any errors. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index b9f5ea232..25813b3ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,7 @@ matrix: install: - | + set -e if [ "${LINT#vimlint}" != "$LINT" ]; then git clone --depth=1 https://github.com/syngan/vim-vimlint /tmp/vimlint git clone --depth=1 https://github.com/ynkdir/vim-vimlparser /tmp/vimlparser @@ -44,6 +45,7 @@ install: fi script: - | + set -e if [ "$LINT" = "vimlint" ]; then sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./config sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./autoload From 793f7f16e5b7b08c882d52694aa6e691326d2bb1 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Fri, 6 Oct 2017 20:54:45 +0800 Subject: [PATCH 31/46] Split command --- .travis.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 25813b3ea..e4ccc2268 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,13 +48,23 @@ script: set -e if [ "$LINT" = "vimlint" ]; then sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./config - sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./autoload + sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/airline + sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/leaderf + sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/SpaceVim + sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/vimfiler + sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/zvim + sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/*.vim sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./ftplugin sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./syntax sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./mode elif [ "$LINT" = "vimlint-errors" ]; then sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./config - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload + sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/airline + sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/leaderf + sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/SpaceVim + sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/vimfiler + sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/zvim + sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/*.vim sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./ftplugin sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./syntax sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./mode From 21021196f1dd54f7196e2b1cb1d307c3014ffbfb Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Fri, 6 Oct 2017 21:20:03 +0800 Subject: [PATCH 32/46] Use for loop --- .travis.yml | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index e4ccc2268..76ef83508 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,27 +47,15 @@ script: - | set -e if [ "$LINT" = "vimlint" ]; then - sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./config - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/airline - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/leaderf - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/SpaceVim - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/vimfiler - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/zvim - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/*.vim - sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./ftplugin - sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./syntax - sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./mode + for file in $(find . -name "*.vim"); + do + sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser $file; + done elif [ "$LINT" = "vimlint-errors" ]; then - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./config - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/airline - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/leaderf - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/SpaceVim - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/vimfiler - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/zvim - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload/*.vim - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./ftplugin - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./syntax - sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./mode + for file in $(find . -name "*.vim"); + do + sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser $file; + done elif [ "$LINT" = "vint" ]; then vint . elif [ "$LINT" = "vint-errors" ]; then From 76d184a23a87f21d310cddac99b6fddd4b03aaf1 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Fri, 6 Oct 2017 21:26:57 +0800 Subject: [PATCH 33/46] Fix lint --- autoload/SpaceVim/layers/core/statusline.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autoload/SpaceVim/layers/core/statusline.vim b/autoload/SpaceVim/layers/core/statusline.vim index 3b6b1879f..415bc569c 100644 --- a/autoload/SpaceVim/layers/core/statusline.vim +++ b/autoload/SpaceVim/layers/core/statusline.vim @@ -423,11 +423,16 @@ endfunction " | " +- a:marked : The number of marked files, or a comma separated list of " the marked filenames. + +" @vimlint(EVL103, 1, a:regex) +" @vimlint(EVL103, 1, a:marked) function! SpaceVim#layers#core#statusline#ctrlp(focus, byfname, regex, prev, item, next, marked) abort return s:STATUSLINE.build([' Ctrlp ', ' ' . a:prev . ' ', ' ' . a:item . ' ', ' ' . a:next . ' '], \ [' ' . a:focus . ' ', ' ' . a:byfname . ' ', ' ' . getcwd() . ' '], s:lsep, s:rsep, '', \ 'SpaceVim_statusline_a_bold', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z') endfunction +" @vimlint(EVL103, 0, a:regex) +" @vimlint(EVL103, 0, a:marked) " a:str : Either the number of files scanned so far, or a string indicating " the current directory is being scanned with a user_command. From e9ead2f5ca108e4acde222b0032310f4fd65c453 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 1 Oct 2017 17:06:18 +0200 Subject: [PATCH 34/46] tests: rename test/test.vim to test/vimrc for clarity --- .travis.yml | 2 +- test/test.sh | 2 +- test/{test.vim => vimrc} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename test/{test.vim => vimrc} (100%) diff --git a/.travis.yml b/.travis.yml index 76ef83508..4a1fb2f2f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,5 +61,5 @@ script: elif [ "$LINT" = "vint-errors" ]; then vint --error . elif [ "$LINT" = "vader" ]; then - vim -Nu test/test.vim -c 'Vader! test/**' + vim -Nu test/vimrc -c 'Vader! test/**' fi diff --git a/test/test.sh b/test/test.sh index fe81b8074..50d2c3b03 100755 --- a/test/test.sh +++ b/test/test.sh @@ -1,4 +1,4 @@ if [ ! -e /tmp/vader ]; then git clone https://github.com/junegunn/vader.vim.git /tmp/vader fi -vim -Nu test/test.vim -c 'Vader! test/**' +vim -Nu test/vimrc -c 'Vader! test/**' diff --git a/test/test.vim b/test/vimrc similarity index 100% rename from test/test.vim rename to test/vimrc From f48fdc32714e2cc00791e0a8ed40683ffa54ee02 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 1 Oct 2017 17:07:20 +0200 Subject: [PATCH 35/46] tests: use --depth=1 with git-clone for vader --- .travis.yml | 2 +- test/test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4a1fb2f2f..0e6f405b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ install: elif [ "${LINT#vint}" != "$LINT" ]; then virtualenv /tmp/vint && source /tmp/vint/bin/activate && pip install vim-vint elif [ "${LINT#vader}" != "$LINT" ]; then - git clone https://github.com/junegunn/vader.vim.git /tmp/vader + git clone --depth 1 https://github.com/junegunn/vader.vim.git /tmp/vader C_OPTS="--prefix=$DEPS --with-features=huge --disable-gui --enable-pythoninterp" git clone --depth 1 https://github.com/vim/vim cd vim diff --git a/test/test.sh b/test/test.sh index 50d2c3b03..8ca8586b3 100755 --- a/test/test.sh +++ b/test/test.sh @@ -1,4 +1,4 @@ if [ ! -e /tmp/vader ]; then - git clone https://github.com/junegunn/vader.vim.git /tmp/vader + git clone --depth 1 https://github.com/junegunn/vader.vim.git /tmp/vader fi vim -Nu test/vimrc -c 'Vader! test/**' From b7ac199623f574e309070e31c41040c1b47b974b Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 5 Oct 2017 00:21:24 +0200 Subject: [PATCH 36/46] Move test/test.sh into (new) Makefile --- .gitignore | 1 + Makefile | 8 ++++++++ test/test.sh | 4 ---- test/vimrc | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 759a81299..bfb1d49c7 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ cscope.files cscope.out cscope.in.out cscope.po.out +build/ diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..41f10ba40 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +test: build/vader | build + vim -Nu test/vimrc -c 'Vader! test/**' + +build/vader: + git clone --depth 1 https://github.com/junegunn/vader.vim.git $@ + +build: + mkdir -p $@ diff --git a/test/test.sh b/test/test.sh index 8ca8586b3..e69de29bb 100755 --- a/test/test.sh +++ b/test/test.sh @@ -1,4 +0,0 @@ -if [ ! -e /tmp/vader ]; then - git clone --depth 1 https://github.com/junegunn/vader.vim.git /tmp/vader -fi -vim -Nu test/vimrc -c 'Vader! test/**' diff --git a/test/vimrc b/test/vimrc index 4922aee54..610ba93a3 100644 --- a/test/vimrc +++ b/test/vimrc @@ -1,5 +1,5 @@ filetype off -set rtp+=/tmp/vader +set rtp+=build/vader set rtp+=. set rtp+=after filetype plugin indent on From a8e1f533ced32a7da477ca5031b40c6968d40bc3 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 5 Oct 2017 00:23:54 +0200 Subject: [PATCH 37/46] .travis.yml: use make test --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0e6f405b7..de67a6671 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,6 @@ install: elif [ "${LINT#vint}" != "$LINT" ]; then virtualenv /tmp/vint && source /tmp/vint/bin/activate && pip install vim-vint elif [ "${LINT#vader}" != "$LINT" ]; then - git clone --depth 1 https://github.com/junegunn/vader.vim.git /tmp/vader C_OPTS="--prefix=$DEPS --with-features=huge --disable-gui --enable-pythoninterp" git clone --depth 1 https://github.com/vim/vim cd vim @@ -61,5 +60,5 @@ script: elif [ "$LINT" = "vint-errors" ]; then vint --error . elif [ "$LINT" = "vader" ]; then - vim -Nu test/vimrc -c 'Vader! test/**' + make test fi From 09b44ca2cb0c9296bf9f272029f58696feef8307 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 5 Oct 2017 00:47:40 +0200 Subject: [PATCH 38/46] Makefile: add clean/PHONY --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 41f10ba40..30e38f308 100644 --- a/Makefile +++ b/Makefile @@ -6,3 +6,8 @@ build/vader: build: mkdir -p $@ + +clean: + $(RM) -r build + +.PHONY: clean test From 7a5fc697fe5ec455ee93e623a8ebf4a78a96d854 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 5 Oct 2017 00:51:29 +0200 Subject: [PATCH 39/46] Remove wrong codecov.yml This looks like a .coveragerc for covimerage, but should not be necessary anyway. --- codecov.yml | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index 02c2f4205..000000000 --- a/codecov.yml +++ /dev/null @@ -1,2 +0,0 @@ -[run] -plugins = covimerage From 36606dba08ff17cf12fd2e1026dab24bb5706c27 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 6 Oct 2017 00:18:20 +0200 Subject: [PATCH 40/46] Travis: set -x for script --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index de67a6671..a3beb7b02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,7 @@ install: fi script: - | - set -e + set -ex if [ "$LINT" = "vimlint" ]; then for file in $(find . -name "*.vim"); do From b0046388a2fb53e435221ea50f6c7ab462bfe038 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 7 Oct 2017 01:37:26 +0200 Subject: [PATCH 41/46] Travis: build Vim in /tmp --- .travis.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index a3beb7b02..22aaa8cae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,12 +35,10 @@ install: virtualenv /tmp/vint && source /tmp/vint/bin/activate && pip install vim-vint elif [ "${LINT#vader}" != "$LINT" ]; then C_OPTS="--prefix=$DEPS --with-features=huge --disable-gui --enable-pythoninterp" - git clone --depth 1 https://github.com/vim/vim - cd vim - ./configure $C_OPTS - make - make install - cd - + (git clone --depth 1 https://github.com/vim/vim /tmp/vim && + cd /tmp/vim && + ./configure $C_OPTS && + make install) fi script: - | From c6adab923b2e10f255bf66949b49fcc3bb799d9b Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 7 Oct 2017 20:33:06 +0800 Subject: [PATCH 42/46] Close #874 --- config/plugins/neocomplete.vim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config/plugins/neocomplete.vim b/config/plugins/neocomplete.vim index 345631a97..a69367d22 100644 --- a/config/plugins/neocomplete.vim +++ b/config/plugins/neocomplete.vim @@ -69,4 +69,13 @@ inoremap neocomplete#smart_close_popup()."\" inoremap neocomplete#close_popup() inoremap neocomplete#cancel_popup() +" Called once right before you start selecting multiple cursors +function! Multiple_cursors_before() + NeoCompleteLock +endfunction + +" Called once only when the multiple selection is canceled (default ) +function! Multiple_cursors_after() + NeoCompleteUnlock +endfunction " vim:set et sw=2 cc=80: From 60b50ad74379a0b1799705246fd88dab0d7e1a85 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 7 Oct 2017 21:35:09 +0800 Subject: [PATCH 43/46] Update job api --- autoload/SpaceVim/api/job.vim | 334 ++++++++++++++++++---------------- 1 file changed, 174 insertions(+), 160 deletions(-) diff --git a/autoload/SpaceVim/api/job.vim b/autoload/SpaceVim/api/job.vim index 5376671f9..193f69b07 100644 --- a/autoload/SpaceVim/api/job.vim +++ b/autoload/SpaceVim/api/job.vim @@ -1,5 +1,5 @@ function! SpaceVim#api#job#get() abort - return deepcopy(s:self) + return deepcopy(s:self) endfunction " make vim and neovim use same job func. @@ -9,195 +9,209 @@ let s:self.nvim_job = has('nvim') let s:self.vim_job = !has('nvim') && has('job') && has('patch-8.0.0027') let s:self.vim_co = SpaceVim#api#import('vim#compatible') +if !s:self.nvim_job && !s:self.vim_job + let s:self.job_argv = ['', '', ''] + augroup SpaceVim_job + au! + au! User SpaceVim_job_stdout call call(self.opts.on_stdout, self.job_argv) + au! User SpaceVim_job_stderr call call(self.opts.on_stderr, self.job_argv) + au! User SpaceVim_job_exit call call(self.opts.on_exit, self.job_argv) + augroup ENd +endif + function! s:self.warn(...) abort - if len(a:000) == 0 - echohl WarningMsg | echom 'Current version do not support job feature, fallback to sync system()' | echohl None - elseif len(a:000) == 1 && type(a:1) == type('') - echohl WarningMsg | echom a:1| echohl None - else - endif + if len(a:000) == 0 + echohl WarningMsg | echom 'Current version do not support job feature, fallback to sync system()' | echohl None + elseif len(a:000) == 1 && type(a:1) == type('') + echohl WarningMsg | echom a:1| echohl None + else + endif endfunction function! s:self.warp(argv, opts) abort - let obj = {} - let obj._argv = a:argv - let obj._opts = a:opts - let obj.in_io = get(a:opts, 'in_io', 'pipe') - " @vimlint(EVL103, 1, a:job_id) - function! obj._out_cb(job_id, data) abort - if has_key(self._opts, 'on_stdout') - call self._opts.on_stdout(self._opts.jobpid, [a:data], 'stdout') - endif - endfunction - - function! obj._err_cb(job_id, data) abort - if has_key(self._opts, 'on_stderr') - call self._opts.on_stderr(self._opts.jobpid, [a:data], 'stderr') - endif - endfunction - - function! obj._exit_cb(job_id, data) abort - if has_key(self._opts, 'on_exit') - call self._opts.on_exit(self._opts.jobpid, a:data, 'exit') - endif - endfunction - " @vimlint(EVL103, 0, a:job_id) - - let obj = { - \ 'argv': a:argv, - \ 'opts': { - \ 'mode': 'nl', - \ 'in_io' : obj.in_io, - \ 'out_cb': obj._out_cb, - \ 'err_cb': obj._err_cb, - \ 'exit_cb': obj._exit_cb, - \ } - \ } - if has_key(a:opts, 'cwd') - call extend(obj.opts, {'cwd' : a:opts.cwd}) + let obj = {} + let obj._argv = a:argv + let obj._opts = a:opts + let obj.in_io = get(a:opts, 'in_io', 'pipe') + " @vimlint(EVL103, 1, a:job_id) + function! obj._out_cb(job_id, data) abort + if has_key(self._opts, 'on_stdout') + call self._opts.on_stdout(self._opts.jobpid, [a:data], 'stdout') endif - return obj + endfunction + + function! obj._err_cb(job_id, data) abort + if has_key(self._opts, 'on_stderr') + call self._opts.on_stderr(self._opts.jobpid, [a:data], 'stderr') + endif + endfunction + + function! obj._exit_cb(job_id, data) abort + if has_key(self._opts, 'on_exit') + call self._opts.on_exit(self._opts.jobpid, a:data, 'exit') + endif + endfunction + " @vimlint(EVL103, 0, a:job_id) + + let obj = { + \ 'argv': a:argv, + \ 'opts': { + \ 'mode': 'nl', + \ 'in_io' : obj.in_io, + \ 'out_cb': obj._out_cb, + \ 'err_cb': obj._err_cb, + \ 'exit_cb': obj._exit_cb, + \ } + \ } + if has_key(a:opts, 'cwd') + call extend(obj.opts, {'cwd' : a:opts.cwd}) + endif + return obj endfunction " start a job, and return the job_id. function! s:self.start(argv, ...) abort - if self.nvim_job - if len(a:000) > 0 - let job = jobstart(a:argv, a:1) - else - let job = jobstart(a:argv) - endi - if job > 0 - let msg = ['process '. jobpid(job), ' run'] - call extend(self.jobs, {job : msg}) - endif - return job - elseif self.vim_job - if len(a:000) > 0 - let opts = a:1 - else - let opts = {} - endif - let id = len(self.jobs) + 1 - let opts.jobpid = id - let wrapped = self.warp(a:argv, opts) - if has_key(wrapped.opts, 'cwd') - let old_wd = getcwd() - let cwd = expand(wrapped.opts.cwd, 1) - " Avoid error E475: Invalid argument: cwd - call remove(wrapped.opts, 'cwd') - exe 'cd' fnameescape(cwd) - endif - let job = job_start(wrapped.argv, wrapped.opts) - if exists('old_wd') - exe 'cd' fnameescape(old_wd) - endif - call extend(self.jobs, {id : job}) - return id + if self.nvim_job + if len(a:000) > 0 + let job = jobstart(a:argv, a:1) else - if len(a:000) > 0 - let opts = a:1 - else - let opts = {} - endif - if has_key(opts, 'cwd') - let old_wd = getcwd() - let cwd = expand(opts.cwd, 1) - exe 'cd' fnameescape(cwd) - endif - let output = self.vim_co.systemlist(a:argv) - if exists('old_wd') - exe 'cd' fnameescape(old_wd) - endif - let id = -1 - if v:shell_error - if has_key(opts,'on_stderr') - call call(opts.on_stderr, [id, output, 'stderr']) - endif - else - if has_key(opts,'on_stdout') - call call(opts.on_stdout, [id, output, 'stdout']) - endif - endif - if has_key(opts,'on_exit') - call call(opts.on_exit, [id, v:shell_error, 'exit']) - endif - return id + let job = jobstart(a:argv) + endi + if job > 0 + let msg = ['process '. jobpid(job), ' run'] + call extend(self.jobs, {job : msg}) endif + return job + elseif self.vim_job + if len(a:000) > 0 + let opts = a:1 + else + let opts = {} + endif + let id = len(self.jobs) + 1 + let opts.jobpid = id + let wrapped = self.warp(a:argv, opts) + if has_key(wrapped.opts, 'cwd') + let old_wd = getcwd() + let cwd = expand(wrapped.opts.cwd, 1) + " Avoid error E475: Invalid argument: cwd + call remove(wrapped.opts, 'cwd') + exe 'cd' fnameescape(cwd) + endif + let job = job_start(wrapped.argv, wrapped.opts) + if exists('old_wd') + exe 'cd' fnameescape(old_wd) + endif + call extend(self.jobs, {id : job}) + return id + else + if len(a:000) > 0 + let opts = a:1 + else + let opts = {} + endif + if has_key(opts, 'cwd') + let old_wd = getcwd() + let cwd = expand(opts.cwd, 1) + exe 'cd' fnameescape(cwd) + endif + let output = self.vim_co.systemlist(a:argv) + if exists('old_wd') + exe 'cd' fnameescape(old_wd) + endif + let id = -1 + let self.opts = opts + if v:shell_error + if has_key(opts,'on_stderr') + let self.job_argv = [id, output, 'stderr'] + doautocmd User SpaceVim_job_stderr + endif + else + if has_key(opts,'on_stdout') + let self.job_argv = [id, output, 'stdout'] + doautocmd User SpaceVim_job_stdout + endif + endif + if has_key(opts,'on_exit') + let self.job_argv = [id, output, 'exit'] + doautocmd User SpaceVim_job_exit + endif + return id + endif endfunction function! s:self.stop(id) abort - if self.nvim_job - if has_key(self.jobs, a:id) - call jobstop(a:id) - call remove(self.jobs, a:id) - else - call self.warn('No job with such id') - endif - elseif self.vim_job - if has_key(self.jobs, a:id) - call job_stop(get(self.jobs, a:id)) - call remove(self.jobs, a:id) - endif + if self.nvim_job + if has_key(self.jobs, a:id) + call jobstop(a:id) + call remove(self.jobs, a:id) else - call self.warn() + call self.warn('No job with such id') endif + elseif self.vim_job + if has_key(self.jobs, a:id) + call job_stop(get(self.jobs, a:id)) + call remove(self.jobs, a:id) + endif + else + call self.warn() + endif endfunction function! s:self.send(id, data) abort - if self.nvim_job - if has_key(self.jobs, a:id) - if type(a:data) == type('') - call jobsend(a:id, [a:data, '']) - else - call jobsend(a:id, a:data) - endif - else - call self.warn('No job with such id') - endif - elseif self.vim_job - if has_key(self.jobs, a:id) - let job = get(self.jobs, a:id) - let chanel = job_getchannel(job) - call ch_sendraw(chanel, a:data . "\n") - else - call self.warn('No job with such id') - endif + if self.nvim_job + if has_key(self.jobs, a:id) + if type(a:data) == type('') + call jobsend(a:id, [a:data, '']) + else + call jobsend(a:id, a:data) + endif else - call self.warn() + call self.warn('No job with such id') endif + elseif self.vim_job + if has_key(self.jobs, a:id) + let job = get(self.jobs, a:id) + let chanel = job_getchannel(job) + call ch_sendraw(chanel, a:data . "\n") + else + call self.warn('No job with such id') + endif + else + call self.warn() + endif endfunction function! s:self.status(id) abort - if self.nvim_job - if has_key(self.jobs, a:id) - return get(self.jobs, a:id)[1] - endif - elseif self.vim_job - if has_key(self.jobs, a:id) - return job_status(get(self.jobs, a:id)) - endif - else - call self.warn('No job with such id!') + if self.nvim_job + if has_key(self.jobs, a:id) + return get(self.jobs, a:id)[1] endif + elseif self.vim_job + if has_key(self.jobs, a:id) + return job_status(get(self.jobs, a:id)) + endif + else + call self.warn('No job with such id!') + endif endfunction function! s:self.list() abort - return copy(self.jobs) + return copy(self.jobs) endfunction function! s:self.info(id) abort - let info = {} - if self.nvim_job - let info.status = self.status(a:id) - let info.job_id = a:id - return info - elseif self.vim_job - if has_key(self.jobs, a:id) - return job_info(get(self.jobs, a:id)) - else - call self.warn('No job with such id!') - endif + let info = {} + if self.nvim_job + let info.status = self.status(a:id) + let info.job_id = a:id + return info + elseif self.vim_job + if has_key(self.jobs, a:id) + return job_info(get(self.jobs, a:id)) else - call self.warn() + call self.warn('No job with such id!') endif + else + call self.warn() + endif endfunction From 34628404146b8e1d049b63f08d08f47ab6cfde81 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 7 Oct 2017 22:21:45 +0800 Subject: [PATCH 44/46] Update job api --- autoload/SpaceVim/api/job.vim | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/autoload/SpaceVim/api/job.vim b/autoload/SpaceVim/api/job.vim index 193f69b07..2bd8cb3bf 100644 --- a/autoload/SpaceVim/api/job.vim +++ b/autoload/SpaceVim/api/job.vim @@ -10,12 +10,11 @@ let s:self.vim_job = !has('nvim') && has('job') && has('patch-8.0.0027') let s:self.vim_co = SpaceVim#api#import('vim#compatible') if !s:self.nvim_job && !s:self.vim_job - let s:self.job_argv = ['', '', ''] augroup SpaceVim_job au! - au! User SpaceVim_job_stdout call call(self.opts.on_stdout, self.job_argv) - au! User SpaceVim_job_stderr call call(self.opts.on_stderr, self.job_argv) - au! User SpaceVim_job_exit call call(self.opts.on_exit, self.job_argv) + au! User SpaceVim_job_stdout nested call call(s:self.opts.on_stdout, s:self.job_argv) + au! User SpaceVim_job_stderr nested call call(s:self.opts.on_stderr, s:self.job_argv) + au! User SpaceVim_job_exit nested call call(s:self.opts.on_exit, s:self.job_argv) augroup ENd endif @@ -119,21 +118,33 @@ function! s:self.start(argv, ...) abort exe 'cd' fnameescape(old_wd) endif let id = -1 - let self.opts = opts + let s:self.opts = opts if v:shell_error if has_key(opts,'on_stderr') - let self.job_argv = [id, output, 'stderr'] - doautocmd User SpaceVim_job_stderr + let s:self.job_argv = [id, output, 'stderr'] + try + doautocmd User SpaceVim_job_stderr + catch + doautocmd User SpaceVim_job_stderr + endtry endif else if has_key(opts,'on_stdout') - let self.job_argv = [id, output, 'stdout'] - doautocmd User SpaceVim_job_stdout + let s:self.job_argv = [id, output, 'stdout'] + try + doautocmd User SpaceVim_job_stdout + catch + doautocmd User SpaceVim_job_stdout + endtry endif endif if has_key(opts,'on_exit') - let self.job_argv = [id, output, 'exit'] + let s:self.job_argv = [id, v:shell_error, 'exit'] + try doautocmd User SpaceVim_job_exit + catch + doautocmd User SpaceVim_job_exit + endtry endif return id endif From a80cfdb7a307c7b0cfcb31d85fe8c694bf3f7ed4 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 7 Oct 2017 22:57:35 +0800 Subject: [PATCH 45/46] Update UI for dein --- README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 77f8cd200..5c1a3e382 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ [![SpaceVim](https://spacevim.org/logo.png)](https://spacevim.org) -[Wiki](https://github.com/SpaceVim/SpaceVim/wiki) | -[Documentation](http://spacevim.org/documentation/) | -[Twitter](https://twitter.com/SpaceVim) | -[Community](https://spacevim.org/community/) | -[Gitter **Chat**](https://gitter.im/SpaceVim/SpaceVim) | +[Wiki](https://github.com/SpaceVim/SpaceVim/wiki) \| +[Documentation](http://spacevim.org/documentation/) \| +[Twitter](https://twitter.com/SpaceVim) \| +[Community](https://spacevim.org/community/) \| +[Gitter **Chat**](https://gitter.im/SpaceVim/SpaceVim) \| [中文文档](http://spacevim.org/README_zh_cn/) [![Build Status](https://travis-ci.org/SpaceVim/SpaceVim.svg?branch=dev)](https://travis-ci.org/SpaceVim/SpaceVim) @@ -19,14 +19,12 @@ SpaceVim is a community-driven vim distribution that seeks to provide layer feat ![welcome-page](https://cloud.githubusercontent.com/assets/13142418/26402270/28ad72b8-40bc-11e7-945e-003f41e057be.png) - See the [documentation](https://spacevim.org/documentation) or [the list of layers](http://spacevim.org/layers/) for more information. Here is a throughput graph of the repository for the last few weeks: [![Throughput Graph](https://graphs.waffle.io/SpaceVim/SpaceVim/throughput.svg)](https://waffle.io/SpaceVim/SpaceVim/metrics/throughput) - ### Requirements SpaceVim's basic mode only requests `git` comamnd in your `$PATH`, but if you want to get better user experience, you need to install [nerd-font](https://github.com/ryanoasis/nerd-fonts). And make sure your terminal support [true colors](https://gist.github.com/XVilka/8346728). @@ -47,11 +45,11 @@ curl -sLf https://spacevim.org/install.sh | bash -s -- -h ### Features -- **Great documentation:** access documentation in Vim with - :h SpaceVim. +- **Great documentation:** access documentation in Vim with :h SpaceVim. - **Beautiful GUI:** you'll love the awesome UI and its useful features. - **Mnemonic key bindings:** all key bindings have mnemonic prefixes. - **Lazy load plugins:** Lazy-load 90% of plugins with [dein.vim](https://github.com/Shougo/dein.vim) + ![UI for dein](https://user-images.githubusercontent.com/13142418/31309093-36c01150-abb3-11e7-836c-3ad406bdd71a.gif) - **Neovim centric:** Dark powered mode of SpaceVim ### Support SpaceVim From de43970de301b9841fd17019c7e52ac2474fd94f Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 7 Oct 2017 23:46:22 +0800 Subject: [PATCH 46/46] Update lang#vim layer --- autoload/SpaceVim/layers/lang/vim.vim | 43 ++++++++++++++++++++------- docs/layers/lang/vim.md | 28 +++++++++++++++++ 2 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 docs/layers/lang/vim.md diff --git a/autoload/SpaceVim/layers/lang/vim.vim b/autoload/SpaceVim/layers/lang/vim.vim index 81e6311eb..9dcaf8764 100644 --- a/autoload/SpaceVim/layers/lang/vim.vim +++ b/autoload/SpaceVim/layers/lang/vim.vim @@ -1,16 +1,37 @@ function! SpaceVim#layers#lang#vim#plugins() abort - let plugins = [ - \ ['syngan/vim-vimlint', { 'on_ft' : 'vim'}], - \ ['ynkdir/vim-vimlparser', { 'on_ft' : 'vim'}], - \ ['todesking/vint-syntastic', { 'on_ft' : 'vim'}], - \ ] - call add(plugins,['tweekmonster/exception.vim']) - call add(plugins,['mhinz/vim-lookup']) - call add(plugins,['Shougo/neco-vim', { 'on_event' : 'InsertEnter', 'loadconf_before' : 1}]) - call add(plugins,['tweekmonster/helpful.vim', {'on_cmd': 'HelpfulVersion'}]) - return plugins + let plugins = [ + \ ['syngan/vim-vimlint', { 'on_ft' : 'vim'}], + \ ['ynkdir/vim-vimlparser', { 'on_ft' : 'vim'}], + \ ['todesking/vint-syntastic', { 'on_ft' : 'vim'}], + \ ] + call add(plugins,['tweekmonster/exception.vim']) + call add(plugins,['mhinz/vim-lookup']) + call add(plugins,['Shougo/neco-vim', { 'on_event' : 'InsertEnter', 'loadconf_before' : 1}]) + call add(plugins,['tweekmonster/helpful.vim', {'on_cmd': 'HelpfulVersion'}]) + return plugins endfunction function! SpaceVim#layers#lang#vim#config() abort - call SpaceVim#mapping#gd#add('vim','lookup#lookup') + call SpaceVim#mapping#gd#add('vim','lookup#lookup') + call SpaceVim#mapping#space#regesit_lang_mappings('vim', funcref('s:language_specified_mappings')) +endfunction + +function! s:language_specified_mappings() abort + call SpaceVim#mapping#space#langSPC('nmap', ['l','e'], 'call call(' + \ . string(function('s:eval_cursor')) . ', [])', + \ 'echo eval under cursor', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','v'], 'call call(' + \ . string(function('s:helpversion_cursor')) . ', [])', + \ 'echo helpversion under cursor', 1) +endfunction + +function! s:eval_cursor() abort + let is_keyword = &iskeyword + set iskeyword+=: + echo expand('') 'is' eval(expand('')) + let &iskeyword = is_keyword +endfunction + +function! s:helpversion_cursor() abort + exe 'HelpfulVersion' expand('') endfunction diff --git a/docs/layers/lang/vim.md b/docs/layers/lang/vim.md new file mode 100644 index 000000000..fe5dda783 --- /dev/null +++ b/docs/layers/lang/vim.md @@ -0,0 +1,28 @@ +--- +title: "SpaceVim lang#vim layer" +--- + +# [SpaceVim Layers:](https://spacevim.org/layers) lang#vim + + + +- [Description](#description) +- [Layer Installation](#layer-installation) +- [Key bindings](#key-bindings) + + + +## Description + +This layer is for vim plugin development. + +## Layer Installation + +To use this configuration layer, add `call SpaceVim#layers#load('lang#vim')` to your custom configuration file. + +## Key bindings + +| Key Binding | Description | +| ----------- | ----------------------------------------- | +| `SPC l e` | print the eval under the cursor | +| `SPC l v` | print the helpfulversion under the cursor |