summaryrefslogtreecommitdiffstats
path: root/runtime/autoload
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:05:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:05:15 +0000
commit6e9cd6b491267e6dff3e3f3f37d8af5f28e40672 (patch)
tree35661af16c4a0ef2a9a8e225d2d5cc82605ea289 /runtime/autoload
parentAdding upstream version 2:9.1.0496. (diff)
downloadvim-6e9cd6b491267e6dff3e3f3f37d8af5f28e40672.tar.xz
vim-6e9cd6b491267e6dff3e3f3f37d8af5f28e40672.zip
Adding upstream version 2:9.1.0698.upstream/2%9.1.0698
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'runtime/autoload')
-rw-r--r--runtime/autoload/dist/ft.vim101
-rw-r--r--runtime/autoload/dist/man.vim7
-rw-r--r--runtime/autoload/dist/vim.vim4
-rw-r--r--runtime/autoload/dist/vim9.vim4
-rw-r--r--runtime/autoload/netrw.vim203
-rw-r--r--runtime/autoload/typst.vim50
-rw-r--r--runtime/autoload/zip.vim258
7 files changed, 355 insertions, 272 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index bf9e32e..c8942eb 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -9,6 +9,8 @@ vim9script
# These functions are moved here from runtime/filetype.vim to make startup
# faster.
+var prolog_pattern = '^\s*\(:-\|%\+\(\s\|$\)\|\/\*\)\|\.\s*$'
+
export def Check_inp()
if getline(1) =~ '%%'
setf tex
@@ -402,18 +404,38 @@ export def FTharedoc()
endif
enddef
-# Distinguish between HTML, XHTML and Django
+# Distinguish between HTML, XHTML, Django and Angular
export def FThtml()
var n = 1
- while n < 10 && n <= line("$")
+
+ # Test if the filename follows the Angular component template convention
+ # Disabled for the reasons mentioned here: #13594
+ # if expand('%:t') =~ '^.*\.component\.html$'
+ # setf htmlangular
+ # return
+ # endif
+
+ while n < 40 && n <= line("$")
+ # Check for Angular
+ if getline(n) =~ '@\(if\|for\|defer\|switch\)\|\*\(ngIf\|ngFor\|ngSwitch\|ngTemplateOutlet\)\|ng-template\|ng-content\|{{.*}}'
+ setf htmlangular
+ return
+ endif
+ # Check for XHTML
if getline(n) =~ '\<DTD\s\+XHTML\s'
setf xhtml
return
endif
- if getline(n) =~ '{%\s*\(extends\|block\|load\)\>\|{#\s\+'
+ # Check for Django
+ if getline(n) =~ '{%\s*\(autoescape\|block\|comment\|csrf_token\|cycle\|debug\|extends\|filter\|firstof\|for\|if\|ifchanged\|include\|load\|lorem\|now\|query_string\|regroup\|resetcycle\|spaceless\|templatetag\|url\|verbatim\|widthratio\|with\)\>\|{#\s\+'
setf htmldjango
return
endif
+ # Check for SuperHTML
+ if getline(n) =~ '<extend\|<super>'
+ setf superhtml
+ return
+ endif
n += 1
endwhile
setf FALLBACK html
@@ -449,7 +471,7 @@ export def ProtoCheck(default: string)
# recognize Prolog by specific text in the first non-empty line
# require a blank after the '%' because Perl uses "%list" and "%translate"
var lnum = getline(nextnonblank(1))
- if lnum =~ '\<prolog\>' || lnum =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || lnum =~ ':-'
+ if lnum =~ '\<prolog\>' || lnum =~ prolog_pattern
setf prolog
else
exe 'setf ' .. default
@@ -514,6 +536,25 @@ export def FTm()
endif
enddef
+export def FTmake()
+ # Check if it is a Microsoft Makefile
+ unlet! b:make_microsoft
+ var n = 1
+ while n < 1000 && n <= line('$')
+ var line = getline(n)
+ if line =~? '^\s*!\s*\(ifn\=\(def\)\=\|include\|message\|error\)\>'
+ b:make_microsoft = 1
+ break
+ elseif line =~ '^ *ifn\=\(eq\|def\)\>' || line =~ '^ *[-s]\=include\s'
+ break
+ elseif line =~ '^ *\w\+\s*[!?:+]='
+ break
+ endif
+ n += 1
+ endwhile
+ setf make
+enddef
+
export def FTmms()
var n = 1
while n < 20
@@ -628,7 +669,7 @@ export def FTpl()
# recognize Prolog by specific text in the first non-empty line
# require a blank after the '%' because Perl uses "%list" and "%translate"
var line = getline(nextnonblank(1))
- if line =~ '\<prolog\>' || line =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || line =~ ':-'
+ if line =~ '\<prolog\>' || line =~ prolog_pattern
setf prolog
else
setf perl
@@ -1265,6 +1306,56 @@ export def FTtyp()
setf typst
enddef
+# Detect Microsoft Developer Studio Project files (Makefile) or Faust DSP
+# files.
+export def FTdsp()
+ if exists("g:filetype_dsp")
+ exe "setf " .. g:filetype_dsp
+ return
+ endif
+
+ # Test the filename
+ if expand('%:t') =~ '^[mM]akefile.*$'
+ setf make
+ return
+ endif
+
+ # Test the file contents
+ for line in getline(1, 200)
+ # Chech for comment style
+ if line =~ '^#.*'
+ setf make
+ return
+ endif
+
+ # Check for common lines
+ if line =~ '^.*Microsoft Developer Studio Project File.*$'
+ setf make
+ return
+ endif
+
+ if line =~ '^!MESSAGE This is not a valid makefile\..+$'
+ setf make
+ return
+ endif
+
+ # Check for keywords
+ if line =~ '^!(IF,ELSEIF,ENDIF).*$'
+ setf make
+ return
+ endif
+
+ # Check for common assignments
+ if line =~ '^SOURCE=.*$'
+ setf make
+ return
+ endif
+ endfor
+
+ # Otherwise, assume we have a Faust file
+ setf faust
+enddef
+
# Set the filetype of a *.v file to Verilog, V or Cog based on the first 200
# lines.
export def FTv()
diff --git a/runtime/autoload/dist/man.vim b/runtime/autoload/dist/man.vim
index 708e106..d9dbaf4 100644
--- a/runtime/autoload/dist/man.vim
+++ b/runtime/autoload/dist/man.vim
@@ -4,6 +4,7 @@
" Maintainer: SungHyun Nam <goweol@gmail.com>
" Autoload Split: Bram Moolenaar
" Last Change: 2024 Jan 17 (make it work on AIX, see #13847)
+" 2024 Jul 06 (honor command modifiers, #15117)
let s:cpo_save = &cpo
set cpo-=C
@@ -165,7 +166,9 @@ func dist#man#GetPage(cmdmods, ...)
endwhile
endif
if &filetype != "man"
- if exists("g:ft_man_open_mode")
+ if a:cmdmods =~ '\<\(tab\|vertical\|horizontal\)\>'
+ let open_cmd = a:cmdmods . ' split'
+ elseif exists("g:ft_man_open_mode")
if g:ft_man_open_mode == 'vert'
let open_cmd = 'vsplit'
elseif g:ft_man_open_mode == 'tab'
@@ -174,7 +177,7 @@ func dist#man#GetPage(cmdmods, ...)
let open_cmd = 'split'
endif
else
- let open_cmd = a:cmdmods . ' split'
+ let open_cmd = 'split'
endif
endif
endif
diff --git a/runtime/autoload/dist/vim.vim b/runtime/autoload/dist/vim.vim
index 021244c..d519406 100644
--- a/runtime/autoload/dist/vim.vim
+++ b/runtime/autoload/dist/vim.vim
@@ -18,6 +18,10 @@ endif
if !has('vim9script')
function dist#vim#IsSafeExecutable(filetype, executable)
let cwd = getcwd()
+ if empty(exepath(a:executable))
+ echomsg a:executable .. " not found in $PATH"
+ return v:false
+ endif
return get(g:, a:filetype .. '_exec', get(g:, 'plugin_exec', 0)) &&
\ (fnamemodify(exepath(a:executable), ':p:h') !=# cwd
\ || (split($PATH, has('win32') ? ';' : ':')->index(cwd) != -1 &&
diff --git a/runtime/autoload/dist/vim9.vim b/runtime/autoload/dist/vim9.vim
index 807140d..8fa9380 100644
--- a/runtime/autoload/dist/vim9.vim
+++ b/runtime/autoload/dist/vim9.vim
@@ -6,6 +6,10 @@ vim9script
# Last Change: 2023 Oct 25
export def IsSafeExecutable(filetype: string, executable: string): bool
+ if empty(exepath(executable))
+ echomsg executable .. " not found in $PATH"
+ return v:false
+ endif
var cwd = getcwd()
return get(g:, filetype .. '_exec', get(g:, 'plugin_exec', 0))
&& (fnamemodify(exepath(executable), ':p:h') !=# cwd
diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim
index d8de432..e747ce2 100644
--- a/runtime/autoload/netrw.vim
+++ b/runtime/autoload/netrw.vim
@@ -3,7 +3,7 @@
" Maintainer: This runtime file is looking for a new maintainer.
" Date: May 03, 2023
" Version: 173a
-" Last Change:
+" Last Change: {{{1
" 2023 Nov 21 by Vim Project: ignore wildignore when expanding $COMSPEC (v173a)
" 2023 Nov 22 by Vim Project: fix handling of very long filename on longlist style (v173a)
" 2024 Feb 19 by Vim Project: (announce adoption)
@@ -15,6 +15,15 @@
" 2024 May 13 by Vim Project: prefer scp over pscp
" 2024 Jun 04 by Vim Project: set bufhidden if buffer changed, nohidden is set and buffer shall be switched (#14915)
" 2024 Jun 13 by Vim Project: glob() on Windows fails when a directory name contains [] (#14952)
+" 2024 Jun 23 by Vim Project: save ad restore registers when liststyle = WIDELIST (#15077, #15114)
+" 2024 Jul 22 by Vim Project: avoid endless recursion (#15318)
+" 2024 Jul 23 by Vim Project: escape filename before trying to delete it (#15330)
+" 2024 Jul 30 by Vim Project: handle mark-copy to same target directory (#12112)
+" 2024 Aug 02 by Vim Project: honor g:netrw_alt{o,v} for :{S,H,V}explore (#15417)
+" 2024 Aug 15 by Vim Project: style changes, prevent E121 (#15501)
+" 2024 Aug 22 by Vim Project: fix mf-selection highlight (#15551)
+" 2024 Aug 22 by Vim Project: adjust echo output of mx command (#15550)
+" }}}
" Former Maintainer: Charles E Campbell
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
@@ -57,11 +66,6 @@ if exists("s:needspatches")
endif
let g:loaded_netrw = "v173"
-if !exists("s:NOTE")
- let s:NOTE = 0
- let s:WARNING = 1
- let s:ERROR = 2
-endif
let s:keepcpo= &cpo
setl cpo&vim
@@ -99,7 +103,7 @@ fun! netrw#ErrorMsg(level,msg,errnum)
endif
" call Decho("level=".level,'~'.expand("<slnum>"))
- if g:netrw_use_errorwindow == 2 && (v:version > 802 || (v:version == 802 && has("patch486")))
+ if g:netrw_use_errorwindow == 2 && exists("*popup_atcursor")
" use popup window
if type(a:msg) == 3
let msg = [level]+a:msg
@@ -215,6 +219,11 @@ if !exists("s:LONGLIST")
call s:NetrwInit("s:MAXLIST" ,4)
endif
+let s:NOTE = 0
+let s:WARNING = 1
+let s:ERROR = 2
+call s:NetrwInit("g:netrw_errorlvl", s:NOTE)
+
" ---------------------------------------------------------------------
" Default option values: {{{2
let g:netrw_localcopycmdopt = ""
@@ -224,7 +233,10 @@ let g:netrw_localmovecmdopt = ""
" ---------------------------------------------------------------------
" Default values for netrw's global protocol variables {{{2
-if (v:version > 802 || (v:version == 802 && has("patch486"))) && has("balloon_eval") && !exists("s:initbeval") && !exists("g:netrw_nobeval") && has("syntax") && exists("g:syntax_on") && has("mouse")
+if exists("*popup_atcursor")
+\ && has("syntax")
+\ && exists("g:syntax_on")
+\ && has("mouse")
call s:NetrwInit("g:netrw_use_errorwindow",2)
else
call s:NetrwInit("g:netrw_use_errorwindow",1)
@@ -342,7 +354,6 @@ call s:NetrwInit("s:didstarstar",0)
call s:NetrwInit("g:netrw_dirhistcnt" , 0)
call s:NetrwInit("g:netrw_decompress" , '{ ".gz" : "gunzip", ".bz2" : "bunzip2", ".zip" : "unzip", ".tar" : "tar -xf", ".xz" : "unxz" }')
call s:NetrwInit("g:netrw_dirhistmax" , 10)
-call s:NetrwInit("g:netrw_errorlvl" , s:NOTE)
call s:NetrwInit("g:netrw_fastbrowse" , 1)
call s:NetrwInit("g:netrw_ftp_browse_reject", '^total\s\+\d\+$\|^Trying\s\+\d\+.*$\|^KERBEROS_V\d rejected\|^Security extensions not\|No such file\|: connect to address [0-9a-fA-F:]*: No route to host$')
if !exists("g:netrw_ftp_list_cmd")
@@ -693,12 +704,11 @@ fun! netrw#Explore(indx,dosplit,style,...)
\ ((isdirectory(s:NetrwFile(a:1))))? 'is a directory' : 'is not a directory',
\ '~'.expand("<slnum>"))
if a:1 =~ "\\\s" && !filereadable(s:NetrwFile(a:1)) && !isdirectory(s:NetrwFile(a:1))
-" call Decho("re-trying Explore with <".substitute(a:1,'\\\(\s\)','\1','g').">",'~'.expand("<slnum>"))
- call netrw#Explore(a:indx,a:dosplit,a:style,substitute(a:1,'\\\(\s\)','\1','g'))
-" call Dret("netrw#Explore : returning from retry")
- return
-" else " Decho
-" call Decho("retry not needed",'~'.expand("<slnum>"))
+ let a1 = substitute(a:1, '\\\(\s\)', '\1', 'g')
+ if a1 != a:1
+ call netrw#Explore(a:indx, a:dosplit, a:style, a1)
+ return
+ endif
endif
endif
@@ -714,7 +724,6 @@ fun! netrw#Explore(indx,dosplit,style,...)
" -or- file has been modified AND file not hidden when abandoned
" -or- Texplore used
if a:dosplit || (&modified && &hidden == 0 && &bufhidden != "hide") || a:style == 6
-" call Decho("case dosplit=".a:dosplit." modified=".&modified." a:style=".a:style.": dosplit or file has been modified",'~'.expand("<slnum>"))
call s:SaveWinVars()
let winsz= g:netrw_winsize
if a:indx > 0
@@ -722,57 +731,41 @@ fun! netrw#Explore(indx,dosplit,style,...)
endif
if a:style == 0 " Explore, Sexplore
-" call Decho("style=0: Explore or Sexplore",'~'.expand("<slnum>"))
let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz
if winsz == 0|let winsz= ""|endif
- exe "noswapfile ".winsz."wincmd s"
-" call Decho("exe noswapfile ".winsz."wincmd s",'~'.expand("<slnum>"))
+ exe "noswapfile ".(g:netrw_alto ? "below " : "above ").winsz."wincmd s"
- elseif a:style == 1 "Explore!, Sexplore!
-" call Decho("style=1: Explore! or Sexplore!",'~'.expand("<slnum>"))
+ elseif a:style == 1 " Explore!, Sexplore!
let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz
if winsz == 0|let winsz= ""|endif
- exe "keepalt noswapfile ".winsz."wincmd v"
-" call Decho("exe keepalt noswapfile ".winsz."wincmd v",'~'.expand("<slnum>"))
+ exe "keepalt noswapfile ".(g:netrw_altv ? "rightbelow " : "leftabove ").winsz."wincmd v"
elseif a:style == 2 " Hexplore
-" call Decho("style=2: Hexplore",'~'.expand("<slnum>"))
let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz
if winsz == 0|let winsz= ""|endif
- exe "keepalt noswapfile bel ".winsz."wincmd s"
-" call Decho("exe keepalt noswapfile bel ".winsz."wincmd s",'~'.expand("<slnum>"))
+ exe "keepalt noswapfile ".(g:netrw_alto ? "below " : "above ").winsz."wincmd s"
elseif a:style == 3 " Hexplore!
-" call Decho("style=3: Hexplore!",'~'.expand("<slnum>"))
let winsz= (winsz > 0)? (winsz*winheight(0))/100 : -winsz
if winsz == 0|let winsz= ""|endif
- exe "keepalt noswapfile abo ".winsz."wincmd s"
-" call Decho("exe keepalt noswapfile abo ".winsz."wincmd s",'~'.expand("<slnum>"))
+ exe "keepalt noswapfile ".(!g:netrw_alto ? "below " : "above ").winsz."wincmd s"
elseif a:style == 4 " Vexplore
-" call Decho("style=4: Vexplore",'~'.expand("<slnum>"))
let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz
if winsz == 0|let winsz= ""|endif
- exe "keepalt noswapfile lefta ".winsz."wincmd v"
-" call Decho("exe keepalt noswapfile lefta ".winsz."wincmd v",'~'.expand("<slnum>"))
+ exe "keepalt noswapfile ".(g:netrw_altv ? "rightbelow " : "leftabove ").winsz."wincmd v"
elseif a:style == 5 " Vexplore!
-" call Decho("style=5: Vexplore!",'~'.expand("<slnum>"))
let winsz= (winsz > 0)? (winsz*winwidth(0))/100 : -winsz
if winsz == 0|let winsz= ""|endif
- exe "keepalt noswapfile rightb ".winsz."wincmd v"
-" call Decho("exe keepalt noswapfile rightb ".winsz."wincmd v",'~'.expand("<slnum>"))
+ exe "keepalt noswapfile ".(!g:netrw_altv ? "rightbelow " : "leftabove ").winsz."wincmd v"
elseif a:style == 6 " Texplore
call s:SaveBufVars()
-" call Decho("style = 6: Texplore",'~'.expand("<slnum>"))
exe "keepalt tabnew ".fnameescape(curdir)
-" call Decho("exe keepalt tabnew ".fnameescape(curdir),'~'.expand("<slnum>"))
call s:RestoreBufVars()
endif
call s:RestoreWinVars()
-" else " Decho
-" call Decho("case a:dosplit=".a:dosplit." AND modified=".&modified." AND a:style=".a:style." is not 6",'~'.expand("<slnum>"))
endif
NetrwKeepj norm! 0
@@ -4496,7 +4489,15 @@ fun! s:NetrwGetWord()
call cursor(line("."),filestart+1)
NetrwKeepj norm! ma
endif
- let rega= @a
+
+ let dict={}
+ " save the unnamed register and register 0-9 and a
+ let dict.a=[getreg('a'), getregtype('a')]
+ for i in range(0, 9)
+ let dict[i] = [getreg(i), getregtype(i)]
+ endfor
+ let dict.unnamed = [getreg(''), getregtype('')]
+
let eofname= filestart + b:netrw_cpf + 1
if eofname <= col("$")
call cursor(line("."),filestart+b:netrw_cpf+1)
@@ -4504,8 +4505,10 @@ fun! s:NetrwGetWord()
else
NetrwKeepj norm! "ay$
endif
+
let dirname = @a
- let @a = rega
+ call s:RestoreRegister(dict)
+
" call Decho("2: dirname<".dirname.">",'~'.expand("<slnum>"))
let dirname= substitute(dirname,'\s\+$','','e')
" call Decho("3: dirname<".dirname.">",'~'.expand("<slnum>"))
@@ -5573,13 +5576,12 @@ endfun
" ---------------------------------------------------------------------
" netrw#BrowseXVis: used by gx in visual mode to select a file for browsing {{{2
fun! netrw#BrowseXVis()
-" call Dfunc("netrw#BrowseXVis()")
- let akeep = @a
+ let dict={}
+ let dict.a=[getreg('a'), getregtype('a')]
norm! gv"ay
let gxfile= @a
- let @a = akeep
+ call s:RestoreRegister(dict)
call netrw#BrowseX(gxfile,netrw#CheckIfRemote(gxfile))
-" call Dret("netrw#BrowseXVis")
endfun
" ---------------------------------------------------------------------
@@ -6887,11 +6889,7 @@ fun! s:NetrwMarkFile(islocal,fname)
let ykeep = @@
let curbufnr= bufnr("%")
- if a:fname =~ '^\a'
- let leader= '\<'
- else
- let leader= ''
- endif
+ let leader= '\(^\|\s\)\zs'
if a:fname =~ '\a$'
let trailer = '\>[@=|\/\*]\=\ze\%( \|\t\|$\)'
else
@@ -7154,7 +7152,7 @@ fun! s:NetrwMarkFileCopy(islocal,...)
endif
" copy marked files while within the same directory (ie. allow renaming)
- if simplify(s:netrwmftgt) == simplify(b:netrw_curdir)
+ if s:StripTrailingSlash(simplify(s:netrwmftgt)) == s:StripTrailingSlash(simplify(b:netrw_curdir))
if len(s:netrwmarkfilelist_{bufnr('%')}) == 1
" only one marked file
" call Decho("case: only one marked file",'~'.expand("<slnum>"))
@@ -7231,7 +7229,7 @@ fun! s:NetrwMarkFileCopy(islocal,...)
" call Decho("system(".copycmd." '".args."' '".tgt."')",'~'.expand("<slnum>"))
call system(copycmd.g:netrw_localcopycmdopt." '".args."' '".tgt."'")
if v:shell_error != 0
- if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && !g:netrw_keepdir
+ if exists("b:netrw_curdir") && b:netrw_curdir != getcwd() && g:netrw_keepdir
call netrw#ErrorMsg(s:ERROR,"copy failed; perhaps due to vim's current directory<".getcwd()."> not matching netrw's (".b:netrw_curdir.") (see :help netrw-cd)",101)
else
call netrw#ErrorMsg(s:ERROR,"tried using g:netrw_localcopycmd<".g:netrw_localcopycmd.">; it doesn't work!",80)
@@ -7500,7 +7498,13 @@ fun! s:NetrwMarkFileExe(islocal,enbloc)
NetrwKeepj call netrw#ErrorMsg(s:ERROR,"command<".xcmd."> failed, aborting",54)
break
else
- echo ret
+ if ret !=# ''
+ echo "\n"
+ " skip trailing new line
+ echo ret[0:-2]
+ else
+ echo ret
+ endif
endif
endfor
@@ -9779,7 +9783,13 @@ fun! s:NetrwWideListing()
" fpl: filenames per line
" fpc: filenames per column
setl ma noro
- let keepa= @a
+ let dict={}
+ " save the unnamed register and register 0-9 and a
+ let dict.a=[getreg('a'), getregtype('a')]
+ for i in range(0, 9)
+ let dict[i] = [getreg(i), getregtype(i)]
+ endfor
+ let dict.unnamed = [getreg(''), getregtype('')]
" call Decho("setl ma noro",'~'.expand("<slnum>"))
let b:netrw_cpf= 0
if line("$") >= w:netrw_bannercnt
@@ -9787,7 +9797,8 @@ fun! s:NetrwWideListing()
exe 'sil NetrwKeepj '.w:netrw_bannercnt.',$g/^./if virtcol("$") > b:netrw_cpf|let b:netrw_cpf= virtcol("$")|endif'
NetrwKeepj call histdel("/",-1)
else
- let @a= keepa
+ " restore stored registers
+ call s:RestoreRegister(dict)
" call Dret("NetrwWideListing")
return
endif
@@ -9839,7 +9850,7 @@ fun! s:NetrwWideListing()
exe 'nno <buffer> <silent> b :call search(''^.\\|\s\s\zs\S'',''bW'')'."\<cr>"
" call Decho("NetrwWideListing) setl noma nomod ro",'~'.expand("<slnum>"))
exe "setl ".g:netrw_bufsettings
- let @a= keepa
+ call s:RestoreRegister(dict)
" call Decho("ro=".&l:ro." ma=".&l:ma." mod=".&l:mod." wrap=".&l:wrap." (filename<".expand("%")."> win#".winnr()." ft<".&ft.">)",'~'.expand("<slnum>"))
" call Dret("NetrwWideListing")
return
@@ -9851,7 +9862,6 @@ fun! s:NetrwWideListing()
sil! nunmap <buffer> b
endif
endif
-
endfun
" ---------------------------------------------------------------------
@@ -10172,7 +10182,8 @@ fun! s:SetupNetrwStatusLine(statline)
endif
" set up User9 highlighting as needed
- let keepa= @a
+ let dict={}
+ let dict.a=[getreg('a'), getregtype('a')]
redir @a
try
hi User9
@@ -10184,7 +10195,7 @@ fun! s:SetupNetrwStatusLine(statline)
endif
endtry
redir END
- let @a= keepa
+ call s:RestoreRegister(dict)
endif
" set up status line (may use User9 highlighting)
@@ -11435,7 +11446,7 @@ fun! s:NetrwLocalRmFile(path,fname,all)
let all= a:all
let ok = ""
NetrwKeepj norm! 0
- let rmfile= s:NetrwFile(s:ComposePath(a:path,a:fname))
+ let rmfile= s:NetrwFile(s:ComposePath(a:path,escape(a:fname, '\\')))
" call Decho("rmfile<".rmfile.">",'~'.expand("<slnum>"))
if rmfile !~ '^"' && (rmfile =~ '@$' || rmfile !~ '[\/]$')
@@ -11444,7 +11455,7 @@ fun! s:NetrwLocalRmFile(path,fname,all)
if !all
echohl Statement
call inputsave()
- let ok= input("Confirm deletion of file<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
+ let ok= input("Confirm deletion of file <".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
call inputrestore()
echohl NONE
if ok == ""
@@ -11468,7 +11479,7 @@ fun! s:NetrwLocalRmFile(path,fname,all)
if !all
echohl Statement
call inputsave()
- let ok= input("Confirm *recursive* deletion of directory<".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
+ let ok= input("Confirm *recursive* deletion of directory <".rmfile."> ","[{y(es)},n(o),a(ll),q(uit)] ")
call inputrestore()
let ok= substitute(ok,'\[{y(es)},n(o),a(ll),q(uit)]\s*','','e')
if ok == ""
@@ -11628,6 +11639,13 @@ fun! netrw#WinPath(path)
endfun
" ---------------------------------------------------------------------
+" s:StripTrailingSlash: removes trailing slashes from a path {{{2
+fun! s:StripTrailingSlash(path)
+ " remove trailing slash
+ return substitute(a:path, '[/\\]$', '', 'g')
+endfun
+
+" ---------------------------------------------------------------------
" s:NetrwBadd: adds marked files to buffer list or vice versa {{{2
" cb : bl2mf=0 add marked files to buffer list
" cB : bl2mf=1 use bufferlist to mark files
@@ -11994,6 +12012,16 @@ fun! s:RestoreCursorline()
" call Dret("s:RestoreCursorline : restored cul=".&l:cursorline." cuc=".&l:cursorcolumn)
endfun
+" s:RestoreRegister: restores all registers given in the dict {{{2
+fun! s:RestoreRegister(dict)
+ for [key, val] in items(a:dict)
+ if key == 'unnamed'
+ let key = ''
+ endif
+ call setreg(key, val[0], val[1])
+ endfor
+endfun
+
" ---------------------------------------------------------------------
" s:NetrwDelete: Deletes a file. {{{2
" Uses Steve Hall's idea to insure that Windows paths stay
@@ -12801,54 +12829,3 @@ unlet s:keepcpo
" Modelines: {{{1
" ===============
" vim:ts=8 fdm=marker
-" doing autoload/netrw.vim version v172g ~57
-" varname<g:netrw_dirhistcnt> value=0 ~1
-" varname<s:THINLIST> value=0 ~1
-" varname<s:LONGLIST> value=1 ~1
-" varname<s:WIDELIST> value=2 ~1
-" varname<s:TREELIST> value=3 ~1
-" varname<s:MAXLIST> value=4 ~1
-" varname<g:netrw_use_errorwindow> value=2 ~1
-" varname<g:netrw_http_xcmd> value=-q -O ~1
-" varname<g:netrw_http_put_cmd> value=curl -T ~1
-" varname<g:netrw_keepj> value=keepj ~1
-" varname<g:netrw_rcp_cmd> value=rcp ~1
-" varname<g:netrw_rsync_cmd> value=rsync ~1
-" varname<g:netrw_rsync_sep> value=/ ~1
-" varname<g:netrw_scp_cmd> value=scp -q ~1
-" varname<g:netrw_sftp_cmd> value=sftp ~1
-" varname<g:netrw_ssh_cmd> value=ssh ~1
-" varname<g:netrw_alto> value=0 ~1
-" varname<g:netrw_altv> value=1 ~1
-" varname<g:netrw_banner> value=1 ~1
-" varname<g:netrw_browse_split> value=0 ~1
-" varname<g:netrw_bufsettings> value=noma nomod nonu nobl nowrap ro nornu ~1
-" varname<g:netrw_chgwin> value=-1 ~1
-" varname<g:netrw_clipboard> value=1 ~1
-" varname<g:netrw_compress> value=gzip ~1
-" varname<g:netrw_ctags> value=ctags ~1
-" varname<g:netrw_cursor> value=2 ~1
-" (netrw) COMBAK: cuc=0 cul=0 initialization of s:netrw_cu[cl]
-" varname<g:netrw_cygdrive> value=/cygdrive ~1
-" varname<s:didstarstar> value=0 ~1
-" varname<g:netrw_dirhistcnt> value=0 ~1
-" varname<g:netrw_decompress> value={ ".gz" : "gunzip", ".bz2" : "bunzip2", ".zip" : "unzip", ".tar" : "tar -xf", ".xz" : "unxz" } ~1
-" varname<g:netrw_dirhistmax> value=10 ~1
-" varname<g:netrw_errorlvl> value=0 ~1
-" varname<g:netrw_fastbrowse> value=1 ~1
-" varname<g:netrw_ftp_browse_reject> value=^total\s\+\d\+$\|^Trying\s\+\d\+.*$\|^KERBEROS_V\d rejected\|^Security extensions not\|No such file\|: connect to address [0-9a-fA-F:]*: No route to host$ ~1
-" varname<g:netrw_ftpmode> value=binary ~1
-" varname<g:netrw_hide> value=1 ~1
-" varname<g:netrw_keepdir> value=1 ~1
-" varname<g:netrw_list_hide> value= ~1
-" varname<g:netrw_localmkdir> value=mkdir ~1
-" varname<g:netrw_remote_mkdir> value=mkdir ~1
-" varname<g:netrw_liststyle> value=0 ~1
-" varname<g:netrw_markfileesc> value=*./[\~ ~1
-" varname<g:netrw_maxfilenamelen> value=32 ~1
-" varname<g:netrw_menu> value=1 ~1
-" varname<g:netrw_mkdir_cmd> value=ssh USEPORT HOSTNAME mkdir ~1
-" varname<g:netrw_mousemaps> value=1 ~1
-" varname<g:netrw_retmap> value=0 ~1
-" varname<g:netrw_chgperm> value=chmod PERM FILENAME ~1
-" varname<g:netrw_preview> value=0 ~1
diff --git a/runtime/autoload/typst.vim b/runtime/autoload/typst.vim
new file mode 100644
index 0000000..55edd23
--- /dev/null
+++ b/runtime/autoload/typst.vim
@@ -0,0 +1,50 @@
+" Language: Typst
+" Maintainer: Gregory Anders
+" Last Change: 2024-07-14
+" Based on: https://github.com/kaarmu/typst.vim
+
+function! typst#indentexpr() abort
+ let l:lnum = v:lnum
+ let s:sw = shiftwidth()
+
+ let [l:plnum, l:pline] = s:get_prev_nonblank(l:lnum - 1)
+ if l:plnum == 0 | return 0 | endif
+
+ let l:line = getline(l:lnum)
+ let l:ind = indent(l:plnum)
+
+ let l:synname = synIDattr(synID(l:lnum, 1, 1), 'name')
+
+ " Use last indent for block comments
+ if l:synname == 'typstCommentBlock'
+ return l:ind
+ endif
+
+ if l:pline =~ '\v[{[(]\s*$'
+ let l:ind += s:sw
+ endif
+
+ if l:line =~ '\v^\s*[}\])]'
+ let l:ind -= s:sw
+ endif
+
+ return l:ind
+endfunction
+
+" Gets the previous non-blank line that is not a comment.
+function! s:get_prev_nonblank(lnum) abort
+ let l:lnum = prevnonblank(a:lnum)
+ let l:line = getline(l:lnum)
+
+ while l:lnum > 0 && l:line =~ '^\s*//'
+ let l:lnum = prevnonblank(l:lnum - 1)
+ let l:line = getline(l:lnum)
+ endwhile
+
+ return [l:lnum, s:remove_comments(l:line)]
+endfunction
+
+" Removes comments from the given line.
+function! s:remove_comments(line) abort
+ return substitute(a:line, '\s*//.*', '', '')
+endfunction
diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim
index d0e706e..4a53fc5 100644
--- a/runtime/autoload/zip.vim
+++ b/runtime/autoload/zip.vim
@@ -1,11 +1,19 @@
" zip.vim: Handles browsing zipfiles
-" AUTOLOAD PORTION
-" Date: Mar 12, 2023
-" Version: 33
+" AUTOLOAD PORTION
+" Date: 2024 Aug 21
+" Version: 34
" Maintainer: This runtime file is looking for a new maintainer.
" Former Maintainer: Charles E Campbell
" Last Change:
-" 2024 Jun 16 by Vim Project: handle whitespace on Windows properly (#14998)
+" 2024 Jun 16 by Vim Project: handle whitespace on Windows properly (#14998)
+" 2024 Jul 23 by Vim Project: fix 'x' command
+" 2024 Jul 24 by Vim Project: use delete() function
+" 2024 Jul 30 by Vim Project: fix opening remote zipfile
+" 2024 Aug 04 by Vim Project: escape '[' in name of file to be extracted
+" 2024 Aug 05 by Vim Project: workaround for the FreeBSD's unzip
+" 2024 Aug 05 by Vim Project: clean-up and make it work with shellslash on Windows
+" 2024 Aug 18 by Vim Project: correctly handle special globbing chars
+" 2024 Aug 21 by Vim Project: simplify condition to detect MS-Windows
" License: Vim License (see vim's :help license)
" Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1
" Permission is hereby granted to use and distribute this code,
@@ -22,16 +30,9 @@
if &cp || exists("g:loaded_zip")
finish
endif
-let g:loaded_zip= "v33"
-if v:version < 702
- echohl WarningMsg
- echo "***warning*** this version of zip needs vim 7.2 or later"
- echohl Normal
- finish
-endif
+let g:loaded_zip= "v34"
let s:keepcpo= &cpo
set cpo&vim
-"DechoTabOn
let s:zipfile_escape = ' ?&;\'
let s:ERROR = 2
@@ -59,8 +60,28 @@ if !exists("g:zip_extractcmd")
let g:zip_extractcmd= g:zip_unzipcmd
endif
+" ---------------------------------------------------------------------
+" required early
+" s:Mess: {{{2
+fun! s:Mess(group, msg)
+ redraw!
+ exe "echohl " . a:group
+ echomsg a:msg
+ echohl Normal
+endfun
+
+if v:version < 901
+ " required for defer
+ call s:Mess('WarningMsg', "***warning*** this version of zip needs vim 9.1 or later")
+ finish
+endif
+" sanity checks
+if !executable(g:zip_unzipcmd)
+ call s:Mess('Error', "***error*** (zip#Browse) unzip not available on your system")
+ finish
+endif
if !dist#vim#IsSafeExecutable('zip', g:zip_unzipcmd)
- echoerr "Warning: NOT executing " .. g:zip_unzipcmd .. " from current directory!"
+ call s:Mess('Error', "Warning: NOT executing " .. g:zip_unzipcmd .. " from current directory!")
finish
endif
@@ -71,47 +92,28 @@ endif
" ---------------------------------------------------------------------
" zip#Browse: {{{2
fun! zip#Browse(zipfile)
-" call Dfunc("zip#Browse(zipfile<".a:zipfile.">)")
- " sanity check: insure that the zipfile has "PK" as its first two letters
- " (zipped files have a leading PK as a "magic cookie")
- if !filereadable(a:zipfile) || readfile(a:zipfile, "", 1)[0] !~ '^PK'
- exe "noswapfile noautocmd noswapfile e ".fnameescape(a:zipfile)
-" call Dret("zip#Browse : not a zipfile<".a:zipfile.">")
+ " sanity check: ensure that the zipfile has "PK" as its first two letters
+ " (zip files have a leading PK as a "magic cookie")
+ if filereadable(a:zipfile) && readblob(a:zipfile, 0, 2) != 0z50.4B
+ exe "noswapfile noautocmd e " .. fnameescape(a:zipfile)
return
-" else " Decho
-" call Decho("zip#Browse: a:zipfile<".a:zipfile."> passed PK test - it's a zip file")
endif
- let repkeep= &report
- set report=10
+ let dict = s:SetSaneOpts()
+ defer s:RestoreOpts(dict)
" sanity checks
- if !exists("*fnameescape")
- if &verbose > 1
- echoerr "the zip plugin is not available (your vim doesn't support fnameescape())"
- endif
- return
- endif
if !executable(g:zip_unzipcmd)
- redraw!
- echohl Error | echo "***error*** (zip#Browse) unzip not available on your system"
-" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
- let &report= repkeep
-" call Dret("zip#Browse")
+ call s:Mess('Error', "***error*** (zip#Browse) unzip not available on your system")
return
endif
if !filereadable(a:zipfile)
if a:zipfile !~# '^\a\+://'
" if it's an url, don't complain, let url-handlers such as vim do its thing
- redraw!
- echohl Error | echo "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None
-" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+ call s:Mess('Error', "***error*** (zip#Browse) File not readable <".a:zipfile.">")
endif
- let &report= repkeep
-" call Dret("zip#Browse : file<".a:zipfile."> not readable")
return
endif
-" call Decho("passed sanity checks")
if &ma != 1
set ma
endif
@@ -136,19 +138,15 @@ fun! zip#Browse(zipfile)
\ '" Select a file with cursor and press ENTER'])
keepj $
-" call Decho("exe silent r! ".g:zip_unzipcmd." -l -- ".s:Escape(a:zipfile,1))
- exe "keepj sil! r! ".g:zip_unzipcmd." -Z -1 -- ".s:Escape(a:zipfile,1)
+ exe $"keepj sil r! {g:zip_unzipcmd} -Z1 -- {s:Escape(a:zipfile, 1)}"
if v:shell_error != 0
- redraw!
- echohl WarningMsg | echo "***warning*** (zip#Browse) ".fnameescape(a:zipfile)." is not a zip file" | echohl None
-" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+ call s:Mess('WarningMsg', "***warning*** (zip#Browse) ".fnameescape(a:zipfile)." is not a zip file")
keepj sil! %d
let eikeep= &ei
set ei=BufReadCmd,FileReadCmd
exe "keepj r ".fnameescape(a:zipfile)
let &ei= eikeep
keepj 1d
-" call Dret("zip#Browse")
return
endif
@@ -160,63 +158,46 @@ fun! zip#Browse(zipfile)
noremap <silent> <buffer> <leftmouse> <leftmouse>:call <SID>ZipBrowseSelect()<cr>
endif
- let &report= repkeep
-" call Dret("zip#Browse")
endfun
" ---------------------------------------------------------------------
" ZipBrowseSelect: {{{2
fun! s:ZipBrowseSelect()
- " call Dfunc("ZipBrowseSelect() zipfile<".((exists("b:zipfile"))? b:zipfile : "n/a")."> curfile<".expand("%").">")
- let repkeep= &report
- set report=10
+ let dict = s:SetSaneOpts()
+ defer s:RestoreOpts(dict)
let fname= getline(".")
if !exists("b:zipfile")
-" call Dret("ZipBrowseSelect : b:zipfile doesn't exist!")
return
endif
" sanity check
if fname =~ '^"'
- let &report= repkeep
-" call Dret("ZipBrowseSelect")
return
endif
if fname =~ '/$'
- redraw!
- echohl Error | echo "***error*** (zip#Browse) Please specify a file, not a directory" | echohl None
-" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
- let &report= repkeep
-" call Dret("ZipBrowseSelect")
+ call s:Mess('Error', "***error*** (zip#Browse) Please specify a file, not a directory")
return
endif
-" call Decho("fname<".fname.">")
-
" get zipfile to the new-window
let zipfile = b:zipfile
let curfile = expand("%")
-" call Decho("zipfile<".zipfile.">")
-" call Decho("curfile<".curfile.">")
noswapfile new
if !exists("g:zip_nomax") || g:zip_nomax == 0
wincmd _
endif
let s:zipfile_{winnr()}= curfile
-" call Decho("exe e ".fnameescape("zipfile://".zipfile.'::'.fname))
exe "noswapfile e ".fnameescape("zipfile://".zipfile.'::'.fname)
filetype detect
- let &report= repkeep
-" call Dret("ZipBrowseSelect : s:zipfile_".winnr()."<".s:zipfile_{winnr()}.">")
endfun
" ---------------------------------------------------------------------
" zip#Read: {{{2
fun! zip#Read(fname,mode)
- let repkeep= &report
- set report=10
+ let dict = s:SetSaneOpts()
+ defer s:RestoreOpts(dict)
if has("unix")
let zipfile = substitute(a:fname,'zipfile://\(.\{-}\)::[^\\].*$','\1','')
@@ -224,23 +205,20 @@ fun! zip#Read(fname,mode)
else
let zipfile = substitute(a:fname,'^.\{-}zipfile://\(.\{-}\)::[^\\].*$','\1','')
let fname = substitute(a:fname,'^.\{-}zipfile://.\{-}::\([^\\].*\)$','\1','')
- let fname = substitute(fname, '[', '[[]', 'g')
endif
+ let fname = fname->substitute('[', '[[]', 'g')->escape('?*\\')
" sanity check
if !executable(substitute(g:zip_unzipcmd,'\s\+.*$','',''))
- redraw!
- echohl Error | echo "***error*** (zip#Read) sorry, your system doesn't appear to have the ".g:zip_unzipcmd." program" | echohl None
-" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
- let &report= repkeep
+ call s:Mess('Error', "***error*** (zip#Read) sorry, your system doesn't appear to have the ".g:zip_unzipcmd." program")
return
endif
" the following code does much the same thing as
- " exe "keepj sil! r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1)
+ " exe "keepj sil! r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1)
" but allows zipfile://... entries in quickfix lists
let temp = tempname()
let fn = expand('%:p')
- exe "sil! !".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1).' > '.temp
+ exe "sil !".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1).' > '.temp
sil exe 'keepalt file '.temp
sil keepj e!
sil exe 'keepalt file '.fnameescape(fn)
@@ -251,58 +229,42 @@ fun! zip#Read(fname,mode)
" cleanup
set nomod
- let &report= repkeep
endfun
" ---------------------------------------------------------------------
" zip#Write: {{{2
fun! zip#Write(fname)
-" call Dfunc("zip#Write(fname<".a:fname.">) zipfile_".winnr()."<".s:zipfile_{winnr()}.">")
- let repkeep= &report
- set report=10
+ let dict = s:SetSaneOpts()
+ defer s:RestoreOpts(dict)
" sanity checks
if !executable(substitute(g:zip_zipcmd,'\s\+.*$','',''))
- redraw!
- echohl Error | echo "***error*** (zip#Write) sorry, your system doesn't appear to have the ".g:zip_zipcmd." program" | echohl None
-" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
- let &report= repkeep
-" call Dret("zip#Write")
+ call s:Mess('Error', "***error*** (zip#Write) sorry, your system doesn't appear to have the ".g:zip_zipcmd." program")
return
endif
if !exists("*mkdir")
- redraw!
- echohl Error | echo "***error*** (zip#Write) sorry, mkdir() doesn't work on your system" | echohl None
-" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
- let &report= repkeep
-" call Dret("zip#Write")
+ call s:Mess('Error', "***error*** (zip#Write) sorry, mkdir() doesn't work on your system")
return
endif
let curdir= getcwd()
let tmpdir= tempname()
-" call Decho("orig tempname<".tmpdir.">")
if tmpdir =~ '\.'
let tmpdir= substitute(tmpdir,'\.[^.]*$','','e')
endif
-" call Decho("tmpdir<".tmpdir.">")
call mkdir(tmpdir,"p")
" attempt to change to the indicated directory
if s:ChgDir(tmpdir,s:ERROR,"(zip#Write) cannot cd to temporary directory")
- let &report= repkeep
-" call Dret("zip#Write")
return
endif
-" call Decho("current directory now: ".getcwd())
" place temporary files under .../_ZIPVIM_/
if isdirectory("_ZIPVIM_")
- call s:Rmdir("_ZIPVIM_")
+ call delete("_ZIPVIM_", "rf")
endif
call mkdir("_ZIPVIM_")
cd _ZIPVIM_
-" call Decho("current directory now: ".getcwd())
if has("unix")
let zipfile = substitute(a:fname,'zipfile://\(.\{-}\)::[^\\].*$','\1','')
@@ -311,21 +273,17 @@ fun! zip#Write(fname)
let zipfile = substitute(a:fname,'^.\{-}zipfile://\(.\{-}\)::[^\\].*$','\1','')
let fname = substitute(a:fname,'^.\{-}zipfile://.\{-}::\([^\\].*\)$','\1','')
endif
-" call Decho("zipfile<".zipfile.">")
-" call Decho("fname <".fname.">")
if fname =~ '/'
let dirpath = substitute(fname,'/[^/]\+$','','e')
if has("win32unix") && executable("cygpath")
let dirpath = substitute(system("cygpath ".s:Escape(dirpath,0)),'\n','','e')
endif
-" call Decho("mkdir(dirpath<".dirpath.">,p)")
call mkdir(dirpath,"p")
endif
if zipfile !~ '/'
let zipfile= curdir.'/'.zipfile
endif
-" call Decho("zipfile<".zipfile."> fname<".fname.">")
exe "w! ".fnameescape(fname)
if has("win32unix") && executable("cygpath")
@@ -336,17 +294,13 @@ fun! zip#Write(fname)
let fname = substitute(fname, '[', '[[]', 'g')
endif
-" call Decho(g:zip_zipcmd." -u ".s:Escape(fnamemodify(zipfile,":p"),0)." ".s:Escape(fname,0))
call system(g:zip_zipcmd." -u ".s:Escape(fnamemodify(zipfile,":p"),0)." ".s:Escape(fname,0))
if v:shell_error != 0
- redraw!
- echohl Error | echo "***error*** (zip#Write) sorry, unable to update ".zipfile." with ".fname | echohl None
-" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
+ call s:Mess('Error', "***error*** (zip#Write) sorry, unable to update ".zipfile." with ".fname)
elseif s:zipfile_{winnr()} =~ '^\a\+://'
" support writing zipfiles across a network
let netzipfile= s:zipfile_{winnr()}
-" call Decho("handle writing <".zipfile."> across network as <".netzipfile.">")
1split|enew
let binkeep= &binary
let eikeep = &ei
@@ -358,58 +312,58 @@ fun! zip#Write(fname)
q!
unlet s:zipfile_{winnr()}
endif
-
+
" cleanup and restore current directory
cd ..
- call s:Rmdir("_ZIPVIM_")
+ call delete("_ZIPVIM_", "rf")
call s:ChgDir(curdir,s:WARNING,"(zip#Write) unable to return to ".curdir."!")
- call s:Rmdir(tmpdir)
+ call delete(tmpdir, "rf")
setlocal nomod
- let &report= repkeep
-" call Dret("zip#Write")
endfun
" ---------------------------------------------------------------------
" zip#Extract: extract a file from a zip archive {{{2
fun! zip#Extract()
-" call Dfunc("zip#Extract()")
- let repkeep= &report
- set report=10
+ let dict = s:SetSaneOpts()
+ defer s:RestoreOpts(dict)
let fname= getline(".")
-" call Decho("fname<".fname.">")
" sanity check
if fname =~ '^"'
- let &report= repkeep
-" call Dret("zip#Extract")
return
endif
if fname =~ '/$'
- redraw!
- echohl Error | echo "***error*** (zip#Extract) Please specify a file, not a directory" | echohl None
- let &report= repkeep
-" call Dret("zip#Extract")
+ call s:Mess('Error', "***error*** (zip#Extract) Please specify a file, not a directory")
+ return
+ endif
+ if filereadable(fname)
+ call s:Mess('Error', "***error*** (zip#Extract) <" .. fname .."> already exists in directory, not overwriting!")
return
endif
+ let target = fname->substitute('\[', '[[]', 'g')
+ if &shell =~ 'cmd' && has("win32")
+ let target = target
+ \ ->substitute('[?*]', '[&]', 'g')
+ \ ->substitute('[\\]', '?', 'g')
+ \ ->shellescape()
+ " there cannot be a file name with '\' in its name, unzip replaces it by _
+ let fname = fname->substitute('[\\?*]', '_', 'g')
+ else
+ let target = target->escape('*?\\')->shellescape()
+ endif
" extract the file mentioned under the cursor
-" call Decho("system(".g:zip_extractcmd." ".shellescape(b:zipfile)." ".shellescape(shell).")")
- call system(g:zip_extractcmd." ".shellescape(b:zipfile)." ".shellescape(shell))
-" call Decho("zipfile<".b:zipfile.">")
+ call system($"{g:zip_extractcmd} -o {shellescape(b:zipfile)} {target}")
if v:shell_error != 0
- echohl Error | echo "***error*** ".g:zip_extractcmd." ".b:zipfile." ".fname.": failed!" | echohl NONE
+ call s:Mess('Error', "***error*** ".g:zip_extractcmd." ".b:zipfile." ".fname.": failed!")
elseif !filereadable(fname)
- echohl Error | echo "***error*** attempted to extract ".fname." but it doesn't appear to be present!"
+ call s:Mess('Error', "***error*** attempted to extract ".fname." but it doesn't appear to be present!")
else
- echo "***note*** successfully extracted ".fname
+ echomsg "***note*** successfully extracted ".fname
endif
- " restore option
- let &report= repkeep
-
-" call Dret("zip#Extract")
endfun
" ---------------------------------------------------------------------
@@ -424,48 +378,48 @@ fun! s:Escape(fname,isfilt)
else
let qnameq= g:zip_shq.escape(a:fname,g:zip_shq).g:zip_shq
endif
- if exists("+shellslash") && &shellslash && &shell =~ "cmd.exe"
- " renormalize directory separator on Windows
- let qnameq=substitute(qnameq, '/', '\\', 'g')
- endif
return qnameq
endfun
" ---------------------------------------------------------------------
-" ChgDir: {{{2
+" s:ChgDir: {{{2
fun! s:ChgDir(newdir,errlvl,errmsg)
-" call Dfunc("ChgDir(newdir<".a:newdir."> errlvl=".a:errlvl." errmsg<".a:errmsg.">)")
-
try
exe "cd ".fnameescape(a:newdir)
catch /^Vim\%((\a\+)\)\=:E344/
redraw!
if a:errlvl == s:NOTE
- echo "***note*** ".a:errmsg
+ echomsg "***note*** ".a:errmsg
elseif a:errlvl == s:WARNING
- echohl WarningMsg | echo "***warning*** ".a:errmsg | echohl NONE
+ call s:Mess("WarningMsg", "***warning*** ".a:errmsg)
elseif a:errlvl == s:ERROR
- echohl Error | echo "***error*** ".a:errmsg | echohl NONE
+ call s:Mess("Error", "***error*** ".a:errmsg)
endif
-" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
-" call Dret("ChgDir 1")
return 1
endtry
-" call Dret("ChgDir 0")
return 0
endfun
" ---------------------------------------------------------------------
-" s:Rmdir: {{{2
-fun! s:Rmdir(fname)
-" call Dfunc("Rmdir(fname<".a:fname.">)")
- if (has("win32") || has("win95") || has("win64") || has("win16")) && &shell !~? 'sh$'
- call system("rmdir /S/Q ".s:Escape(a:fname,0))
- else
- call system("/bin/rm -rf ".s:Escape(a:fname,0))
- endif
-" call Dret("Rmdir")
+" s:SetSaneOpts: {{{2
+fun! s:SetSaneOpts()
+ let dict = {}
+ let dict.report = &report
+ let dict.shellslash = &shellslash
+
+ let &report = 10
+ let &shellslash = 0
+
+ return dict
+endfun
+
+" ---------------------------------------------------------------------
+" s:RestoreOpts: {{{2
+fun! s:RestoreOpts(dict)
+ for [key, val] in items(a:dict)
+ exe $"let &{key} = {val}"
+ endfor
endfun
" ------------------------------------------------------------------------