diff options
| -rw-r--r-- | autoload/crystal_lang.vim | 19 | ||||
| -rw-r--r-- | autoload/vital.vim | 16 | ||||
| -rw-r--r-- | autoload/vital/_crystal.vim | 310 | ||||
| -rw-r--r-- | autoload/vital/_crystal/ColorEcho.vim | 9 | ||||
| -rw-r--r-- | autoload/vital/_crystal/Data/List.vim | 26 | ||||
| -rw-r--r-- | autoload/vital/_crystal/Data/String.vim | 177 | ||||
| -rw-r--r-- | autoload/vital/_crystal/Prelude.vim | 389 | ||||
| -rw-r--r-- | autoload/vital/_crystal/Process.vim | 88 | ||||
| -rw-r--r-- | autoload/vital/_crystal/Web/JSON.vim | 90 | ||||
| -rw-r--r-- | autoload/vital/crystal.vital | 2 | ||||
| -rw-r--r-- | autoload/xml/html5.vim | 3 | ||||
| -rw-r--r-- | ftdetect/polyglot.vim | 1 | ||||
| -rw-r--r-- | ftplugin/elixir.vim | 25 | ||||
| -rw-r--r-- | ftplugin/mail_vifm.vim | 4 | ||||
| -rw-r--r-- | syntax/go.vim | 14 | ||||
| -rw-r--r-- | syntax/html.vim | 2 | ||||
| -rw-r--r-- | syntax/json.vim | 10 | ||||
| -rw-r--r-- | syntax/julia.vim | 27 | ||||
| -rw-r--r-- | syntax/plantuml.vim | 2 | ||||
| -rw-r--r-- | syntax/terraform.vim | 111 | 
20 files changed, 465 insertions, 860 deletions
| diff --git a/autoload/crystal_lang.vim b/autoload/crystal_lang.vim index 01244746..94cc9db3 100644 --- a/autoload/crystal_lang.vim +++ b/autoload/crystal_lang.vim @@ -3,11 +3,21 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1  let s:save_cpo = &cpo  set cpo&vim -let s:V = vital#of('crystal') +let s:V = vital#crystal#new()  let s:P = s:V.import('Process') -let s:J = s:V.import('Web.JSON')  let s:C = s:V.import('ColorEcho') +if exists('*json_decode') +    function! s:decode_json(text) abort +        return json_decode(a:text) +    endfunction +else +    let s:J = s:V.import('Web.JSON') +    function! s:decode_json(text) abort +        return s:J.decode(a:text) +    endfunction +endif +  function! s:echo_error(msg, ...) abort      echohl ErrorMsg      if a:0 == 0 @@ -102,7 +112,7 @@ function! crystal_lang#jump_to_definition(file, pos) abort          return s:echo_error(cmd_result.output)      endif -    let impl = s:J.decode(cmd_result.output) +    let impl = s:decode_json(cmd_result.output)      if impl.status !=# 'ok'          return s:echo_error(impl.message)      endif @@ -149,7 +159,6 @@ endfunction  function! crystal_lang#complete(findstart, base) abort      if a:findstart -        echom 'find start'          return s:find_completion_start()      endif @@ -158,7 +167,7 @@ function! crystal_lang#complete(findstart, base) abort          return      endif -    let contexts = s:J.decode(cmd_result.output) +    let contexts = s:decode_json(cmd_result.output)      if contexts.status !=# 'ok'          return      endif diff --git a/autoload/vital.vim b/autoload/vital.vim deleted file mode 100644 index 98fe948f..00000000 --- a/autoload/vital.vim +++ /dev/null @@ -1,16 +0,0 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 -   -function! vital#of(name) abort -  let files = globpath(&runtimepath, 'autoload/vital/' . a:name . '.vital') -  let file = split(files, "\n") -  if empty(file) -    throw 'vital: version file not found: ' . a:name -  endif -  let ver = readfile(file[0], 'b') -  if empty(ver) -    throw 'vital: invalid version file: ' . a:name -  endif -  return vital#_{substitute(ver[0], '\W', '', 'g')}#new() -endfunction - -endif diff --git a/autoload/vital/_crystal.vim b/autoload/vital/_crystal.vim index f5ff37f3..55eea487 100644 --- a/autoload/vital/_crystal.vim +++ b/autoload/vital/_crystal.vim @@ -1,313 +1,13 @@  if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 -let s:self_version = expand('<sfile>:t:r') -let s:self_file = expand('<sfile>') +let s:_plugin_name = expand('<sfile>:t:r') -" Note: The extra argument to globpath() was added in Patch 7.2.051. -let s:globpath_third_arg = v:version > 702 || v:version == 702 && has('patch51') - -let s:loaded = {} -let s:cache_module_path = {} -let s:cache_sid = {} - -let s:_vital_files_cache_runtimepath = '' -let s:_vital_files_cache = [] -let s:_unify_path_cache = {} - -function! s:import(name, ...) abort -  let target = {} -  let functions = [] -  for a in a:000 -    if type(a) == type({}) -      let target = a -    elseif type(a) == type([]) -      let functions = a -    endif -    unlet a -  endfor -  let module = s:_import(a:name) -  if empty(functions) -    call extend(target, module, 'keep') -  else -    for f in functions -      if has_key(module, f) && !has_key(target, f) -        let target[f] = module[f] -      endif -    endfor -  endif -  return target -endfunction - -function! s:load(...) dict abort -  for arg in a:000 -    let [name; as] = type(arg) == type([]) ? arg[: 1] : [arg, arg] -    let target = split(join(as, ''), '\W\+') -    let dict = self -    let dict_type = type({}) -    while !empty(target) -      let ns = remove(target, 0) -      if !has_key(dict, ns) -        let dict[ns] = {} -      endif -      if type(dict[ns]) == dict_type -        let dict = dict[ns] -      else -        unlet dict -        break -      endif -    endwhile - -    if exists('dict') -      call extend(dict, s:_import(name)) -    endif -    unlet arg -  endfor -  return self -endfunction - -function! s:unload() abort -  let s:loaded = {} -  let s:cache_sid = {} -  let s:cache_module_path = {} -endfunction - -function! s:exists(name) abort -  return s:_get_module_path(a:name) !=# '' -endfunction - -function! s:search(pattern) abort -  let paths = s:_vital_files(a:pattern) -  let modules = sort(map(paths, 's:_file2module(v:val)')) -  return s:_uniq(modules) -endfunction - -function! s:expand_modules(entry, all) abort -  if type(a:entry) == type([]) -    let candidates = s:_concat(map(copy(a:entry), 's:search(v:val)')) -    if empty(candidates) -      throw printf('vital: Any of module %s is not found', string(a:entry)) -    endif -    if eval(join(map(copy(candidates), 'has_key(a:all, v:val)'), '+')) -      let modules = [] -    else -      let modules = [candidates[0]] -    endif -  else -    let modules = s:search(a:entry) -    if empty(modules) -      throw printf('vital: Module %s is not found', a:entry) -    endif -  endif -  call filter(modules, '!has_key(a:all, v:val)') -  for module in modules -    let a:all[module] = 1 -  endfor -  return modules -endfunction - -function! s:_import(name) abort -  if type(a:name) == type(0) -    return s:_build_module(a:name) -  endif -  let path = s:_get_module_path(a:name) -  if path ==# '' -    throw 'vital: module not found: ' . a:name -  endif -  let sid = s:_get_sid_by_script(path) -  if !sid -    try -      execute 'source' fnameescape(path) -    catch /^Vim\%((\a\+)\)\?:E484/ -      throw 'vital: module not found: ' . a:name -    catch /^Vim\%((\a\+)\)\?:E127/ -      " Ignore. -    endtry - -    let sid = s:_get_sid_by_script(path) -  endif -  return s:_build_module(sid) -endfunction - -function! s:_get_module_path(name) abort -  let key = a:name . '_' -  if has_key(s:cache_module_path, key) -    return s:cache_module_path[key] -  endif -  if s:_is_absolute_path(a:name) && filereadable(a:name) -    return a:name -  endif -  if a:name ==# '' -    let paths = [s:self_file] -  elseif a:name =~# '\v^\u\w*%(\.\u\w*)*$' -    let paths = s:_vital_files(a:name) -  else -    throw 'vital: Invalid module name: ' . a:name -  endif - -  call filter(paths, 'filereadable(expand(v:val, 1))') -  let path = get(paths, 0, '') -  let s:cache_module_path[key] = path -  return path -endfunction - -function! s:_get_sid_by_script(path) abort -  if has_key(s:cache_sid, a:path) -    return s:cache_sid[a:path] -  endif - -  let path = s:_unify_path(a:path) -  for line in filter(split(s:_redir('scriptnames'), "\n"), -  \                  'stridx(v:val, s:self_version) > 0') -    let list = matchlist(line, '^\s*\(\d\+\):\s\+\(.\+\)\s*$') -    if !empty(list) && s:_unify_path(list[2]) ==# path -      let s:cache_sid[a:path] = list[1] - 0 -      return s:cache_sid[a:path] -    endif -  endfor -  return 0 -endfunction - -function! s:_file2module(file) abort -  let filename = fnamemodify(a:file, ':p:gs?[\\/]?/?') -  let tail = matchstr(filename, 'autoload/vital/_\w\+/\zs.*\ze\.vim$') -  return join(split(tail, '[\\/]\+'), '.') -endfunction - -if filereadable(expand('<sfile>:r') . '.VIM') -  " resolve() is slow, so we cache results. -  " Note: On windows, vim can't expand path names from 8.3 formats. -  " So if getting full path via <sfile> and $HOME was set as 8.3 format, -  " vital load duplicated scripts. Below's :~ avoid this issue. -  function! s:_unify_path(path) abort -    if has_key(s:_unify_path_cache, a:path) -      return s:_unify_path_cache[a:path] -    endif -    let value = tolower(fnamemodify(resolve(fnamemodify( -    \                   a:path, ':p')), ':~:gs?[\\/]?/?')) -    let s:_unify_path_cache[a:path] = value -    return value -  endfunction -else -  function! s:_unify_path(path) abort -    return resolve(fnamemodify(a:path, ':p:gs?[\\/]?/?')) -  endfunction -endif - -if s:globpath_third_arg -  function! s:_runtime_files(path) abort -    return split(globpath(&runtimepath, a:path, 1), "\n") -  endfunction -else -  function! s:_runtime_files(path) abort -    return split(globpath(&runtimepath, a:path), "\n") -  endfunction -endif - -function! s:_vital_files(pattern) abort -  if s:_vital_files_cache_runtimepath !=# &runtimepath -    let path = printf('autoload/vital/%s/**/*.vim', s:self_version) -    let s:_vital_files_cache = s:_runtime_files(path) -    let mod = ':p:gs?[\\/]\+?/?' -    call map(s:_vital_files_cache, 'fnamemodify(v:val, mod)') -    let s:_vital_files_cache_runtimepath = &runtimepath -  endif -  let target = substitute(a:pattern, '\.', '/', 'g') -  let target = substitute(target, '\*', '[^/]*', 'g') -  let regexp = printf('autoload/vital/%s/%s.vim', s:self_version, target) -  return filter(copy(s:_vital_files_cache), 'v:val =~# regexp') -endfunction - -" Copy from System.Filepath -if has('win16') || has('win32') || has('win64') -  function! s:_is_absolute_path(path) abort -    return a:path =~? '^[a-z]:[/\\]' -  endfunction -else -  function! s:_is_absolute_path(path) abort -    return a:path[0] ==# '/' -  endfunction -endif - -function! s:_build_module(sid) abort -  if has_key(s:loaded, a:sid) -    return copy(s:loaded[a:sid]) -  endif -  let functions = s:_get_functions(a:sid) - -  let prefix = '<SNR>' . a:sid . '_' -  let module = {} -  for func in functions -    let module[func] = function(prefix . func) -  endfor -  if has_key(module, '_vital_created') -    call module._vital_created(module) -  endif -  let export_module = filter(copy(module), 'v:key =~# "^\\a"') -  let s:loaded[a:sid] = get(g:, 'vital_debug', 0) ? module : export_module -  if has_key(module, '_vital_loaded') -    let V = vital#{s:self_version}#new() -    call module._vital_loaded(V) -  endif -  return copy(s:loaded[a:sid]) -endfunction - -if exists('+regexpengine') -  function! s:_get_functions(sid) abort -    let funcs = s:_redir(printf("function /\\%%#=2^\<SNR>%d_", a:sid)) -    let map_pat = '<SNR>' . a:sid . '_\zs\w\+' -    return map(split(funcs, "\n"), 'matchstr(v:val, map_pat)') -  endfunction -else -  function! s:_get_functions(sid) abort -    let prefix = '<SNR>' . a:sid . '_' -    let funcs = s:_redir('function') -    let filter_pat = '^\s*function ' . prefix -    let map_pat = prefix . '\zs\w\+' -    return map(filter(split(funcs, "\n"), -    \          'stridx(v:val, prefix) > 0 && v:val =~# filter_pat'), -    \          'matchstr(v:val, map_pat)') -  endfunction -endif - -if exists('*uniq') -  function! s:_uniq(list) abort -    return uniq(a:list) -  endfunction -else -  function! s:_uniq(list) abort -    let i = len(a:list) - 1 -    while 0 < i -      if a:list[i] ==# a:list[i - 1] -        call remove(a:list, i) -        let i -= 2 -      else -        let i -= 1 -      endif -    endwhile -    return a:list -  endfunction -endif - -function! s:_concat(lists) abort -  let result_list = [] -  for list in a:lists -    let result_list += list -  endfor -  return result_list -endfunction - -function! s:_redir(cmd) abort -  let [save_verbose, save_verbosefile] = [&verbose, &verbosefile] -  set verbose=0 verbosefile= -  redir => res -    silent! execute a:cmd -  redir END -  let [&verbose, &verbosefile] = [save_verbose, save_verbosefile] -  return res +function! vital#{s:_plugin_name}#new() abort +  return vital#{s:_plugin_name[1:]}#new()  endfunction -function! vital#{s:self_version}#new() abort -  return s:_import('') +function! vital#{s:_plugin_name}#function(funcname) abort +  silent! return function(a:funcname)  endfunction  endif diff --git a/autoload/vital/_crystal/ColorEcho.vim b/autoload/vital/_crystal/ColorEcho.vim index f2eae658..8358cc66 100644 --- a/autoload/vital/_crystal/ColorEcho.vim +++ b/autoload/vital/_crystal/ColorEcho.vim @@ -1,5 +1,14 @@  if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 +" ___vital___ +" NOTE: lines between '" ___vital___' is generated by :Vitalize. +" Do not mofidify the code nor insert new lines before '" ___vital___' +function! s:_SID() abort +  return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$') +endfunction +execute join(['function! vital#_crystal#ColorEcho#import() abort', printf("return map({'get_echorizer': '', 'echo': '', 'is_available': ''}, \"vital#_crystal#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") +delfunction s:_SID +" ___vital___  scriptencoding utf-8  let s:save_cpo = &cpo  set cpo&vim diff --git a/autoload/vital/_crystal/Data/List.vim b/autoload/vital/_crystal/Data/List.vim index 55703b3d..1aac999f 100644 --- a/autoload/vital/_crystal/Data/List.vim +++ b/autoload/vital/_crystal/Data/List.vim @@ -1,5 +1,14 @@  if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 +" ___vital___ +" NOTE: lines between '" ___vital___' is generated by :Vitalize. +" Do not mofidify the code nor insert new lines before '" ___vital___' +function! s:_SID() abort +  return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$') +endfunction +execute join(['function! vital#_crystal#Data#List#import() abort', printf("return map({'combinations': '', 'and': '', 'sort_by': '', 'foldr1': '', 'sort': '', 'flatten': '', 'has_index': '', 'find_indices': '', 'any': '', 'unshift': '', 'span': '', 'pop': '', 'binary_search': '', 'uniq_by': '', 'or': '', 'all': '', 'zip': '', 'find_last_index': '', 'find': '', 'partition': '', 'shift': '', 'permutations': '', 'break': '', 'max_by': '', 'foldl': '', 'foldr': '', 'find_index': '', 'drop_while': '', 'group_by': '', 'take_while': '', 'conj': '', 'push': '', 'char_range': '', 'cons': '', 'foldl1': '', 'intersect': '', 'concat': '', 'map_accum': '', 'clear': '', 'has_common_items': '', 'product': '', 'zip_fill': '', 'uniq': '', 'has': '', 'min_by': '', 'with_index': ''}, \"vital#_crystal#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") +delfunction s:_SID +" ___vital___  " Utilities for list.  let s:save_cpo = &cpo @@ -175,6 +184,11 @@ function! s:take_while(f, xs) abort    return s:span(a:f, a:xs)[0]  endfunction +" similar to Haskell's Data.List.dropWhile +function! s:drop_while(f, xs) abort +  return s:span(a:f, a:xs)[1] +endfunction +  " similar to Haskell's Data.List.partition  function! s:partition(f, xs) abort    return [filter(copy(a:xs), a:f), filter(copy(a:xs), '!(' . a:f . ')')] @@ -271,14 +285,22 @@ endfunction  " similar to Ruby's detect or Haskell's find.  function! s:find(list, default, f) abort +  let l:Call = type(a:f) is type(function('function')) +  \          ? function('call') +  \          : function('s:_call_string_expr') +    for x in a:list -    if eval(substitute(a:f, 'v:val', string(x), 'g')) +    if l:Call(a:f, [x])        return x      endif    endfor    return a:default  endfunction +function! s:_call_string_expr(expr, args) abort +  return map([a:args[0]], a:expr)[0] +endfunction +  " Returns the index of the first element which satisfies the given expr.  function! s:find_index(xs, f, ...) abort    let len = len(a:xs) @@ -426,7 +448,7 @@ function! s:combinations(list, r) abort    if a:r > len(a:list)      return []    elseif a:r < 0 -    throw 'vital: Data:List: {r} must be non-negative integer' +    throw 'vital: Data.List: {r} must be non-negative integer'    endif    let n = len(a:list)    let result = [] diff --git a/autoload/vital/_crystal/Data/String.vim b/autoload/vital/_crystal/Data/String.vim index c2e2382c..7d3ef2c3 100644 --- a/autoload/vital/_crystal/Data/String.vim +++ b/autoload/vital/_crystal/Data/String.vim @@ -1,5 +1,14 @@  if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 +" ___vital___ +" NOTE: lines between '" ___vital___' is generated by :Vitalize. +" Do not mofidify the code nor insert new lines before '" ___vital___' +function! s:_SID() abort +  return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$') +endfunction +execute join(['function! vital#_crystal#Data#String#import() abort', printf("return map({'starts_with': '', 'split3': '', 'replace_first': '', 'chop': '', 'unescape': '', 'split_posix_text': '', 'replace': '', 'scan': '', 'strwidthpart': '', 'common_head': '', 'reverse': '', 'escape_pattern': '', 'trim_end': '', '_vital_depends': '', 'wrap': '', 'join_posix_lines': '', 'contains_multibyte': '', 'truncate_skipping': '', 'split_leftright': '', 'ends_with': '', 'nsplit': '', 'strwidthpart_reverse': '', 'unescape_pattern': '', 'levenshtein_distance': '', 'trim_start': '', 'justify_equal_spacing': '', 'nr2hex': '', 'iconv': '', 'pad_left': '', 'nr2enc_char': '', 'lines': '', 'repair_posix_text': '', 'nr2byte': '', 'trim': '', 'diffidx': '', 'truncate': '', 'split_by_displaywidth': '', '_vital_created': '', 'padding_by_displaywidth': '', 'hash': '', 'chomp': '', 'pad_between_letters': '', 'dstring': '', 'pad_both_sides': '', 'substitute_last': '', 'pad_right': '', 'remove_ansi_sequences': '', '_vital_loaded': ''}, \"vital#_crystal#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") +delfunction s:_SID +" ___vital___  " Utilities for string.  let s:save_cpo = &cpo @@ -7,12 +16,21 @@ set cpo&vim  function! s:_vital_loaded(V) abort    let s:V = a:V -  let s:P = s:V.import('Prelude')    let s:L = s:V.import('Data.List')  endfunction  function! s:_vital_depends() abort -  return ['Prelude', 'Data.List'] +  return ['Data.List'] +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  endfunction  " Substitute a:from => a:to by string. @@ -61,7 +79,7 @@ function! s:common_head(strs) abort    endif    let strs = len == 2 ? a:strs : sort(copy(a:strs))    let pat = substitute(strs[0], '.', '\="[" . escape(submatch(0), "^\\") . "]"', 'g') -  return pat == '' ? '' : matchstr(strs[-1], '\C^\%[' . pat . ']') +  return pat ==# '' ? '' : matchstr(strs[-1], '\C^\%[' . pat . ']')  endfunction  " Split to two elements of List. ([left, right]) @@ -130,9 +148,7 @@ endfunction  " even if a:str contains multibyte character(s).  " s:strchars(str) {{{  if exists('*strchars') -  function! s:strchars(str) abort -    return strchars(a:str) -  endfunction +  let s:strchars = function('strchars')  else    function! s:strchars(str) abort      return strlen(substitute(copy(a:str), '.', 'x', 'g')) @@ -210,7 +226,7 @@ function! s:nr2byte(nr) abort  endfunction  function! s:nr2enc_char(charcode) abort -  if &encoding == 'utf-8' +  if &encoding ==# 'utf-8'      return nr2char(a:charcode)    endif    let char = s:nr2byte(a:charcode) @@ -222,7 +238,7 @@ endfunction  function! s:nr2hex(nr) abort    let n = a:nr -  let r = "" +  let r = ''    while n      let r = '0123456789ABCDEF'[n % 16] . r      let n = n / 16 @@ -318,7 +334,7 @@ function! s:levenshtein_distance(str1, str2) abort    let letters2 = split(a:str2, '\zs')    let length1 = len(letters1)    let length2 = len(letters2) -  let distances = map(range(1, length1 + 1), 'map(range(1, length2 + 1), "0")') +  let distances = map(range(1, length1 + 1), 'map(range(1, length2 + 1), ''0'')')    for i1 in range(0, length1)      let distances[i1][0] = i1 @@ -373,7 +389,7 @@ function! s:split_by_displaywidth(expr, width, float, is_wrap) abort    let text = ''    while cs_index < len(cs) -    if cs[cs_index] is "\n" +    if cs[cs_index] is# "\n"        let text = s:padding_by_displaywidth(text, a:width, a:float)        let lines += [text]        let text = '' @@ -394,7 +410,7 @@ function! s:split_by_displaywidth(expr, width, float, is_wrap) abort          if a:is_wrap            if a:width < w              if a:width < strdisplaywidth(cs[cs_index]) -              while get(cs, cs_index, "\n") isnot "\n" +              while get(cs, cs_index, "\n") isnot# "\n"                  let cs_index += 1                endwhile                continue @@ -403,7 +419,7 @@ function! s:split_by_displaywidth(expr, width, float, is_wrap) abort              endif            endif          else -          while get(cs, cs_index, "\n") isnot "\n" +          while get(cs, cs_index, "\n") isnot# "\n"              let cs_index += 1            endwhile            continue @@ -440,8 +456,9 @@ function! s:truncate(str, width) abort    " http://github.com/mattn/googlereader-vim/tree/master    if a:str =~# '^[\x00-\x7f]*$' -    return len(a:str) < a:width ? -          \ printf('%-'.a:width.'s', a:str) : strpart(a:str, 0, a:width) +    return len(a:str) < a:width +          \ ? printf('%-' . a:width . 's', a:str) +          \ : strpart(a:str, 0, a:width)    endif    let ret = a:str @@ -471,57 +488,20 @@ function! s:truncate_skipping(str, max, footer_width, separator) abort  endfunction  function! s:strwidthpart(str, width) abort -  if a:width <= 0 -    return '' -  endif -  let strarr = split(a:str, '\zs') -  let width = s:wcswidth(a:str) -  let index = len(strarr) -  let diff = (index + 1) / 2 -  let rightindex = index - 1 -  while width > a:width -    let index = max([rightindex - diff + 1, 0]) -    let partwidth = s:wcswidth(join(strarr[(index):(rightindex)], '')) -    if width - partwidth >= a:width || diff <= 1 -      let width -= partwidth -      let rightindex = index - 1 -    endif -    if diff > 1 -      let diff = diff / 2 -    endif -  endwhile -  return index ? join(strarr[:index - 1], '') : '' +  let str = tr(a:str, "\t", ' ') +  let vcol = a:width + 2 +  return matchstr(str, '.*\%<' . (vcol < 0 ? 0 : vcol) . 'v')  endfunction  function! s:strwidthpart_reverse(str, width) abort -  if a:width <= 0 -    return '' -  endif -  let strarr = split(a:str, '\zs') -  let width = s:wcswidth(a:str) -  let strlen = len(strarr) -  let diff = (strlen + 1) / 2 -  let leftindex = 0 -  let index = -1 -  while width > a:width -    let index = min([leftindex + diff, strlen]) - 1 -    let partwidth = s:wcswidth(join(strarr[(leftindex):(index)], '')) -    if width - partwidth >= a:width || diff <= 1 -      let width -= partwidth -      let leftindex = index + 1 -    endif -    if diff > 1 -      let diff = diff / 2 -    endif -  endwhile -  return index < strlen ? join(strarr[(index + 1):], '') : '' +  let str = tr(a:str, "\t", ' ') +  let vcol = s:wcswidth(str) - a:width +  return matchstr(str, '\%>' . (vcol < 0 ? 0 : vcol) . 'v.*')  endfunction  if v:version >= 703    " Use builtin function. -  function! s:wcswidth(str) abort -    return strwidth(a:str) -  endfunction +  let s:wcswidth = function('strwidth')  else    function! s:wcswidth(str) abort      if a:str =~# '^[\x00-\x7f]*$' @@ -564,9 +544,88 @@ else    endfunction  endif +function! s:remove_ansi_sequences(text) abort +  return substitute(a:text, '\e\[\%(\%(\d\+;\)*\d\+\)\?[mK]', '', 'g') +endfunction + +function! s:escape_pattern(str) abort +  " escape characters for no-magic +  return escape(a:str, '^$~.*[]\') +endfunction + +function! s:unescape_pattern(str) abort +  " unescape characters for no-magic +  return s:unescape(a:str, '^$~.*[]\') +endfunction + +function! s:unescape(str, chars) abort +  let chars = map(split(a:chars, '\zs'), 'escape(v:val, ''^$~.*[]\'')') +  return substitute(a:str, '\\\(' . join(chars, '\|') . '\)', '\1', 'g') +endfunction + +function! s:iconv(expr, from, to) abort +  if a:from ==# '' || a:to ==# '' || a:from ==? a:to +    return a:expr +  endif +  let result = iconv(a:expr, a:from, a:to) +  return empty(result) ? a:expr : result +endfunction + +" NOTE: +" A definition of a TEXT file is "A file that contains characters organized +" into one or more lines." +" A definition of a LINE is "A sequence of zero or more non- <newline>s +" plus a terminating <newline>" +" That's why {stdin} always ends with <newline> ideally. However, there are +" some programs which does not follow the POSIX rule and a Vim's way to join +" List into TEXT; join({text}, "\n"); does not add <newline> to the end of +" the last line. +" That's why add a trailing <newline> if it does not exist. +" REF: +" http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_392 +" http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_205 +" :help split() +" NOTE: +" it does nothing if the text is a correct POSIX text +function! s:repair_posix_text(text, ...) abort +  let newline = get(a:000, 0, "\n") +  return a:text =~# '\n$' ? a:text : a:text . newline +endfunction + +" NOTE: +" A definition of a TEXT file is "A file that contains characters organized +" into one or more lines." +" A definition of a LINE is "A sequence of zero or more non- <newline>s +" plus a terminating <newline>" +" REF: +" http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_392 +" http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_205 +function! s:join_posix_lines(lines, ...) abort +  let newline = get(a:000, 0, "\n") +  return join(a:lines, newline) . newline +endfunction + +" NOTE: +" A definition of a TEXT file is "A file that contains characters organized +" into one or more lines." +" A definition of a LINE is "A sequence of zero or more non- <newline>s +" plus a terminating <newline>" +" TEXT into List; split({text}, '\r\?\n', 1); add an extra empty line at the +" end of List because the end of TEXT ends with <newline> and keepempty=1 is +" specified. (btw. keepempty=0 cannot be used because it will remove +" emptylines in the head and the tail). +" That's why removing a trailing <newline> before proceeding to 'split' is required +" REF: +" http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_392 +" http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_205 +function! s:split_posix_text(text, ...) abort +  let newline = get(a:000, 0, '\r\?\n') +  let text = substitute(a:text, newline . '$', '', '') +  return split(text, newline, 1) +endfunction +  let &cpo = s:save_cpo  unlet s:save_cpo -  " vim:set et ts=2 sts=2 sw=2 tw=0:  endif diff --git a/autoload/vital/_crystal/Prelude.vim b/autoload/vital/_crystal/Prelude.vim deleted file mode 100644 index be31f980..00000000 --- a/autoload/vital/_crystal/Prelude.vim +++ /dev/null @@ -1,389 +0,0 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 -   -let s:save_cpo = &cpo -set cpo&vim - -if v:version ># 703 || -\  (v:version is 703 && has('patch465')) -  function! s:glob(expr) abort -    return glob(a:expr, 1, 1) -  endfunction -else -  function! s:glob(expr) abort -    let R = glob(a:expr, 1) -    return split(R, '\n') -  endfunction -endif - -function! s:globpath(path, expr) abort -  let R = globpath(a:path, a:expr, 1) -  return split(R, '\n') -endfunction - -" Wrapper functions for type(). -let [ -\   s:__TYPE_NUMBER, -\   s:__TYPE_STRING, -\   s:__TYPE_FUNCREF, -\   s:__TYPE_LIST, -\   s:__TYPE_DICT, -\   s:__TYPE_FLOAT] = [ -      \   type(3), -      \   type(""), -      \   type(function('tr')), -      \   type([]), -      \   type({}), -      \   has('float') ? type(str2float('0')) : -1] -" __TYPE_FLOAT = -1 when -float -" This doesn't match to anything. - -" Number or Float -function! s:is_numeric(Value) abort -  let _ = type(a:Value) -  return _ ==# s:__TYPE_NUMBER -  \   || _ ==# s:__TYPE_FLOAT -endfunction - -" Number -function! s:is_number(Value) abort -  return type(a:Value) ==# s:__TYPE_NUMBER -endfunction - -" Float -function! s:is_float(Value) abort -  return type(a:Value) ==# s:__TYPE_FLOAT -endfunction -" String -function! s:is_string(Value) abort -  return type(a:Value) ==# s:__TYPE_STRING -endfunction -" Funcref -function! s:is_funcref(Value) abort -  return type(a:Value) ==# s:__TYPE_FUNCREF -endfunction -" List -function! s:is_list(Value) abort -  return type(a:Value) ==# s:__TYPE_LIST -endfunction -" Dictionary -function! s:is_dict(Value) abort -  return type(a:Value) ==# s:__TYPE_DICT -endfunction - -function! s:truncate_skipping(str, max, footer_width, separator) abort -  call s:_warn_deprecated("truncate_skipping", "Data.String.truncate_skipping") - -  let width = s:wcswidth(a:str) -  if width <= a:max -    let ret = a:str -  else -    let header_width = a:max - s:wcswidth(a:separator) - a:footer_width -    let ret = s:strwidthpart(a:str, header_width) . a:separator -          \ . s:strwidthpart_reverse(a:str, a:footer_width) -  endif - -  return s:truncate(ret, a:max) -endfunction - -function! s:truncate(str, width) abort -  " Original function is from mattn. -  " http://github.com/mattn/googlereader-vim/tree/master - -  call s:_warn_deprecated("truncate", "Data.String.truncate") - -  if a:str =~# '^[\x00-\x7f]*$' -    return len(a:str) < a:width ? -          \ printf('%-'.a:width.'s', a:str) : strpart(a:str, 0, a:width) -  endif - -  let ret = a:str -  let width = s:wcswidth(a:str) -  if width > a:width -    let ret = s:strwidthpart(ret, a:width) -    let width = s:wcswidth(ret) -  endif - -  if width < a:width -    let ret .= repeat(' ', a:width - width) -  endif - -  return ret -endfunction - -function! s:strwidthpart(str, width) abort -  call s:_warn_deprecated("strwidthpart", "Data.String.strwidthpart") - -  if a:width <= 0 -    return '' -  endif -  let ret = a:str -  let width = s:wcswidth(a:str) -  while width > a:width -    let char = matchstr(ret, '.$') -    let ret = ret[: -1 - len(char)] -    let width -= s:wcswidth(char) -  endwhile - -  return ret -endfunction -function! s:strwidthpart_reverse(str, width) abort -  call s:_warn_deprecated("strwidthpart_reverse", "Data.String.strwidthpart_reverse") - -  if a:width <= 0 -    return '' -  endif -  let ret = a:str -  let width = s:wcswidth(a:str) -  while width > a:width -    let char = matchstr(ret, '^.') -    let ret = ret[len(char) :] -    let width -= s:wcswidth(char) -  endwhile - -  return ret -endfunction - -if v:version >= 703 -  " Use builtin function. -  function! s:wcswidth(str) abort -    call s:_warn_deprecated("wcswidth", "Data.String.wcswidth") -    return strwidth(a:str) -  endfunction -else -  function! s:wcswidth(str) abort -    call s:_warn_deprecated("wcswidth", "Data.String.wcswidth") - -    if a:str =~# '^[\x00-\x7f]*$' -      return strlen(a:str) -    end - -    let mx_first = '^\(.\)' -    let str = a:str -    let width = 0 -    while 1 -      let ucs = char2nr(substitute(str, mx_first, '\1', '')) -      if ucs == 0 -        break -      endif -      let width += s:_wcwidth(ucs) -      let str = substitute(str, mx_first, '', '') -    endwhile -    return width -  endfunction - -  " UTF-8 only. -  function! s:_wcwidth(ucs) abort -    let ucs = a:ucs -    if (ucs >= 0x1100 -          \  && (ucs <= 0x115f -          \  || ucs == 0x2329 -          \  || ucs == 0x232a -          \  || (ucs >= 0x2e80 && ucs <= 0xa4cf -          \      && ucs != 0x303f) -          \  || (ucs >= 0xac00 && ucs <= 0xd7a3) -          \  || (ucs >= 0xf900 && ucs <= 0xfaff) -          \  || (ucs >= 0xfe30 && ucs <= 0xfe6f) -          \  || (ucs >= 0xff00 && ucs <= 0xff60) -          \  || (ucs >= 0xffe0 && ucs <= 0xffe6) -          \  || (ucs >= 0x20000 && ucs <= 0x2fffd) -          \  || (ucs >= 0x30000 && ucs <= 0x3fffd) -          \  )) -      return 2 -    endif -    return 1 -  endfunction -endif - -let s:is_windows = has('win16') || has('win32') || has('win64') || has('win95') -let s:is_cygwin = has('win32unix') -let s:is_mac = !s:is_windows && !s:is_cygwin -      \ && (has('mac') || has('macunix') || has('gui_macvim') || -      \   (!isdirectory('/proc') && executable('sw_vers'))) -let s:is_unix = has('unix') - -function! s:is_windows() abort -  return s:is_windows -endfunction - -function! s:is_cygwin() abort -  return s:is_cygwin -endfunction - -function! s:is_mac() abort -  return s:is_mac -endfunction - -function! s:is_unix() abort -  return s:is_unix -endfunction - -function! s:_warn_deprecated(name, alternative) abort -  try -    echohl Error -    echomsg "Prelude." . a:name . " is deprecated!  Please use " . a:alternative . " instead." -  finally -    echohl None -  endtry -endfunction - -function! s:smart_execute_command(action, word) abort -  execute a:action . ' ' . (a:word == '' ? '' : '`=a:word`') -endfunction - -function! s:escape_file_searching(buffer_name) abort -  return escape(a:buffer_name, '*[]?{}, ') -endfunction - -function! s:escape_pattern(str) abort -  return escape(a:str, '~"\.^$[]*') -endfunction - -function! s:getchar(...) abort -  let c = call('getchar', a:000) -  return type(c) == type(0) ? nr2char(c) : c -endfunction - -function! s:getchar_safe(...) abort -  let c = s:input_helper('getchar', a:000) -  return type(c) == type("") ? c : nr2char(c) -endfunction - -function! s:input_safe(...) abort -  return s:input_helper('input', a:000) -endfunction - -function! s:input_helper(funcname, args) abort -  let success = 0 -  if inputsave() !=# success -    throw 'vital: Prelude: inputsave() failed' -  endif -  try -    return call(a:funcname, a:args) -  finally -    if inputrestore() !=# success -      throw 'vital: Prelude: inputrestore() failed' -    endif -  endtry -endfunction - -function! s:set_default(var, val) abort -  if !exists(a:var) || type({a:var}) != type(a:val) -    let {a:var} = a:val -  endif -endfunction - -function! s:substitute_path_separator(path) abort -  return s:is_windows ? substitute(a:path, '\\', '/', 'g') : a:path -endfunction - -function! s:path2directory(path) abort -  return s:substitute_path_separator(isdirectory(a:path) ? a:path : fnamemodify(a:path, ':p:h')) -endfunction - -function! s:_path2project_directory_git(path) abort -  let parent = a:path - -  while 1 -    let path = parent . '/.git' -    if isdirectory(path) || filereadable(path) -      return parent -    endif -    let next = fnamemodify(parent, ':h') -    if next == parent -      return '' -    endif -    let parent = next -  endwhile -endfunction - -function! s:_path2project_directory_svn(path) abort -  let search_directory = a:path -  let directory = '' - -  let find_directory = s:escape_file_searching(search_directory) -  let d = finddir('.svn', find_directory . ';') -  if d == '' -    return '' -  endif - -  let directory = fnamemodify(d, ':p:h:h') - -  " Search parent directories. -  let parent_directory = s:path2directory( -        \ fnamemodify(directory, ':h')) - -  if parent_directory != '' -    let d = finddir('.svn', parent_directory . ';') -    if d != '' -      let directory = s:_path2project_directory_svn(parent_directory) -    endif -  endif -  return directory -endfunction - -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 d = finddir(vcs, find_directory . ';') -  if d == '' -    return '' -  endif -  return fnamemodify(d, ':p:h:h') -endfunction - -function! s:path2project_directory(path, ...) abort -  let is_allow_empty = get(a:000, 0, 0) -  let search_directory = s:path2directory(a:path) -  let directory = '' - -  " Search VCS directory. -  for vcs in ['.git', '.bzr', '.hg', '.svn'] -    if vcs ==# '.git' -      let directory = s:_path2project_directory_git(search_directory) -    elseif vcs ==# '.svn' -      let directory = s:_path2project_directory_svn(search_directory) -    else -      let directory = s:_path2project_directory_others(vcs, search_directory) -    endif -    if directory != '' -      break -    endif -  endfor - -  " Search project file. -  if directory == '' -    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) . ';') -      if d != '' -        let directory = fnamemodify(d, ':p:h') -        break -      endif -    endfor -  endif - -  if directory == '' -    " Search /src/ directory. -    let base = s:substitute_path_separator(search_directory) -    if base =~# '/src/' -      let directory = base[: strridx(base, '/src/') + 3] -    endif -  endif - -  if directory == '' && !is_allow_empty -    " Use original path. -    let directory = search_directory -  endif - -  return s:substitute_path_separator(directory) -endfunction - -let &cpo = s:save_cpo -unlet s:save_cpo - -" vim:set et ts=2 sts=2 sw=2 tw=0: - -endif diff --git a/autoload/vital/_crystal/Process.vim b/autoload/vital/_crystal/Process.vim index c2deb9e5..1f7b001c 100644 --- a/autoload/vital/_crystal/Process.vim +++ b/autoload/vital/_crystal/Process.vim @@ -1,5 +1,14 @@  if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 +" ___vital___ +" NOTE: lines between '" ___vital___' is generated by :Vitalize. +" Do not mofidify the code nor insert new lines before '" ___vital___' +function! s:_SID() abort +  return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$') +endfunction +execute join(['function! vital#_crystal#Process#import() abort', printf("return map({'shellescape': '', 'has_vimproc': '', 'system': '', 'iconv': '', 'spawn': '', 'get_last_status': ''}, \"vital#_crystal#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") +delfunction s:_SID +" ___vital___  " TODO: move all comments to doc file.  "  " @@ -21,62 +30,36 @@ let s:need_trans = v:version < 704 || (v:version == 704 && !has('patch122'))  let s:TYPE_DICT = type({})  let s:TYPE_LIST = type([]) -let s:TYPE_STRING = type("") - +let s:TYPE_STRING = type('') -" Execute program in the background from Vim. -" Return an empty string always. -" -" If a:expr is a List, shellescape() each argument. -" If a:expr is a String, the arguments are passed as-is. -" -" Windows: -" Using :!start , execute program without via cmd.exe. -" Spawning 'expr' with 'noshellslash' -" keep special characters from unwanted expansion. -" (see :help shellescape()) -" -" Unix: -" using :! , execute program in the background by shell.  function! s:spawn(expr, ...) abort -  let shellslash = 0 +  if type(a:expr) is s:TYPE_LIST +    let special = 1 +    let cmdline = join(map(a:expr, 's:shellescape(v:val, special)'), ' ') +  elseif type(a:expr) is s:TYPE_STRING +    let cmdline = a:expr +    if a:0 && a:1 +      " for :! command +      let cmdline = substitute(cmdline, '\([!%#]\|<[^<>]\+>\)', '\\\1', 'g') +    endif +  else +    throw 'vital: Process: invalid argument (value type:' . type(a:expr) . ')' +  endif    if s:is_windows -    let shellslash = &l:shellslash -    setlocal noshellslash +    silent execute '!start' cmdline +  else +    silent execute '!' cmdline '&'    endif -  try -    if type(a:expr) is s:TYPE_LIST -      let special = 1 -      let cmdline = join(map(a:expr, 'shellescape(v:val, special)'), ' ') -    elseif type(a:expr) is s:TYPE_STRING -      let cmdline = a:expr -      if a:0 && a:1 -        " for :! command -        let cmdline = substitute(cmdline, '\([!%#]\|<[^<>]\+>\)', '\\\1', 'g') -      endif -    else -      throw 'Process.spawn(): invalid argument (value type:'.type(a:expr).')' -    endif -    if s:is_windows -      silent execute '!start' cmdline -    else -      silent execute '!' cmdline '&' -    endif -  finally -    if s:is_windows -      let &l:shellslash = shellslash -    endif -  endtry    return ''  endfunction  " iconv() wrapper for safety.  function! s:iconv(expr, from, to) abort -  if a:from == '' || a:to == '' || a:from ==? a:to +  if a:from ==# '' || a:to ==# '' || a:from ==? a:to      return a:expr    endif    let result = iconv(a:expr, a:from, a:to) -  return result != '' ? result : a:expr +  return result !=# '' ? result : a:expr  endfunction  " Check vimproc. @@ -128,7 +111,7 @@ function! s:system(str, ...) abort      elseif type(a:1) is s:TYPE_STRING        let args += [s:iconv(a:1, &encoding, 'char')]      else -      throw 'Process.system(): invalid argument (value type:'.type(a:1).')' +      throw 'vital: Process: invalid argument (value type:' . type(a:1) . ')'      endif    elseif a:0 >= 2      " {command} [, {input} [, {timeout}]] @@ -145,13 +128,16 @@ function! s:system(str, ...) abort    elseif type(a:str) is s:TYPE_STRING      let command = a:str    else -    throw 'Process.system(): invalid argument (value type:'.type(a:str).')' +    throw 'vital: Process: invalid argument (value type:' . type(a:str) . ')'    endif    if s:need_trans      let command = s:iconv(command, &encoding, 'char')    endif    let args = [command] + args    if background && (use_vimproc || !s:is_windows) +    if has('nvim') +      throw "vital: Process: neovim's system() doesn't support background(&) process (cmdline:" . string(a:str) . ')' +    endif      let args[0] = args[0] . ' &'    endif @@ -167,8 +153,14 @@ function! s:get_last_status() abort  endfunction  if s:is_windows -  function! s:shellescape(command) abort -    return substitute(a:command, '[&()[\]{}^=;!''+,`~]', '^\0', 'g') +  function! s:shellescape(...) abort +    try +      let shellslash = &shellslash +      set noshellslash +      return call('shellescape', a:000) +    finally +      let &shellslash = shellslash +    endtry    endfunction  else    function! s:shellescape(...) abort diff --git a/autoload/vital/_crystal/Web/JSON.vim b/autoload/vital/_crystal/Web/JSON.vim index 0e42ee0d..e99fa733 100644 --- a/autoload/vital/_crystal/Web/JSON.vim +++ b/autoload/vital/_crystal/Web/JSON.vim @@ -1,5 +1,14 @@  if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1 +" ___vital___ +" NOTE: lines between '" ___vital___' is generated by :Vitalize. +" Do not mofidify the code nor insert new lines before '" ___vital___' +function! s:_SID() abort +  return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$') +endfunction +execute join(['function! vital#_crystal#Web#JSON#import() abort', printf("return map({'decode': '', '_vital_depends': '', '_vital_created': '', 'encode': '', '_vital_loaded': ''}, \"vital#_crystal#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n") +delfunction s:_SID +" ___vital___  let s:save_cpo = &cpo  set cpo&vim @@ -15,11 +24,6 @@ function! s:_null() abort    return 0  endfunction -let s:const = {} -let s:const.true = function('s:_true') -let s:const.false = function('s:_false') -let s:const.null = function('s:_null') -  function! s:_resolve(val, prefix) abort    let t = type(a:val)    if t == type('') @@ -36,6 +40,13 @@ endfunction  function! s:_vital_created(module) abort    " define constant variables +  if !exists('s:const') +    let s:const = {} +    let s:const.true = function('s:_true') +    let s:const.false = function('s:_false') +    let s:const.null = function('s:_null') +    lockvar s:const +  endif    call extend(a:module, s:const)  endfunction @@ -55,7 +66,7 @@ function! s:decode(json, ...) abort    let settings = extend({          \ 'use_token': 0,          \}, get(a:000, 0, {})) -  let json = iconv(a:json, "utf-8", &encoding) +  let json = iconv(a:json, 'utf-8', &encoding)    let json = join(split(json, "\n"), '')    let json = substitute(json, '\\u34;', '\\"', 'g')    let json = substitute(json, '\\u\(\x\x\x\x\)', '\=s:string.nr2enc_char("0x".submatch(1))', 'g') @@ -75,7 +86,11 @@ endfunction  " @vimlint(EVL102, 0, l:true)  " @vimlint(EVL102, 0, l:false) -function! s:encode(val) abort +function! s:encode(val, ...) abort +  let settings = extend({ +        \ 'indent': 0, +        \}, get(a:000, 0, {}) +        \)    if type(a:val) == 0      return a:val    elseif type(a:val) == 1 @@ -83,7 +98,7 @@ function! s:encode(val) abort      let json = substitute(json, "\r", '\\r', 'g')      let json = substitute(json, "\n", '\\n', 'g')      let json = substitute(json, "\t", '\\t', 'g') -    return iconv(json, &encoding, "utf-8") +    return iconv(json, &encoding, 'utf-8')    elseif type(a:val) == 2      if s:const.true == a:val        return 'true' @@ -96,14 +111,69 @@ function! s:encode(val) abort        return string(a:val)      endif    elseif type(a:val) == 3 -    return '[' . join(map(copy(a:val), 's:encode(v:val)'), ',') . ']' +    return s:_encode_list(a:val, settings)    elseif type(a:val) == 4 -    return '{' . join(map(keys(a:val), 's:encode(v:val).":".s:encode(a:val[v:val])'), ',') . '}' +    return s:_encode_dict(a:val, settings)    else      return string(a:val)    endif  endfunction +" @vimlint(EVL102, 1, l:ns) +function! s:_encode_list(val, settings) abort +  if empty(a:val) +    return '[]' +  elseif !a:settings.indent +    let encoded_candidates = map(copy(a:val), 's:encode(v:val, a:settings)') +    return printf('[%s]', join(encoded_candidates, ',')) +  else +    let previous_indent = get(a:settings, '_previous_indent') +    let indent = previous_indent + a:settings.indent +    let ns = extend(copy(a:settings), { +          \ '_previous_indent': indent, +          \}) +    let encoded_candidates = map( +          \ copy(a:val), +          \ printf('''%s'' . s:encode(v:val, ns)', repeat(' ', indent)), +          \) +    return printf( +          \ "[\n%s\n%s]", +          \ join(encoded_candidates, ",\n"), +          \ repeat(' ', previous_indent) +          \) +  endif +endfunction +" @vimlint(EVL102, 0, l:ns) + +" @vimlint(EVL102, 1, l:ns) +function! s:_encode_dict(val, settings) abort +  if empty(a:val) +    return '{}' +  elseif !a:settings.indent +    let encoded_candidates = map(keys(a:val), +          \ 's:encode(v:val, a:settings) . '':'' . s:encode(a:val[v:val], a:settings)' +          \) +    return printf('{%s}', join(encoded_candidates, ',')) +  else +    let previous_indent = get(a:settings, '_previous_indent') +    let indent = previous_indent + a:settings.indent +    let ns = extend(copy(a:settings), { +          \ '_previous_indent': indent, +          \}) +    let encoded_candidates = map(keys(a:val), +          \ printf( +          \   '''%s'' . s:encode(v:val, ns) . '': '' . s:encode(a:val[v:val], ns)', +          \   repeat(' ', indent), +          \ ), +          \) +    return printf("{\n%s\n%s}", +          \ join(encoded_candidates, ",\n"), +          \ repeat(' ', previous_indent), +          \) +  endif +endfunction +" @vimlint(EVL102, 0, l:ns) +  let &cpo = s:save_cpo  unlet s:save_cpo diff --git a/autoload/vital/crystal.vital b/autoload/vital/crystal.vital index 7c1f45ff..72fc7273 100644 --- a/autoload/vital/crystal.vital +++ b/autoload/vital/crystal.vital @@ -1,7 +1,7 @@  if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'crystal') == -1  crystal -a977489 +bee84ae23effb0510137ad177e98c94d8b3657a6  Process  Web.JSON diff --git a/autoload/xml/html5.vim b/autoload/xml/html5.vim index f3d0e9df..20353bd5 100644 --- a/autoload/xml/html5.vim +++ b/autoload/xml/html5.vim @@ -82,6 +82,7 @@ let attributes_value = {      \ 'action': ['URL', ''],      \ 'allowfullscreen': ['Bool', ''],      \ 'allowpaymentrequest': ['Bool', ''], +    \ 'allowpresentation': ['Bool', ''],      \ 'allowusermedia': ['Bool', ''],      \ 'alt': ['Text', ''],      \ 'async': ['Bool', ''], @@ -579,7 +580,7 @@ let g:xmldata_html5 = {  \ ],  \ 'iframe': [      \ [], -    \ extend(copy(global_attributes), {'src': [], 'srcdoc': [], 'name': [], 'width': [], 'height': [], 'sandbox': ['allow-same-origin', 'allow-forms', 'allow-scripts'], 'seamless': ['seamless', ''], 'referrerpolicy': ['no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-cross-origin', 'unsafe-url'], 'allowfullscreen': [], 'allowpaymentrequest': [], 'allowusermedia': []}) +    \ extend(copy(global_attributes), {'src': [], 'srcdoc': [], 'name': [], 'width': [], 'height': [], 'sandbox': ['allow-same-origin', 'allow-forms', 'allow-scripts'], 'seamless': ['seamless', ''], 'referrerpolicy': ['no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-cross-origin', 'unsafe-url'], 'allowfullscreen': [], 'allowpaymentrequest': [], 'allowpresentation': [], 'allowusermedia': []})  \ ],  \ 'img': [      \ [], diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 00d588ef..3c49d096 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -353,6 +353,7 @@ augroup END  augroup filetypedetect  " json:elzr/vim-json  autocmd BufNewFile,BufRead *.json setlocal filetype=json +autocmd BufNewFile,BufRead *.jsonl setlocal filetype=json  autocmd BufNewFile,BufRead *.jsonp setlocal filetype=json  autocmd BufNewFile,BufRead *.geojson setlocal filetype=json  autocmd BufNewFile,BufRead *.template setlocal filetype=json diff --git a/ftplugin/elixir.vim b/ftplugin/elixir.vim index 651cfba6..7219cb95 100644 --- a/ftplugin/elixir.vim +++ b/ftplugin/elixir.vim @@ -1,12 +1,12 @@  if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'elixir') == -1 -if (exists("b:did_ftplugin")) +if exists('b:did_ftplugin')    finish  endif  let b:did_ftplugin = 1  " Matchit support -if exists("loaded_matchit") && !exists("b:match_words") +if exists('loaded_matchit') && !exists('b:match_words')    let b:match_ignorecase = 0    let b:match_words = '\:\@<!\<\%(do\|fn\)\:\@!\>' . @@ -32,9 +32,26 @@ let &l:path =  setlocal includeexpr=elixir#util#get_filename(v:fname)  setlocal suffixesadd=.ex,.exs,.eex,.erl,.yrl,.hrl +let &l:define = 'def\(macro|guard|delegate\)p' + +silent! setlocal formatoptions-=t formatoptions+=croqlj + +let b:block_begin = '\<\(do$\|fn\>\)' +let b:block_end = '\<end\>' + +nnoremap <buffer> <silent> <expr> ]] ':silent keeppatterns /'.b:block_begin.'<CR>' +nnoremap <buffer> <silent> <expr> [[ ':silent keeppatterns ?'.b:block_begin.'<CR>' +nnoremap <buffer> <silent> <expr> ][ ':silent keeppatterns /'.b:block_end  .'<CR>' +nnoremap <buffer> <silent> <expr> [] ':silent keeppatterns ?'.b:block_end  .'<CR>' + +onoremap <buffer> <silent> <expr> ]] ':silent keeppatterns /'.b:block_begin.'<CR>' +onoremap <buffer> <silent> <expr> [[ ':silent keeppatterns ?'.b:block_begin.'<CR>' +onoremap <buffer> <silent> <expr> ][ ':silent keeppatterns /'.b:block_end  .'<CR>' +onoremap <buffer> <silent> <expr> [] ':silent keeppatterns ?'.b:block_end  .'<CR>' +  silent! setlocal formatoptions-=t formatoptions+=croqlj -let b:undo_ftplugin = 'setlocal sw< sts< et< isk< com< cms< path< inex< sua< '. -      \ '| unlet! b:match_ignorecase b:match_words' +let b:undo_ftplugin = 'setlocal sw< sts< et< isk< com< cms< path< inex< sua< def<'. +      \ '| unlet! b:match_ignorecase b:match_words b:block_begin b:block_end'  endif diff --git a/ftplugin/mail_vifm.vim b/ftplugin/mail_vifm.vim index 09cac4c6..9d6ffb68 100644 --- a/ftplugin/mail_vifm.vim +++ b/ftplugin/mail_vifm.vim @@ -2,7 +2,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vifm') == -1  " Mail file type extension to pick files for attachments via vifm  " Maintainer:  xaizek <xaizek@posteo.net> -" Last Change: January 23, 2016 +" Last Change: January 01, 2018  " Insert attachment picked via vifm after 'Subject' header  function! s:AddMailAttacments() @@ -26,7 +26,7 @@ function! s:AddMailAttacments()  	else  		" Work around handicapped neovim...  		let callback = { 'listf': l:listf } -		function! callback.on_exit(id, code) +		function! callback.on_exit(id, code, event)  			buffer #  			silent! bdelete! #  			call s:HandleRunResults(a:code, self.listf) diff --git a/syntax/go.vim b/syntax/go.vim index ef0bdd6b..4d5819ec 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -204,7 +204,19 @@ else  endif  if g:go_highlight_format_strings != 0 -  syn match       goFormatSpecifier   /\([^%]\(%%\)*\)\@<=%[-#0 +]*\%(\*\|\d\+\)\=\%(\.\%(\*\|\d\+\)\)*[vTtbcdoqxXUeEfgGsp]/ contained containedin=goString +  " [n] notation is valid for specifying explicit argument indexes +  " 1. Match a literal % not preceded by a %. +  " 2. Match any number of -, #, 0, space, or + +  " 3. Match * or [n]* or any number or nothing before a . +  " 4. Match * or [n]* or any number or nothing after a . +  " 5. Match [n] or nothing before a verb +  " 6. Match a formatting verb +  syn match       goFormatSpecifier   /\ +        \([^%]\(%%\)*\)\ +        \@<=%[-#0 +]*\ +        \%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\ +        \%(\.\%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\)\=\ +        \%(\[\d\+\]\)\=[vTtbcdoqxXUeEfFgGsp]/ contained containedin=goString,goRawString    hi def link     goFormatSpecifier   goSpecialString  endif diff --git a/syntax/html.vim b/syntax/html.vim index 19148af2..28e09e0b 100644 --- a/syntax/html.vim +++ b/syntax/html.vim @@ -112,7 +112,7 @@ syn keyword htmlArg contained async  " <content>  syn keyword htmlArg contained select  " <iframe> -syn keyword htmlArg contained seamless srcdoc sandbox allowfullscreen allowusermedia allowpaymentrequest  +syn keyword htmlArg contained seamless srcdoc sandbox allowfullscreen allowusermedia allowpaymentrequest allowpresentation  " <picture>  syn keyword htmlArg contained srcset sizes  " <a> diff --git a/syntax/json.vim b/syntax/json.vim index a65214a5..e41dbb98 100644 --- a/syntax/json.vim +++ b/syntax/json.vim @@ -73,10 +73,12 @@ if (!exists("g:vim_json_warnings") || g:vim_json_warnings==1)  	syn match   jsonTrailingCommaError  ",\_s*[}\]]"  	" Syntax: Watch out for missing commas between elements -	syn match   jsonMissingCommaError /\("\|\]\|\d\)\zs\_s\+\ze"/ -	syn match   jsonMissingCommaError /\(\]\|\}\)\_s\+\ze"/ "arrays/objects as values -	syn match   jsonMissingCommaError /}\_s\+\ze{/ "objects as elements in an array -	syn match   jsonMissingCommaError /\(true\|false\)\_s\+\ze"/ "true/false as value +  syn match   jsonMissingCommaError /\("\|\]\|\d\)\zs\_s\+\ze"/ +  syn match   jsonMissingCommaError /\(\]\|\}\)\_s\+\ze"/ "arrays/objects as values +  if (expand('%:e') !=? 'jsonl') +    syn match   jsonMissingCommaError /}\_s\+\ze{/ "objects as elements in an array +  endif +  syn match   jsonMissingCommaError /\(true\|false\)\_s\+\ze"/ "true/false as value  endif  " ********************************************** END OF ERROR WARNINGS diff --git a/syntax/julia.vim b/syntax/julia.vim index 915cc680..3af7ecb2 100644 --- a/syntax/julia.vim +++ b/syntax/julia.vim @@ -112,13 +112,13 @@ else  endif  syntax cluster juliaTypesItemsAll	contains=juliaBaseTypeBasic,juliaBaseTypeNum,juliaBaseTypeC,juliaBaseTypeError,juliaBaseTypeIter,juliaBaseTypeString,juliaBaseTypeArray,juliaBaseTypeDict,juliaBaseTypeSet,juliaBaseTypeIO,juliaBaseTypeProcess,juliaBaseTypeRange,juliaBaseTypeRegex,juliaBaseTypeFact,juliaBaseTypeFact,juliaBaseTypeSort,juliaBaseTypeRound,juliaBaseTypeSpecial,juliaBaseTypeRandom,juliaBaseTypeDisplay,juliaBaseTypeTime,juliaBaseTypeOther  syntax cluster juliaTypesItems05	contains=juliaBaseTypeIter05,juliaBaseTypeRange05 -syntax cluster juliaTypesItems0506	contains=juliaBaseTypeRange0506,juliaBaseTypeSet0506 +syntax cluster juliaTypesItems0506	contains=juliaBaseTypeNum0506,juliaBaseTypeRange0506,juliaBaseTypeSet0506  syntax cluster juliaTypesItems0607	contains=juliaBaseTypeBasic0607,juliaBaseTypeArray0607,juliaBaseTypeSet0607,juliaBaseTypeProcess0607,juliaBaseTypeRange0607,juliaBaseTypeTime0607 -syntax cluster juliaTypesItems07	contains=juliaBaseTypeRange07,juliaBaseTypeSet07 +syntax cluster juliaTypesItems07	contains=juliaBaseTypeBasic07,juliaBaseTypeNum07,juliaBaseTypeError07,juliaBaseTypeIter07,juliaBaseTypeRange07,juliaBaseTypeArray07,juliaBaseTypeSet07,juliaBaseTypeC07,juliaBaseTypeDisplay07,juliaBaseTypeIO07  syntax cluster juliaConstItemsAll	contains=juliaConstNum,juliaConstBool,juliaConstEnv,juliaConstIO,juliaConstMMap,juliaConstC,juliaConstGeneric  syntax cluster juliaConstItems0506	contains=juliaConstNum0506 -syntax cluster juliaConstItems07	contains=juliaPossibleEuler +syntax cluster juliaConstItems07	contains=juliaConstGeneric07,juliaPossibleEuler  if b:julia_syntax_version <= 6    syntax cluster juliaConstItems	contains=@juliaConstItemsAll,@juliaConstItems0506  else @@ -208,20 +208,28 @@ exec 'syntax match   juliaOuter    contained "\<outer\ze\s\+' . s:idregex . '\>"  syntax match   juliaBaseTypeBasic	display "\<\%(Tuple\|NTuple\|Symbol\|\%(Intrinsic\)\?Function\|Union\|Type\%(Name\|Constructor\|Var\)\?\|Any\|ANY\|Vararg\|Top\|None\|Nothing\|Ptr\|Void\|Exception\|Module\|Box\|Expr\|LambdaStaticData\|\%(Data\|Union\)Type\|\%(LineNumber\|Label\|Goto\|Quote\|Top\|Symbol\|Getfield\)Node\|\%(Weak\|Global\)\?Ref\|Associative\|Method\(Table\)\?\|GetfieldNode\|Nullable\|Pair\|Val\|TypeMap\%(Level\|Entry\)\)\>"  syntax match   juliaBaseTypeBasic0607	display "\<\%(UnionAll\|CodeInfo\)\>" -syntax match   juliaBaseTypeNum		display "\<\%(U\?Int\%(8\|16\|32\|64\|128\)\?\|Float\%(16\|32\|64\)\|Complex\%(32\|64\|128\)\?\|Bool\|Char\|Number\|Signed\|Unsigned\|Integer\|AbstractFloat\|Real\|Rational\|Irrational\|Enum\|BigInt\|BigFloat\|MathConst\)\>" +syntax match   juliaBaseTypeBasic07	display "\<\%(Some\|Missing\)\>" +syntax match   juliaBaseTypeNum		display "\<\%(U\?Int\%(8\|16\|32\|64\|128\)\?\|Float\%(16\|32\|64\)\|Complex\|Bool\|Char\|Number\|Signed\|Unsigned\|Integer\|AbstractFloat\|Real\|Rational\|Irrational\|Enum\|BigInt\|BigFloat\|MathConst\)\>" +syntax match   juliaBaseTypeNum0506	display "\<Complex\%(32\|64\|128\)\>" +syntax match   juliaBaseTypeNum07	display "\<\%(AbstractIrrational\|ComplexF\%(16\|32\|64\)\)\>"  syntax match   juliaBaseTypeC		display "\<\%(FileOffset\|C\%(u\?\%(char\|short\|int\|long\(long\)\?\|w\?string\)\|float\|double\|\%(ptrdiff\|s\?size\|wchar\|off\|u\?intmax\)_t\)\)\>" +syntax match   juliaBaseTypeC07		display "\<Cvoid\>"  syntax match   juliaBaseTypeError	display "\<\%(\%(Bounds\|Divide\|Domain\|\%(Stack\)\?Overflow\|EOF\|Undef\%(Ref\|Var\)\|System\|Type\|Parse\|Argument\|Key\|Load\|Method\|Inexact\|OutOfMemory\|Init\|Assertion\|Unicode\|ReadOnlyMemory\)Error\|\%(Interrupt\|Error\|ProcessExited\|Captured\|Composite\|InvalidState\|Null\|Remote\)Exception\|DimensionMismatch\|SegmentationFault\)\>" +syntax match   juliaBaseTypeError07	display "\<\%(StringIndexError\|MissingException\)\>"  syntax match   juliaBaseTypeIter	display "\<\%(EachLine\|Enumerate\|Cartesian\%(Index\|Range\)\|LinSpace\)\>"  syntax match   juliaBaseTypeIter05	display "\<\%(Zip\|Filter\)\>" +syntax match   juliaBaseTypeIter07	display "\<CartesianIndices\>"  syntax match   juliaBaseTypeString	display "\<\%(DirectIndex\|Sub\|Rep\|Rev\|Abstract\)\?String\>"  syntax match   juliaBaseTypeArray	display "\<\%(\%(Sub\)\?Array\|\%(Abstract\|Dense\|Strided\)\?\%(Array\|Matrix\|Vec\%(tor\|OrMat\)\)\|SparseMatrixCSC\|\%(AbstractSparse\|Bit\|Shared\)\%(Array\|Vector\|Matrix\)\|\%\(D\|Bid\|\%(Sym\)\?Trid\)iagonal\|Hermitian\|Symmetric\|UniformScaling\|\%(Lower\|Upper\)Triangular\|SparseVector\|VecElement\)\>"  syntax match   juliaBaseTypeArray0607	display "\<\%(Conj\%(Array\|Matrix\|Vector\)\|Index\%(Cartesian\|Linear\|Style\)\|PermutedDimsArray\|RowVector\)\>" +syntax match   juliaBaseTypeArray07	display "\<\%(BroadcastStyle\|Adjoint\|Transpose\|LinearIndices\)\>"  syntax match   juliaBaseTypeDict	display "\<\%(WeakKey\|ObjectId\)\?Dict\>"  syntax match   juliaBaseTypeSet		display "\<Set\>"  syntax match   juliaBaseTypeSet0506	display "\<IntSet\>"  syntax match   juliaBaseTypeSet0607	display "\<AbstractSet\>" -syntax match   juliaBaseTypeSet07	display "\<BitSet\>" +syntax match   juliaBaseTypeSet07	display "\<\%(\%(Bit\|Key\)Set\|AbstractDict\)\>"  syntax match   juliaBaseTypeIO		display "\<\%(IO\%(Stream\|Buffer\|Context\)\?\|RawFD\|StatStruct\|DevNull\|FileMonitor\|PollingFileWatcher\|Timer\|Base64\%(Decode\|Encode\)Pipe\|\%(UDP\|TCP\)Socket\|\%(Abstract\)\?Channel\|BufferStream\|ReentrantLock\)\>" +syntax match   juliaBaseTypeIO07	display "\<GenericIOBuffer\>"  syntax match   juliaBaseTypeProcess	display "\<\%(ProcessGroup\|Pipe\|Cmd\)\>"  syntax match   juliaBaseTypeProcess0607	display "\<PipeBuffer\>"  syntax match   juliaBaseTypeRange	display "\<\%(Dims\|RangeIndex\|\%(Ordinal\|Step\|\%(Abstract\)\?Unit\)Range\|Colon\)\>" @@ -236,6 +244,7 @@ syntax match   juliaBaseTypeRound	display "\<Round\%(ingMode\|FromZero\|Down\|Ne  syntax match   juliaBaseTypeSpecial	display "\<\%(LocalProcess\|ClusterManager\)\>"  syntax match   juliaBaseTypeRandom	display "\<\%(AbstractRNG\|MersenneTwister\|RandomDevice\)\>"  syntax match   juliaBaseTypeDisplay	display "\<\%(Text\(Display\)\?\|Display\|MIME\|HTML\)\>" +syntax match   juliaBaseTypeDisplay07	display "\<AbstractDisplay\>"  syntax match   juliaBaseTypeTime	display "\<\%(Date\%(Time\)\?\)\>"  syntax match   juliaBaseTypeTime0607	display "\<DateFormat\>"  syntax match   juliaBaseTypeOther	display "\<\%(RemoteRef\|Task\|Condition\|VersionNumber\|IPv[46]\|SerializationState\|WorkerConfig\|Future\|RemoteChannel\|IPAddr\|Stack\%(Trace\|Frame\)\|\(Caching\|Worker\)Pool\|AbstractSerializer\)\>" @@ -254,6 +263,7 @@ syntax match   juliaConstEnv		display "\<\%(ARGS\|ENV\|CPU_CORES\|OS_NAME\|ENDIA  syntax match   juliaConstIO		display "\<\%(STD\%(OUT\|IN\|ERR\)\)\>"  syntax match   juliaConstC		display "\<\%(WORD_SIZE\|C_NULL\)\>"  syntax match   juliaConstGeneric	display "\<\%(nothing\|Main\)\>" +syntax match   juliaConstGeneric07	display "\<missing\>"  syntax match   juliaPossibleMacro	transparent "@" contains=juliaMacroCall,juliaMacroCallP,juliaPrintfMacro @@ -442,11 +452,11 @@ for t in ["Iter", "Range"]    let h = b:julia_syntax_version == 5 ? "Type" : b:julia_syntax_version == 6 ? "juliaDeprecated" : "NONE"    exec "hi! def link juliaBaseType" . t . "05 " . h  endfor -for t in ["Range", "Set"] +for t in ["Num", "Range", "Set"]    let h = b:julia_syntax_version <= 6 ? "Type" : "juliaDeprecated"    exec "hi! def link juliaBaseType" . t . "0506 " . h  endfor -for t in ["Range", "Set"] +for t in ["Range", "Set", "Basic", "C", "Array", "Iter", "Display", "IO", "Num", "Error"]    let h = b:julia_syntax_version >= 7 ? "Type" : "NONE"    exec "hi! def link juliaBaseType" . t . "07 " . h  endfor @@ -469,6 +479,9 @@ hi def link juliaConstGeneric		Constant  hi def link juliaRangeEnd		Constant  hi def link juliaConstBool		Boolean +let h = b:julia_syntax_version >= 7 ? "Constant" : "NONE" +exec "hi! def link juliaConstGeneric07 " . h +  hi def link juliaComprehensionFor	Keyword  hi def link juliaComprehensionIf	Keyword diff --git a/syntax/plantuml.vim b/syntax/plantuml.vim index 2c20b0e4..b75ce52a 100644 --- a/syntax/plantuml.vim +++ b/syntax/plantuml.vim @@ -66,7 +66,7 @@ syntax match plantumlHorizontalArrow /\%([-\.]\%(|>\|>\|\*\|o\>\|\\\\\|\\\|\/\/\  syntax match plantumlDirectedOrVerticalArrowLR /[-\.]\%(le\?f\?t\?\|ri\?g\?h\?t\?\|up\?\|do\?w\?n\?\)\?[-\.]\%(|>\|>>\|>\|\*\|o\>\|\\\\\|\\\|\/\/\|\/\|\.\|-\)\%(\[[^\]]*\]\)\?/ contains=plantumlLabel  syntax match plantumlDirectedOrVerticalArrowRL /\%(<|\|<<\|<\|\*\|\<o\|\\\\\|\\\|\/\/\|\/\)[-\.]\%(le\?f\?t\?\|ri\?g\?h\?t\?\|up\?\|do\?w\?n\?\)\?[-\.]\%(\[[^\]]*\]\)\?/ contains=plantumlLabel  syntax region plantumlLabel start=/\[/ms=s+1 end=/\]/me=s-1 contained contains=plantumlText -syntax match plantumlText /\%([0-9A-Za-zÀ-ÿ]\|\s\|[\.,;_-]\)\+/ contained +syntax match plantumlText /\%([0-9A-Za-z\0xc0-\0xff]\|\s\|[\.,;_-]\)\+/ contained  " Note  syntax region plantumlNoteMultiLine start=/\%(^\s*[rh]\?note\)\@<=\s\%([^:"]\+$\)\@=/ end=/^\%(\s*end \?[rh]\?note$\)\@=/ contains=plantumlSpecialString,plantumlNoteMultiLineStart diff --git a/syntax/terraform.vim b/syntax/terraform.vim index 25cb3ffe..ba463913 100644 --- a/syntax/terraform.vim +++ b/syntax/terraform.vim @@ -14,9 +14,20 @@ syn keyword terraValueBool true false on off yes no  """ data  syn keyword terraDataTypeBI +          \ alicloud_dns_domain_groups +          \ alicloud_dns_domain_records +          \ alicloud_dns_domains +          \ alicloud_dns_groups +          \ alicloud_dns_records            \ alicloud_images            \ alicloud_instance_types            \ alicloud_key_pairs +          \ alicloud_ram_account_alias +          \ alicloud_ram_account_aliases +          \ alicloud_ram_groups +          \ alicloud_ram_policies +          \ alicloud_ram_roles +          \ alicloud_ram_users            \ alicloud_regions            \ alicloud_vpcs            \ alicloud_zones @@ -52,6 +63,7 @@ syn keyword terraDataTypeBI            \ aws_elastic_beanstalk_solution_stack            \ aws_elasticache_cluster            \ aws_elasticache_replication_group +          \ aws_elb            \ aws_elb_hosted_zone_id            \ aws_elb_service_account            \ aws_iam_account_alias @@ -73,6 +85,7 @@ syn keyword terraDataTypeBI            \ aws_lb_listener            \ aws_lb_target_group            \ aws_nat_gateway +          \ aws_network_interface            \ aws_partition            \ aws_prefix_list            \ aws_rds_cluster @@ -97,6 +110,7 @@ syn keyword terraDataTypeBI            \ azurerm_image            \ azurerm_key_vault_access_policy            \ azurerm_managed_disk +          \ azurerm_network_security_group            \ azurerm_platform_image            \ azurerm_public_ip            \ azurerm_resource_group @@ -104,6 +118,7 @@ syn keyword terraDataTypeBI            \ azurerm_snapshot            \ azurerm_subnet            \ azurerm_subscription +          \ azurerm_virtual_network            \ circonus_account            \ circonus_collector            \ cloudstack_template @@ -124,21 +139,28 @@ syn keyword terraDataTypeBI            \ github_team            \ github_user            \ google_active_folder +          \ google_billing_account            \ google_client_config            \ google_compute_address            \ google_compute_global_address +          \ google_compute_image            \ google_compute_instance_group            \ google_compute_lb_ip_ranges            \ google_compute_network +          \ google_compute_region_instance_group            \ google_compute_subnetwork            \ google_compute_zones +          \ google_container_cluster            \ google_container_engine_versions            \ google_dns_managed_zone            \ google_iam_policy +          \ google_kms_secret +          \ google_organization            \ google_storage_object_signed_url            \ http            \ kubernetes_service            \ kubernetes_storage_class +          \ local_file            \ logicmonitor_collectors            \ logicmonitor_device_group            \ newrelic_application @@ -154,6 +176,10 @@ syn keyword terraDataTypeBI            \ openstack_networking_network_v2            \ openstack_networking_secgroup_v2            \ openstack_networking_subnet_v2 +          \ opentelekomcloud_images_image_v2 +          \ opentelekomcloud_networking_network_v2 +          \ opentelekomcloud_networking_secgroup_v2 +          \ opentelekomcloud_s3_bucket_object            \ opsgenie_user            \ ovh_publiccloud_region            \ ovh_publiccloud_regions @@ -175,22 +201,33 @@ syn keyword terraDataTypeBI            \ template_cloudinit_config            \ template_file            \ terraform_remote_state +          \ triton_account +          \ triton_datacenter            \ triton_image            \ triton_network +          \ vsphere_custom_attribute            \ vsphere_datacenter +          \ vsphere_datastore            \ vsphere_distributed_virtual_switch            \ vsphere_host            \ vsphere_network +          \ vsphere_resource_pool            \ vsphere_tag            \ vsphere_tag_category +          \ vsphere_virtual_machine            \ vsphere_vmfs_disks  """ end data sources  """ resource  syn keyword terraResourceTypeBI +          \ alicloud_cdn_domain +          \ alicloud_container_cluster            \ alicloud_db_instance            \ alicloud_disk            \ alicloud_disk_attachment +          \ alicloud_dns +          \ alicloud_dns_group +          \ alicloud_dns_record            \ alicloud_eip            \ alicloud_eip_association            \ alicloud_ess_scaling_configuration @@ -204,12 +241,26 @@ syn keyword terraResourceTypeBI            \ alicloud_nat_gateway            \ alicloud_oss_bucket            \ alicloud_oss_bucket_object +          \ alicloud_ram_access_key +          \ alicloud_ram_account_alias +          \ alicloud_ram_alias +          \ alicloud_ram_group +          \ alicloud_ram_group_membership +          \ alicloud_ram_group_policy_attachment +          \ alicloud_ram_login_profile +          \ alicloud_ram_policy +          \ alicloud_ram_role +          \ alicloud_ram_role_attachment +          \ alicloud_ram_role_policy_attachment +          \ alicloud_ram_user +          \ alicloud_ram_user_policy_attachment            \ alicloud_route_entry            \ alicloud_router_interface            \ alicloud_security_group            \ alicloud_security_group_rule            \ alicloud_slb            \ alicloud_slb_attachment +          \ alicloud_slb_listener            \ alicloud_snat_entry            \ alicloud_subnet            \ alicloud_vpc @@ -247,6 +298,7 @@ syn keyword terraResourceTypeBI            \ aws_api_gateway_usage_plan_key            \ aws_app_cookie_stickiness_policy            \ aws_appautoscaling_policy +          \ aws_appautoscaling_scheduled_action            \ aws_appautoscaling_target            \ aws_athena_database            \ aws_athena_named_query @@ -270,6 +322,7 @@ syn keyword terraResourceTypeBI            \ aws_cloudwatch_log_destination_policy            \ aws_cloudwatch_log_group            \ aws_cloudwatch_log_metric_filter +          \ aws_cloudwatch_log_resource_policy            \ aws_cloudwatch_log_stream            \ aws_cloudwatch_log_subscription_filter            \ aws_cloudwatch_metric_alarm @@ -309,6 +362,7 @@ syn keyword terraResourceTypeBI            \ aws_dms_replication_subnet_group            \ aws_dms_replication_task            \ aws_dx_connection +          \ aws_dx_connection_association            \ aws_dx_lag            \ aws_dynamodb_table            \ aws_ebs_snapshot @@ -398,6 +452,9 @@ syn keyword terraResourceTypeBI            \ aws_load_balancer_listener_policy            \ aws_load_balancer_policy            \ aws_main_route_table_association +          \ aws_media_store_container +          \ aws_mq_broker +          \ aws_mq_configuration            \ aws_nat_gateway            \ aws_network_acl            \ aws_network_acl_rule @@ -443,6 +500,8 @@ syn keyword terraResourceTypeBI            \ aws_s3_bucket_policy            \ aws_security_group            \ aws_security_group_rule +          \ aws_service_discovery_private_dns_namespace +          \ aws_service_discovery_public_dns_namespace            \ aws_servicecatalog_portfolio            \ aws_ses_active_receipt_rule_set            \ aws_ses_configuration_set @@ -559,6 +618,7 @@ syn keyword terraResourceTypeBI            \ azurerm_local_network_gateway            \ azurerm_log_analytics_workspace            \ azurerm_managed_disk +          \ azurerm_management_lock            \ azurerm_mysql_configuration            \ azurerm_mysql_database            \ azurerm_mysql_firewall_rule @@ -566,6 +626,7 @@ syn keyword terraResourceTypeBI            \ azurerm_network_interface            \ azurerm_network_security_group            \ azurerm_network_security_rule +          \ azurerm_network_watcher            \ azurerm_postgresql_configuration            \ azurerm_postgresql_database            \ azurerm_postgresql_firewall_rule @@ -758,10 +819,11 @@ syn keyword terraResourceTypeBI            \ google_container_cluster            \ google_container_node_pool            \ google_dataproc_cluster +          \ google_dataproc_job            \ google_dns_managed_zone            \ google_dns_record_set            \ google_folder -          \ google_folder_iam_policy +          \ google_folder_organization_policy            \ google_kms_crypto_key            \ google_kms_key_ring            \ google_logging_billing_account_sink @@ -770,9 +832,7 @@ syn keyword terraResourceTypeBI            \ google_organization_iam_custom_role            \ google_organization_policy            \ google_project -          \ google_project_iam_binding            \ google_project_iam_custom_role -          \ google_project_iam_member            \ google_project_iam_policy            \ google_project_service            \ google_project_services @@ -874,6 +934,7 @@ syn keyword terraResourceTypeBI            \ opc_compute_ip_network            \ opc_compute_ip_network_exchange            \ opc_compute_ip_reservation +          \ opc_compute_orchestrated_instance            \ opc_compute_route            \ opc_compute_sec_rule            \ opc_compute_security_application @@ -887,7 +948,6 @@ syn keyword terraResourceTypeBI            \ opc_compute_storage_volume            \ opc_compute_storage_volume_snapshot            \ opc_compute_vnic_set -          \ opc_database_service_instance            \ opc_storage_container            \ opc_storage_object            \ openstack_blockstorage_volume_attach_v2 @@ -901,6 +961,8 @@ syn keyword terraResourceTypeBI            \ openstack_compute_secgroup_v2            \ openstack_compute_servergroup_v2            \ openstack_compute_volume_attach_v2 +          \ openstack_db_database_v1 +          \ openstack_db_instance_v1            \ openstack_dns_recordset_v2            \ openstack_dns_zone_v2            \ openstack_fw_firewall_v1 @@ -929,8 +991,47 @@ syn keyword terraResourceTypeBI            \ openstack_networking_subnet_v2            \ openstack_objectstorage_container_v1            \ openstack_objectstorage_object_v1 +          \ opentelekomcloud_blockstorage_volume_v2 +          \ opentelekomcloud_ces_alarmrule +          \ opentelekomcloud_compute_floatingip_associate_v2 +          \ opentelekomcloud_compute_floatingip_v2 +          \ opentelekomcloud_compute_instance_v2 +          \ opentelekomcloud_compute_keypair_v2 +          \ opentelekomcloud_compute_secgroup_v2 +          \ opentelekomcloud_compute_servergroup_v2 +          \ opentelekomcloud_compute_volume_attach_v2 +          \ opentelekomcloud_dns_recordset_v2 +          \ opentelekomcloud_dns_zone_v2 +          \ opentelekomcloud_elb_backend +          \ opentelekomcloud_elb_health +          \ opentelekomcloud_elb_listener +          \ opentelekomcloud_elb_loadbalancer +          \ opentelekomcloud_fw_firewall_group_v2 +          \ opentelekomcloud_fw_policy_v2 +          \ opentelekomcloud_fw_rule_v2 +          \ opentelekomcloud_images_image_v2 +          \ opentelekomcloud_lb_listener_v2 +          \ opentelekomcloud_lb_loadbalancer_v2 +          \ opentelekomcloud_lb_member_v2 +          \ opentelekomcloud_lb_monitor_v2 +          \ opentelekomcloud_lb_pool_v2 +          \ opentelekomcloud_networking_floatingip_v2 +          \ opentelekomcloud_networking_network_v2 +          \ opentelekomcloud_networking_port_v2 +          \ opentelekomcloud_networking_router_interface_v2 +          \ opentelekomcloud_networking_router_route_v2 +          \ opentelekomcloud_networking_router_v2 +          \ opentelekomcloud_networking_secgroup_rule_v2 +          \ opentelekomcloud_networking_secgroup_v2 +          \ opentelekomcloud_networking_subnet_v2 +          \ opentelekomcloud_s3_bucket +          \ opentelekomcloud_s3_bucket_object +          \ opentelekomcloud_s3_bucket_policy +          \ opentelekomcloud_smn_subscription_v2 +          \ opentelekomcloud_smn_topic_v2            \ opsgenie_team            \ opsgenie_user +          \ ovh_domain_zone_record            \ ovh_publiccloud_private_network            \ ovh_publiccloud_private_network_subnet            \ ovh_publiccloud_user @@ -984,6 +1085,7 @@ syn keyword terraResourceTypeBI            \ rancher_registry_credential            \ rancher_secret            \ rancher_stack +          \ rancher_volume            \ random_id            \ random_integer            \ random_pet @@ -1029,6 +1131,7 @@ syn keyword terraResourceTypeBI            \ vcd_snat            \ vcd_vapp            \ vcd_vapp_vm +          \ vsphere_custom_attribute            \ vsphere_datacenter            \ vsphere_distributed_port_group            \ vsphere_distributed_virtual_switch | 
