Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: vim scp autocomplete



shawn wilson wrote:
> i'm curious if anyone has gotten this working?
> 
> i found this:
> http://stackoverflow.com/questions/7197021/custom-autocompletion-for-zsh
> and i'm sure i can/will (eventually) figure this out. but i just
> figured i'd ask if anyone has done this first.

I've got something half finished which I attach below. Actually, as far
as vim is concerned this should basically do the job. To finish this, I
wanted to do some work on _remote_files to make it use an interface
closer to _files: -/ instead of --no-files for example.

I've got a lot of half-finished functions and really ought to find time
to finish them off.

Oliver

diff --git a/Completion/Unix/Command/_vim b/Completion/Unix/Command/_vim
index 2c9b0a1..8d0610d 100644
--- a/Completion/Unix/Command/_vim
+++ b/Completion/Unix/Command/_vim
@@ -4,6 +4,7 @@
 _vim_files () {
   case $PREFIX in
     (+*) _files -P './' $* && return 0 ;;
+    (scp|http(|s)|(|s)ftp):*) _urls ;;
     (*) _files $* ;;
   esac
   case $PREFIX in
diff --git a/Completion/Unix/Type/_urls b/Completion/Unix/Type/_urls
index b53f5a0..87f73f8 100644
--- a/Completion/Unix/Type/_urls
+++ b/Completion/Unix/Type/_urls
@@ -75,7 +75,7 @@ fi
 scheme="$match[1]"
 
 case "$scheme" in
-  http(|s)|ftp|gopher)
+  http(|s)|(|s)ftp|scp|gopher)
     if ! compset -P //; then
       _wanted -C "$scheme" prefixes expl 'end of prefix' compadd -S '' "$@" //
       return
@@ -143,7 +143,7 @@ host="$match[1]"
 
 # Complete part after hostname
 
-_tags -C local files || return 1
+_tags remote-files files || return 1
 
 if [[ "$localhttp_servername" = "$host" ]]; then
   if compset -P \~; then
@@ -170,10 +170,12 @@ if [[ "$localhttp_servername" = "$host" ]]; then
   fi
 else
   while _tags; do
-    while _next_label files expl 'local file'; do
+    (( $#urls )) && while _next_label files expl 'local file'; do
       _path_files "$expl[@]" "$@" -W $urls/$scheme/$host "${glob[@]}" && ret=0
       _path_files -S/ -r '/' "$expl[@]" -W $urls/$scheme/$host -/ && ret=0
     done
+    [[ $scheme = (scp|sftp) ]] && _requested remote-files &&
+        _remote_files -- ssh && ret=0
     (( ret )) || return 0
   done
 fi



Messages sorted by: Reverse Date, Date, Thread, Author