Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
Update vital
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdalisue committed Feb 18, 2020
1 parent 884cdf6 commit dd5340e
Show file tree
Hide file tree
Showing 17 changed files with 86 additions and 185 deletions.
9 changes: 1 addition & 8 deletions autoload/vital/_gina/App/Emitter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_gina#App#Emitter#import() abort', printf("return map({'subscribe': '', 'unsubscribe': '', 'emit': '', '_vital_healthcheck': '', 'remove_middleware': '', 'add_middleware': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
execute join(['function! vital#_gina#App#Emitter#import() abort', printf("return map({'subscribe': '', 'unsubscribe': '', 'emit': '', 'add_middleware': '', 'remove_middleware': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
let s:listeners = {}
let s:middlewares = []

function! s:_vital_healthcheck() abort
if (!has('nvim') && v:version >= 800) || has('nvim-0.2.0')
return
endif
return 'This module requires Vim 8.0.0000 or Neovim 0.2.0'
endfunction

function! s:subscribe(name, listener, ...) abort
let dict = get(a:000, 0, v:null)
let s:listeners[a:name] = get(s:listeners, a:name, [])
Expand Down
9 changes: 1 addition & 8 deletions autoload/vital/_gina/App/Revelator.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_gina#App#Revelator#import() abort', printf("return map({'info': '', '_vital_depends': '', 'unregister': '', '_vital_created': '', 'register': '', 'call': '', 'message': '', '_vital_healthcheck': '', 'critical': '', 'get_default_receiver': '', 'warning': '', 'error': '', '_vital_loaded': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
execute join(['function! vital#_gina#App#Revelator#import() abort', printf("return map({'info': '', '_vital_depends': '', 'unregister': '', '_vital_created': '', 'register': '', 'call': '', 'message': '', 'warning': '', 'critical': '', 'get_default_receiver': '', 'error': '', '_vital_loaded': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
let s:t_number = type(0)
let s:receivers = []


function! s:_vital_healthcheck() abort
if (!has('nvim') && v:version >= 800) || has('nvim-0.2.0')
return
endif
return 'This module requires Vim 8.0.0000 or Neovim 0.2.0'
endfunction

function! s:_vital_loaded(V) abort
let s:Console = a:V.import('Vim.Console')
endfunction
Expand Down
4 changes: 1 addition & 3 deletions autoload/vital/_gina/Bitwise.vim
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ if has('num64')
" NOTE:
" An int literal larger than or equal to 0x8000000000000000 will be rounded
" to 0x7FFFFFFFFFFFFFFF after Vim 8.0.0219, so create it without literal
let s:xFFFFFFFF00000000 = has('patch-8.0.0219')
\ ? 0xFFFFFFFF * s:pow2[and(32, s:mask)]
\ : 0xFFFFFFFF00000000
let s:xFFFFFFFF00000000 = 0xFFFFFFFF * s:pow2[and(32, s:mask)]
function! s:sign_extension(n) abort
if and(a:n, 0x80000000)
return or(a:n, s:xFFFFFFFF00000000)
Expand Down
9 changes: 1 addition & 8 deletions autoload/vital/_gina/Config.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_gina#Config#import() abort', printf("return map({'define': '', 'translate': '', '_vital_healthcheck': '', 'config': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
execute join(['function! vital#_gina#Config#import() abort', printf("return map({'define': '', 'translate': '', 'config': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
let s:plugin_name = expand('<sfile>:p:h:t')
Expand All @@ -14,13 +14,6 @@ let s:plugin_name = s:plugin_name =~# '^__.\+__$'
\ ? s:plugin_name[1:]
\ : s:plugin_name

function! s:_vital_healthcheck() abort
if (!has('nvim') && v:version >= 800) || has('nvim-0.2.0')
return
endif
return 'This module requires Vim 8.0.0000 or Neovim 0.2.0'
endfunction

function! s:define(prefix, default) abort
let prefix = a:prefix =~# '^g:' ? a:prefix : 'g:' . a:prefix
for [key, Value] in items(a:default)
Expand Down
13 changes: 12 additions & 1 deletion autoload/vital/_gina/Data/List.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_gina#Data#List#import() abort', printf("return map({'combinations': '', 'and': '', 'sort_by': '', 'foldr1': '', 'sort': '', 'flatten': '', 'has_index': '', 'filter': '', 'find_indices': '', 'any': '', 'map': '', 'unshift': '', 'span': '', 'pop': '', 'binary_search': '', 'uniq_by': '', 'or': '', 'all': '', 'zip': '', 'find_last_index': '', 'find': '', 'partition': '', 'shift': '', 'permutations': '', 'break': '', 'max_by': '', 'foldl': '', 'foldr': '', 'new': '', 'find_index': '', 'drop_while': '', 'group_by': '', 'take_while': '', 'conj': '', 'push': '', 'char_range': '', 'cons': '', 'foldl1': '', 'intersect': '', 'concat': '', 'map_accum': '', 'clear': '', 'has_common_items': '', 'product': '', 'uncons': '', 'zip_fill': '', 'uniq': '', 'has': '', 'min_by': '', 'with_index': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
execute join(['function! vital#_gina#Data#List#import() abort', printf("return map({'combinations': '', 'and': '', 'sort_by': '', 'foldr1': '', 'sort': '', 'flatten': '', 'has_index': '', 'filter': '', 'find_indices': '', 'any': '', 'map': '', 'unshift': '', 'span': '', 'pop': '', 'binary_search': '', 'uniq_by': '', 'or': '', 'all': '', 'zip': '', 'count': '', 'find_last_index': '', 'find': '', 'partition': '', 'map_accum': '', 'permutations': '', 'break': '', 'max_by': '', 'foldl': '', 'foldr': '', 'new': '', 'find_index': '', 'drop_while': '', 'group_by': '', 'take_while': '', 'conj': '', 'push': '', 'char_range': '', 'cons': '', 'foldl1': '', 'intersect': '', 'concat': '', 'shift': '', 'clear': '', 'has_common_items': '', 'product': '', 'uncons': '', 'zip_fill': '', 'uniq': '', 'has': '', 'min_by': '', 'with_index': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
" Utilities for list.
Expand Down Expand Up @@ -382,6 +382,17 @@ function! s:foldr1(f, xs) abort
return s:foldr(a:f, a:xs[-1], a:xs[0:-2])
endfunction

function! s:count(f, xs) abort
let num = 0
for x in a:xs
if a:f(x)
let num += 1
endif
endfor
return num
endfunction


" Similar to python's zip() .
function! s:zip(...) abort
return map(range(min(map(copy(a:000), 'len(v:val)'))), "map(copy(a:000), 'v:val['.v:val.']')")
Expand Down
69 changes: 27 additions & 42 deletions autoload/vital/_gina/Data/String.vim
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ endfunction

function! s:_vital_created(module) abort
" Expose script-local funcref
if exists('s:strchars')
let a:module.strchars = s:strchars
endif
if exists('s:wcswidth')
let a:module.wcswidth = s:wcswidth
endif
let a:module.strchars = function('strchars')
let a:module.wcswidth = function('strwidth')
endfunction

" Substitute a:from => a:to by string.
Expand Down Expand Up @@ -112,50 +108,41 @@ function! s:nsplit(expr, n, ...) abort
if a:n <= 1
return [expr]
endif
while 1

while len(ret) < a:n - 1
let pos = match(expr, pattern)
if pos == -1
if expr !~ pattern || keepempty
call add(ret, expr)
endif
break
elseif pos >= 0
if pos >= 0 " matched
let left = pos > 0 ? expr[:pos-1] : ''
let ml = len(matchstr(expr, pattern))
let right = expr[pos+ml :]
if pos > 0 || keepempty
call add(ret, left)
endif
let ml = len(matchstr(expr, pattern))
if pos == 0 && ml == 0
let pos = 1
endif
let expr = expr[pos+ml :]
endif
if len(expr) == 0
let expr = right
else " pos == -1 means no more matches
if expr !~ pattern || keepempty
call add(ret, expr)
endif
let expr = v:none
break
endif
if len(ret) == a:n - 1
endwhile

" node count last check
if len(ret) == a:n - 1 && type(expr) == type('')
if len(expr) > 0 || keepempty
call add(ret, expr)
break
endif
endwhile
endif
return ret
endfunction

" Returns the number of character in a:str.
" NOTE: This returns proper value
" even if a:str contains multibyte character(s).
" s:strchars(str) {{{
if exists('*strchars')
let s:strchars = function('strchars')
else
function! s:strchars(str) abort
return strlen(substitute(copy(a:str), '.', 'x', 'g'))
endfunction
endif "}}}

" Returns the bool of contains any multibyte character in s:str
function! s:contains_multibyte(str) abort "{{{
return strlen(a:str) != s:strchars(a:str)
return strlen(a:str) != strchars(a:str)
endfunction "}}}

" Remove last character from a:str.
Expand All @@ -180,14 +167,14 @@ endfunction "}}}
" FIXME don't repeat yourself
function! s:_split_by_wcswidth_once(body, x) abort
let fst = s:strwidthpart(a:body, a:x)
let snd = s:strwidthpart_reverse(a:body, s:wcswidth(a:body) - s:wcswidth(fst))
let snd = s:strwidthpart_reverse(a:body, strwidth(a:body) - strwidth(fst))
return [fst, snd]
endfunction

function! s:_split_by_wcswidth(body, x) abort
let memo = []
let body = a:body
while s:wcswidth(body) > a:x
while strwidth(body) > a:x
let [tmp, body] = s:_split_by_wcswidth_once(body, a:x)
call add(memo, tmp)
endwhile
Expand Down Expand Up @@ -461,10 +448,10 @@ function! s:truncate(str, width) abort
endif

let ret = a:str
let width = s:wcswidth(a:str)
let width = strwidth(a:str)
if width > a:width
let ret = s:strwidthpart(ret, a:width)
let width = s:wcswidth(ret)
let width = strwidth(ret)
endif

if width < a:width
Expand All @@ -475,11 +462,11 @@ function! s:truncate(str, width) abort
endfunction

function! s:truncate_skipping(str, max, footer_width, separator) abort
let width = s:wcswidth(a:str)
let width = strwidth(a:str)
if width <= a:max
let ret = a:str
else
let header_width = a:max - s:wcswidth(a:separator) - a:footer_width
let header_width = a:max - strwidth(a:separator) - a:footer_width
let ret = s:strwidthpart(a:str, header_width) . a:separator
\ . s:strwidthpart_reverse(a:str, a:footer_width)
endif
Expand All @@ -494,12 +481,10 @@ endfunction

function! s:strwidthpart_reverse(str, width) abort
let str = tr(a:str, "\t", ' ')
let vcol = s:wcswidth(str) - a:width
let vcol = strwidth(str) - a:width
return matchstr(str, '\%>' . (vcol < 0 ? 0 : vcol) . 'v.*')
endfunction

let s:wcswidth = function('strwidth')

function! s:remove_ansi_sequences(text) abort
return substitute(a:text, '\e\[\%(\%(\d\+;\)*\d\+\)\?[mK]', '', 'g')
endfunction
Expand Down
29 changes: 24 additions & 5 deletions autoload/vital/_gina/Prelude.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_gina#Prelude#import() abort', printf("return map({'escape_pattern': '', 'is_funcref': '', 'path2directory': '', 'wcswidth': '', 'is_string': '', 'input_helper': '', 'is_number': '', 'is_cygwin': '', 'path2project_directory': '', 'strwidthpart_reverse': '', 'input_safe': '', 'is_list': '', 'truncate_skipping': '', 'glob': '', 'truncate': '', 'is_dict': '', 'set_default': '', 'is_numeric': '', 'getchar_safe': '', 'substitute_path_separator': '', 'is_mac': '', 'strwidthpart': '', 'getchar': '', 'is_unix': '', 'is_windows': '', 'globpath': '', 'escape_file_searching': '', 'is_float': '', 'smart_execute_command': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
execute join(['function! vital#_gina#Prelude#import() abort', printf("return map({'escape_pattern': '', 'is_funcref': '', 'path2directory': '', 'wcswidth': '', 'is_string': '', 'input_helper': '', 'is_number': '', 'is_cygwin': '', 'path2project_directory': '', 'strwidthpart_reverse': '', 'input_safe': '', 'is_list': '', 'truncate_skipping': '', 'glob': '', 'truncate': '', 'is_dict': '', 'set_default': '', 'is_numeric': '', 'getchar_safe': '', 'substitute_path_separator': '', 'is_infinity': '', 'is_mac': '', 'strwidthpart': '', 'getchar': '', 'is_unix': '', 'is_windows': '', 'globpath': '', 'is_float': '', 'smart_execute_command': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
let s:save_cpo = &cpo
Expand Down Expand Up @@ -70,6 +70,25 @@ function! s:is_float(Value) abort
return type(a:Value) ==# s:__TYPE_FLOAT
endfunction

" Infinity
if exists('*isinf')
function! s:is_infinity(Value) abort
return isinf(a:Value)
endfunction
else
function! s:is_infinity(Value) abort
if type(a:Value) ==# s:__TYPE_FLOAT
let s = string(a:Value)
if s ==# 'inf'
return 1
elseif s ==# '-inf'
return -1
endif
endif
return 0
endfunction
endif


function! s:truncate_skipping(str, max, footer_width, separator) abort
call s:_warn_deprecated('truncate_skipping', 'Data.String.truncate_skipping')
Expand Down Expand Up @@ -185,7 +204,7 @@ function! s:smart_execute_command(action, word) abort
execute a:action . ' ' . (a:word ==# '' ? '' : '`=a:word`')
endfunction

function! s:escape_file_searching(buffer_name) abort
function! s:_escape_file_searching(buffer_name) abort
return escape(a:buffer_name, '*[]?{}, ')
endfunction

Expand Down Expand Up @@ -259,7 +278,7 @@ function! s:_path2project_directory_svn(path) abort
let search_directory = a:path
let directory = ''

let find_directory = s:escape_file_searching(search_directory)
let find_directory = s:_escape_file_searching(search_directory)
let d = finddir('.svn', find_directory . ';')
if d ==# ''
return ''
Expand All @@ -284,7 +303,7 @@ function! s:_path2project_directory_others(vcs, path) abort
let vcs = a:vcs
let search_directory = a:path

let find_directory = s:escape_file_searching(search_directory)
let find_directory = s:_escape_file_searching(search_directory)
let d = finddir(vcs, find_directory . ';')
if d ==# ''
return ''
Expand Down Expand Up @@ -316,7 +335,7 @@ function! s:path2project_directory(path, ...) abort
for d in ['build.xml', 'prj.el', '.project', 'pom.xml', 'package.json',
\ 'Makefile', 'configure', 'Rakefile', 'NAnt.build',
\ 'P4CONFIG', 'tags', 'gtags']
let d = findfile(d, s:escape_file_searching(search_directory) . ';')
let d = findfile(d, s:_escape_file_searching(search_directory) . ';')
if d !=# ''
let directory = fnamemodify(d, ':p:h')
break
Expand Down
10 changes: 1 addition & 9 deletions autoload/vital/_gina/System/Job.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_gina#System#Job#import() abort', printf("return map({'_vital_depends': '', '_vital_healthcheck': '', 'is_available': '', 'start': '', '_vital_loaded': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
execute join(['function! vital#_gina#System#Job#import() abort', printf("return map({'_vital_depends': '', 'is_available': '', 'start': '', '_vital_loaded': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
let s:t_string = type('')
Expand All @@ -25,14 +25,6 @@ function! s:_vital_depends() abort
\]
endfunction

function! s:_vital_healthcheck() abort
if has('patch-8.0.0027') || has('nvim-0.2.0')
return
endif
return 'This module requires Vim 8.0.0027 or Neovim 0.2.0'
endfunction


" Note:
" Vim does not raise E902 on Unix system even the prog is not found so use a
" custom exception instead to make the method compatible.
Expand Down
9 changes: 1 addition & 8 deletions autoload/vital/_gina/Vim/Buffer/ANSI.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,9 @@
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_gina#Vim#Buffer#ANSI#import() abort', printf("return map({'_vital_created': '', '_vital_healthcheck': '', 'define_syntax': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
execute join(['function! vital#_gina#Vim#Buffer#ANSI#import() abort', printf("return map({'_vital_created': '', 'define_syntax': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
function! s:_vital_healthcheck() abort
if (!has('nvim') && v:version >= 800) || has('nvim-0.2.0')
return
endif
return 'This module requires Vim 8.0.0000 or Neovim 0.2.0'
endfunction

function! s:_vital_created(module) abort
let s:COLORS = {
\ '\%(30\|0;30\|30;0\)': 'AnsiColor0',
Expand Down
9 changes: 1 addition & 8 deletions autoload/vital/_gina/Vim/Buffer/Group.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_gina#Vim#Buffer#Group#import() abort', printf("return map({'_vital_healthcheck': '', 'new': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
execute join(['function! vital#_gina#Vim#Buffer#Group#import() abort', printf("return map({'new': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
let s:groups = {}

function! s:_vital_healthcheck() abort
if (!has('nvim') && v:version >= 800) || has('nvim-0.2.0')
return
endif
return 'This module requires Vim 8.0.0000 or Neovim 0.2.0'
endfunction

function! s:new(...) abort
let options = extend({
\ 'on_close_fail': v:null,
Expand Down
9 changes: 1 addition & 8 deletions autoload/vital/_gina/Vim/Buffer/Opener.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_gina#Vim#Buffer#Opener#import() abort', printf("return map({'_vital_depends': '', 'is_preview_opener': '', '_vital_healthcheck': '', 'open': '', '_vital_loaded': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
execute join(['function! vital#_gina#Vim#Buffer#Opener#import() abort', printf("return map({'_vital_depends': '', 'is_preview_opener': '', 'open': '', '_vital_loaded': ''}, \"vital#_gina#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
let s:t_string = type('')

function! s:_vital_healthcheck() abort
if (!has('nvim') && v:version >= 800) || has('nvim-0.2.0')
return
endif
return 'This module requires Vim 8.0.0000 or Neovim 0.2.0'
endfunction

function! s:_vital_depends() abort
return ['Vim.Buffer', 'Vim.BufferManager']
endfunction
Expand Down
Loading

0 comments on commit dd5340e

Please sign in to comment.