1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 02:30:03 +08:00

Merge dev

This commit is contained in:
wsdjeg 2017-07-17 07:47:59 +08:00
commit 6afd8ce554
37 changed files with 2095 additions and 92 deletions

View File

@ -0,0 +1,78 @@
function! s:generate_content() abort
let content = ['## Achievements', '']
let content += s:issues_ac()
let content += s:stargazers_ac()
return content
endfunction
function! s:find_position() abort
let start = search('^<!-- SpaceVim Achievements start -->$','bwnc')
let end = search('^<!-- SpaceVim Achievements end -->$','bnwc')
return sort([start, end])
endfunction
function! s:issues_ac() abort
let line = ['### issues']
call add(line, '')
call add(line, 'Achievements | Account')
call add(line, '----- | -----')
let acc = [100, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]
for id in acc
let issue = github#api#issues#Get_issue('SpaceVim', 'SpaceVim', id)
if has_key(issue, 'id')
let is_pr = has_key(issue, 'pull_request')
call add(line, '[' . id . 'th issue(' .
\ (is_pr ? 'PR' : 'issue') .
\ ')](https://github.com/SpaceVim/SpaceVim/issues/' . id . ') | [' . issue.user.login
\ . '](https://github.com/' . issue.user.login . ')'
\ )
else
break
endif
endfor
if line[-1] != ''
let line += ['']
endif
return line
endfunction
function! s:stargazers_ac() abort
let line = ['### Stars, forks and watchers']
call add(line, '')
call add(line, 'Achievements | Account')
call add(line, '----- | -----')
let stc = [1, 100, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]
for id in stc
if id == 1
let user = github#api#activity#List_stargazers('SpaceVim','SpaceVim')[0]
call add(line, 'First stargazers | [' . user.login . '](https://github.com/' . user.login . ')')
else
let index = id % 30
if index == 0
let page = id/30
let index = 30
else
let page = id/30 + 1
endif
let users = github#api#activity#List_stargazers('SpaceVim','SpaceVim', page)
if type(users) == type([]) && len(users) >= index
let user = users[index - 1]
call add(line, id . 'th stargazers | [' . user.login . '](https://github.com/' . user.login . ')')
endif
endif
endfor
if line[-1] != ''
let line += ['']
endif
return line
endfunction
function! SpaceVim#dev#Achievements#update()
let [start, end] = s:find_position()
if start != 0 && end != 0
if end - start > 1
exe (start + 1) . ',' . (end - 1) . 'delete'
endif
call append(start, s:generate_content())
endif
endfunction

View File

@ -123,20 +123,20 @@ let g:spacevim_max_column = 80
let g:spacevim_plugin_bundle_dir = '~/.cache/vimfiles/'
" set SpaceVim colorscheme
let g:spacevim_colorscheme = 'jellybeans'
let g:spacevim_colorscheme = 'gruvbox'
" Set plugin manager, you want to use, default is dein.vim
let g:spacevim_plugin_manager = 'dein' " neobundle or dein or vim-plug
" use space as `<Leader>`
let mapleader = "\<space>"
" Set windows shortcut leader [Window], default is `s`
let g:spacevim_windows_leader = 's'
" Set unite work flow shortcut leader [Unite], default is `f`
let g:spacevim_unite_leader = 'f'
" Set Denite work flow shortcut leader [Denite], default is `F`
let g:spacevim_denite_leader = 'F'
" By default, language specific plugins are not loaded. This can be changed
" with the following, then the plugins for go development will be loaded.
call SpaceVim#layers#load('lang#go')
@ -193,11 +193,6 @@ curl -sLf https://spacevim.org/install.sh | bash
**After SpaceVim is installed, launch `vim` and SpaceVim will automatically install plugins**
Once plugins start installing, at the bottom of the vim window, you will see
`[dein] Install started: (YYYY/MM/DD HH:MM:SS)`
Please wait for all the plugins to complete installing before using vim. Once the plugin installation completes, you will see
`[dein] Done: (YYYY/MM/DD HH:MM:SS) `. At this point you can start using vim.
SpaceVim required Vim7.4 above or neovim, here is the installation of neovim/vim with python support:

View File

@ -416,6 +416,7 @@ let g:spacevim_leader_guide_submode_mappings = {'<C-C>': "win_close"}
command -nargs=1 LeaderGuide call SpaceVim#mapping#guide#start_by_prefix('0', <args>)
command -range -nargs=1 LeaderGuideVisual call SpaceVim#mapping#guide#start_by_prefix('1', <args>)
function! SpaceVim#loadCustomConfig() abort
let custom_confs_old = SpaceVim#util#globpath(getcwd(), '.local.vim')

View File

@ -8,15 +8,43 @@ function! SpaceVim#api#data#list#get() abort
\ 'char_range' : '',
\ 'has' : '',
\ 'has_index' : '',
\ 'listpart' : '',
\ },
\ "function('s:' . v:key)"
\ )
endfunction
""
" @section data#list, api-data-list
" @parentsection api
" pop({list})
"
" Removes the last element from {list} and returns the element,
" as if the {list} is a stack.
"
" push({list})
"
" Appends {val} to the end of {list} and returns the list itself,
" as if the {list} is a stack.
"
" listpart({list}, {start}[, {len}])
"
" The result is a List, which is part of {list}, starting from
" index {start}, with the length {len}
function! s:pop(list) abort
return remove(a:list, -1)
endfunction
function! s:listpart(list, start, ...)
let idx = range(a:start, a:start + get(a:000, 0, 0))
let rst = []
for i in idx
call add(rst, get(a:list, i))
endfor
return rst
endfunction
function! s:push(list, val) abort
call add(a:list, a:val)
return a:list

View File

@ -63,6 +63,15 @@ endfunction
let s:file['trim_end'] = function('s:trim_end')
function! s:string2chars(str) abort
let chars = []
for i in range(len(a:str))
call add(chars, a:str[i : i])
endfor
return chars
endfunction
let s:file['string2chars'] = function('s:string2chars')
function! SpaceVim#api#data#string#get() abort
return deepcopy(s:file)
endfunction

View File

@ -21,6 +21,7 @@ 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')
@ -45,6 +46,7 @@ function! s:self.warp(argv, opts) abort
\ '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,

View File

@ -0,0 +1,81 @@
let s:self = {}
let s:NUMBER = SpaceVim#api#import('data#number')
let s:STRING = SpaceVim#api#import('data#string')
function! s:self.generate_simple(len) abort
let temp = s:STRING.string2chars('abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ')
let ps = []
" random(0,len_temp)
let i = 0
while i < str2nr(a:len)
call add(ps, temp[s:NUMBER.random(0, len(temp))])
let i += 1
endwhile
return join(ps, '')
endfunction
function! s:self.generate_strong(len) abort
let temp = s:STRING.string2chars('abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ_@!.^%,&-')
let ps = []
" random(0,len_temp)
let i = 0
while i < str2nr(a:len)
call add(ps, temp[s:NUMBER.random(0, len(temp))])
let i += 1
endwhile
return join(ps, '')
endfunction
function! s:self.generate_paranoid(len) abort
let temp = s:STRING.string2chars('abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_-+=/?,.><[]{}~')
let ps = []
" random(0,len_temp)
let i = 0
while i < str2nr(a:len)
call add(ps, temp[s:NUMBER.random(0, len(temp))])
let i += 1
endwhile
return join(ps, '')
endfunction
function! s:self.generate_numeric(len) abort
let temp = s:STRING.string2chars('0123456789')
let ps = []
" random(0,len_temp)
let i = 0
while i < str2nr(a:len)
call add(ps, temp[s:NUMBER.random(0, len(temp))])
let i += 1
endwhile
return join(ps, '')
endfunction
function! s:self.generate_phonetic(len) abort
let temp_A = s:STRING.string2chars('eyuioa')
let temp_B = s:STRING.string2chars('wrtpsdfghjkzxcvbnm')
let temp_N = s:STRING.string2chars('123456789')
let type = 1
let ps = []
" random(0,len_temp)
let i = 0
while i < str2nr(a:len)
if type == 1
call add(ps, temp_A[s:NUMBER.random(0, len(temp_A))])
let type = 2
elseif type == 2
call add(ps, temp_B[s:NUMBER.random(0, len(temp_B))])
let type = 3
elseif type == 3
call add(ps, temp_N[s:NUMBER.random(0, len(temp_N))])
let type = 1
endif
let i += 1
endwhile
return join(ps, '')
endfunction
function! SpaceVim#api#password#get() abort
return deepcopy(s:self)
endfunction

View File

@ -0,0 +1,147 @@
""
" @section prompt, api-prompt
" @parentsection api
" open()
"
" Create a cmdline prompt, use while loop to get the input from user. The
" default mapping for prompt is:
" >
" <Bs> remove last character
" <C-w> remove the Word before the cursor
" <C-u> remove the Line before the cursor
" <C-k> remove the Line after the cursor
" <C-a> / <Home> Go to the beginning of the line
" <C-e> / <End> Go to the end of the line
" <
let s:self = {}
let s:self._keys = {
\ 'close' : "\<Esc>",
\ 'cursor_back' : '<Left>',
\ 'cursor_forword' : '<Right>',
\ }
let s:self._prompt = {
\ 'mpt' : '==>',
\ 'begin' : '',
\ 'cursor' : '',
\ 'end' : '',
\ }
let s:self._function_key = {}
let s:self._quit = 1
let s:self._handle_fly = ''
let s:self._onclose = ''
let s:self._oninputpro = ''
func! s:self.open() abort
let self._quit = 0
let save_redraw = &lazyredraw
set nolazyredraw
call self._build_prompt()
call self._handle_input()
let &lazyredraw = save_redraw
endf
function! s:self._getchar(...) abort
let ret = call('getchar', a:000)
return (type(ret) == type(0) ? nr2char(ret) : ret)
endfunction
func! s:self._handle_input() abort
while self._quit == 0
let char = self._getchar()
if has_key(self._function_key, char)
call call(self._function_key[char], [])
continue
endif
if char ==# "\<Right>" || char == 6
let self._prompt.begin = self._prompt.begin . self._prompt.cursor
let self._prompt.cursor = matchstr(self._prompt.end, '^.')
let self._prompt.end = substitute(self._prompt.end, '^.', '', 'g')
call self._build_prompt()
continue
elseif char ==# "\<Left>" || char == 2
if self._prompt.begin !=# ''
let self._prompt.end = self._prompt.cursor . self._prompt.end
let self._prompt.cursor = matchstr(self._prompt.begin, '.$')
let self._prompt.begin = substitute(self._prompt.begin, '.$', '', 'g')
call self._build_prompt()
endif
continue
elseif char ==# "\<C-w>"
let self._prompt.begin = substitute(self._prompt.begin,'[^\ .*]\+\s*$','','g')
call self._build_prompt()
elseif char ==# "\<C-a>" || char ==# "\<Home>"
let self._prompt.end = substitute(self._prompt.begin . self._prompt.cursor . self._prompt.end, '^.', '', 'g')
let self._prompt.cursor = matchstr(self._prompt.begin, '^.')
let self._prompt.begin = ''
call self._build_prompt()
continue
elseif char ==# "\<C-e>" || char ==# "\<End>"
let self._prompt.begin = self._prompt.begin . self._prompt.cursor . self._prompt.end
let self._prompt.cursor = ''
let self._prompt.end = ''
call self._build_prompt()
continue
elseif char ==# "\<C-u>"
let self._prompt.begin = ''
call self._build_prompt()
elseif char ==# "\<C-k>"
let self._prompt.cursor = ''
let self._prompt.end = ''
call self._build_prompt()
elseif char ==# "\<bs>"
let self._prompt.begin = substitute(self._prompt.begin,'.$','','g')
call self._build_prompt()
elseif char == self._keys.close
call self.close()
break
elseif char ==# "\<FocusLost>" || char ==# "\<FocusGained>" || char2nr(char) == 128
continue
else
let self._prompt.begin .= char
call self._build_prompt()
endif
if self._oninputpro !=# ''
call call(self._oninputpro, [])
endif
if self._handle_fly !=# ''
call call(self._handle_fly, [self._prompt.begin . self._prompt.cursor . self._prompt.end])
endif
endwhile
endf
func! s:self._build_prompt() abort
redraw
echohl Comment | echon self._prompt.mpt
echohl None | echon self._prompt.begin
echohl Wildmenu | echon self._prompt.cursor
echohl None | echon self._prompt.end
endf
function! s:self._clear_prompt() abort
let self._prompt = {
\ 'mpt' : self._prompt.mpt,
\ 'begin' : '',
\ 'cursor' : '',
\ 'end' : '',
\ }
endfunction
function! s:self.close() abort
if self._onclose !=# ''
call call(self._onclose, [])
endif
call self._clear_prompt()
normal! :
let self._quit = 1
endfunction
function! SpaceVim#api#prompt#get() abort
return deepcopy(s:self)
endfunction

