From 46aac2c01377079db88d94b56519110d3d6bf2f7 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Thu, 8 Jun 2017 00:29:31 +0800 Subject: [PATCH 1/6] Add doc for file tree --- docs/documentation.md | 58 +++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/docs/documentation.md b/docs/documentation.md index 253b529bb..64e363627 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -61,6 +61,9 @@ title: "Documentation" * [Special Buffers](#special-buffers) * [Files manipulations key bindings](#files-manipulations-key-bindings) * [Vim and SpaceVim files](#vim-and-spacevim-files) + * [File tree](#file-tree) + * [File tree navigation](#file-tree-navigation) + * [Plugin: VimFiler](#plugin-vimfiler) * [Auto-saving](#auto-saving) * [Searching](#searching) * [Editing](#editing) @@ -97,7 +100,6 @@ title: "Documentation" * [Window Management](#window-management) * [Native functions](#native-functions) * [Plugin: Unite](#plugin-unite) - * [Plugin: VimFiler](#plugin-vimfiler) * [Plugin: neocomplete](#plugin-neocomplete) * [Plugin: NERD Commenter](#plugin-nerd-commenter) * [Plugin: Goyo and Limelight](#plugin-goyo-and-limelight) @@ -803,6 +805,42 @@ Key Binding | Description `SPC f v v` | display and copy SpaceVim version `SPC f v d` | open SpaceVim custom configuration file +#### File tree + +SpaceVim use vimfiler as the default file tree, and the default key binding is `F3`, and SpaceVim also provide `SPC f t` and `SPC f T` to open the file tree. + +VCS integration is supported, there will be a colum status, this feature maybe make vimfiler slow, so it is not enabled by default. to enable this feature, add `let g:spacevim_enable_vimfiler_gitstatus = 1` to your custom config. here is any picture for this feature: + +![file-tree](https://user-images.githubusercontent.com/13142418/26881817-279225b2-4bcb-11e7-8872-7e4bd3d1c84e.png) + +##### File tree navigation + +Navigation is centered on the `hjkl` keys with the hope of providing a fast navigation experience like in [vifm](https://github.com/vifm): + +###### Plugin: VimFiler + +Key Binding | Description +-----------| ----------- +`` or `SPC f t` | Toggle file explorer +| **Within _VimFiler_ buffers** | | +`h` or `RET` | go to parent node and collapse expanded directory +`` or `j` | select next file or directory +`` or `k` | select previous file or directory +`l` | open selected file +`Ctrl`+`j` | Un-map +`Ctrl`+`l` | Un-map +`E` | Un-map +`sv` | Split edit +`sg` | Vertical split edit +`p` | Preview +`i` | Switch to directory history +`v` | Quick look +`gx` | Execute with vimfiler associated +`'` | Toggle mark current line +`V` | Clear all marks +`Ctrl`+`r` | Redraw + + ### Auto-saving @@ -1212,24 +1250,6 @@ Key | Mode | Action ``+`ugf` | Normal | Opens Unite file with word at cursor ``+`ugt` | Normal/visual | Opens Unite tag with word at cursor -##### Plugin: VimFiler - -Key | Mode | Action ------ |:----:| ------------------ -`` | Normal | Toggle file explorer -| **Within _VimFiler_ buffers** ||| -`Ctrl`+`j` | Normal | Un-map -`Ctrl`+`l` | Normal | Un-map -`E` | Normal | Un-map -`sv` | Normal | Split edit -`sg` | Normal | Vertical split edit -`p` | Normal | Preview -`i` | Normal | Switch to directory history -`v` | Normal | Quick look -`gx` | Normal | Execute with vimfiler associated -`'` | Normal | Toggle mark current line -`V` | Normal | Clear all marks -`Ctrl`+`r` | Normal | Redraw ##### Plugin: neocomplete From a40cc8ed6c156f617a8634c7200c8473e7369a93 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Fri, 9 Jun 2017 21:08:16 +0800 Subject: [PATCH 2/6] Fix enter dir --- autoload/SpaceVim.vim | 1 + config/main.vim | 4 +++- docs/documentation.md | 14 ++++++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/autoload/SpaceVim.vim b/autoload/SpaceVim.vim index 899495f16..914ff4338 100644 --- a/autoload/SpaceVim.vim +++ b/autoload/SpaceVim.vim @@ -529,6 +529,7 @@ endfunction function! SpaceVim#welcome() abort + exe 'cd ' . g:_spacevim_enter_dir if exists('g:_spacevim_checking_flag') && g:_spacevim_checking_flag return endif diff --git a/config/main.vim b/config/main.vim index 04c76cb9f..25b763aa9 100644 --- a/config/main.vim +++ b/config/main.vim @@ -12,6 +12,8 @@ function! s:parser_argv() abort else return [1, getcwd()] endif + elseif argv(0) ==# '.' + return [1, getcwd()] elseif isdirectory(expand(argv(0))) return [1, expand(argv(0)) ] else @@ -20,7 +22,7 @@ function! s:parser_argv() abort endfunction let s:status = s:parser_argv() if s:status[0] - exe 'cd ' . s:status[1] + let g:_spacevim_enter_dir = s:status[1] augroup SPwelcom au! autocmd VimEnter * call SpaceVim#welcome() diff --git a/docs/documentation.md b/docs/documentation.md index 64e363627..7bf4a25f8 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -63,7 +63,7 @@ title: "Documentation" * [Vim and SpaceVim files](#vim-and-spacevim-files) * [File tree](#file-tree) * [File tree navigation](#file-tree-navigation) - * [Plugin: VimFiler](#plugin-vimfiler) + * [Open file with file tree.](#open-file-with-file-tree) * [Auto-saving](#auto-saving) * [Searching](#searching) * [Editing](#editing) @@ -807,7 +807,12 @@ Key Binding | Description #### File tree -SpaceVim use vimfiler as the default file tree, and the default key binding is `F3`, and SpaceVim also provide `SPC f t` and `SPC f T` to open the file tree. +SpaceVim use vimfiler as the default file tree, and the default key binding is `F3`, and SpaceVim also provide `SPC f t` and `SPC f T` to open the file tree. to change the file explore to nerdtree: + +```vim +" the default value is vimfiler +let g:spacevim_filemanager = 'nerdtree' +``` VCS integration is supported, there will be a colum status, this feature maybe make vimfiler slow, so it is not enabled by default. to enable this feature, add `let g:spacevim_enable_vimfiler_gitstatus = 1` to your custom config. here is any picture for this feature: @@ -817,7 +822,6 @@ VCS integration is supported, there will be a colum status, this feature maybe m Navigation is centered on the `hjkl` keys with the hope of providing a fast navigation experience like in [vifm](https://github.com/vifm): -###### Plugin: VimFiler Key Binding | Description -----------| ----------- @@ -826,7 +830,7 @@ Key Binding | Description `h` or `RET` | go to parent node and collapse expanded directory `` or `j` | select next file or directory `` or `k` | select previous file or directory -`l` | open selected file +`l` | open selected file or expand directory `Ctrl`+`j` | Un-map `Ctrl`+`l` | Un-map `E` | Un-map @@ -840,7 +844,9 @@ Key Binding | Description `V` | Clear all marks `Ctrl`+`r` | Redraw +##### Open file with file tree. +By default a file is opened in the last active window, ### Auto-saving From c10761bfa4215c6b2b5ca3f12ad3fc47e9d404fb Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Fri, 9 Jun 2017 22:29:52 +0800 Subject: [PATCH 3/6] Remove vimfiler message when toggle buffer --- autoload/zvim/util.vim | 4 ++-- config/plugins/vimfiler.vim | 18 ++++++++++-------- docs/documentation.md | 13 ++++++++++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/autoload/zvim/util.vim b/autoload/zvim/util.vim index 07ee0da79..7be33f3cb 100644 --- a/autoload/zvim/util.vim +++ b/autoload/zvim/util.vim @@ -187,7 +187,7 @@ endfunction function! zvim#util#OpenVimfiler() abort if bufnr('vimfiler') == -1 - VimFiler + silent VimFiler if exists(':AirlineRefresh') AirlineRefresh endif @@ -198,7 +198,7 @@ function! zvim#util#OpenVimfiler() abort endif wincmd p else - VimFiler + silent VimFiler doautocmd WinEnter if exists(':AirlineRefresh') AirlineRefresh diff --git a/config/plugins/vimfiler.vim b/config/plugins/vimfiler.vim index 24c96b057..9a8f1a680 100644 --- a/config/plugins/vimfiler.vim +++ b/config/plugins/vimfiler.vim @@ -79,14 +79,16 @@ function! s:vimfilerinit() nnoremap sg vimfiler#do_action('vsplit') nnoremap sv vimfiler#do_action('split') nnoremap st vimfiler#do_action('tabswitch') - nmap gx (vimfiler_execute_vimfiler_associated) - nmap ' (vimfiler_toggle_mark_current_line) - nmap v (vimfiler_quick_look) - nmap p (vimfiler_preview_file) - nmap V (vimfiler_clear_mark_all_lines) - nmap i (vimfiler_switch_to_history_directory) - nmap (vimfiler_switch_to_other_window) - nmap (vimfiler_redraw_screen) + nmap gx (vimfiler_execute_vimfiler_associated) + nmap ' (vimfiler_toggle_mark_current_line) + nmap v (vimfiler_quick_look) + nmap p (vimfiler_preview_file) + nmap V (vimfiler_clear_mark_all_lines) + nmap i (vimfiler_switch_to_history_directory) + nmap (vimfiler_switch_to_other_window) + nmap (vimfiler_redraw_screen) + nmap (vimfiler_smart_h) + nmap (vimfiler_smart_l) endf " vim:set et sw=2: diff --git a/docs/documentation.md b/docs/documentation.md index 7bf4a25f8..519f5e7b6 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -827,13 +827,14 @@ Key Binding | Description -----------| ----------- `` or `SPC f t` | Toggle file explorer | **Within _VimFiler_ buffers** | | -`h` or `RET` | go to parent node and collapse expanded directory +`` or `h` | go to parent node and collapse expanded directory `` or `j` | select next file or directory `` or `k` | select previous file or directory -`l` | open selected file or expand directory +`` or `l` | open selected file or expand directory `Ctrl`+`j` | Un-map `Ctrl`+`l` | Un-map `E` | Un-map +`.` | toggle visible ignored files `sv` | Split edit `sg` | Vertical split edit `p` | Preview @@ -846,7 +847,13 @@ Key Binding | Description ##### Open file with file tree. -By default a file is opened in the last active window, +If there is only one file buffer opened, a file is opened in the active window, otherwise we need to use vim-choosewin to select a window to open the file. + +Key Binding | Description +-----------| ----------- +`l` or `Enter` | open file in one window +`sg` | open file in an vertically split window +`sv` | open file in an horizontally split window ### Auto-saving From 0cb3a400d84d4e2449131dc19ca5aaeeb3643b15 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 11 Jun 2017 20:54:12 +0800 Subject: [PATCH 4/6] Ignore warnning msg --- autoload/SpaceVim/api/vim/highlight.vim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/autoload/SpaceVim/api/vim/highlight.vim b/autoload/SpaceVim/api/vim/highlight.vim index 0765bafd6..482676a83 100644 --- a/autoload/SpaceVim/api/vim/highlight.vim +++ b/autoload/SpaceVim/api/vim/highlight.vim @@ -70,10 +70,16 @@ function! s:self.hide_in_normal(name) abort endif if &termguicolors || has('gui_running') let bg = self.group2dict('Normal').guibg + if empty(bg) + return + endif let group.guifg = bg let group.guibg = bg else let bg = self.group2dict('Normal').ctermbg + if empty(bg) + return + endif let group.ctermfg = bg let group.ctermbg = bg endif From badecf87603d5f862c3c9fe06257059a70cb0da5 Mon Sep 17 00:00:00 2001 From: Wang Shidong Date: Fri, 16 Jun 2017 23:37:28 +0800 Subject: [PATCH 5/6] Update php.vim (#632) --- autoload/SpaceVim/layers/lang/php.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/lang/php.vim b/autoload/SpaceVim/layers/lang/php.vim index 18b1c7182..977752dde 100644 --- a/autoload/SpaceVim/layers/lang/php.vim +++ b/autoload/SpaceVim/layers/lang/php.vim @@ -21,7 +21,7 @@ function! SpaceVim#layers#lang#php#plugins() abort call add(plugins, ['StanAngeloff/php.vim', { 'on_ft' : 'php'}]) call add(plugins, ['2072/PHP-Indenting-for-VIm', { 'on_ft' : 'php'}]) call add(plugins, ['rafi/vim-phpspec', { 'on_ft' : 'php'}]) - call add(plugins, ['lvht/phpfold.vim', { 'on_ft' : 'php'}]) + call add(plugins, ['lvht/phpfold.vim', { 'on_ft' : 'php', 'build' : 'composer install'}]) return plugins endfunction From d76d83f4c093bff29bf26f2d7c9ed25fda0cb00d Mon Sep 17 00:00:00 2001 From: Wang Shidong Date: Sat, 17 Jun 2017 10:37:07 +0800 Subject: [PATCH 6/6] Create 2017-02-11-vim8-new-feature-timers-zh_cn.md (#633) * Create 2017-02-11-vim8-new-feature-timers-zh_cn.md * Update 2017-02-11-vim8-new-feature-timers-zh_cn.md * Update README_zh_cn.md * Update README_zh_cn.md * Update 2017-02-11-vim8-new-feature-timers-zh_cn.md * Add example for starting a timer * Update 2017-02-11-vim8-new-feature-timers-zh_cn.md --- docs/README_zh_cn.md | 15 +++++ ...017-02-11-vim8-new-feature-timers-zh_cn.md | 58 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 docs/_posts/2017-02-11-vim8-new-feature-timers-zh_cn.md diff --git a/docs/README_zh_cn.md b/docs/README_zh_cn.md index 1b713b41f..35bb4534b 100644 --- a/docs/README_zh_cn.md +++ b/docs/README_zh_cn.md @@ -168,3 +168,18 @@ let g:spacevim_guifont = 'DejaVu\ Sans\ Mono\ for\ Powerline\ 11' `g:spacevim_guifont` | '' | 设置SpaceVim字体 `g:spacevim_sidebar_width` | 30 | 设置边栏宽度,文件树以及语法树 `g:spacevim_custom_plugins` | `[]` | 设置自定义插件 + + +### 延伸阅读 + +#### Vim 8 新特新之旅 + +
    + {% for post in site.categories.tutorials_cn %} +
  • + {{ post.title }} +
  • + {% endfor %} +
+ + diff --git a/docs/_posts/2017-02-11-vim8-new-feature-timers-zh_cn.md b/docs/_posts/2017-02-11-vim8-new-feature-timers-zh_cn.md new file mode 100644 index 000000000..fbc7a79dd --- /dev/null +++ b/docs/_posts/2017-02-11-vim8-new-feature-timers-zh_cn.md @@ -0,0 +1,58 @@ +--- +title: "VIM 8 新特性之旅: 定时器 (timers)" +categories: tutorials_cn +excerpt: "VIM 8 新特性之旅系列教程 - 定时器" +--- + +## 定时器( timer ) +> vim 需要支持 +timers 特性 + +### 什么是定时器? + +Vim 的定时器是指在指定时间后重复指定次数执行某个回调函数。 这一功能需要 Vim 支持 `+timers` 特性。 + +### 启动定时器 + +`timer_start({毫秒}, {回调函数}[,{选项}])` + +Vim 中这个方法将创建一个计时器,并且返回这个定时器的 ID。 回调函数接受一个参数,可以是字符串,表示方法具体名称,也可以是 `Funcref` 变量。 下面是一个示例: + +```vim +func MyHandler(id) + echo 'This is handler called for timer-' . a:id +endfunc +let timer = timer_start(500, 'MyHandler', + \ {'repeat': 3}) +``` + +#### 获取定时器信息 + +`timer_info([{ID}])` + +这个方法会返回一个存储定时器信息的列表, 当编号为 ID 的定时器不存在,将返回一个空的列表,当直接调用这个方法, 而不传递任何参数时,将返回所有定时器的信息。返回列表中每一个元素实际上是一个字典数据类型,具体的结构如下: + + + { + "id" : 该定时器的 ID, + "time" : 定时器启动是所设置的毫秒数, + "remaining" : 距定时器启动还剩余的毫秒数, + "repeat" : 定时器还需要重复执行的次数,无限执行则返回 -1, + "callback" : 回调函数, + "paused" : 是否被暂停,是则返回 1,否则返回 0 + } +     +#### 暂停定时器 + +`timer_pause({ID} , {是否})` + +这个方法接受 2 个参数,第一个参数是 定时器的 ID, 第二个参数是决定是 暂停 还是 取消暂停 的关键,当第二个参数是一个非 0 数值,或非空字符串,则该定时器被暂停,否则即为取消暂停。 + +#### 停止定时器 + +`timer_stop([{ID}])` + +停止一个编号为 ID 的定时器,ID 即为 timer_start() 方法的返回值,因此必须为数值,即便编号为 ID 的定时器不存在,这个方法也不会报错。 + +另外一个方法 timer_stopall(), 将停止所有定时器。就个人来看 vim 这个方法设计并不完美, 一个软件的方法命名应该存在一定的规则,比如前面的 timer_info() 就是一个可变参数的方法,当无参执行是返回所有定时器的信息,那么这个 timer_staop() 应该也是可以参数方法,无参执行时取消所有定时器。当然了这个仅仅是个人意见。 + +查阅跟多 Vim 中文教程,请阅读: