From ca4232735609b66edf9d57e5ae685f92e9e4702e Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Thu, 25 Jan 2018 22:57:56 +0800 Subject: [PATCH] Enable fold code --- autoload/SpaceVim/plugins/flygrep.vim | 160 ++++++++++-------- .../2017-01-26-SpaceVim-release-v0.1.0.md | 1 + .../2017-02-11-use-vim-as-a-java-ide.md | 1 + ...017-02-11-vim8-new-feature-timers-zh_cn.md | 1 + ...stall-vim-or-neovim-with-python-support.md | 1 + .../2017-03-30-SpaceVim-release-v0.2.0.md | 1 + ...-05-25-mnemonic-key-bindings-navigation.md | 1 + ...17-05-31-SpaceVim-Newsletter-A-New-Hope.md | 1 + .../2017-05-31-SpaceVim-release-v0.3.0.md | 1 + .../2017-06-27-SpaceVim-release-v0.3.1.md | 1 + .../2017-08-05-SpaceVim-release-v0.4.0.md | 1 + .../2017-08-11-Asynchronous-plugin-manager.md | 1 + ...2017-11-04-use-ctrl-in-terminal-and-vim.md | 1 + .../2017-11-06-SpaceVim-release-v0.5.0.md | 1 + ...-11-6-help-description-for-key-bindings.md | 1 + ...017-12-07-async-code-runner-in-SpaceVim.md | 1 + .../2017-12-30-SpaceVim-release-v0.6.0.md | 1 + ...Vim-Newsletter-Never-lost-never-give-up.md | 1 + 18 files changed, 108 insertions(+), 69 deletions(-) diff --git a/autoload/SpaceVim/plugins/flygrep.vim b/autoload/SpaceVim/plugins/flygrep.vim index 304e19a1f..40640488b 100644 --- a/autoload/SpaceVim/plugins/flygrep.vim +++ b/autoload/SpaceVim/plugins/flygrep.vim @@ -1,48 +1,19 @@ +" Loadding SpaceVim api {{{ scriptencoding utf-8 let s:MPT = SpaceVim#api#import('prompt') let s:JOB = SpaceVim#api#import('job') let s:SYS = SpaceVim#api#import('system') let s:BUFFER = SpaceVim#api#import('vim#buffer') -let s:grepid = 0 -let s:MPT._prompt.mpt = '➭ ' - -" keys: -" files: files for grep, @buffers means listed buffer. -" dir: specific a directory for grep -function! SpaceVim#plugins#flygrep#open(agrv) abort - noautocmd rightbelow split __flygrep__ - setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber - let save_tve = &t_ve - setlocal t_ve= - " setlocal nomodifiable - setf SpaceVimFlyGrep - redraw! - let s:MPT._prompt.begin = get(a:agrv, 'input', '') - let fs = get(a:agrv, 'files', '') - if fs ==# '@buffers' - let s:grep_files = map(s:BUFFER.listed_buffers(), 'bufname(v:val)') - elseif !empty(fs) - let s:grep_files = fs - else - let s:grep_files = '' - endif - let dir = expand(get(a:agrv, 'dir', '')) - if !empty(dir) && isdirectory(dir) - let s:grep_dir = dir - else - let s:grep_dir = '' - endif - let s:grep_exe = get(a:agrv, 'cmd', s:grep_default_exe) - let s:grep_opt = get(a:agrv, 'opt', s:grep_default_opt) - let s:grep_ropt = get(a:agrv, 'ropt', s:grep_default_ropt) - call s:MPT.open() - let &t_ve = save_tve -endfunction +"}}} +" Init local options: {{{ let s:grep_expr = '' let [s:grep_default_exe, s:grep_default_opt, s:grep_default_ropt] = SpaceVim#mapping#search#default_tool() let s:grep_timer_id = 0 +let s:grepid = 0 +" }}} +" grep local funcs:{{{ " @vimlint(EVL103, 1, a:timer) function! s:grep_timer(timer) abort let cmd = s:get_search_cmd(join(split(s:grep_expr), '.*')) @@ -54,6 +25,41 @@ function! s:grep_timer(timer) abort \ 'on_exit' : function('s:grep_exit'), \ }) endfunction + +function! s:get_search_cmd(expr) abort + let cmd = [s:grep_exe] + s:grep_opt + if !empty(s:grep_files) && type(s:grep_files) == 3 + return cmd + [a:expr] + s:grep_files + elseif !empty(s:grep_files) && type(s:grep_files) == 1 + return cmd + [a:expr] + [s:grep_files] + elseif !empty(s:grep_dir) + return cmd + [a:expr] + [s:grep_dir] + else + return cmd + [a:expr] + s:grep_ropt + endif +endfunction + +function! s:flygrep(expr) abort + call s:MPT._build_prompt() + if a:expr ==# '' + redrawstatus + return + endif + try + call matchdelete(s:hi_id) + catch + endtr + hi def link FlyGrepPattern MoreMsg + let s:hi_id = matchadd('FlyGrepPattern', '\c' . join(split(a:expr), '\|'), 1) + let s:grep_expr = a:expr + let s:grep_timer_id = timer_start(200, function('s:grep_timer'), {'repeat' : 1}) +endfunction + +" set default handle func: s:flygrep +let s:MPT._handle_fly = function('s:flygrep') +" }}} + +" filter local funcs: {{{ " @vimlint(EVL103, 0, a:timer) let s:filter_file = '' function! s:start_filter() abort @@ -104,25 +110,13 @@ function! s:get_filter_cmd(expr) abort let cmd = [s:grep_exe] + SpaceVim#mapping#search#getFopt(s:grep_exe) return cmd + [a:expr] + [s:filter_file] endfunction +" }}} -function! s:flygrep(expr) abort - call s:MPT._build_prompt() - if a:expr ==# '' - redrawstatus - return - endif - try - call matchdelete(s:hi_id) - catch - endtr - hi def link FlyGrepPattern MoreMsg - let s:hi_id = matchadd('FlyGrepPattern', '\c' . join(split(a:expr), '\|'), 1) - let s:grep_expr = a:expr - let s:grep_timer_id = timer_start(200, function('s:grep_timer'), {'repeat' : 1}) -endfunction - -let s:MPT._handle_fly = function('s:flygrep') +" API: MPT._prompt {{{ +let s:MPT._prompt.mpt = '➭ ' +" }}} +" API: MPT._onclose {{{ function! s:close_buffer() abort if s:grepid != 0 call s:JOB.stop(s:grepid) @@ -132,10 +126,10 @@ function! s:close_buffer() abort endif q endfunction - let s:MPT._onclose = function('s:close_buffer') +" }}} - +" API: MPT._oninputpro {{{ function! s:close_grep_job() abort if s:grepid != 0 call s:JOB.stop(s:grepid) @@ -147,7 +141,9 @@ function! s:close_grep_job() abort endfunction let s:MPT._oninputpro = function('s:close_grep_job') +" }}} +" FlyGrep job handles: {{{ " @vimlint(EVL103, 1, a:data) " @vimlint(EVL103, 1, a:id) " @vimlint(EVL103, 1, a:event) @@ -176,24 +172,12 @@ function! s:grep_exit(id, data, event) abort redrawstatus let s:grepid = 0 endfunction - " @vimlint(EVL103, 0, a:data) " @vimlint(EVL103, 0, a:id) " @vimlint(EVL103, 0, a:event) +"}}} -function! s:get_search_cmd(expr) abort - let cmd = [s:grep_exe] + s:grep_opt - if !empty(s:grep_files) && type(s:grep_files) == 3 - return cmd + [a:expr] + s:grep_files - elseif !empty(s:grep_files) && type(s:grep_files) == 1 - return cmd + [a:expr] + [s:grep_files] - elseif !empty(s:grep_dir) - return cmd + [a:expr] + [s:grep_dir] - else - return cmd + [a:expr] + s:grep_ropt - endif -endfunction - +" FlyGrep Key prompt key bindings: {{{ function! s:next_item() abort if line('.') == line('$') normal! gg @@ -292,8 +276,45 @@ if has('nvim') \ } \ ) endif +" }}} -" statusline api +" Public API: SpaceVim#plugins#flygrep#open(argv) {{{ + +" keys: +" files: files for grep, @buffers means listed buffer. +" dir: specific a directory for grep +function! SpaceVim#plugins#flygrep#open(agrv) abort + noautocmd rightbelow split __flygrep__ + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber + let save_tve = &t_ve + setlocal t_ve= + " setlocal nomodifiable + setf SpaceVimFlyGrep + redraw! + let s:MPT._prompt.begin = get(a:agrv, 'input', '') + let fs = get(a:agrv, 'files', '') + if fs ==# '@buffers' + let s:grep_files = map(s:BUFFER.listed_buffers(), 'bufname(v:val)') + elseif !empty(fs) + let s:grep_files = fs + else + let s:grep_files = '' + endif + let dir = expand(get(a:agrv, 'dir', '')) + if !empty(dir) && isdirectory(dir) + let s:grep_dir = dir + else + let s:grep_dir = '' + endif + let s:grep_exe = get(a:agrv, 'cmd', s:grep_default_exe) + let s:grep_opt = get(a:agrv, 'opt', s:grep_default_opt) + let s:grep_ropt = get(a:agrv, 'ropt', s:grep_default_ropt) + call s:MPT.open() + let &t_ve = save_tve +endfunction +" }}} + +" Plugin API: SpaceVim#plugins#flygrep#lineNr() {{{ function! SpaceVim#plugins#flygrep#lineNr() abort if getline(1) ==# '' return '' @@ -301,3 +322,4 @@ function! SpaceVim#plugins#flygrep#lineNr() abort return line('.') . '/' . line('$') endif endfunction +" }}} diff --git a/docs/_posts/2017-01-26-SpaceVim-release-v0.1.0.md b/docs/_posts/2017-01-26-SpaceVim-release-v0.1.0.md index 25b5f92dd..3f87305c0 100644 --- a/docs/_posts/2017-01-26-SpaceVim-release-v0.1.0.md +++ b/docs/_posts/2017-01-26-SpaceVim-release-v0.1.0.md @@ -3,6 +3,7 @@ title: SpaceVim release v0.1.0 categories: changelog excerpt: "Here you can check what has been done so far." type: NewsArticle +comments: true --- # [Changelogs](https://spacevim.org/development#changelog) > SpaceVim release v0.1.0 diff --git a/docs/_posts/2017-02-11-use-vim-as-a-java-ide.md b/docs/_posts/2017-02-11-use-vim-as-a-java-ide.md index 29277af92..b90d6c61c 100644 --- a/docs/_posts/2017-02-11-use-vim-as-a-java-ide.md +++ b/docs/_posts/2017-02-11-use-vim-as-a-java-ide.md @@ -4,6 +4,7 @@ categories: tutorials excerpt: "I am a vimmer and a java developer. Here are some useful plugins for developing java in vim/neovim." redirect_from: "/2017/02/11/use-vim-as-a-java-ide.html" type: BlogPosting +comments: true --- # [Blogs](https://spacevim.org/community#blogs) > Use Vim as a Java IDE 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 index 0fbad9006..46cdbb350 100644 --- 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 @@ -2,6 +2,7 @@ title: "VIM 8 新特性之旅: 定时器 (timers)" categories: tutorials_cn excerpt: "VIM 8 新特性之旅系列教程 - 定时器, 介绍定时器具体使用方法以及场景" +comments: true --- ## 定时器( timer ) diff --git a/docs/_posts/2017-02-20-install-vim-or-neovim-with-python-support.md b/docs/_posts/2017-02-20-install-vim-or-neovim-with-python-support.md index 4404e5528..b7f4d8596 100644 --- a/docs/_posts/2017-02-20-install-vim-or-neovim-with-python-support.md +++ b/docs/_posts/2017-02-20-install-vim-or-neovim-with-python-support.md @@ -2,6 +2,7 @@ title: "Install vim/neovim with python support" categories: tutorials excerpt: "How to build vim or neovim from source with python enabled?" +comments: true --- diff --git a/docs/_posts/2017-03-30-SpaceVim-release-v0.2.0.md b/docs/_posts/2017-03-30-SpaceVim-release-v0.2.0.md index fab1aa28d..b51179e07 100644 --- a/docs/_posts/2017-03-30-SpaceVim-release-v0.2.0.md +++ b/docs/_posts/2017-03-30-SpaceVim-release-v0.2.0.md @@ -3,6 +3,7 @@ title: SpaceVim release v0.2.0 categories: changelog excerpt: "Mnemonic key bindings in SpaceVim" type: NewsArticle +comments: true --- # [Changelogs](https://spacevim.org/development#changelog) > SpaceVim release v0.2.0 diff --git a/docs/_posts/2017-05-25-mnemonic-key-bindings-navigation.md b/docs/_posts/2017-05-25-mnemonic-key-bindings-navigation.md index cdafc3d5a..a810e519f 100644 --- a/docs/_posts/2017-05-25-mnemonic-key-bindings-navigation.md +++ b/docs/_posts/2017-05-25-mnemonic-key-bindings-navigation.md @@ -3,6 +3,7 @@ title: "Mnemonic key bindings navigation" categories: feature excerpt: "Key bindings are organized using mnemonic prefixes like b for buffer, p for project, s for search, h for help, etc…" image: https://user-images.githubusercontent.com/13142418/31550099-c8173ff8-b062-11e7-967e-6378a9c3b467.gif +comments: true --- # Mnemonic key bindings navigation diff --git a/docs/_posts/2017-05-31-SpaceVim-Newsletter-A-New-Hope.md b/docs/_posts/2017-05-31-SpaceVim-Newsletter-A-New-Hope.md index 5de115535..811cefa69 100644 --- a/docs/_posts/2017-05-31-SpaceVim-Newsletter-A-New-Hope.md +++ b/docs/_posts/2017-05-31-SpaceVim-Newsletter-A-New-Hope.md @@ -2,6 +2,7 @@ title: Newsletter #1 - A New Hope categories: newsletter excerpt: "A new hope: turn vim/neovim to be an IDE for most languages" +comments: true --- # [newsletter](https://spacevim.org/development#newsletter) > A New Hope diff --git a/docs/_posts/2017-05-31-SpaceVim-release-v0.3.0.md b/docs/_posts/2017-05-31-SpaceVim-release-v0.3.0.md index c6bd2e6b0..8964a79f9 100644 --- a/docs/_posts/2017-05-31-SpaceVim-release-v0.3.0.md +++ b/docs/_posts/2017-05-31-SpaceVim-release-v0.3.0.md @@ -3,6 +3,7 @@ title: SpaceVim release v0.3.0 categories: changelog excerpt: "Here you can check what has been done so far." type: NewsArticle +comments: true --- # [Changelogs](https://spacevim.org/development#changelog) > SpaceVim release v0.3.0 diff --git a/docs/_posts/2017-06-27-SpaceVim-release-v0.3.1.md b/docs/_posts/2017-06-27-SpaceVim-release-v0.3.1.md index 4ee4e406b..50830c07c 100644 --- a/docs/_posts/2017-06-27-SpaceVim-release-v0.3.1.md +++ b/docs/_posts/2017-06-27-SpaceVim-release-v0.3.1.md @@ -3,6 +3,7 @@ title: SpaceVim release v0.3.1 categories: changelog excerpt: "Here you can check what has been done so far." type: NewsArticle +comments: true --- # [Changelogs](https://spacevim.org/development#changelog) > SpaceVim release v0.3.1 diff --git a/docs/_posts/2017-08-05-SpaceVim-release-v0.4.0.md b/docs/_posts/2017-08-05-SpaceVim-release-v0.4.0.md index cf836416b..1aace194f 100644 --- a/docs/_posts/2017-08-05-SpaceVim-release-v0.4.0.md +++ b/docs/_posts/2017-08-05-SpaceVim-release-v0.4.0.md @@ -3,6 +3,7 @@ title: SpaceVim release v0.4.0 categories: changelog excerpt: "Here you can check what has been done so far." type: NewsArticle +comments: true --- # [Changelogs](https://spacevim.org/development#changelog) > SpaceVim release v0.4.0 diff --git a/docs/_posts/2017-08-11-Asynchronous-plugin-manager.md b/docs/_posts/2017-08-11-Asynchronous-plugin-manager.md index 7d94ab93c..258d0fe6c 100644 --- a/docs/_posts/2017-08-11-Asynchronous-plugin-manager.md +++ b/docs/_posts/2017-08-11-Asynchronous-plugin-manager.md @@ -3,6 +3,7 @@ title: "Asynchronous plugin manager" categories: feature excerpt: "" image: https://user-images.githubusercontent.com/13142418/34907332-903ae968-f842-11e7-8ac9-07fcc9940a53.gif +comments: true --- diff --git a/docs/_posts/2017-11-04-use-ctrl-in-terminal-and-vim.md b/docs/_posts/2017-11-04-use-ctrl-in-terminal-and-vim.md index 56de826ac..446e9fe9c 100644 --- a/docs/_posts/2017-11-04-use-ctrl-in-terminal-and-vim.md +++ b/docs/_posts/2017-11-04-use-ctrl-in-terminal-and-vim.md @@ -2,6 +2,7 @@ title: "VIM 中 ctrl 相关的组合键的使用" categories: tutorials_cn excerpt: "枚举 Vim 内置的 Ctrl 组合键功能,以及终端下的一些区别" +comments: true --- # Vim 中 ctrl 组合键的使用 diff --git a/docs/_posts/2017-11-06-SpaceVim-release-v0.5.0.md b/docs/_posts/2017-11-06-SpaceVim-release-v0.5.0.md index 93393c969..35e317bd6 100644 --- a/docs/_posts/2017-11-06-SpaceVim-release-v0.5.0.md +++ b/docs/_posts/2017-11-06-SpaceVim-release-v0.5.0.md @@ -3,6 +3,7 @@ title: SpaceVim release v0.5.0 categories: changelog excerpt: "Many new features come out with v0.5.0" type: NewsArticle +comments: true --- # [Changelogs](https://spacevim.org/development#changelog) > SpaceVim release v0.5.0 diff --git a/docs/_posts/2017-11-6-help-description-for-key-bindings.md b/docs/_posts/2017-11-6-help-description-for-key-bindings.md index 84b7ef5db..74340d703 100644 --- a/docs/_posts/2017-11-6-help-description-for-key-bindings.md +++ b/docs/_posts/2017-11-6-help-description-for-key-bindings.md @@ -3,6 +3,7 @@ title: "Help description for key bindings" categories: feature excerpt: "Key bindings are defined with help description, this feature is for getting Help description and jump to the position where the key bindings is defined." image: https://user-images.githubusercontent.com/13142418/34907415-c2cf7e88-f843-11e7-92d3-ef0f9b1b72ae.gif +comments: true --- # Mnemonic key bindings navigation diff --git a/docs/_posts/2017-12-07-async-code-runner-in-SpaceVim.md b/docs/_posts/2017-12-07-async-code-runner-in-SpaceVim.md index cc6b57eaf..e822fe9ae 100644 --- a/docs/_posts/2017-12-07-async-code-runner-in-SpaceVim.md +++ b/docs/_posts/2017-12-07-async-code-runner-in-SpaceVim.md @@ -2,6 +2,7 @@ title: "An async code runner in SpaceVim" categories: tutorials excerpt: "A better way for running code with in vim, more info about the command status, will not move cursor from code buffer." +comments: true --- # [Blogs](https://spacevim.org/community#blogs) > An async code runner in SpaceVim diff --git a/docs/_posts/2017-12-30-SpaceVim-release-v0.6.0.md b/docs/_posts/2017-12-30-SpaceVim-release-v0.6.0.md index 8afc32f88..f73483ff1 100644 --- a/docs/_posts/2017-12-30-SpaceVim-release-v0.6.0.md +++ b/docs/_posts/2017-12-30-SpaceVim-release-v0.6.0.md @@ -4,6 +4,7 @@ categories: changelog excerpt: "Many new features come out with v0.6.0" type: NewsArticle image: https://user-images.githubusercontent.com/13142418/33793078-3446cb6e-dc76-11e7-9998-376a355557a4.png +comments: true --- # [Changelogs](https://spacevim.org/development#changelog) > SpaceVim release v0.6.0 diff --git a/docs/_posts/2018-01-01-SpaceVim-Newsletter-Never-lost-never-give-up.md b/docs/_posts/2018-01-01-SpaceVim-Newsletter-Never-lost-never-give-up.md index d1d204f61..7ac4db80e 100644 --- a/docs/_posts/2018-01-01-SpaceVim-Newsletter-Never-lost-never-give-up.md +++ b/docs/_posts/2018-01-01-SpaceVim-Newsletter-Never-lost-never-give-up.md @@ -3,6 +3,7 @@ title: "Newsletter #2 - Never lost, Never give up" categories: newsletter excerpt: "We know exactly what is the purpose of SpaceVim, and we keep trying to get it, never get lost, never give up..." image: https://user-images.githubusercontent.com/13142418/34612367-18fdf2d6-f1ef-11e7-885e-5e82613c1444.png +comments: true --- # [newsletter](https://spacevim.org/development#newsletter) > Never lost, Never give up