View File

@ -3,7 +3,16 @@ let s:self = {}
function! s:self.group2dict(name) abort
let id = index(map(range(1999), "synIDattr(v:val, 'name')"), a:name)
if id == -1
return {}
return {
\ 'name' : '',
\ 'ctermbg' : '',
\ 'ctermfg' : '',
\ 'bold' : '',
\ 'italic' : '',
\ 'underline' : '',
\ 'guibg' : '',
\ 'guifg' : '',
\ }
endif
let rst = {
\ 'name' : synIDattr(id, 'name'),
@ -32,35 +41,35 @@ function! s:self.unite(base, target, part) abort
endfunction
function! s:self.hi(info) abort
if empty(a:info)
if empty(a:info) || get(a:info, 'name', '') ==# ''
return
endif
let cmd = 'hi! ' . a:info.name
if !empty(a:info.ctermbg)
let cmd .= ' ctermbg=' . a:info.ctermbg
endif
if !empty(a:info.ctermfg)
let cmd .= ' ctermfg=' . a:info.ctermfg
endif
if !empty(a:info.guibg)
let cmd .= ' guibg=' . a:info.guibg
endif
if !empty(a:info.guifg)
let cmd .= ' guifg=' . a:info.guifg
endif
let style = []
for sty in ['hold', 'italic', 'underline']
if get(a:info, sty, '') ==# '1'
call add(style, sty)
endif
endfor
if !empty(style)
let cmd .= ' gui=' . join(style, ',') . ' cterm=' . join(style, ',')
endif
try
exe cmd
catch
endtry
let cmd = 'hi! ' . a:info.name
if !empty(a:info.ctermbg)
let cmd .= ' ctermbg=' . a:info.ctermbg
endif
if !empty(a:info.ctermfg)
let cmd .= ' ctermfg=' . a:info.ctermfg
endif
if !empty(a:info.guibg)
let cmd .= ' guibg=' . a:info.guibg
endif
if !empty(a:info.guifg)
let cmd .= ' guifg=' . a:info.guifg
endif
let style = []
for sty in ['hold', 'italic', 'underline']
if get(a:info, sty, '') ==# '1'
call add(style, sty)
endif
endfor
if !empty(style)
let cmd .= ' gui=' . join(style, ',') . ' cterm=' . join(style, ',')
endif
try
exe cmd
catch
endtry
endfunction
function! s:self.hide_in_normal(name) abort
@ -68,7 +77,7 @@ function! s:self.hide_in_normal(name) abort
if empty(group)
return
endif
if &termguicolors || has('gui_running')
if (exists('+termguicolors') && &termguicolors ) || has('gui_running')
let bg = self.group2dict('Normal').guibg
if empty(bg)
return

View File

@ -0,0 +1,53 @@
let s:save_cpo = &cpo
set cpo&vim
let s:self = {}
let s:XML = SpaceVim#api#import('web#xml')
let s:HTTP = SpaceVim#api#import('web#http')
function! s:self.decodeEntityReference(str) abort
let str = a:str
let str = substitute(str, '&gt;', '>', 'g')
let str = substitute(str, '&lt;', '<', 'g')
let str = substitute(str, '&quot;', '"', 'g')
let str = substitute(str, '&apos;', "'", 'g')
let str = substitute(str, '&nbsp;', ' ', 'g')
let str = substitute(str, '&yen;', '\&#65509;', 'g')
let str = substitute(str, '&#\(\d\+\);', '\=s:nr2enc_char(submatch(1))', 'g')
let str = substitute(str, '&amp;', '\&', 'g')
let str = substitute(str, '&raquo;', '>', 'g')
let str = substitute(str, '&laquo;', '<', 'g')
return str
endfunction
function! s:self.encodeEntityReference(str) abort
let str = a:str
let str = substitute(str, '&', '\&amp;', 'g')
let str = substitute(str, '>', '\&gt;', 'g')
let str = substitute(str, '<', '\&lt;', 'g')
let str = substitute(str, "\n", '\&#x0d;', 'g')
let str = substitute(str, '"', '\&quot;', 'g')
let str = substitute(str, "'", '\&apos;', 'g')
let str = substitute(str, ' ', '\&nbsp;', 'g')
return str
endfunction
function! s:self.parse(html) abort
let html = substitute(a:html, '<\(area\|base\|basefont\|br\|nobr\|col\|frame\|hr\|img\|input\|isindex\|link\|meta\|param\|embed\|keygen\|command\)\([^>]*[^/]\|\)>', '<\1\2/>', 'g')
return s:XML.parse(html)
endfunction
function! s:self.parseFile(file) abort
return self.parse(join(readfile(a:file), "\n"))
endfunction
function! s:self.parseURL(url) abort
return self.parse(s:HTTP.get(a:url).content)
endfunction
function! SpaceVim#api#web#html#get() abort
return deepcopy(s:self)
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@ -0,0 +1,478 @@
let s:save_cpo = &cpo
set cpo&vim
let s:self = {}
let s:system = function(get(g:, 'webapi#system_function', 'system'))
function! s:nr2byte(nr) abort
if a:nr < 0x80
return nr2char(a:nr)
elseif a:nr < 0x800
return nr2char(a:nr/64+192).nr2char(a:nr%64+128)
elseif a:nr < 0x10000
return nr2char(a:nr/4096%16+224).nr2char(a:nr/64%64+128).nr2char(a:nr%64+128)
elseif a:nr < 0x200000
return nr2char(a:nr/262144%16+240).nr2char(a:nr/4096/16+128).nr2char(a:nr/64%64+128).nr2char(a:nr%64+128)
elseif a:nr < 0x4000000
return nr2char(a:nr/16777216%16+248).nr2char(a:nr/262144%16+128).nr2char(a:nr/4096/16+128).nr2char(a:nr/64%64+128).nr2char(a:nr%64+128)
else
return nr2char(a:nr/1073741824%16+252).nr2char(a:nr/16777216%16+128).nr2char(a:nr/262144%16+128).nr2char(a:nr/4096/16+128).nr2char(a:nr/64%64+128).nr2char(a:nr%64+128)
endif
endfunction
function! s:nr2enc_char(charcode) abort
if &encoding ==# 'utf-8'
return nr2char(a:charcode)
endif
let char = s:nr2byte(a:charcode)
if strlen(char) > 1
let char = strtrans(iconv(char, 'utf-8', &encoding))
endif
return char
endfunction
function! s:nr2hex(nr) abort
let n = a:nr
let r = ''
while n
let r = '0123456789ABCDEF'[n % 16] . r
let n = n / 16
endwhile
return r
endfunction
function! s:urlencode_char(c, ...) abort
let is_binary = get(a:000, 1)
let c = a:c
if !is_binary
let c = iconv(a:c, &encoding, 'utf-8')
if c ==# ''
let c = a:c
endif
endif
let s = ''
for i in range(strlen(c))
let s .= printf('%%%02X', char2nr(c[i]))
endfor
return s
endfunction
function! s:self.decodeURI(str) abort
let ret = a:str
let ret = substitute(ret, '+', ' ', 'g')
let ret = substitute(ret, '%\(\x\x\)', '\=printf("%c", str2nr(submatch(1), 16))', 'g')
return ret
endfunction
function! s:self.escape(str) abort
return substitute(a:str, '[^a-zA-Z0-9_.~/-]', '\=s:urlencode_char(submatch(0))', 'g')
endfunction
function! s:self.encodeURI(items, ...) abort
let is_binary = get(a:000, 1)
let ret = ''
if type(a:items) == 4
for key in sort(keys(a:items))
if strlen(ret) | let ret .= '&' | endif
let ret .= key . '=' . s:self.encodeURI(a:items[key])
endfor
elseif type(a:items) == 3
for item in sort(a:items)
if strlen(ret) | let ret .= '&' | endif
let ret .= item
endfor
else
let ret = substitute(a:items, '[^a-zA-Z0-9_.~-]', '\=s:urlencode_char(submatch(0), is_binary)', 'g')
endif
return ret
endfunction
function! s:self.encodeURIComponent(items) abort
let ret = ''
if type(a:items) == 4
for key in sort(keys(a:items))
if strlen(ret) | let ret .= '&' | endif
let ret .= key . '=' . s:self.encodeURIComponent(a:items[key])
endfor
elseif type(a:items) == 3
for item in sort(a:items)
if strlen(ret) | let ret .= '&' | endif
let ret .= item
endfor
else
let items = iconv(a:items, &enc, 'utf-8')
let len = strlen(items)
let i = 0
while i < len
let ch = items[i]
if ch =~# '[0-9A-Za-z-._~!''()*]'
let ret .= ch
elseif ch ==# ' '
let ret .= '+'
else
let ret .= '%' . substitute('0' . s:nr2hex(char2nr(ch)), '^.*\(..\)$', '\1', '')
endif
let i = i + 1
endwhile
endif
return ret
endfunction
function! s:self.get(url, ...) abort
let getdata = a:0 > 0 ? a:000[0] : {}
let headdata = a:0 > 1 ? a:000[1] : {}
let follow = a:0 > 2 ? a:000[2] : 1
let url = a:url
let getdatastr = self.encodeURI(getdata)
if strlen(getdatastr)
let url .= '?' . getdatastr
endif
if executable('curl')
let command = printf('curl -q %s -s -k -i', follow ? '-L' : '')
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' -H ' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' -H ' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' ' . quote . url . quote
let res = s:system(command)
elseif executable('wget')
let command = printf('wget -O- --save-headers --server-response -q %s', follow ? '-L' : '')
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' --header=' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' --header=' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' ' . quote . url . quote
let res = s:system(command)
else
throw 'require `curl` or `wget` command'
endif
if follow != 0
let mx = 'HTTP/\%(1\.[01]\|2\%(\.0\)\?\)'
while res =~# '^' . mx . ' 3' || res =~# '^' . mx . ' [0-9]\{3} .\+\n\r\?\n' . mx . ' .\+'
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let res = strpart(res, pos+4)
else
let pos = stridx(res, "\n\n")
let res = strpart(res, pos+2)
endif
endwhile
endif
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let content = strpart(res, pos+4)
else
let pos = stridx(res, "\n\n")
let content = strpart(res, pos+2)
endif
let header = split(res[:pos-1], '\r\?\n')
let matched = matchlist(get(header, 0), '^HTTP/\%(1\.[01]\|2\%(\.0\)\?\)\s\+\(\d\+\)\s*\(.*\)')
if !empty(matched)
let [status, message] = matched[1 : 2]
call remove(header, 0)
else
if v:shell_error || len(matched)
let [status, message] = ['500', "Couldn't connect to host"]
else
let [status, message] = ['200', 'OK']
endif
endif
return {
\ 'status' : status,
\ 'message' : message,
\ 'header' : header,
\ 'content' : content
\}
endfunction
function! s:self.post(url, ...) abort
let postdata = a:0 > 0 ? a:000[0] : {}
let headdata = a:0 > 1 ? a:000[1] : {}
let method = a:0 > 2 ? a:000[2] : 'POST'
let follow = a:0 > 3 ? a:000[3] : 1
let url = a:url
if type(postdata) == 4
let postdatastr = self.encodeURI(postdata)
else
let postdatastr = postdata
endif
let file = tempname()
if executable('curl')
let command = printf('curl -q %s -s -k -i -X %s', (follow ? '-L' : ''), len(method) ? method : 'POST')
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' -H ' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' -H ' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' ' . quote . url . quote
call writefile(split(postdatastr, "\n"), file, 'b')
let res = s:system(command . ' --data-binary @' . quote.file.quote)
elseif executable('wget')
let command = printf('wget -O- --save-headers --server-response -q %s', follow ? '-L' : '')
let headdata['X-HTTP-Method-Override'] = method
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' --header=' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' --header=' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' '.quote.url.quote
call writefile(split(postdatastr, "\n"), file, 'b')
let res = s:system(command . ' --post-data @' . quote.file.quote)
else
throw 'require `curl` or `wget` command'
endif
call delete(file)
if follow != 0
let mx = 'HTTP/\%(1\.[01]\|2\%(\.0\)\?\)'
while res =~# '^' . mx . ' 3' || res =~# '^' . mx . ' [0-9]\{3} .\+\n\r\?\n' . mx . ' .\+'
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let res = strpart(res, pos+4)
else
let pos = stridx(res, "\n\n")
let res = strpart(res, pos+2)
endif
endwhile
endif
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let content = strpart(res, pos+4)
else
let pos = stridx(res, "\n\n")
let content = strpart(res, pos+2)
endif
let header = split(res[:pos-1], '\r\?\n')
let matched = matchlist(get(header, 0), '^HTTP/\%(1\.[01]\|2\%(\.0\)\?\)\s\+\(\d\+\)\s*\(.*\)')
if !empty(matched)
let [status, message] = matched[1 : 2]
call remove(header, 0)
else
if v:shell_error || len(matched)
let [status, message] = ['500', "Couldn't connect to host"]
else
let [status, message] = ['200', 'OK']
endif
endif
return {
\ 'status' : status,
\ 'message' : message,
\ 'header' : header,
\ 'content' : content
\}
endfunction
function! s:self.send(req) abort
let postdata = get(a:req, 'data', '')
let method = get(a:req, 'method', postdata ==# '' ? 'GET': 'POST')
let headdata = get(a:req, 'header', {})
let follow = get(a:req, 'follow', 1)
let url = get(a:req, 'url', '')
if type(postdata) == 4
let postdatastr = self.encodeURI(postdata)
else
let postdatastr = postdata
endif
if empty(postdatastr)
let file = ''
else
let file = tempname()
endif
if executable('curl')
let command = printf('curl -q %s -s -k -i -X %s', (follow ? '-L' : ''), len(method) ? method : 'POST')
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' -H ' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' -H ' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' ' . quote . url . quote
if file ==# ''
let res = s:system(command)
else
call writefile(split(postdatastr, "\n"), file, 'b')
let res = s:system(command . ' --data-binary @' . quote.file.quote)
call delete(file)
endif
elseif executable('wget')
let command = printf('wget -O- --save-headers --server-response -q %s', follow ? '-L' : '')
let headdata['X-HTTP-Method-Override'] = method
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' --header=' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' --header=' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' '.quote.url.quote
if file ==# ''
let res = s:system(command)
else
call writefile(split(postdatastr, "\n"), file, 'b')
let res = s:system(command . ' --post-data @' . quote.file.quote)
call delete(file)
endif
else
throw 'require `curl` or `wget` command'
endif
if follow != 0
let mx = 'HTTP/\%(1\.[01]\|2\%(\.0\)\?\)'
while res =~# '^' . mx . ' 3' || res =~# '^' . mx . ' [0-9]\{3} .\+\n\r\?\n' . mx . ' .\+'
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let res = strpart(res, pos+4)
else
let pos = stridx(res, "\n\n")
let res = strpart(res, pos+2)
endif
endwhile
endif
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let content = strpart(res, pos+4)
else
let pos = stridx(res, "\n\n")
let content = strpart(res, pos+2)
endif
let header = split(res[:pos-1], '\r\?\n')
let matched = matchlist(get(header, 0), '^HTTP/\%(1\.[01]\|2\%(\.0\)\?\)\s\+\(\d\+\)\s*\(.*\)')
if !empty(matched)
let [status, message] = matched[1 : 2]
call remove(header, 0)
else
if v:shell_error || len(matched)
let [status, message] = ['500', "Couldn't connect to host"]
else
let [status, message] = ['200', 'OK']
endif
endif
return {
\ 'status' : status,
\ 'message' : message,
\ 'header' : header,
\ 'content' : content
\}
endfunction
function! s:self.stream(req) abort
let postdata = get(a:req, 'data', '')
let method = get(a:req, 'method', postdata ==# '' ? 'GET': 'POST')
let headdata = get(a:req, 'header', {})
let follow = get(a:req, 'follow', 1)
let url = get(a:req, 'url', '')
let mode = get(a:req, 'mode', 'nl')
if type(postdata) == 4
let postdatastr = self.encodeURI(postdata)
else
let postdatastr = postdata
endif
if empty(postdatastr)
let file = ''
else
let file = tempname()
endif
if executable('curl')
let command = printf('curl -q %s -s -k -X %s', (follow ? '-L' : ''), len(method) ? method : 'POST')
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' -H ' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' -H ' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' '.quote . url . quote
if file ==# ''
let job = job_start(command)
else
call writefile(split(postdatastr, "\n"), file, 'b')
let job = job_start(command . ' --data-binary @' . quote.file.quote)
call delete(file)
endif
elseif executable('wget')
let command = printf('wget -O- -q %s', follow ? '-L' : '')
let headdata['X-HTTP-Method-Override'] = method
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' --header=' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' --header=' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' '.quote.url.quote
if file ==# ''
let job = job_start(command)
else
call writefile(split(postdatastr, "\n"), file, 'b')
let job = job_start(command . ' --post-data @' . quote.file.quote)
call delete(file)
endif
else
throw 'require `curl` or `wget` command'
endif
call job_setoptions(job,
\{
\ 'exit_cb': function('webapi#http#exit_cb', [a:req]),
\ 'stoponexit': 'kill',
\})
let a:req['job'] = job
let channel = job_getchannel(job)
call ch_setoptions(channel,
\{
\ 'out_cb': function('webapi#http#out_cb', [a:req]),
\ 'mode': mode,
\})
let a:req['channel'] = channel
let a:req['file'] = file
endfunction
" @vimlint(EVL103, 1, a:job)
function! s:self.exit_cb(req, job, code) abort
let file = get(a:req, 'file')
if file !=# ''
call delete(file)
endif
let fexit_cb = get(a:req, 'exit_cb', v:none)
if fexit_cb != v:none
call call(fexit_cb, [a:code])
endif
endfunction
" @vimlint(EVL103, 0, a:job)
" @vimlint(EVL103, 1, a:ch)
function! s:self.out_cb(req, ch, data) abort
let fout_cb = get(a:req, 'out_cb', v:none)
if fout_cb != v:none
call Fout_cb(a:data)
call call(fout_cb, [a:data])
endif
endfunction
" @vimlint(EVL103, 0, a:ch)
function! SpaceVim#api#web#http#get() abort
return deepcopy(s:self)
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et:

View File

@ -0,0 +1,328 @@
let s:save_cpo = &cpo
set cpo&vim
let s:self = {}
let s:HTTP = SpaceVim#api#import('web#http')
let s:template = { 'name': '', 'attr': {}, 'child': [] }
function! s:nr2byte(nr) abort
if a:nr < 0x80
return nr2char(a:nr)
elseif a:nr < 0x800
return nr2char(a:nr/64+192).nr2char(a:nr%64+128)
else
return nr2char(a:nr/4096%16+224).nr2char(a:nr/64%64+128).nr2char(a:nr%64+128)
endif
endfunction
function! s:nr2enc_char(charcode) abort
if &encoding ==# 'utf-8'
return nr2char(a:charcode)
endif
let char = s:nr2byte(a:charcode)
if strlen(char) > 1
let char = strtrans(iconv(char, 'utf-8', &encoding))
endif
return char
endfunction
function! s:nr2hex(nr) abort
let n = a:nr
let r = ''
while n
let r = '0123456789ABCDEF'[n % 16] . r
let n = n / 16
endwhile
return r
endfunction
function! s:decodeEntityReference(str, ...) abort
let str = a:str
let str = substitute(str, '&gt;', '>', 'g')
let str = substitute(str, '&lt;', '<', 'g')
if get(g:, 'webapi#xml#decodeAsHTML', 0)
let str = substitute(str, '&quot;', '"', 'g')
let str = substitute(str, '&apos;', "'", 'g')
let str = substitute(str, '&nbsp;', ' ', 'g')
let str = substitute(str, '&yen;', '\&#65509;', 'g')
endif
let str = substitute(str, '&#x\([0-9a-fA-F]\+\);', '\=s:nr2enc_char("0x".submatch(1))', 'g')
let str = substitute(str, '&#\(\d\+\);', '\=s:nr2enc_char(submatch(1))', 'g')
let str = substitute(str, '&amp;', '\&', 'g')
return str
endfunction
function! s:encodeEntityReference(str) abort
let str = a:str
let str = substitute(str, '&', '\&amp;', 'g')
let str = substitute(str, '>', '\&gt;', 'g')
let str = substitute(str, '<', '\&lt;', 'g')
let str = substitute(str, '"', '\&#34;', 'g')
"let str = substitute(str, "\n", '\&#x0d;', 'g')
"let str = substitute(str, '"', '&quot;', 'g')
"let str = substitute(str, "'", '&apos;', 'g')
"let str = substitute(str, ' ', '&nbsp;', 'g')
return str
endfunction
function! s:matchNode(node, cond) abort
if type(a:cond) == 1 && a:node.name == a:cond
return 1
endif
if type(a:cond) == 2
return a:cond(a:node)
endif
if type(a:cond) == 3
let ret = 1
for l:R in a:cond
if !s:matchNode(a:node, l:R) | let ret = 0 | endif
unlet l:R
endfor
return ret
endif
if type(a:cond) == 4
for k in keys(a:cond)
if has_key(a:node.attr, k) && a:node.attr[k] == a:cond[k] | return 1 | endif
endfor
endif
return 0
endfunction
function! s:template.childNode(...) dict abort
for c in self.child
if type(c) == 4 && s:matchNode(c, a:000)
return c
endif
unlet c
endfor
return {}
endfunction
function! s:template.childNodes(...) dict abort
let ret = []
for c in self.child
if type(c) == 4 && s:matchNode(c, a:000)
let ret += [c]
endif
unlet c
endfor
return ret
endfunction
function! s:template.value(...) dict abort
if a:0
let self.child = a:000
return
endif
let ret = ''
for c in self.child
if type(c) <= 1 || type(c) == 5
let ret .= c
elseif type(c) == 4
let ret .= c.value()
endif
unlet c
endfor
return ret
endfunction
function! s:template.find(...) dict abort
for c in self.child
if type(c) == 4
if s:matchNode(c, a:000)
return c
endif
unlet! ret
let ret = c.find(a:000)
if !empty(ret)
return ret
endif
endif
unlet c
endfor
return {}
endfunction
function! s:template.findAll(...) dict abort
let ret = []
for c in self.child
if type(c) == 4
if s:matchNode(c, a:000)
call add(ret, c)
endif
let ret += c.findAll(a:000)
endif
unlet c
endfor
return ret
endfunction
function! s:template.toString() dict abort
let xml = '<' . self.name
for attr in keys(self.attr)
let xml .= ' ' . attr . '="' . s:encodeEntityReference(self.attr[attr]) . '"'
endfor
if len(self.child)
let xml .= '>'
for c in self.child
if type(c) == 4
let xml .= c.toString()
elseif type(c) > 1
let xml .= s:encodeEntityReference(string(c))
else
let xml .= s:encodeEntityReference(c)
endif
unlet c
endfor
let xml .= '</' . self.name . '>'
else
let xml .= ' />'
endif
return xml
endfunction
function! s:self.createElement(name) abort
let node = deepcopy(s:template)
let node.name = a:name
return node
endfunction
" @vimlint(EVL102, 1, l:content)
function! s:parse_tree(ctx, top) abort
let node = a:top
let stack = [a:top]
" content accumulates the text only tags
let content = ''
let append_content_to_parent = 'if len(stack) && content != "" | call add(stack[-1].child, content) | let content ="" | endif'
let mx = '^\s*\(<?xml[^>]\+>\)'
if a:ctx['xml'] =~ mx
let match = matchstr(a:ctx['xml'], mx)
let a:ctx['xml'] = a:ctx['xml'][stridx(a:ctx['xml'], match) + len(match):]
let mx = 'encoding\s*=\s*["'']\{0,1}\([^"'' \t]\+\|[^"'']\+\)["'']\{0,1}'
let matches = matchlist(match, mx)
if len(matches)
let encoding = matches[1]
if len(encoding) && len(a:ctx['encoding']) == 0
let a:ctx['encoding'] = encoding
let a:ctx['xml'] = iconv(a:ctx['xml'], encoding, &encoding)
endif
endif
endif
" this regex matches
" 1) the remaining until the next tag begins
" 2) maybe closing "/" of tag name
" 3) tagname
" 4) the attributes of the text (optional)
" 5) maybe closing "/" (end of tag name)
" or
" 6) CDATA or ''
" 7) text content of CDATA
" 8) the remaining text after the tag (rest)
" (These numbers correspond to the indexes in matched list m)
let tag_mx = '^\(\_.\{-}\)\%(\%(<\(/\?\)\([^!/>[:space:]]\+\)\(\%([[:space:]]*[^/>=[:space:]]\+[[:space:]]*=[[:space:]]*\%([^"'' >\t]\+\|"[^"]*"\|''[^'']*''\)\|[[:space:]]\+[^/>=[:space:]]\+[[:space:]]*\)*\)[[:space:]]*\(/\?\)>\)\|\%(<!\[\(CDATA\)\[\(.\{-}\)\]\]>\)\|\(<!--.\{-}-->\)\)'
while len(a:ctx['xml']) > 0
let m = matchlist(a:ctx.xml, tag_mx)
if empty(m) | break | endif
let a:ctx.xml = a:ctx.xml[len(m[0]) :]
let is_end_tag = m[2] ==# '/' && m[5] ==# ''
let is_start_and_end_tag = m[2] ==# '' && m[5] ==# '/'
let tag_name = m[3]
let attrs = m[4]
if len(m[1])
let content .= s:decodeEntityReference(m[1])
endif
if is_end_tag
" closing tag: pop from stack and continue at upper level
exec append_content_to_parent
if len(stack) " TODO: checking whether opened tag is exist.
call remove(stack, -1)
endif
continue
endif
" comment tag
if m[8] !=# ''
continue
endif
" if element is a CDATA
if m[6] !=# ''
let content .= m[7]
continue
endif
let node = deepcopy(s:template)
let node.name = tag_name
let attr_mx = '\([^=[:space:]]\+\)\s*\%(=\s*''\([^'']*\)''\|=\s*"\([^"]*\)"\|=\s*\(\w\+\)\|\)'
while len(attrs) > 0
let attr_match = matchlist(attrs, attr_mx)
if len(attr_match) == 0
break
endif
let name = attr_match[1]
let value = len(attr_match[2]) ? attr_match[2] : len(attr_match[3]) ? attr_match[3] : len(attr_match[4]) ? attr_match[4] : ''
if value ==# ''
let value = name
endif
let node.attr[name] = s:decodeEntityReference(value)
let attrs = attrs[stridx(attrs, attr_match[0]) + len(attr_match[0]):]
endwhile
exec append_content_to_parent
if len(stack)
call add(stack[-1].child, node)
endif
if !is_start_and_end_tag
" opening tag, continue parsing its contents
call add(stack, node)
endif
endwhile
endfunction
" @vimlint(EVL102, 0, l:content)
function! s:self.parse(xml) abort
let top = deepcopy(s:template)
let oldmaxmempattern=&maxmempattern
let oldmaxfuncdepth=&maxfuncdepth
let &maxmempattern=2000000
let &maxfuncdepth=2000
"try
call s:parse_tree({'xml': a:xml, 'encoding': ''}, top)
for node in top.child
if type(node) == 4
return node
endif
unlet node
endfor
"catch /.*/
"endtry
let &maxmempattern=oldmaxmempattern
let &maxfuncdepth=oldmaxfuncdepth
throw 'Parse Error'
endfunction
function! s:self.parseFile(file) abort
return self.parse(join(readfile(a:file), "\n"))
endfunction
function! s:self.parseURL(url) abort
return self.parse(s:HTTP.get(a:url).content)
endfunction
function! SpaceVim#api#web#xml#get() abort
return deepcopy(s:self)
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et sw=2 cc=80:

View File

@ -65,6 +65,7 @@ function! SpaceVim#autocmds#init() abort
" Instead of reverting the cursor to the last position in the buffer, we
" set it to the first line when editing a git commit message
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
au StdinReadPost * call s:disable_welcome()
autocmd InsertEnter * call s:fixindentline()
if executable('synclient') && g:spacevim_auto_disable_touchpad
let s:touchpadoff = 0
@ -138,5 +139,11 @@ function! SpaceVim#autocmds#VimEnter() abort
endif
endfunction
function! s:disable_welcome() abort
augroup SPwelcome
au!
augroup END
endfunction
" vim:set et sw=2:

View File

@ -107,6 +107,10 @@ function! SpaceVim#default#SetOptions() abort
set ttimeout
set ttimeoutlen=50
set lazyredraw
if has('patch-7.4.314')
" don't give ins-completion-menu messages.
set shortmess+=c
endif
endfunction
function! SpaceVim#default#SetPlugins() abort

View File

@ -53,7 +53,7 @@ let s:modes = {
\ },
\ }
let s:loaded_sections = ['syntax checking', 'major mode', 'minor mode lighters', 'version control info']
let s:loaded_sections = ['syntax checking', 'major mode', 'minor mode lighters', 'version control info', 'cursorpos']
function! s:battery_status() abort
if executable('acpi')
@ -156,6 +156,10 @@ function! s:whitespace() abort
endif
endfunction
function! s:cursorpos() abort
return ' %l:%c '
endfunction
function! s:modes() abort
let m = ' ❖ '
@ -210,6 +214,10 @@ function! SpaceVim#layers#core#statusline#get(...) abort
\ . '%#SpaceVim_statusline_a_bold_SpaceVim_statusline_b# %{get(unite#get_context(), "buffer_name", "")} '
\ . '%#SpaceVim_statusline_b_SpaceVim_statusline_c# '
\ . '%#SpaceVim_statusline_c# %{unite#get_status_string()} '
elseif &filetype ==# 'SpaceVimFlyGrep'
return '%#SpaceVim_statusline_a# FlyGrep %#SpaceVim_statusline_a_SpaceVim_statusline_b#'
\ . '%#SpaceVim_statusline_b# %{getcwd()}%#SpaceVim_statusline_b_SpaceVim_statusline_c#'
\ . '%#SpaceVim_statusline_c# %{SpaceVim#plugins#flygrep#lineNr()}'
endif
if a:0 > 0
return s:active()
@ -237,10 +245,14 @@ function! s:active() abort
if index(s:loaded_sections, 'version control info') != -1
call add(lsec, s:git_branch())
endif
call add(lsec, SpaceVim#plugins#searcher#count())
if index(s:loaded_sections, 'battery status') != -1
call add(rsec, s:battery_status())
endif
call add(rsec, '%{" " . &ff . "|" . (&fenc!=""?&fenc:&enc) . " "}')
call add(rsec, '%{" " . &ff . " | " . (&fenc!=""?&fenc:&enc) . " "}')
if index(s:loaded_sections, 'cursorpos') != -1
call add(rsec, s:cursorpos())
endif
call add(rsec, ' %P ')
if index(s:loaded_sections, 'time') != -1
call add(rsec, s:time())
@ -343,6 +355,8 @@ function! SpaceVim#layers#core#statusline#config() abort
\ 'toggle the battery status', 1)
call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 't'], 'call SpaceVim#layers#core#statusline#toggle_section("time")',
\ 'toggle the time', 1)
call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'p'], 'call SpaceVim#layers#core#statusline#toggle_section("cursorpos")',
\ 'toggle the cursor position', 1)
call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'T'], 'if &laststatus == 2 | let &laststatus = 0 | else | let &laststatus = 2 | endif',
\ 'toggle the statuline itself', 1)
function! TagbarStatusline(...) abort

