Update vital

This commit is contained in:
haya14busa 2016-03-22 23:04:08 +09:00
parent cdc77add59
commit 07e3665dbc
25 changed files with 272 additions and 44 deletions

View File

@ -9,15 +9,14 @@ let s:cache_sid = {}
let s:_unify_path_cache = {} let s:_unify_path_cache = {}
function! s:plugin_name() abort function! s:plugin_name() abort
let info_file = get(split(glob(s:base_dir . '/*.vital', 1), "\n"), 0, '') return s:self_version[1 :]
return fnamemodify(info_file, ':t:r')
endfunction endfunction
function! s:vital_files() abort function! s:vital_files() abort
if !exists('s:vital_files') if !exists('s:vital_files')
let s:vital_files = let s:vital_files =
\ map( \ map(
\ s:plugin_name() ==# 'vital' \ s:plugin_name() ==# '_latest__'
\ ? s:_global_vital_files() \ ? s:_global_vital_files()
\ : s:_self_vital_files(), \ : s:_self_vital_files(),
\ 'fnamemodify(v:val, ":p:gs?[\\\\/]?/?")') \ 'fnamemodify(v:val, ":p:gs?[\\\\/]?/?")')

View File

@ -0,0 +1,127 @@
" Utilities for dictionary.
let s:save_cpo = &cpo
set cpo&vim
" Makes a dict from keys and values
function! s:make(keys, values, ...) abort
let dict = {}
let fill = a:0 ? a:1 : 0
for i in range(len(a:keys))
let key = type(a:keys[i]) == type('') ? a:keys[i] : string(a:keys[i])
if key ==# ''
throw "vital: Data.Dict: Can't use an empty string for key."
endif
let dict[key] = get(a:values, i, fill)
endfor
return dict
endfunction
" Swaps keys and values
function! s:swap(dict) abort
return s:make(values(a:dict), keys(a:dict))
endfunction
" Makes a index dict from a list
function! s:make_index(list, ...) abort
let value = a:0 ? a:1 : 1
return s:make(a:list, [], value)
endfunction
function! s:pick(dict, keys) abort
let new_dict = {}
for key in a:keys
if has_key(a:dict, key)
let new_dict[key] = a:dict[key]
endif
endfor
return new_dict
endfunction
function! s:omit(dict, keys) abort
let new_dict = copy(a:dict)
for key in a:keys
if has_key(a:dict, key)
call remove(new_dict, key)
endif
endfor
return new_dict
endfunction
function! s:clear(dict) abort
for key in keys(a:dict)
call remove(a:dict, key)
endfor
return a:dict
endfunction
function! s:_max_by(dict, expr) abort
let dict = s:swap(map(copy(a:dict), a:expr))
let key = dict[max(keys(dict))]
return [key, a:dict[key]]
endfunction
function! s:max_by(dict, expr) abort
if empty(a:dict)
throw 'vital: Data.Dict: Empty dictionary'
endif
return s:_max_by(a:dict, a:expr)
endfunction
function! s:min_by(dict, expr) abort
if empty(a:dict)
throw 'vital: Data.Dict: Empty dictionary'
endif
return s:_max_by(a:dict, '-(' . a:expr . ')')
endfunction
function! s:_foldl(f, init, xs) abort
let memo = a:init
for [k, v] in a:xs
let expr = substitute(a:f, 'v:key', string(k), 'g')
let expr = substitute(expr, 'v:val', string(v), 'g')
let expr = substitute(expr, 'v:memo', string(memo), 'g')
unlet memo
let memo = eval(expr)
endfor
return memo
endfunction
function! s:foldl(f, init, dict) abort
return s:_foldl(a:f, a:init, items(a:dict))
endfunction
function! s:foldr(f, init, dict) abort
return s:_foldl(a:f, a:init, reverse(items(a:dict)))
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et ts=2 sts=2 sw=2 tw=0:
" ___Revitalizer___
" NOTE: below code is generated by :Revitalize.
" Do not mofidify the code nor append new lines
if v:version > 703 || v:version == 703 && has('patch1170')
function! s:___revitalizer_function___(fstr) abort
return function(a:fstr)
endfunction
else
function! s:___revitalizer_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze____revitalizer_SID$')
endfunction
let s:___revitalizer_sid = '<SNR>' . s:___revitalizer_SID() . '_'
function! s:___revitalizer_function___(fstr) abort
return function(substitute(a:fstr, 's:', s:___revitalizer_sid, 'g'))
endfunction
endif
let s:___revitalizer_functions___ = {'clear': s:___revitalizer_function___('s:clear'),'foldl': s:___revitalizer_function___('s:foldl'),'foldr': s:___revitalizer_function___('s:foldr'),'make': s:___revitalizer_function___('s:make'),'make_index': s:___revitalizer_function___('s:make_index'),'max_by': s:___revitalizer_function___('s:max_by'),'min_by': s:___revitalizer_function___('s:min_by'),'omit': s:___revitalizer_function___('s:omit'),'pick': s:___revitalizer_function___('s:pick'),'swap': s:___revitalizer_function___('s:swap')}
unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___
function! vital#_easymotion#Data#Dict#import() abort
return s:___revitalizer_functions___
endfunction
" ___Revitalizer___

