diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-09-02 21:07:30 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-09-02 21:07:30 +0200 |
commit | 20aac6c1126988339611576d425965a25a777658 (patch) | |
tree | 7954ca9025cbef1081a0ea9ad231e5692c6238b0 /runtime/autoload | |
parent | acca8df9d475bbfbafc71691ebc3b857ecd2777e (diff) |
Update runtime files.
Diffstat (limited to 'runtime/autoload')
-rw-r--r-- | runtime/autoload/ccomplete.vim | 39 | ||||
-rw-r--r-- | runtime/autoload/dist/ft.vim | 2 | ||||
-rw-r--r-- | runtime/autoload/tar.vim | 33 |
3 files changed, 60 insertions, 14 deletions
diff --git a/runtime/autoload/ccomplete.vim b/runtime/autoload/ccomplete.vim index d5bfa076a9..156b3af025 100644 --- a/runtime/autoload/ccomplete.vim +++ b/runtime/autoload/ccomplete.vim @@ -1,7 +1,7 @@ " Vim completion script " Language: C " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2012 Jun 20 +" Last Change: 2018 Aug 20 let s:cpo_save = &cpo set cpo&vim @@ -72,8 +72,10 @@ function! ccomplete#Complete(findstart, base) " Split item in words, keep empty word after "." or "->". " "aa" -> ['aa'], "aa." -> ['aa', ''], "aa.bb" -> ['aa', 'bb'], etc. " We can't use split, because we need to skip nested [...]. + " "aa[...]" -> ['aa', '[...]'], "aa.bb[...]" -> ['aa', 'bb', '[...]'], etc. let items = [] let s = 0 + let arrays = 0 while 1 let e = match(base, '\.\|->\|\[', s) if e < 0 @@ -107,6 +109,7 @@ function! ccomplete#Complete(findstart, base) endwhile let e += 1 call add(items, strpart(base, s, e - s)) + let arrays += 1 let s = e endif endwhile @@ -161,15 +164,26 @@ function! ccomplete#Complete(findstart, base) endif endif let res = [{'match': match, 'tagline' : '', 'kind' : kind, 'info' : line}] + elseif len(items) == arrays + 1 + " Completing one word and it's a local array variable: build tagline + " from declaration line + let match = items[0] + let kind = 'v' + let tagline = "\t/^" . line . '$/' + let res = [{'match': match, 'tagline' : tagline, 'kind' : kind, 'info' : line}] else " Completing "var.", "var.something", etc. let res = s:Nextitem(strpart(line, 0, col), items[1:], 0, 1) endif endif - if len(items) == 1 + if len(items) == 1 || len(items) == arrays + 1 " Only one part, no "." or "->": complete from tags file. - let tags = taglist('^' . base) + if len(items) == 1 + let tags = taglist('^' . base) + else + let tags = taglist('^' . items[0] . '$') + endif " Remove members, these can't appear without something in front. call filter(tags, 'has_key(v:val, "kind") ? v:val["kind"] != "m" : 1') @@ -516,11 +530,24 @@ function! s:StructMembers(typename, items, all) endif endif + " Skip over [...] items + let idx = 0 + while 1 + if idx >= len(a:items) + let target = '' " No further items, matching all members + break + endif + if a:items[idx][0] != '[' + let target = a:items[idx] + break + endif + let idx += 1 + endwhile " Put matching members in matches[]. let matches = [] for l in qflist let memb = matchstr(l['text'], '[^\t]*') - if memb =~ '^' . a:items[0] + if memb =~ '^' . target " Skip matches local to another file. if match(l['text'], "\tfile:") < 0 || bufnr('%') == bufnr(matchstr(l['text'], '\t\zs[^\t]*')) let item = {'match': memb, 'tagline': l['text']} @@ -540,8 +567,8 @@ function! s:StructMembers(typename, items, all) endfor if len(matches) > 0 - " Skip over [...] items - let idx = 1 + " Skip over next [...] items + let idx += 1 while 1 if idx >= len(a:items) return matches " No further items, return the result. diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 81fdc9d956..160cdcff64 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -632,7 +632,7 @@ endfunc " Choose context, plaintex, or tex (LaTeX) based on these rules: " 1. Check the first line of the file for "%&<format>". " 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords. -" 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc. +" 3. Default to "plain" or to g:tex_flavor, can be set in user's vimrc. func dist#ft#FTtex() let firstline = getline(1) if firstline =~ '^%&\s*\a\+' diff --git a/runtime/autoload/tar.vim b/runtime/autoload/tar.vim index 34eab96709..d92fe1b180 100644 --- a/runtime/autoload/tar.vim +++ b/runtime/autoload/tar.vim @@ -152,13 +152,16 @@ fun! tar#Browse(tarfile) " assuming cygwin let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e') endif + + let gzip_command = s:get_gzip_command(tarfile) + let curlast= line("$") if tarfile =~# '\.\(gz\|tgz\)$' " call Decho("1: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ") - exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " + exe "sil! r! " . gzip_command . " -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " elseif tarfile =~# '\.lrp' " call Decho("2: exe silent r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - ") - exe "sil! r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - " + exe "sil! r! cat -- ".shellescape(tarfile,1)."|" . gzip_command . " -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - " elseif tarfile =~# '\.\(bz2\|tbz\|tb2\)$' " call Decho("3: exe silent r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ") exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - " @@ -287,15 +290,18 @@ fun! tar#Read(fname,mode) else let tar_secure= " " endif + + let gzip_command = s:get_gzip_command(tarfile) + if tarfile =~# '\.bz2$' " call Decho("7: exe silent r! bzip2 -d -c ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp) exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp elseif tarfile =~# '\.\(gz\|tgz\)$' " call Decho("5: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd.' -'.g:tar_readoptions.' - '.tar_secure.shellescape(fname,1)) - exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp + exe "sil! r! " . gzip_command . " -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp elseif tarfile =~# '\.lrp$' " call Decho("6: exe silent r! cat ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp) - exe "sil! r! cat -- ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp + exe "sil! r! cat -- ".shellescape(tarfile,1)." | " . gzip_command . " -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp elseif tarfile =~# '\.lzma$' " call Decho("7: exe silent r! lzma -d -c ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp) exe "sil! r! lzma -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp @@ -389,6 +395,8 @@ fun! tar#Write(fname) let tarfile = substitute(b:tarfile,'tarfile:\(.\{-}\)::.*$','\1','') let fname = substitute(b:tarfile,'tarfile:.\{-}::\(.*\)$','\1','') + let gzip_command = s:get_gzip_command(tarfile) + " handle compressed archives if tarfile =~# '\.bz2' call system("bzip2 -d -- ".shellescape(tarfile,0)) @@ -396,12 +404,12 @@ fun! tar#Write(fname) let compress= "bzip2 -- ".shellescape(tarfile,0) " call Decho("compress<".compress.">") elseif tarfile =~# '\.gz' - call system("gzip -d -- ".shellescape(tarfile,0)) + call system(gzip_command . " -d -- ".shellescape(tarfile,0)) let tarfile = substitute(tarfile,'\.gz','','e') let compress= "gzip -- ".shellescape(tarfile,0) " call Decho("compress<".compress.">") elseif tarfile =~# '\.tgz' - call system("gzip -d -- ".shellescape(tarfile,0)) + call system(gzip_command . " -d -- ".shellescape(tarfile,0)) let tarfile = substitute(tarfile,'\.tgz','.tar','e') let compress= "gzip -- ".shellescape(tarfile,0) let tgz = 1 @@ -581,7 +589,9 @@ fun! tar#Vimuntar(...) " if necessary, decompress the tarball; then, extract it if tartail =~ '\.tgz' - if executable("gunzip") + if executable("bzip2") + silent exe "!bzip2 -d ".shellescape(tartail) + elseif executable("gunzip") silent exe "!gunzip ".shellescape(tartail) elseif executable("gzip") silent exe "!gzip -d ".shellescape(tartail) @@ -619,6 +629,15 @@ fun! tar#Vimuntar(...) " call Dret("tar#Vimuntar") endfun +func s:get_gzip_command(file) + if a:file =~# 'z$' && executable('bzip2') + " Some .tgz files are actually compressed with bzip2. Since bzip2 can + " handle the format from gzip, use it if the command exists. + return 'bzip2' + endif + return 'gzip' +endfunc + " ===================================================================== " Modelines And Restoration: {{{1 let &cpo= s:keepcpo |