View File

@ -1,4 +1,8 @@
scriptencoding utf-8
let s:PASSWORD = SpaceVim#api#import('password')
let s:NUMBER = SpaceVim#api#import('data#number')
let s:LIST = SpaceVim#api#import('data#list')
function! SpaceVim#layers#edit#plugins() abort
let plugins = [
\ ['tpope/vim-surround'],
@ -66,6 +70,38 @@ function! SpaceVim#layers#edit#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'C'], 'silent call call('
\ . string(s:_function('s:UpperCamelCase')) . ', [])',
\ 'change symbol style to UpperCamelCase', 1)
let g:_spacevim_mappings_space.i = {'name' : '+Insertion'}
let g:_spacevim_mappings_space.i.l = {'name' : '+Lorem-ipsum'}
let g:_spacevim_mappings_space.i.p = {'name' : '+Passwords'}
let g:_spacevim_mappings_space.i.U = {'name' : '+UUID'}
call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 1], 'call call('
\ . string(s:_function('s:insert_simple_password')) . ', [])',
\ 'insert simple password', 1)
call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 2], 'call call('
\ . string(s:_function('s:insert_stronger_password')) . ', [])',
\ 'insert stronger password', 1)
call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 3], 'call call('
\ . string(s:_function('s:insert_paranoid_password')) . ', [])',
\ 'insert password for paranoids', 1)
call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 'p'], 'call call('
\ . string(s:_function('s:insert_phonetically_password')) . ', [])',
\ 'insert a phonetically easy password', 1)
call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 'n'], 'call call('
\ . string(s:_function('s:insert_numerical_password')) . ', [])',
\ 'insert a numerical password', 1)
call SpaceVim#mapping#space#def('nnoremap', ['i', 'u'], 'Unite unicode', 'search and insert unicode', 1)
call SpaceVim#mapping#space#def('nnoremap', ['i', 'U', 'U'], 'call call('
\ . string(s:_function('s:uuidgen_U')) . ', [])',
\ 'uuidgen-4', 1)
call SpaceVim#mapping#space#def('nnoremap', ['i', 'l', 'l'], 'call call('
\ . string(s:_function('s:insert_lorem_ipsum_list')) . ', [])',
\ 'insert lorem-ipsum list', 1)
call SpaceVim#mapping#space#def('nnoremap', ['i', 'l', 'p'], 'call call('
\ . string(s:_function('s:insert_lorem_ipsum_paragraph')) . ', [])',
\ 'insert lorem-ipsum paragraph', 1)
call SpaceVim#mapping#space#def('nnoremap', ['i', 'l', 's'], 'call call('
\ . string(s:_function('s:insert_lorem_ipsum_sentence')) . ', [])',
\ 'insert lorem-ipsum sentence', 1)
endfunction
function! s:lowerCamelCase() abort
@ -129,6 +165,133 @@ function! s:delete_extra_space() abort
endif
endif
endfunction
let s:local_lorem_ipsum = [
\ 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.',
\ 'Donec hendrerit tempor tellus.',
\ 'Donec pretium posuere tellus.',
\ 'Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus.',
\ 'Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.',
\ 'Nulla posuere.',
\ 'Donec vitae dolor.',
\ 'Nullam tristique diam non turpis.',
\ 'Cras placerat accumsan nulla.',
\ 'Nullam rutrum.',
\ 'Nam vestibulum accumsan nisl.',
\ 'Pellentesque dapibus suscipit ligula.',
\ 'Donec posuere augue in quam.',
\ 'Etiam vel tortor sodales tellus ultricies commodo.',
\ 'Suspendisse potenti.',
\ 'Aenean in sem ac leo mollis blandit.',
\ 'Donec neque quam, dignissim in, mollis nec, sagittis eu, wisi.',
\ 'Phasellus lacus.',
\ 'Etiam laoreet quam sed arcu.',
\ 'Phasellus at dui in ligula mollis ultricies.',
\ 'Integer placerat tristique nisl.',
\ 'Praesent augue.',
\ 'Fusce commodo.',
\ 'Vestibulum convallis, lorem a tempus semper, dui dui euismod elit, vitae placerat urna tortor vitae lacus.',
\ 'Nullam libero mauris, consequat quis, varius et, dictum id, arcu.',
\ 'Mauris mollis tincidunt felis.',
\ 'Aliquam feugiat tellus ut neque.',
\ 'Nulla facilisis, risus a rhoncus fermentum, tellus tellus lacinia purus, et dictum nunc justo sit amet elit.',
\ 'Aliquam erat volutpat.',
\ 'Nunc eleifend leo vitae magna.',
\ 'In id erat non orci commodo lobortis.',
\ 'Proin neque massa, cursus ut, gravida ut, lobortis eget, lacus.',
\ 'Sed diam.',
\ 'Praesent fermentum tempor tellus.',
\ 'Nullam tempus.',
\ 'Mauris ac felis vel velit tristique imperdiet.',
\ 'Donec at pede.',
\ 'Etiam vel neque nec dui dignissim bibendum.',
\ 'Vivamus id enim.',
\ 'Phasellus neque orci, porta a, aliquet quis, semper a, massa.',
\ 'Phasellus purus.',
\ 'Pellentesque tristique imperdiet tortor.',
\ 'Nam euismod tellus id erat.',
\ 'Nullam eu ante vel est convallis dignissim.',
\ 'Fusce suscipit, wisi nec facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis odio.',
\ 'Nunc porta vulputate tellus.',
\ 'Nunc rutrum turpis sed pede.',
\ 'Sed bibendum.',
\ 'Aliquam posuere.',
\ 'Nunc aliquet, augue nec adipiscing interdum, lacus tellus malesuada massa, quis varius mi purus non odio.',
\ 'Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna.',
\ 'Curabitur vulputate vestibulum lorem.',
\ 'Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla lacinia eros.',
\ 'Sed id ligula quis est convallis tempor.',
\ 'Curabitur lacinia pulvinar nibh.',
\ 'Nam a sapien.',
\ ]
let s:lorem_ipsum_paragraph_separator = "\n\n"
let s:lorem_ipsum_sentence_separator = ' '
let s:lorem_ipsum_list_beginning = ''
let s:lorem_ipsum_list_bullet = '* '
let s:lorem_ipsum_list_item_end = "\n"
let s:lorem_ipsum_list_end = ''
function! s:insert_lorem_ipsum_list() abort
let save_register = @k
let @k = '* ' . s:local_lorem_ipsum[s:NUMBER.random(0, len(s:local_lorem_ipsum))] . "\n"
normal! "kgP
let @k = save_register
endfunction
function! s:insert_lorem_ipsum_paragraph() abort
let save_register = @k
let pids = len(s:local_lorem_ipsum) / 11
let pid = s:NUMBER.random(0, pids) * 11
let @k = join(s:LIST.listpart(s:local_lorem_ipsum, pid, 11), s:lorem_ipsum_sentence_separator) . s:lorem_ipsum_paragraph_separator
normal! "kgP
let @k = save_register
endfunction
function! s:insert_lorem_ipsum_sentence() abort
let save_register = @k
let @k = s:local_lorem_ipsum[s:NUMBER.random(0, len(s:local_lorem_ipsum))] . s:lorem_ipsum_sentence_separator
normal! "kgP
let @k = save_register
endfunction
function! s:insert_simple_password() abort
let save_register = @k
let @k = s:PASSWORD.generate_simple(8)
normal! "kPl
let @k = save_register
endfunction
function! s:insert_stronger_password() abort
let save_register = @k
let @k = s:PASSWORD.generate_strong(12)
normal! "kPl
let @k = save_register
endfunction
function! s:insert_paranoid_password() abort
let save_register = @k
let @k = s:PASSWORD.generate_paranoid(20)
normal! "kPl
let @k = save_register
endfunction
function! s:insert_numerical_password() abort
let save_register = @k
let @k = s:PASSWORD.generate_numeric(4)
normal! "kPl
let @k = save_register
endfunction
function! s:insert_phonetically_password() abort
let save_register = @k
let @k = s:PASSWORD.generate_phonetic(8)
normal! "kPl
let @k = save_register
endfunction
function! s:uuidgen_U() abort
let uuid = system('uuidgen')
let save_register = @k
let @k = uuid
normal! "kPl
let @k = save_register
endfunction
" function() wrapper
if v:version > 703 || v:version == 703 && has('patch1170')

