@@ -449,6 +449,13 @@ if [ -n "$BASH_VERSION" ] && type complete >/dev/null 2>&1; then
449449 eval "$(VP_COMPLETE=bash command vp)"
450450elif [ -n "$ZSH_VERSION" ] && type compdef >/dev/null 2>&1; then
451451 eval "$(VP_COMPLETE=zsh command vp)"
452+ _vpr_complete() {
453+ local -a orig=("${words[@]}")
454+ words=("vp" "run" "${orig[@]:1}")
455+ CURRENT=$((CURRENT + 1))
456+ ${=_comps[vp]}
457+ }
458+ compdef _vpr_complete vpr
452459fi
453460"#
454461 . replace ( "__VP_BIN__" , & bin_path_ref) ;
478485
479486# Dynamic shell completion for fish
480487VP_COMPLETE=fish command vp | source
488+
489+ function __vpr_complete
490+ set -l tokens (commandline --current-process --tokenize --cut-at-cursor)
491+ set -l current (commandline --current-token)
492+ VP_COMPLETE=fish command vp -- vp run $tokens[2..] $current
493+ end
494+ complete -c vpr --keep-order --exclusive --arguments "(__vpr_complete)"
481495"#
482496 . replace ( "__VP_BIN__" , & bin_path_ref) ;
483497 let env_fish_file = vite_plus_home. join ( "env.fish" ) ;
@@ -518,6 +532,27 @@ function vp {
518532$env:VP_COMPLETE = "powershell"
519533& (Join-Path $__vp_bin "vp.exe") | Out-String | Invoke-Expression
520534Remove-Item Env:\VP_COMPLETE -ErrorAction SilentlyContinue
535+
536+ $__vpr_comp = {
537+ param($wordToComplete, $commandAst, $cursorPosition)
538+ $prev = $env:VP_COMPLETE
539+ $env:VP_COMPLETE = "powershell"
540+ $commandLine = $commandAst.Extent.Text
541+ $args = $commandLine.Substring(0, [math]::Min($cursorPosition, $commandLine.Length))
542+ $args = $args -replace '^(vpr\.exe|vpr)\b', 'vp run'
543+ if ($wordToComplete -eq "") { $args += " ''" }
544+ $results = Invoke-Expression @"
545+ & (Join-Path $__vp_bin 'vp.exe') -- $args
546+ "@;
547+ if ($prev) { $env:VP_COMPLETE = $prev } else { Remove-Item Env:\VP_COMPLETE }
548+ $results | ForEach-Object {
549+ $split = $_.Split("`t")
550+ $cmd = $split[0];
551+ if ($split.Length -eq 2) { $help = $split[1] } else { $help = $split[0] }
552+ [System.Management.Automation.CompletionResult]::new($cmd, $cmd, 'ParameterValue', $help)
553+ }
554+ }
555+ Register-ArgumentCompleter -Native -CommandName vpr -ScriptBlock $__vpr_comp
521556"# ;
522557
523558 // For PowerShell, use the actual absolute path (not $HOME-relative)
@@ -866,7 +901,6 @@ mod tests {
866901 let fish_content = tokio:: fs:: read_to_string ( home. join ( "env.fish" ) ) . await . unwrap ( ) ;
867902 let ps1_content = tokio:: fs:: read_to_string ( home. join ( "env.ps1" ) ) . await . unwrap ( ) ;
868903
869- // Verify completion env is set
870904 assert ! (
871905 env_content. contains( "VP_COMPLETE=bash" ) && env_content. contains( "VP_COMPLETE=zsh" ) ,
872906 "env file should contain completion for bash and zsh"
@@ -879,5 +913,15 @@ mod tests {
879913 ps1_content. contains( "VP_COMPLETE = \" powershell\" " ) ,
880914 "env.ps1 file should contain completion for PowerShell"
881915 ) ;
916+
917+ assert ! (
918+ env_content. contains( "compdef _vpr_complete vpr" ) ,
919+ "env should have vpr completion for zsh"
920+ ) ;
921+ assert ! ( fish_content. contains( "complete -c vpr" ) , "env.fish should have vpr completion" ) ;
922+ assert ! (
923+ ps1_content. contains( "Register-ArgumentCompleter -Native -CommandName vpr" ) ,
924+ "env.ps1 should have vpr completion"
925+ ) ;
882926 }
883927}
0 commit comments