View File

@ -457,7 +457,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'flatten': s:___revitalizer_function___('s:flatten'),'find_indices': s:___revitalizer_function___('s:find_indices'),'sort_by': s:___revitalizer_function___('s:sort_by'),'foldr1': s:___revitalizer_function___('s:foldr1'),'sort': s:___revitalizer_function___('s:sort'),'combinations': s:___revitalizer_function___('s:combinations'),'has_index': s:___revitalizer_function___('s:has_index'),'and': s:___revitalizer_function___('s:and'),'any': s:___revitalizer_function___('s:any'),'unshift': s:___revitalizer_function___('s:unshift'),'span': s:___revitalizer_function___('s:span'),'pop': s:___revitalizer_function___('s:pop'),'binary_search': s:___revitalizer_function___('s:binary_search'),'uniq_by': s:___revitalizer_function___('s:uniq_by'),'or': s:___revitalizer_function___('s:or'),'all': s:___revitalizer_function___('s:all'),'zip': s:___revitalizer_function___('s:zip'),'find_last_index': s:___revitalizer_function___('s:find_last_index'),'find': s:___revitalizer_function___('s:find'),'partition': s:___revitalizer_function___('s:partition'),'shift': s:___revitalizer_function___('s:shift'),'permutations': s:___revitalizer_function___('s:permutations'),'break': s:___revitalizer_function___('s:break'),'max_by': s:___revitalizer_function___('s:max_by'),'foldl': s:___revitalizer_function___('s:foldl'),'foldr': s:___revitalizer_function___('s:foldr'),'find_index': s:___revitalizer_function___('s:find_index'),'with_index': s:___revitalizer_function___('s:with_index'),'take_while': s:___revitalizer_function___('s:take_while'),'conj': s:___revitalizer_function___('s:conj'),'push': s:___revitalizer_function___('s:push'),'char_range': s:___revitalizer_function___('s:char_range'),'cons': s:___revitalizer_function___('s:cons'),'foldl1': s:___revitalizer_function___('s:foldl1'),'intersect': s:___revitalizer_function___('s:intersect'),'concat': s:___revitalizer_function___('s:concat'),'map_accum': s:___revitalizer_function___('s:map_accum'),'clear': s:___revitalizer_function___('s:clear'),'has_common_items': s:___revitalizer_function___('s:has_common_items'),'product': s:___revitalizer_function___('s:product'),'zip_fill': s:___revitalizer_function___('s:zip_fill'),'group_by': s:___revitalizer_function___('s:group_by'),'uniq': s:___revitalizer_function___('s:uniq'),'has': s:___revitalizer_function___('s:has'),'min_by': s:___revitalizer_function___('s:min_by')} let s:___revitalizer_functions___ = {'all': s:___revitalizer_function___('s:all'),'and': s:___revitalizer_function___('s:and'),'any': s:___revitalizer_function___('s:any'),'binary_search': s:___revitalizer_function___('s:binary_search'),'break': s:___revitalizer_function___('s:break'),'char_range': s:___revitalizer_function___('s:char_range'),'clear': s:___revitalizer_function___('s:clear'),'combinations': s:___revitalizer_function___('s:combinations'),'concat': s:___revitalizer_function___('s:concat'),'conj': s:___revitalizer_function___('s:conj'),'cons': s:___revitalizer_function___('s:cons'),'find': s:___revitalizer_function___('s:find'),'find_index': s:___revitalizer_function___('s:find_index'),'find_indices': s:___revitalizer_function___('s:find_indices'),'find_last_index': s:___revitalizer_function___('s:find_last_index'),'flatten': s:___revitalizer_function___('s:flatten'),'foldl': s:___revitalizer_function___('s:foldl'),'foldl1': s:___revitalizer_function___('s:foldl1'),'foldr': s:___revitalizer_function___('s:foldr'),'foldr1': s:___revitalizer_function___('s:foldr1'),'group_by': s:___revitalizer_function___('s:group_by'),'has': s:___revitalizer_function___('s:has'),'has_common_items': s:___revitalizer_function___('s:has_common_items'),'has_index': s:___revitalizer_function___('s:has_index'),'intersect': s:___revitalizer_function___('s:intersect'),'map_accum': s:___revitalizer_function___('s:map_accum'),'max_by': s:___revitalizer_function___('s:max_by'),'min_by': s:___revitalizer_function___('s:min_by'),'or': s:___revitalizer_function___('s:or'),'partition': s:___revitalizer_function___('s:partition'),'permutations': s:___revitalizer_function___('s:permutations'),'pop': s:___revitalizer_function___('s:pop'),'product': s:___revitalizer_function___('s:product'),'push': s:___revitalizer_function___('s:push'),'shift': s:___revitalizer_function___('s:shift'),'sort': s:___revitalizer_function___('s:sort'),'sort_by': s:___revitalizer_function___('s:sort_by'),'span': s:___revitalizer_function___('s:span'),'take_while': s:___revitalizer_function___('s:take_while'),'uniq': s:___revitalizer_function___('s:uniq'),'uniq_by': s:___revitalizer_function___('s:uniq_by'),'unshift': s:___revitalizer_function___('s:unshift'),'with_index': s:___revitalizer_function___('s:with_index'),'zip': s:___revitalizer_function___('s:zip'),'zip_fill': s:___revitalizer_function___('s:zip_fill')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -284,7 +284,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'set': s:___revitalizer_function___('s:set'),'frozenset': s:___revitalizer_function___('s:frozenset')} let s:___revitalizer_functions___ = {'frozenset': s:___revitalizer_function___('s:frozenset'),'set': s:___revitalizer_function___('s:set')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -126,7 +126,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'create': s:___revitalizer_function___('s:create'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded')} let s:___revitalizer_functions___ = {'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'create': s:___revitalizer_function___('s:create')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -72,7 +72,7 @@ let s:overwin = {
\ 'cursor': 'HitAHintCursor', \ 'cursor': 'HitAHintCursor',
\ }, \ },
\ 'jump_first_target_keys': [], \ 'jump_first_target_keys': [],
\ 'do_shade': s:TRUE, \ 'do_shade': s:FALSE,
\ } \ }
\ } \ }
@ -539,11 +539,10 @@ function! s:Hinter._show_hint_for_line(winnr, lnum, col2hint) abort
let is_consecutive = cnum is# prev_cnum + 1 let is_consecutive = cnum is# prev_cnum + 1
if !is_consecutive if !is_consecutive
let col_num += next_offset let col_num += next_offset
else
let save_next_offset = next_offset
endif endif
let save_next_offset = next_offset
let [line, offset, next_offset] = self._replace_line_for_hint(a:lnum, col_num, line, hint) let [line, offset, next_offset] = self._replace_line_for_hint(col_num, line, hint)
if is_consecutive if is_consecutive
let col_offset += save_next_offset let col_offset += save_next_offset
@ -570,7 +569,7 @@ endfunction
" depends on the col number of next hint in the same line, so it returns " depends on the col number of next hint in the same line, so it returns
" `next_offset` instead of returning offset all at once. " `next_offset` instead of returning offset all at once.
" @return {(string, number, number)} (line, offset, next_offset) " @return {(string, number, number)} (line, offset, next_offset)
function! s:Hinter._replace_line_for_hint(lnum, col_num, line, hint) abort function! s:Hinter._replace_line_for_hint(col_num, line, hint) abort
let line = a:line let line = a:line
let col_num = a:col_num let col_num = a:col_num
let do_replace_target = !(self.config.do_shade || s:can_preserve_syntax) let do_replace_target = !(self.config.do_shade || s:can_preserve_syntax)
@ -585,9 +584,9 @@ function! s:Hinter._replace_line_for_hint(lnum, col_num, line, hint) abort
let offset = 0 let offset = 0
if target is# "\t" if target is# "\t"
let [line, offset] = self._replace_tab_target(a:lnum, col_num, line) let [line, offset] = self._replace_tab_target(col_num, line)
elseif strdisplaywidth(target) > 1 elseif strdisplaywidth(target) > 1
let line = self._replace_text_to_space(line, a:lnum, col_num, strdisplaywidth(target)) let line = self._replace_text_to_space(line, col_num, strdisplaywidth(target))
let offset = strdisplaywidth(target) - len(target) let offset = strdisplaywidth(target) - len(target)
else else
if do_replace_target if do_replace_target
@ -602,19 +601,19 @@ function! s:Hinter._replace_line_for_hint(lnum, col_num, line, hint) abort
let next_offset = 0 let next_offset = 0
if len(a:hint) > 1 && target isnot# "\t" if len(a:hint) > 1 && target isnot# "\t"
" pass [' '] as hint to stop recursion. " pass [' '] as hint to stop recursion.
let [line, next_offset, _] = self._replace_line_for_hint(a:lnum, col_num + offset + 1, line, [' ']) let [line, next_offset, _] = self._replace_line_for_hint(col_num + offset + 1, line, [' '])
endif endif
return [line, offset, next_offset] return [line, offset, next_offset]
endfunction endfunction
" @return {(line, offset)} " @return {(line, offset)}
function! s:Hinter._replace_tab_target(lnum, col_num, line) abort function! s:Hinter._replace_tab_target(col_num, line) abort
let space_len = s:tab2spacelen(a:line, a:col_num) let space_len = s:tab2spacelen(a:line, a:col_num)
let line = self._replace_text_to_space(a:line, a:lnum, a:col_num, space_len) let line = self._replace_text_to_space(a:line, a:col_num, space_len)
return [line, space_len - 1] return [line, space_len - 1]
endfunction endfunction
function! s:Hinter._replace_text_to_space(line, lnum, col_num, len) abort function! s:Hinter._replace_text_to_space(line, col_num, len) abort
let target = printf('\%%%dc.', a:col_num) let target = printf('\%%%dc.', a:col_num)
let line = substitute(a:line, target, repeat(' ', a:len), '') let line = substitute(a:line, target, repeat(' ', a:len), '')
return line return line
@ -807,7 +806,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'gather_visible_matched_poses': s:___revitalizer_function___('s:gather_visible_matched_poses'),'gather_poses': s:___revitalizer_function___('s:gather_poses'),'win2pos2hint_to_w2l2c2h': s:___revitalizer_function___('s:win2pos2hint_to_w2l2c2h'),'move_f': s:___revitalizer_function___('s:move_f'),'setline': s:___revitalizer_function___('s:setline'),'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'wincall': s:___revitalizer_function___('s:wincall'),'move': s:___revitalizer_function___('s:move'),'move_to_winpos': s:___revitalizer_function___('s:move_to_winpos'),'pos2hint_to_line2col2hint': s:___revitalizer_function___('s:pos2hint_to_line2col2hint'),'deepextend': s:___revitalizer_function___('s:deepextend'),'move_to_win': s:___revitalizer_function___('s:move_to_win'),'throw': s:___revitalizer_function___('s:throw'),'poskey2pos': s:___revitalizer_function___('s:poskey2pos'),'tab2spacelen': s:___revitalizer_function___('s:tab2spacelen'),'move_f2': s:___revitalizer_function___('s:move_f2'),'new_overwin': s:___revitalizer_function___('s:new_overwin'),'create_win2pos2hint': s:___revitalizer_function___('s:create_win2pos2hint'),'pos2poskey': s:___revitalizer_function___('s:pos2poskey'),'winnr2poses_to_list': s:___revitalizer_function___('s:winnr2poses_to_list'),'has_patch': s:___revitalizer_function___('s:has_patch'),'is_in_fold': s:___revitalizer_function___('s:is_in_fold'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded')} let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'create_win2pos2hint': s:___revitalizer_function___('s:create_win2pos2hint'),'deepextend': s:___revitalizer_function___('s:deepextend'),'gather_poses': s:___revitalizer_function___('s:gather_poses'),'gather_visible_matched_poses': s:___revitalizer_function___('s:gather_visible_matched_poses'),'has_patch': s:___revitalizer_function___('s:has_patch'),'is_in_fold': s:___revitalizer_function___('s:is_in_fold'),'move': s:___revitalizer_function___('s:move'),'move_f': s:___revitalizer_function___('s:move_f'),'move_f2': s:___revitalizer_function___('s:move_f2'),'move_to_win': s:___revitalizer_function___('s:move_to_win'),'move_to_winpos': s:___revitalizer_function___('s:move_to_winpos'),'new_overwin': s:___revitalizer_function___('s:new_overwin'),'pos2hint_to_line2col2hint': s:___revitalizer_function___('s:pos2hint_to_line2col2hint'),'pos2poskey': s:___revitalizer_function___('s:pos2poskey'),'poskey2pos': s:___revitalizer_function___('s:poskey2pos'),'setline': s:___revitalizer_function___('s:setline'),'tab2spacelen': s:___revitalizer_function___('s:tab2spacelen'),'throw': s:___revitalizer_function___('s:throw'),'win2pos2hint_to_w2l2c2h': s:___revitalizer_function___('s:win2pos2hint_to_w2l2c2h'),'wincall': s:___revitalizer_function___('s:wincall'),'winnr2poses_to_list': s:___revitalizer_function___('s:winnr2poses_to_list')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -606,7 +606,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'make_plain': s:___revitalizer_function___('s:make_plain'),'is_input_waiting': s:___revitalizer_function___('s:is_input_waiting'),'make': s:___revitalizer_function___('s:make'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded')} let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'is_input_waiting': s:___revitalizer_function___('s:is_input_waiting'),'make': s:___revitalizer_function___('s:make'),'make_plain': s:___revitalizer_function___('s:make_plain')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -42,7 +42,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'get': s:___revitalizer_function___('s:get'),'make': s:___revitalizer_function___('s:make'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded')} let s:___revitalizer_functions___ = {'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'get': s:___revitalizer_function___('s:get'),'make': s:___revitalizer_function___('s:make')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -121,7 +121,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'doautocmd_user': s:___revitalizer_function___('s:doautocmd_user'),'get_cmdline': s:___revitalizer_function___('s:get_cmdline'),'make': s:___revitalizer_function___('s:make'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded')} let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'doautocmd_user': s:___revitalizer_function___('s:doautocmd_user'),'get_cmdline': s:___revitalizer_function___('s:get_cmdline'),'make': s:___revitalizer_function___('s:make')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -155,7 +155,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'suffix': s:___revitalizer_function___('s:suffix'),'make': s:___revitalizer_function___('s:make')} let s:___revitalizer_functions___ = {'make': s:___revitalizer_function___('s:make'),'suffix': s:___revitalizer_function___('s:suffix')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -164,7 +164,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'to_string': s:___revitalizer_function___('s:to_string'),'input': s:___revitalizer_function___('s:input'),'get_cmdline_cword': s:___revitalizer_function___('s:get_cmdline_cword'),'make': s:___revitalizer_function___('s:make'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded')} let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'get_cmdline_cword': s:___revitalizer_function___('s:get_cmdline_cword'),'input': s:___revitalizer_function___('s:input'),'make': s:___revitalizer_function___('s:make'),'to_string': s:___revitalizer_function___('s:to_string')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -139,7 +139,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'make_emacs': s:___revitalizer_function___('s:make_emacs'),'make_vim_cmdline_mapping': s:___revitalizer_function___('s:make_vim_cmdline_mapping'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded')} let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'make_emacs': s:___revitalizer_function___('s:make_emacs'),'make_vim_cmdline_mapping': s:___revitalizer_function___('s:make_vim_cmdline_mapping')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -55,7 +55,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'make_special_chars': s:___revitalizer_function___('s:make_special_chars'),'make': s:___revitalizer_function___('s:make')} let s:___revitalizer_functions___ = {'make': s:___revitalizer_function___('s:make'),'make_special_chars': s:___revitalizer_function___('s:make_special_chars')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -46,7 +46,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'throw': s:___revitalizer_function___('s:throw'),'throw_cmd': s:___revitalizer_function___('s:throw_cmd'),'set_prefix': s:___revitalizer_function___('s:set_prefix'),'error': s:___revitalizer_function___('s:error')} let s:___revitalizer_functions___ = {'error': s:___revitalizer_function___('s:error'),'set_prefix': s:___revitalizer_function___('s:set_prefix'),'throw': s:___revitalizer_function___('s:throw'),'throw_cmd': s:___revitalizer_function___('s:throw_cmd')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -95,7 +95,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'unmapping': s:___revitalizer_function___('s:unmapping'),'as_key_config': s:___revitalizer_function___('s:as_key_config'),'match_key': s:___revitalizer_function___('s:match_key'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded')} let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'as_key_config': s:___revitalizer_function___('s:as_key_config'),'match_key': s:___revitalizer_function___('s:match_key'),'unmapping': s:___revitalizer_function___('s:unmapping')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -119,7 +119,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'call': s:___revitalizer_function___('s:call'),'make': s:___revitalizer_function___('s:make'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded')} let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'call': s:___revitalizer_function___('s:call'),'make': s:___revitalizer_function___('s:make')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -164,7 +164,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'length': s:___revitalizer_function___('s:length'),'index': s:___revitalizer_function___('s:index'),'split_by_keys': s:___revitalizer_function___('s:split_by_keys'),'make': s:___revitalizer_function___('s:make'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded')} let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'index': s:___revitalizer_function___('s:index'),'length': s:___revitalizer_function___('s:length'),'make': s:___revitalizer_function___('s:make'),'split_by_keys': s:___revitalizer_function___('s:split_by_keys')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -74,7 +74,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'extend': s:___revitalizer_function___('s:extend'),'command': s:___revitalizer_function___('s:command')} let s:___revitalizer_functions___ = {'command': s:___revitalizer_function___('s:command'),'extend': s:___revitalizer_function___('s:extend')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -133,7 +133,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'capture': s:___revitalizer_function___('s:capture'),'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'parse': s:___revitalizer_function___('s:parse'),'group_list': s:___revitalizer_function___('s:group_list'),'set': s:___revitalizer_function___('s:set'),'parse_to_name': s:___revitalizer_function___('s:parse_to_name'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'get': s:___revitalizer_function___('s:get'),'links_to': s:___revitalizer_function___('s:links_to')} let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'capture': s:___revitalizer_function___('s:capture'),'get': s:___revitalizer_function___('s:get'),'group_list': s:___revitalizer_function___('s:group_list'),'links_to': s:___revitalizer_function___('s:links_to'),'parse': s:___revitalizer_function___('s:parse'),'parse_to_name': s:___revitalizer_function___('s:parse_to_name'),'set': s:___revitalizer_function___('s:set')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -121,7 +121,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'parse_lhs_list': s:___revitalizer_function___('s:parse_lhs_list'),'escape_special_key': s:___revitalizer_function___('s:escape_special_key'),'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'capture': s:___revitalizer_function___('s:capture'),'lhs_key_list': s:___revitalizer_function___('s:lhs_key_list'),'capture_list': s:___revitalizer_function___('s:capture_list'),'rhs_key_list': s:___revitalizer_function___('s:rhs_key_list'),'parse_lhs': s:___revitalizer_function___('s:parse_lhs'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded')} let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'capture': s:___revitalizer_function___('s:capture'),'capture_list': s:___revitalizer_function___('s:capture_list'),'escape_special_key': s:___revitalizer_function___('s:escape_special_key'),'lhs_key_list': s:___revitalizer_function___('s:lhs_key_list'),'parse_lhs': s:___revitalizer_function___('s:parse_lhs'),'parse_lhs_list': s:___revitalizer_function___('s:parse_lhs_list'),'rhs_key_list': s:___revitalizer_function___('s:rhs_key_list')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -400,7 +400,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'escape_pattern': s:___revitalizer_function___('s:escape_pattern'),'is_funcref': s:___revitalizer_function___('s:is_funcref'),'path2directory': s:___revitalizer_function___('s:path2directory'),'strwidthpart_reverse': s:___revitalizer_function___('s:strwidthpart_reverse'),'wcswidth': s:___revitalizer_function___('s:wcswidth'),'is_string': s:___revitalizer_function___('s:is_string'),'input_helper': s:___revitalizer_function___('s:input_helper'),'is_number': s:___revitalizer_function___('s:is_number'),'is_cygwin': s:___revitalizer_function___('s:is_cygwin'),'path2project_directory': s:___revitalizer_function___('s:path2project_directory'),'input_safe': s:___revitalizer_function___('s:input_safe'),'escape_file_searching': s:___revitalizer_function___('s:escape_file_searching'),'set_default': s:___revitalizer_function___('s:set_default'),'truncate_skipping': s:___revitalizer_function___('s:truncate_skipping'),'glob': s:___revitalizer_function___('s:glob'),'truncate': s:___revitalizer_function___('s:truncate'),'is_dict': s:___revitalizer_function___('s:is_dict'),'strwidthpart': s:___revitalizer_function___('s:strwidthpart'),'is_numeric': s:___revitalizer_function___('s:is_numeric'),'getchar_safe': s:___revitalizer_function___('s:getchar_safe'),'is_list': s:___revitalizer_function___('s:is_list'),'is_mac': s:___revitalizer_function___('s:is_mac'),'substitute_path_separator': s:___revitalizer_function___('s:substitute_path_separator'),'getchar': s:___revitalizer_function___('s:getchar'),'is_unix': s:___revitalizer_function___('s:is_unix'),'is_windows': s:___revitalizer_function___('s:is_windows'),'globpath': s:___revitalizer_function___('s:globpath'),'smart_execute_command': s:___revitalizer_function___('s:smart_execute_command'),'is_float': s:___revitalizer_function___('s:is_float')} let s:___revitalizer_functions___ = {'escape_file_searching': s:___revitalizer_function___('s:escape_file_searching'),'escape_pattern': s:___revitalizer_function___('s:escape_pattern'),'getchar': s:___revitalizer_function___('s:getchar'),'getchar_safe': s:___revitalizer_function___('s:getchar_safe'),'glob': s:___revitalizer_function___('s:glob'),'globpath': s:___revitalizer_function___('s:globpath'),'input_helper': s:___revitalizer_function___('s:input_helper'),'input_safe': s:___revitalizer_function___('s:input_safe'),'is_cygwin': s:___revitalizer_function___('s:is_cygwin'),'is_dict': s:___revitalizer_function___('s:is_dict'),'is_float': s:___revitalizer_function___('s:is_float'),'is_funcref': s:___revitalizer_function___('s:is_funcref'),'is_list': s:___revitalizer_function___('s:is_list'),'is_mac': s:___revitalizer_function___('s:is_mac'),'is_number': s:___revitalizer_function___('s:is_number'),'is_numeric': s:___revitalizer_function___('s:is_numeric'),'is_string': s:___revitalizer_function___('s:is_string'),'is_unix': s:___revitalizer_function___('s:is_unix'),'is_windows': s:___revitalizer_function___('s:is_windows'),'path2directory': s:___revitalizer_function___('s:path2directory'),'path2project_directory': s:___revitalizer_function___('s:path2project_directory'),'set_default': s:___revitalizer_function___('s:set_default'),'smart_execute_command': s:___revitalizer_function___('s:smart_execute_command'),'strwidthpart': s:___revitalizer_function___('s:strwidthpart'),'strwidthpart_reverse': s:___revitalizer_function___('s:strwidthpart_reverse'),'substitute_path_separator': s:___revitalizer_function___('s:substitute_path_separator'),'truncate': s:___revitalizer_function___('s:truncate'),'truncate_skipping': s:___revitalizer_function___('s:truncate_skipping'),'wcswidth': s:___revitalizer_function___('s:wcswidth')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -160,7 +160,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'read_content': s:___revitalizer_function___('s:read_content'),'get_selected_text': s:___revitalizer_function___('s:get_selected_text'),'is_cmdwin': s:___revitalizer_function___('s:is_cmdwin'),'edit_content': s:___revitalizer_function___('s:edit_content'),'open': s:___revitalizer_function___('s:open'),'get_last_selected': s:___revitalizer_function___('s:get_last_selected'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded')} let s:___revitalizer_functions___ = {'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'edit_content': s:___revitalizer_function___('s:edit_content'),'get_last_selected': s:___revitalizer_function___('s:get_last_selected'),'get_selected_text': s:___revitalizer_function___('s:get_selected_text'),'is_cmdwin': s:___revitalizer_function___('s:is_cmdwin'),'open': s:___revitalizer_function___('s:open'),'read_content': s:___revitalizer_function___('s:read_content')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -1,18 +1,31 @@
let s:save_cpo = &cpo let s:save_cpo = &cpo
set cpo&vim set cpo&vim
" Use a Funcref as a special term UNDEFINED " Use a Funcref as a special term _UNDEFINED
function! s:undefined() abort function! s:undefined() abort
return 'undefined' return 'undefined'
endfunction endfunction
let s:UNDEFINED = function('s:undefined') let s:_UNDEFINED = function('s:undefined')
function! s:_vital_loaded(V) abort
let s:V = a:V
let s:Prelude = s:V.import('Prelude')
let s:List = s:V.import('Data.List')
let s:Dict = s:V.import('Data.Dict')
endfunction
function! s:_vital_depends() abort
return ['Prelude', 'Data.List', 'Data.Dict']
endfunction
function! s:_vital_created(module) abort function! s:_vital_created(module) abort
" define constant variables " define constant variables
if !exists('s:const') if !exists('s:const')
let s:const = {} let s:const = {}
let s:const.is_local_variable_supported = let s:const.is_local_variable_supported =
\ v:version > 703 || (v:version == 703 && has('patch560')) \ v:version > 703 || (v:version == 703 && has('patch560'))
" NOTE:
" The third argument is available from 7.4.242 but it had bug and that
" bug was fixed from 7.4.513
let s:const.is_third_argument_of_getreg_supported = has('patch-7.4.513')
lockvar s:const lockvar s:const
endif endif
call extend(a:module, s:const) call extend(a:module, s:const)
@ -41,6 +54,60 @@ function! s:option.restore() abort
execute printf('let %s = %s', self.name, string(self.value)) execute printf('let %s = %s', self.name, string(self.value))
endfunction endfunction
let s:register = {}
function! s:_new_register(name) abort
if len(a:name) != 2
call s:_throw(printf(
\'A register name "%s" requires to be "@" + a single character', a:name
\))
elseif a:name !~# '^@'
call s:_throw(printf(
\'A register name "%s" requires to be started from "@"', a:name
\))
elseif a:name =~# '^@[:.%]$'
call s:_throw(printf(
\'A register name "%s" is read only', a:name
\))
elseif a:name !~# '^@[@0-9a-zA-Z#=*+~_/-]$'
call s:_throw(printf(
\'A register name "%s" does not exist. See ":help let-register"', a:name
\))
endif
let name = a:name ==# '@@' ? '' : a:name[1]
let register = copy(s:register)
let register.name = name
if s:const.is_third_argument_of_getreg_supported
let register.value = getreg(name, 1, 1)
else
let register.value = getreg(name, 1)
endif
let register.type = getregtype(name)
return register
endfunction
function! s:register.restore() abort
call setreg(self.name, self.value, self.type)
endfunction
let s:environment = {}
function! s:_new_environment(name) abort
if a:name !~# '^\$'
call s:_throw(printf(
\'An environment variable name "%s" requires to be started from "$"', a:name
\))
elseif !exists(a:name)
call s:_throw(printf(
\'An environment variable name "%s" does not exist. While Vim cannot unlet environment variable, it requires to exist', a:name
\))
endif
let environment = copy(s:environment)
let environment.name = a:name
let environment.value = eval(a:name)
return environment
endfunction
function! s:environment.restore() abort
execute printf('let %s = %s', self.name, string(self.value))
endfunction
let s:variable = {} let s:variable = {}
function! s:_new_variable(name, ...) abort function! s:_new_variable(name, ...) abort
if a:0 == 0 if a:0 == 0
@ -62,7 +129,7 @@ function! s:_new_variable(name, ...) abort
endif endif
let variable = copy(s:variable) let variable = copy(s:variable)
let variable.name = name let variable.name = name
let variable.value = get(namespace, name, s:UNDEFINED) let variable.value = get(namespace, name, s:_UNDEFINED)
let variable.value = let variable.value =
\ type(variable.value) == type({}) || type(variable.value) == type([]) \ type(variable.value) == type({}) || type(variable.value) == type([])
\ ? deepcopy(variable.value) \ ? deepcopy(variable.value)
@ -73,19 +140,51 @@ endfunction
function! s:variable.restore() abort function! s:variable.restore() abort
" unlet the variable to prevent variable type mis-match in case " unlet the variable to prevent variable type mis-match in case
silent! unlet! self._namespace[self.name] silent! unlet! self._namespace[self.name]
if type(self.value) == type(s:UNDEFINED) && self.value == s:UNDEFINED if type(self.value) == type(s:_UNDEFINED) && self.value == s:_UNDEFINED
" do nothing, leave the variable as undefined " do nothing, leave the variable as undefined
else else
let self._namespace[self.name] = self.value let self._namespace[self.name] = self.value
endif endif
endfunction endfunction
let s:instance = {}
function! s:_new_instance(instance, ...) abort
let shallow = get(a:000, 0, 0)
if !s:Prelude.is_list(a:instance) && !s:Prelude.is_dict(a:instance)
call s:_throw(printf(
\'An instance "%s" requires to be List or Dictionary', string(a:instance)
\))
endif
let instance = copy(s:instance)
let instance.instance = a:instance
let instance.values = shallow ? copy(a:instance) : deepcopy(a:instance)
return instance
endfunction
function! s:instance.restore() abort
if s:Prelude.is_list(self.instance)
call s:List.clear(self.instance)
else
call s:Dict.clear(self.instance)
endif
call extend(self.instance, self.values)
endfunction
let s:guard = {} let s:guard = {}
function! s:store(...) abort function! s:store(...) abort
let resources = [] let resources = []
for meta in a:000 for meta in a:000
if type(meta) == type([]) if s:Prelude.is_list(meta)
call add(resources, call('s:_new_variable', meta)) if len(meta) == 1
call add(resources, s:_new_instance(meta[0]))
elseif len(meta) == 2
if s:Prelude.is_string(meta[0])
call add(resources, call('s:_new_variable', meta))
else
call add(resources, call('s:_new_instance', meta))
endif
else
call s:_throw('List assignment requires one or two elements')
endif
elseif type(meta) == type('') elseif type(meta) == type('')
if meta =~# '^[bwtgls]:' if meta =~# '^[bwtgls]:'
" Note: " Note:
@ -93,9 +192,13 @@ function! s:store(...) abort
call add(resources, s:_new_variable(meta)) call add(resources, s:_new_variable(meta))
elseif meta =~# '^&' elseif meta =~# '^&'
call add(resources, s:_new_option(meta)) call add(resources, s:_new_option(meta))
elseif meta =~# '^@'
call add(resources, s:_new_register(meta))
elseif meta =~# '^\$'
call add(resources, s:_new_environment(meta))
else else
call s:_throw(printf( call s:_throw(printf(
\ 'Unknown option or variable "%s" was specified', \ 'Unknown value "%s" was specified',
\ meta \ meta
\)) \))
endif endif
@ -132,7 +235,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'undefined': s:___revitalizer_function___('s:undefined'),'_vital_created': s:___revitalizer_function___('s:_vital_created'),'store': s:___revitalizer_function___('s:store')} let s:___revitalizer_functions___ = {'_vital_created': s:___revitalizer_function___('s:_vital_created'),'_vital_depends': s:___revitalizer_function___('s:_vital_depends'),'_vital_loaded': s:___revitalizer_function___('s:_vital_loaded'),'store': s:___revitalizer_function___('s:store'),'undefined': s:___revitalizer_function___('s:undefined')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -80,7 +80,7 @@ else
endfunction endfunction
endif endif
let s:___revitalizer_functions___ = {'capture': s:___revitalizer_function___('s:capture'),'echomsg': s:___revitalizer_function___('s:echomsg'),'echo': s:___revitalizer_function___('s:echo'),'warn': s:___revitalizer_function___('s:warn'),'get_hit_enter_max_length': s:___revitalizer_function___('s:get_hit_enter_max_length'),'error': s:___revitalizer_function___('s:error')} let s:___revitalizer_functions___ = {'capture': s:___revitalizer_function___('s:capture'),'echo': s:___revitalizer_function___('s:echo'),'echomsg': s:___revitalizer_function___('s:echomsg'),'error': s:___revitalizer_function___('s:error'),'get_hit_enter_max_length': s:___revitalizer_function___('s:get_hit_enter_max_length'),'warn': s:___revitalizer_function___('s:warn')}
unlet! s:___revitalizer_sid unlet! s:___revitalizer_sid
delfunction s:___revitalizer_function___ delfunction s:___revitalizer_function___

View File

@ -1,5 +1,5 @@
easymotion easymotion
e083c2e654d057a09b3e18dfbb728b41de89f4a1 d461a07c1453747ed867b75ed6cbeccb3eb17312
Over.Commandline.Base Over.Commandline.Base
Over.Commandline.Modules.Cancel Over.Commandline.Modules.Cancel