View File

@ -67,10 +67,18 @@ endfunction
let s:si_flag = 0
function! s:update_search_index(key) abort
if a:key == 'n'
normal! n
if mapcheck("<Plug>(incsearch-nohl-n)") !=# ''
call feedkeys("\<Plug>(incsearch-nohl-n)")
else
normal! n
endif
normal! ml
elseif a:key == 'N'
normal! N
if mapcheck("<Plug>(incsearch-nohl-n)") !=# ''
call feedkeys("\<Plug>(incsearch-nohl-N)")
else
normal! N
endif
normal! ml
endif
if s:si_flag == 0

View File

@ -6,7 +6,7 @@ function! SpaceVim#layers#lang#lua#plugins() abort
" Improved Lua 5.3 syntax and indentation support for Vim
call add(plugins, ['tbastos/vim-lua', {'on_ft' : 'lua'}])
call add(plugins, ['WolfgangMehner/lua-support', {'on_ft' : 'lua'}])
call add(plugins, ['SpaceVim/vim-luacomplete', {'on_ft' : 'lua'}])
call add(plugins, ['SpaceVim/vim-luacomplete', {'on_ft' : 'lua', 'if' : has('lua')}])
return plugins
endfunction

View File

@ -13,7 +13,7 @@ function! SpaceVim#layers#lang#python#plugins() abort
if has('nvim')
call add(plugins, ['zchee/deoplete-jedi', { 'on_ft' : 'python'}])
else
call add(plugins, ['davidhalter/jedi-vim', { 'on_ft' : 'python'}])
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

