zsh-users
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: shawn wilson <ag4ve.us@gmail.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: vim scp autocomplete
Date: Tue, 06 Nov 2012 19:20:46 +0100	[thread overview]
Message-ID: <12933.1352226046@thecus.kiddle.eu> (raw)
In-Reply-To: <CAH_OBie4fh=RD5_nfoAPCMXSXb3BfVjphyKOYq7avAkfcv4fqw@mail.gmail.com>

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


  reply	other threads:[~2012-11-06 18:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-06 16:21 shawn wilson
2012-11-06 18:20 ` Oliver Kiddle [this message]
2012-11-07 13:49   ` Oliver Kiddle
2012-11-07 15:02     ` shawn wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12933.1352226046@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --cc=ag4ve.us@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).