View File

@ -169,7 +169,7 @@ function! s:toggle_end_of_buffer() abort
endif
let s:ebflag = 1
else
if &termguicolors || has('gui_running')
if (exists('+termguicolors') && &termguicolors) || has('gui_running')
let normalbg = s:HI.group2dict('Normal').guibg
else
let normalbg = s:HI.group2dict('Normal').ctermbg

View File

@ -3,6 +3,7 @@ function! SpaceVim#layers#unite#plugins() abort
\ ['Shougo/unite.vim',{ 'merged' : 0 , 'loadconf' : 1}],
\ ['Shougo/neoyank.vim'],
\ ['soh335/unite-qflist'],
\ ['SpaceVim/unite-unicode'],
\ ['ujihisa/unite-equery'],
\ ['m2mdas/unite-file-vcs'],
\ ['Shougo/neomru.vim'],

View File

@ -20,6 +20,8 @@ function! SpaceVim#mapping#g#init() abort
nnoremap g, g,
let g:_spacevim_mappings_g[';'] = ['call feedkeys("g;", "n")', 'older position in change list']
nnoremap g; g;
let g:_spacevim_mappings_g['@'] = ['call feedkeys("g@", "n")', 'call operatorfunc']
nnoremap g@ g@
let g:_spacevim_mappings_g['#'] = ['call feedkeys("\<Plug>(incsearch-nohl-g#)")', 'search under cursor backward']
let g:_spacevim_mappings_g['*'] = ['call feedkeys("\<Plug>(incsearch-nohl-g*)")', 'search under cursor forward']

View File

@ -50,3 +50,16 @@ function! SpaceVim#mapping#search#grep(key, scope)
let g:unite_source_grep_default_opts = save_opt
let g:unite_source_grep_recursive_opt = save_ropt
endfunction
function! SpaceVim#mapping#search#default_tool()
if has_key(s:search_tools, 'default_exe')
return s:search_tools.default_exe
else
for t in g:spacevim_search_tools
if executable(t)
let s:search_tools.default_exe = t
return t
endif
endfor
endif
endfunction

View File

@ -3,7 +3,9 @@ function! SpaceVim#mapping#space#init() abort
return
endif
nnoremap <silent><nowait> [SPC] :<c-u>LeaderGuide " "<CR>
vnoremap <silent><nowait> [SPC] :<c-u>LeaderGuideVisual " "<CR>
nmap <Space> [SPC]
vmap <Space> [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']
@ -72,7 +74,26 @@ function! SpaceVim#mapping#space#init() abort
"
" Toggles the comment state of the selected line(s). If the topmost selected
" line is commented, all selected lines are uncommented and vice versa.
call SpaceVim#mapping#space#def('nnoremap', ['c', 'l'], 'call NERDComment("n", "Toggle")', 'Toggle comment line(s)', 1)
call SpaceVim#mapping#space#def('nmap', ['c', 'l'], '<Plug>NERDCommenterComment', 'comment lines', 0, 1)
call SpaceVim#mapping#space#def('nmap', ['c', 'L'], '<Plug>NERDCommenterInvert', 'toggle comment lines', 0, 1)
call SpaceVim#mapping#space#def('nmap', ['c', 'p'], 'vip<Plug>NERDCommenterComment', 'comment paragraphs', 0, 1)
call SpaceVim#mapping#space#def('nmap', ['c', 'P'], 'vip<Plug>NERDCommenterInvert', 'toggle comment paragraphs', 0, 1)
nnoremap <silent> <Plug>CommentToLine :call <SID>comment_to_line(0)<Cr>
nnoremap <silent> <Plug>CommentToLineInvert :call <SID>comment_to_line(1)<Cr>
call SpaceVim#mapping#space#def('nmap', ['c', 't'], '<Plug>CommentToLine', 'comment until the line', 0, 1)
call SpaceVim#mapping#space#def('nmap', ['c', 'T'], '<Plug>CommentToLineInvert', 'toggle comment until the line', 0, 1)
nnoremap <silent> <Plug>CommentOperator :set opfunc=<SID>commentOperator<Cr>g@
let g:_spacevim_mappings_space[';'] = ['call feedkeys("\<Plug>CommentOperator")', 'comment operator']
nmap <silent> [SPC]; <Plug>CommentOperator
" in nerdcomment if has map to <plug>... the default mapping will be
" disable, so we add it for compatibility
nmap <Leader>cc <Plug>NERDCommenterComment
xmap <Leader>cc <Plug>NERDCommenterComment
nmap <Leader>ci <Plug>NERDCommenterInvert
xmap <Leader>ci <Plug>NERDCommenterInvert
let g:_spacevim_mappings_space.e = {'name' : '+Errors/Encoding'}
let g:_spacevim_mappings_space.B = {'name' : '+Global-buffers'}
@ -105,6 +126,13 @@ function! SpaceVim#mapping#space#init() abort
call SpaceVim#mapping#space#def('nnoremap', ['s', 'p'], 'Unite grep:.', 'grep in project', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'P'], "execute 'Unite grep:.::' . expand(\"<cword>\") . ' -start-insert'",
\ 'grep in project', 1)
" Searching background
call SpaceVim#mapping#space#def('nnoremap', ['s', 'j'],
\ 'call SpaceVim#plugins#searcher#find("", SpaceVim#mapping#search#default_tool())', 'Background search keywords in project', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'J'],
\ 'call SpaceVim#plugins#searcher#find(expand("<cword>"),SpaceVim#mapping#search#default_tool())',
\ 'Background search cursor words in project', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'l'], 'call SpaceVim#plugins#searcher#list()', 'List all searching results', 1)
" Searching tools
" ag
@ -119,6 +147,10 @@ function! SpaceVim#mapping#space#init() abort
\ 'search in arbitrary directory with ag', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'a', 'F'], 'call SpaceVim#mapping#search#grep("a", "F")',
\ 'search cursor word in arbitrary directory with ag', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'a', 'j'], 'call SpaceVim#plugins#searcher#find("", "ag")',
\ 'Background search cursor words in project with ag', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'a', 'J'], 'call SpaceVim#plugins#searcher#find(expand("<cword>"), "ag")',
\ 'Background search cursor words in project with ag', 1)
" grep
let g:_spacevim_mappings_space.s.g = {'name' : '+grep'}
call SpaceVim#mapping#space#def('nnoremap', ['s', 'g', 'b'], 'call SpaceVim#mapping#search#grep("g", "b")',
@ -132,6 +164,10 @@ function! SpaceVim#mapping#space#init() abort
\ 'search in arbitrary directory with grep', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'g', 'F'], 'call SpaceVim#mapping#search#grep("g", "F")',
\ 'search cursor word in arbitrary directory with grep', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'g', 'j'], 'call SpaceVim#plugins#searcher#find("", "grep")',
\ 'Background search cursor words in project with grep', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'g', 'J'], 'call SpaceVim#plugins#searcher#find(expand("<cword>"), "grep")',
\ 'Background search cursor words in project with grep', 1)
" ack
let g:_spacevim_mappings_space.s.k = {'name' : '+ack'}
call SpaceVim#mapping#space#def('nnoremap', ['s', 'k', 'b'], 'call SpaceVim#mapping#search#grep("k", "b")', 'search in all buffers with ack', 1)
@ -144,6 +180,10 @@ function! SpaceVim#mapping#space#init() abort
\ 'search in arbitrary directory with ack', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'k', 'F'], 'call SpaceVim#mapping#search#grep("k", "F")',
\ 'search cursor word in arbitrary directory with ack', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'k', 'j'], 'call SpaceVim#plugins#searcher#find("", "ack")',
\ 'Background search cursor words in project with ack', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'k', 'J'], 'call SpaceVim#plugins#searcher#find(expand("<cword>"), "ack")',
\ 'Background search cursor words in project with ack', 1)
" rg
let g:_spacevim_mappings_space.s.r = {'name' : '+rg'}
call SpaceVim#mapping#space#def('nnoremap', ['s', 'r', 'b'], 'call SpaceVim#mapping#search#grep("r", "b")', 'search in all buffers with rt', 1)
@ -156,6 +196,10 @@ function! SpaceVim#mapping#space#init() abort
\ 'search in arbitrary directory with rt', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'r', 'F'], 'call SpaceVim#mapping#search#grep("r", "F")',
\ 'search cursor word in arbitrary directory with rt', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'r', 'j'], 'call SpaceVim#plugins#searcher#find("", "rg")',
\ 'Background search cursor words in project with rg', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'r', 'J'], 'call SpaceVim#plugins#searcher#find(expand("<cword>"), "rg")',
\ 'Background search cursor words in project with rg', 1)
" pt
let g:_spacevim_mappings_space.s.t = {'name' : '+pt'}
call SpaceVim#mapping#space#def('nnoremap', ['s', 't', 'b'], 'call SpaceVim#mapping#search#grep("t", "b")', 'search in all buffers with pt', 1)
@ -168,15 +212,23 @@ function! SpaceVim#mapping#space#init() abort
\ 'search in arbitrary directory with pt', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 't', 'F'], 'call SpaceVim#mapping#search#grep("t", "F")',
\ 'search cursor word in arbitrary directory with pt', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 't', 'j'], 'call SpaceVim#plugins#searcher#find("", "pt")',
\ 'Background search cursor words in project with pt', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 't', 'J'], 'call SpaceVim#plugins#searcher#find(expand("<cword>"), "pt")',
\ 'Background search cursor words in project with pt', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'g', 'G'], 'call SpaceVim#plugins#flygrep#open()',
\ 'grep on the fly', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'c'], 'noh',
\ 'clear search highlight', 1)
endfunction
function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort
function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd, ...) abort
if s:has_map_to_spc()
return
endif
let is_visual = a:0 > 0 ? a:1 : 0
if a:is_cmd
let cmd = ':<C-u>' . a:cmd . '<CR>'
let lcmd = a:cmd
@ -190,6 +242,13 @@ function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort
endif
endif
exe a:m . ' <silent> [SPC]' . join(a:keys, '') . ' ' . substitute(cmd, '|', '\\|', 'g')
if is_visual
if a:m ==# 'nnoremap'
exe 'xnoremap <silent> [SPC]' . join(a:keys, '') . ' ' . substitute(cmd, '|', '\\|', 'g')
elseif a:m ==# 'nmap'
exe 'xmap <silent> [SPC]' . join(a:keys, '') . ' ' . substitute(cmd, '|', '\\|', 'g')
endif
endif
if len(a:keys) == 2
let g:_spacevim_mappings_space[a:keys[0]][a:keys[1]] = [lcmd, a:desc]
elseif len(a:keys) == 3
@ -255,4 +314,45 @@ function! SpaceVim#mapping#space#langSPC(m, keys, cmd, desc, is_cmd) abort
call extend(g:_spacevim_mappings_prefixs['[SPC]'], get(g:, '_spacevim_mappings_space', {}))
endfunction
function! s:commentOperator(type, ...)
let sel_save = &selection
let &selection = "inclusive"
let reg_save = @@
if a:0 " Invoked from Visual mode, use gv command.
silent exe "normal! gv"
call feedkeys("\<Plug>NERDCommenterComment")
elseif a:type == 'line'
call feedkeys('`[V`]')
call feedkeys("\<Plug>NERDCommenterComment")
else
call feedkeys('`[v`]')
call feedkeys("\<Plug>NERDCommenterComment")
endif
let &selection = sel_save
let @@ = reg_save
set opfunc=
endfunction
function! s:comment_to_line(invert) abort
let input = input('line number: ')
if empty(input)
return
endif
let line = str2nr(input)
let ex = line - line('.')
if ex > 0
exe 'normal! V'. ex .'j'
elseif ex == 0
else
exe 'normal! V'. abs(ex) .'k'
endif
if a:invert
call feedkeys("\<Plug>NERDCommenterInvert")
else
call feedkeys("\<Plug>NERDCommenterComment")
endif
endfunction
" vim:set et sw=2 cc=80:

View File

@ -0,0 +1,197 @@
let s:MPT = SpaceVim#api#import('prompt')
let s:JOB = SpaceVim#api#import('job')
let s:SYS = SpaceVim#api#import('system')
let s:grepid = 0
function! SpaceVim#plugins#flygrep#open() abort
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!
call s:MPT.open()
let &t_ve = save_tve
endfunction
let s:grep_expr = ''
let s:grep_exe = SpaceVim#mapping#search#default_tool()
let s:grep_timer_id = 0
" @vimlint(EVL103, 1, a:timer)
function! s:grep_timer(timer) abort
let s:grepid = s:JOB.start(s:get_search_cmd(s:grep_exe, s:grep_expr), {
\ 'on_stdout' : function('s:grep_stdout'),
\ 'in_io' : 'null',
\ 'on_exit' : function('s:grep_exit'),
\ })
endfunction
" @vimlint(EVL103, 0, a:timer)
function! s:flygrep(expr) abort
call s:MPT._build_prompt()
if a:expr ==# ''
redrawstatus
return
endif
try
syn clear FileNames
catch
endtr
exe 'syn match FileNames /' . substitute(a:expr, '\([/\\]\)', '\\\1', 'g') . '/'
hi def link FileNames MoreMsg
let s:grep_expr = a:expr
let s:grep_timer_id = timer_start(500, funcref('s:grep_timer'), {'repeat' : 1})
endfunction
let s:MPT._handle_fly = function('s:flygrep')
function! s:close_buffer() abort
if s:grepid != 0
call s:JOB.stop(s:grepid)
endif
if s:grep_timer_id != 0
call timer_stop(s:grep_timer_id)
endif
q
endfunction
let s:MPT._onclose = function('s:close_buffer')
function! s:close_grep_job() abort
if s:grepid != 0
call s:JOB.stop(s:grepid)
endif
if s:grep_timer_id != 0
call timer_stop(s:grep_timer_id)
endif
normal! "_ggdG
endfunction
let s:MPT._oninputpro = function('s:close_grep_job')
" @vimlint(EVL103, 1, a:data)
" @vimlint(EVL103, 1, a:id)
" @vimlint(EVL103, 1, a:event)
function! s:grep_stdout(id, data, event) abort
let datas =filter(a:data, '!empty(v:val)')
if getline(1) ==# ''
call setline(1, datas)
else
call append('$', datas)
endif
call s:MPT._build_prompt()
endfunction
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(exe, expr) abort
if a:exe ==# 'grep'
return ['grep', '-inHR', '--exclude-dir', '.git', a:expr, '.']
elseif a:exe ==# 'rg'
return ['rg', '-n', '-i', a:expr]
else
return [a:exe, a:expr]
endif
endfunction
function! s:next_item() abort
if line('.') == line('$')
normal! gg
else
normal! j
endif
redrawstatus
call s:MPT._build_prompt()
endfunction
function! s:previous_item() abort
if line('.') == 1
normal! G
else
normal! k
endif
redrawstatus
call s:MPT._build_prompt()
endfunction
function! s:open_item() abort
if line('.') !=# ''
if s:grepid != 0
call s:JOB.stop(s:grepid)
endif
call s:MPT._clear_prompt()
let s:MPT._quit = 1
let isfname = &isfname
if s:SYS.isWindows
set isfname-=:
endif
normal! gF
let nr = bufnr('%')
q
exe 'silent b' . nr
normal! :
let &isfname = isfname
endif
endfunction
function! s:double_click() abort
if line('.') !=# ''
if s:grepid != 0
call s:JOB.stop(s:grepid)
endif
call s:MPT._clear_prompt()
let s:MPT._quit = 1
let isfname = &isfname
if s:SYS.isWindows
set isfname-=:
endif
normal! gF
let nr = bufnr('%')
q
exe 'silent b' . nr
normal! :
let &isfname = isfname
endif
endfunction
function! s:move_cursor() abort
if v:mouse_win == winnr()
let cl = line('.')
if cl < v:mouse_lnum
exe 'normal! ' . (v:mouse_lnum - cl) . 'j'
elseif cl > v:mouse_lnum
exe 'normal! ' . (cl - v:mouse_lnum) . 'k'
endif
endif
call s:MPT._build_prompt()
endfunction
let s:MPT._function_key = {
\ "\<Tab>" : function('s:next_item'),
\ "\<ScrollWheelDown>" : function('s:next_item'),
\ "\<S-tab>" : function('s:previous_item'),
\ "\<ScrollWheelUp>" : function('s:previous_item'),
\ "\<Return>" : function('s:open_item'),
\ "\<LeftMouse>" : function('s:move_cursor'),
\ "\<2-LeftMouse>" : function('s:double_click'),
\ }
" statusline api
function! SpaceVim#plugins#flygrep#lineNr() abort
if getline(1) ==# ''
return ''
else
return line('.') . '/' . line('$')
endif
endfunction

View File

@ -356,9 +356,10 @@ endfunction
function! s:pull(repo) abort
let s:pct += 1
let s:ui_buf[a:repo.name] = s:pct
let argv = ['git', '-C', a:repo.path, 'pull']
let argv = ['git', '-C', a:repo.path, 'pull', '--progress']
if s:JOB.vim_job || s:JOB.nvim_job
let jobid = s:JOB.start(argv,{
\ 'on_stderr' : function('s:on_install_stdout'),
\ 'on_exit' : function('s:on_pull_exit')
\ })
if jobid != 0

View File

@ -0,0 +1,67 @@
let s:JOB = SpaceVim#api#import('job')
let s:rst = []
function! SpaceVim#plugins#searcher#find(expr, exe) abort
if empty(a:expr)
let expr = input('search expr: ')
else
let expr = a:expr
endif
call s:JOB.start(s:get_search_cmd(a:exe, expr), {
\ 'on_stdout' : function('s:search_stdout'),
\ 'in_io' : 'null',
\ 'on_exit' : function('s:search_exit'),
\ })
endfunction
" @vimlint(EVL103, 1, a:id)
" @vimlint(EVL103, 1, a:event)
function! s:search_stdout(id, data, event) abort
for data in a:data
let info = split(data, '\:\d\+\:')
if len(info) == 2
let [fname, text] = info
let lnum = matchstr(data, '\:\d\+\:')[1:-2]
call add(s:rst, {
\ 'filename' : fnamemodify(fname, ':p'),
\ 'lnum' : lnum,
\ 'text' : text,
\ })
endif
endfor
endfunction
function! s:get_search_cmd(exe, expr) abort
if a:exe ==# 'grep'
return ['grep', '-inHR', '--exclude-dir', '.git', a:expr, '.']
elseif a:exe ==# 'rg'
return ['rg', '-n', a:expr]
else
return [a:exe, a:expr]
endif
endfunction
" @vimlint(EVL103, 1, a:data)
function! s:search_exit(id, data, event) abort
let &l:statusline = SpaceVim#layers#core#statusline#get(1)
endfunction
" @vimlint(EVL103, 0, a:data)
" @vimlint(EVL103, 0, a:id)
" @vimlint(EVL103, 0, a:event)
function! SpaceVim#plugins#searcher#list() abort
call setqflist(s:rst)
let s:rst = []
copen
endfunction
function! SpaceVim#plugins#searcher#count() abort
if empty(s:rst)
return ''
else
return ' ' . len(s:rst) . ' items '
endif
endfunction

View File

@ -26,7 +26,7 @@ else
exec 'colorscheme '. g:spacevim_colorscheme_default
endif
if g:spacevim_hiddenfileinfo == 1 && has('patch-7.4.1570')
set shortmess=filnxtToOFs
set shortmess+=F
endif
if !empty(g:spacevim_guifont)
exe 'set guifont=' . g:spacevim_guifont

View File

@ -8,6 +8,7 @@ let g:vimfiler_tree_closed_icon = get(g:, 'vimfiler_tree_closed_icon', '▷')
let g:vimfiler_file_icon = get(g:, 'vimfiler_file_icon', '')
let g:vimfiler_readonly_file_icon = get(g:, 'vimfiler_readonly_file_icon', '*')
let g:vimfiler_marked_file_icon = get(g:, 'vimfiler_marked_file_icon', '√')
let g:vimfiler_direction = get(g:, 'vimfiler_direction', 'rightbelow')
"let g:vimfiler_preview_action = 'auto_preview'
let g:vimfiler_ignore_pattern = get(g:, 'vimfiler_ignore_pattern', [
\ '^\.git$',
@ -41,7 +42,7 @@ call vimfiler#custom#profile('default', 'context', {
\ 'winminwidth' : 30,
\ 'toggle' : 1,
\ 'auto_expand': 1,
\ 'direction' : 'rightbelow',
\ 'direction' : g:vimfiler_direction,
\ 'explorer_columns' : s:setcolum(),
\ 'parent': 0,
\ 'status' : 1,

View File

@ -49,8 +49,10 @@ CONTENTS *SpaceVim-contents*
26. tmux...........................................|SpaceVim-layer-tmux|
6. API........................................................|SpaceVim-api|
1. cmdlinemenu................................|SpaceVim-api-cmdlinemenu|
2. sid............................................|SpaceVim-api-vim-sid|
3. vim#message................................|SpaceVim-api-vim-message|
2. data#list....................................|SpaceVim-api-data-list|
3. prompt..........................................|SpaceVim-api-prompt|
4. sid............................................|SpaceVim-api-vim-sid|
5. vim#message................................|SpaceVim-api-vim-message|
7. FAQ........................................................|SpaceVim-faq|
==============================================================================
@ -963,6 +965,40 @@ Create a cmdline selection menu from a list of {items}, each item should be a
list of two value in it, first one is the description, and the next one should
be a funcrc.
==============================================================================
DATA#LIST *SpaceVim-api-data-list*
pop({list})
Removes the last element from {list} and returns the element, as if the {list}
is a stack.
push({list})
Appends {val} to the end of {list} and returns the list itself, as if the
{list} is a stack.
listpart({list}, {start}[, {len}])
The result is a List, which is part of {list}, starting from index {start},
with the length {len}
==============================================================================
PROMPT *SpaceVim-api-prompt*
open()
Create a cmdline prompt, use while loop to get the input from user. The
default mapping for prompt is:
>
<Bs> remove last character
<C-w> remove the Word before the cursor
<C-u> remove the Line before the cursor
<C-k> remove the Line after the cursor
<C-a> / <Home> Go to the beginning of the line
<C-e> / <End> Go to the end of the line
<
==============================================================================
SID *SpaceVim-api-vim-sid*

View File

@ -74,14 +74,21 @@ title: "Documentation"
* [Searching in all loaded buffers](#searching-in-all-loaded-buffers)
* [Searching in an arbitrary directory](#searching-in-an-arbitrary-directory)
* [Searching in a project](#searching-in-a-project)
* [Background searching in a project](#background-searching-in-a-project)
* [Searching the web](#searching-the-web)
* [Searching on the fly](#searching-on-the-fly)
* [Persistent highlighting](#persistent-highlighting)
* [Editing](#editing)
* [Paste text](#paste-text)
* [Auto-indent pasted text](#auto-indent-pasted-text)
* [Text manipulation commands](#text-manipulation-commands)
* [Text insertion commands](#text-insertion-commands)
* [Commenting](#commenting)
* [Multi-Encodings](#multi-encodings)
* [Errors handling](#errors-handling)
* [Achievements](#achievements)
* [issues](#issues)
* [Stars, forks and watchers](#stars-forks-and-watchers)
* [Features](#features)
* [Awesome ui](#awesome-ui-1)
* [Mnemonic key bindings](#mnemonic-key-bindings)
@ -118,7 +125,7 @@ title: "Documentation"
* [Plugin: Goyo and Limelight](#plugin-goyo-and-limelight)
* [Plugin: ChooseWin](#plugin-choosewin)
* [Plugin: Bookmarks](#plugin-bookmarks)
* [Plugin: Gita](#plugin-gita)
* [Plugin: Gina/Gita](#plugin-ginagita)
* [Plugin: vim-signify](#plugin-vim-signify)
* [Misc Plugins](#misc-plugins)
@ -396,7 +403,7 @@ Key Binding | Description
`SPC t m m` | toggle the minor mode lighters
`SPC t m M` | toggle the major mode
`SPC t m n` | toggle the cat! (if colors layer is declared in your dotfile)
`SPC t m p` | toggle the point character position
`SPC t m p` | toggle the cursor position
`SPC t m t` | toggle the time
`SPC t m T` | toggle the mode line itself
`SPC t m v` | toggle the version control info
@ -1082,6 +1089,7 @@ Key Binding | Description
`SPC *` or `SPC s P` | search with the first found tool with default input
`SPC s a p` | ag
`SPC s a P` | ag with default text
`SPC s g p` | grep
`SPC s g p` | grep with default text
`SPC s k p` | ack
`SPC s k P` | ack with default text
@ -1092,15 +1100,57 @@ Key Binding | Description
**Hint**: It is also possible to search in a project without needing to open a file beforehand. To do so use `SPC p p` and then `C-s` on a given project to directly search into it like with `SPC s p`. (TODO)
##### Background searching in a project
Background search keyword in a project, when searching done, the count will be shown on the statusline.
Key Binding | Description
----------- | -----------
`SPC s j` | searching input expr background with the first found tool
`SPC s J` | searching cursor word background with the first found tool
`SPC s l` | List all searching result in quickfix buffer
`SPC s a j` | ag
`SPC s a J` | ag with default text
`SPC s g j` | grep
`SPC s g J` | grep with default text
`SPC s k j` | ack
`SPC s k J` | ack with default text
`SPC s t j` | pt
`SPC s t J` | pt with default text
`SPC s r j` | rg
`SPC s r J` | rg with default text
##### Searching the web
Key Binding Description
Key Binding | Description
-----------| -----------
`SPC s w g` | Get Google suggestions in vim. Opens Google results in Browser.
`SPC s w w` | Get Wikipedia suggestions in vim. Opens Wikipedia page in Browser.(TODO)
**Note**: to enable google suggestions in vim, you need to add `let g:spacevim_enable_googlesuggest = 1` to your custom Configuration file.
#### Searching on the fly
Key Binding | Description
-----------| -----------
`SPC s g G` | Searching in project on the fly with default tools
key binding in FlyGrep buffer:
Key Binding Description
-----------| -----------
`<Esc>` | close FlyGrep buffer
`<Enter>` | open file at the cursor line
`<Tab>` | move cursor line down
`<S-Tab>` | move cursor line up
`<Bs>` | remove last character
`<C-w>` | remove the Word before the cursor
`<C-u>` | remove the Line before the cursor
`<C-k>` | remove the Line after the cursor
`<C-a>`/`<Home>` | Go to the beginning of the line
`<C-e>`/`<End>` | Go to the end of the line
#### Persistent highlighting
SpaceVim uses `g:spacevim_search_highlight_persist` to keep the searched expression highlighted until the next search. It is also possible to clear the highlighting by pressing `SPC s c` or executing the ex command `:noh`.
@ -1171,6 +1221,45 @@ Key Binding | Description
`SPC x w d` | show dictionary entry of word from wordnik.com
`SPC x TAB` | indent or dedent a region rigidly
#### Text insertion commands
Text insertion commands (start with `i`):
Key binding | Description
----------- | -----------
`SPC i l l` | insert lorem-ipsum list
`SPC i l p` | insert lorem-ipsum paragraph
`SPC i l s` | insert lorem-ipsum sentence
`SPC i p 1` | insert simple password
`SPC i p 2` | insert stronger password
`SPC i p 3` | insert password for paranoids
`SPC i p p` | insert a phonetically easy password
`SPC i p n` | insert a numerical password
`SPC i u` | Search for Unicode characters and insert them into the active buffer.
`SPC i U 1` | insert UUIDv1 (use universal argument to insert with CID format)
`SPC i U 4` | insert UUIDv4 (use universal argument to insert with CID format)
`SPC i U U` | insert UUIDv4 (use universal argument to insert with CID format)
#### Commenting
Comments are handled by [nerdcommenter](https://github.com/scrooloose/nerdcommenter), its bound to the following keys.
Key Binding | Description
----------- | -----------
`SPC ;` | comment operator
`SPC c h` | hide/show comments
`SPC c l` | comment lines
`SPC c L` | invert comment lines
`SPC c p` | comment paragraphs
`SPC c P` | invert comment paragraphs
`SPC c t` | comment to line
`SPC c T` | invert comment to line
`SPC c y` | comment and yank
`SPC c Y` | invert comment and yank
**Tips:** To comment efficiently a block of line use the combo `SPC ; SPC j l`
>>>>>>> dev
#### Multi-Encodings
SpaceVim use utf-8 as default encoding. there are four options for these case:
@ -1213,6 +1302,27 @@ Symbol | Description | Custom option
`✖` | Error | `g:spacevim_error_symbol`
`➤` | warning | `g:spacevim_warning_symbol`
<!-- SpaceVim Achievements start -->
## Achievements
### issues
Achievements | Account
----- | -----
[100th issue(issue)](https://github.com/SpaceVim/SpaceVim/issues/100) | [BenBergman](https://github.com/BenBergman)
### Stars, forks and watchers
Achievements | Account
----- | -----
First stargazers | [monkeydterry](https://github.com/monkeydterry)
100th stargazers | [naraj](https://github.com/naraj)
1000th stargazers | [icecity96](https://github.com/icecity96)
2000th stargazers | [frowhy](https://github.com/frowhy)
3000th stargazers | [purkylin](https://github.com/purkylin)
<!-- SpaceVim Achievements end -->
## Features
### Awesome ui
@ -1626,7 +1736,7 @@ Key | Mode | Action
As SpaceVim use above bookmarks mappings, so you can not use `a`, `m`, `n`, `p` or `i` registers to mark current position, but other registers should works will. if you really need to use these registers, you can add `nnoremap <leader>m m` to your custom configuration, then you use use `a` registers via `\ma`
##### Plugin: Gita
##### Plugin: Gina/Gita
Key | Mode | Action
----- |:----:| ------------------
@ -1635,6 +1745,8 @@ Key | Mode | Action
`<leader>`+`gc` | Normal | Git commit
`<leader>`+`gb` | Normal | Git blame
`<leader>`+`gp` | Normal | Git push
`<leader>`+`ga` | Normal | Git add current buffer
`<leader>`+`gA` | Normal | Git add all files
##### Plugin: vim-signify

View File

@ -1,67 +1,93 @@
#!/usr/bin/env bash
#
# A guarding function to avoid executing an incompletely downloaded script
guard () {
#=============================================================================
# install.sh --- bootstrap script for SpaceVim
# Copyright (c) 2016-2017 Shidong Wang & Contributors
# Author: Shidong Wang < wsdjeg at 163.com >
# URL: https://spacevim.org
# License: MIT license
#=============================================================================
# Reset
Color_off='\033[0m' # Text Reset
Version='0.4.0-dev'
# Regular Colors
Red='\033[0;31m' # Red
Blue='\033[0;34m' # Blue
Red='\033[0;31m'
Blue='\033[0;34m'
Green='\033[0;32m'
need_cmd () {
if ! hash "$1" &>/dev/null; then
echo -e "${Red}need '$1' (command not found)${Color_off}"
error "Need '$1' (command not fount)"
exit 1
fi
}
msg() {
printf '%b\n' "$1" >&2
}
success() {
msg "${Green}[✔]${Color_off} ${1}${2}"
}
info() {
msg "${Blue}==>${Color_off} ${1}${2}"
}
error() {
msg "${Red}[✘]${Color_off} ${1}${2}"
exit 1
}
fetch_repo () {
if [[ -d "$HOME/.SpaceVim" ]]; then
info "Trying to update SpaceVim"
git --git-dir "$HOME/.SpaceVim/.git" pull
echo -e "${Blue}Successfully update SpaceVim${Color_off}"
success "Successfully update SpaceVim"
else
info "Trying to clone SpaceVim"
git clone https://github.com/SpaceVim/SpaceVim.git "$HOME/.SpaceVim"
echo -e "${Blue}Successfully clone SpaceVim${Color_off}"
success "Successfully clone SpaceVim"
fi
}
install_vim () {
if [[ -f "$HOME/.vimrc" ]]; then
mv "$HOME/.vimrc" "$HOME/.vimrc_back"
echo -e "${Blue}BackUp $HOME/.vimrc${Color_off}"
success "Backup $HOME/.vimrc to $HOME/.vimrc_back"
fi
if [[ -d "$HOME/.vim" ]]; then
if [[ "$(readlink $HOME/.vim)" =~ \.SpaceVim$ ]]; then
echo -e "${Blue}Installed SpaceVim for vim${Color_off}"
success "Installed SpaceVim for vim"
else
mv "$HOME/.vim" "$HOME/.vim_back"
echo -e "${Blue}BackUp $HOME/.vim${Color_off}"
success "BackUp $HOME/.vim to $HOME/.vim_back"
ln -s "$HOME/.SpaceVim" "$HOME/.vim"
echo -e "${Blue}Installed SpaceVim for vim${Color_off}"
success "Installed SpaceVim for vim"
fi
else
ln -s "$HOME/.SpaceVim" "$HOME/.vim"
echo -e "${Blue}Installed SpaceVim for vim${Color_off}"
success "Installed SpaceVim for vim"
fi
}
install_neovim () {
if [[ -d "$HOME/.config/nvim" ]]; then
if [[ "$(readlink $HOME/.config/nvim)" =~ \.SpaceVim$ ]]; then
echo -e "${Blue}Installed SpaceVim for neovim${Color_off}"
success "Installed SpaceVim for neovim"
else
mv "$HOME/.config/nvim" "$HOME/.config/nvim_back"
echo -e "${Blue}BackUp $HOME/.config/nvim${Color_off}"
success "BackUp $HOME/.config/nvim to $HOME/.config/nvim_back"
ln -s "$HOME/.SpaceVim" "$HOME/.config/nvim"
echo -e "${Blue}Installed SpaceVim for neovim${Color_off}"
success "Installed SpaceVim for neovim"
fi
else
ln -s "$HOME/.SpaceVim" "$HOME/.config/nvim"
echo -e "${Blue}Installed SpaceVim for neovim${Color_off}"
success "Installed SpaceVim for neovim"
fi
}
@ -69,16 +95,16 @@ uninstall_vim () {
if [[ -d "$HOME/.vim" ]]; then
if [[ "$(readlink $HOME/.vim)" =~ \.SpaceVim$ ]]; then
rm "$HOME/.vim"
echo -e "${Blue}Uninstall SpaceVim for vim${Color_off}"
success "Uninstall SpaceVim for vim"
if [[ -d "$HOME/.vim_back" ]]; then
mv "$HOME/.vim_back" "$HOME/.vim"
echo -e "${Blue}Recover $HOME/.vim${Color_off}"
success "Recover from $HOME/.vim_back"
fi
fi
fi
if [[ -f "$HOME/.vimrc_back" ]]; then
mv "$HOME/.vimrc_back" "$HOME/.vimrc"
echo -e "${Blue}Recover $HOME/.vimrc${Color_off}"
success "Recover from $HOME/.vimrc_back"
fi
}
@ -86,37 +112,55 @@ uninstall_neovim () {
if [[ -d "$HOME/.config/nvim" ]]; then
if [[ "$(readlink $HOME/.config/nvim)" =~ \.SpaceVim$ ]]; then
rm "$HOME/.config/nvim"
echo -e "${Blue}Uninstall SpaceVim for neovim${Color_off}"
success "Uninstall SpaceVim for neovim"
if [[ -d "$HOME/.config/nvim_back" ]]; then
mv "$HOME/.config/nvim_back" "$HOME/.config/nvim"
echo -e "${Blue}Recover $HOME/.config/nvim${Color_off}"
success "Recover from $HOME/.config/nvim_back"
fi
fi
fi
}
usage () {
echo "SpaceVim install script : V 0.1.0-dev"
echo "SpaceVim install script : V ${Version}"
echo ""
echo "Usage : curl -sLf https://spacevim.org/install.sh | bash -s -- [option] [target]"
echo ""
echo " This is bootstrap script for SpaceVim."
echo ""
echo "OPTIONS"
echo ""
echo " -i, --install install spacevim for vim or neovim"
echo " -v, --version Show version information and exit"
echo " -u, --uninstall Uninstall SpaceVim"
echo ""
echo "EXAMPLE"
echo ""
echo " Install SpaceVim for vim and neovim"
echo ""
echo " curl -sLf https://spacevim.org/install.sh | bash"
echo ""
echo " Install SpaceVim for vim only or neovim only"
echo " curl -sLf https://spacevim.org/install.sh | bash -s -- install vim"
echo " or"
echo " curl -sLf https://spacevim.org/install.sh | bash -s -- install neovim"
echo ""
echo " curl -sLf https://spacevim.org/install.sh | bash -s -- --install vim"
echo " curl -sLf https://spacevim.org/install.sh | bash -s -- --install neovim"
echo ""
echo " Uninstall SpaceVim"
echo " curl -sLf https://spacevim.org/install.sh | bash -s -- uninstall"
echo ""
echo " curl -sLf https://spacevim.org/install.sh | bash -s -- --uninstall"
}
if [ $# -gt 0 ]
then
case $1 in
uninstall)
--uninstall|-u)
info "Trying to uninstall SpaceVim"
uninstall_vim
uninstall_neovim
exit 0
;;
install)
--install|-i)
need_cmd 'git'
fetch_repo
if [ $# -eq 2 ]
@ -135,9 +179,13 @@ then
install_neovim
exit 0
;;
-h)
--help|-h)
usage
exit 0
;;
--version|-v)
msg "${Version}"
exit 0
esac
fi
# if no argv, installer will install SpaceVim
@ -145,9 +193,3 @@ need_cmd 'git'
fetch_repo
install_vim
install_neovim
# end of guard
}
# download finished fine
guard $@

View File

@ -3,6 +3,12 @@
Name | Description | Documentation
----- |:----:| ------------------
default | better default for vim and neovim | [documentation](https://spacevim.org/layers/default)
checkers | checking in vim | [documentation](https://spacevim.org/layers/checkers)
autocomplete | autocomplete in vim | [documentation](https://spacevim.org/layers/autocomplete)
chinese | layer for chinese vimer | [documentation](https://spacevim.org/layers/chinese)
colorscheme | all colorscheme in spacevim | [documentation](https://spacevim.org/layers/colorscheme)
chat | chatting in vim | [documentation](https://spacevim.org/layers/chat)
lang#java | java development in vim | [documentation](https://spacevim.org/layers/lang/java)
lang#lisp | lisp development in vim | [documentation](https://spacevim.org/layers/lang/lisp)
lang#markdown | layer for editing markdown in vim | [documentation](https://spacevim.org/layers/lang/markdown)
lang#php | php development in vim | [documentation](https://spacevim.org/layers/lang/php)

View File

@ -0,0 +1,8 @@
if exists("b:current_syntax")
finish
endif
let b:current_syntax = "SpaceVimFlyGrep"
syntax case ignore
syn match FileName /[^:]*:\d\+:/
hi def link FileName Comment

4
test/api/web/html.vader Normal file
View File

@ -0,0 +1,4 @@
Execute (Test web#http api):
let g:test_api_web_html = SpaceVim#api#import('web#html')
let g:test_api_web_html_paser = g:test_api_web_html.parseURL('spacevim.org')
AssertEqual g:test_api_web_html_paser.child[1].child[21].child[0], 'Home - SpaceVim'

4
test/api/web/http.vader Normal file
View File

@ -0,0 +1,4 @@
Execute (Test web#http api):
let g:test_api_web_http = SpaceVim#api#import('web#http')
let g:test_api_web_http_getresult = g:test_api_web_http.get('spacevim.org')
AssertEqual g:test_api_web_http_getresult.status, '200'

4
test/test.sh Executable file
View File

@ -0,0 +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/**'