mirror of
https://github.com/zsh-users/zsh-completions.git
synced 2026-09-17 16:00:19 +00:00
Having a vim modeline or emacs local variable line somewhere in the middle of the file isn't really helpful. By default, vim will only check the first and last 5 lines of a file for a modeline (assuming the modeline option is enabled). Emacs is even more strict about the type of local variable line that was in use, it will only check the first line of the file or the second line if the first line specifies a script interpreter (which isn't the case here). Move the vim modeline to the end of the file so that it can actually be found by vim but is out of the way for editing. For emacs more work is required, convert that to the more verbose Local Variables syntax which emacs will look for starting 3000 characters from the end of the file. Also there is no zsh mode for emacs (according to zsh-users/zsh-completions#75), use the "Shell-Script" mode instead. This seems to automatically detect that the files are for zsh. I'm not an emacs user, so I haven't tested that portion much. But, this does at least improve the syntax highlighting there.
54 lines
1.4 KiB
Bash
54 lines
1.4 KiB
Bash
#compdef ditz
|
|
# ------------------------------------------------------------------------------
|
|
# Description
|
|
# -----------
|
|
#
|
|
# Completion script for Ditz (http://ditz.rubyforge.org).
|
|
#
|
|
# Source: https://github.com/technolize/zsh-completion-funcs
|
|
#
|
|
# ------------------------------------------------------------------------------
|
|
# Authors
|
|
# -------
|
|
#
|
|
# * technolize (https://github.com/technolize)
|
|
#
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
local ME=ditz
|
|
local COMMANDS=--commands
|
|
local OPTIONS='<options>'
|
|
|
|
if (($CURRENT == 2)); then
|
|
# We're completing the first word after the tool: the command.
|
|
_wanted command expl "$ME command" \
|
|
compadd -- $( "$ME" "$COMMANDS" )
|
|
else
|
|
# Find the options/files/URL/etc. for the current command by using the tool itself.
|
|
case "${words[$CURRENT]}"; in
|
|
-*)
|
|
_wanted args expl "Arguments for $ME ${words[2]}" \
|
|
compadd -- $( "$ME" "${words[2]}" "$OPTIONS" ; _files )
|
|
;;
|
|
ht*|ft*)
|
|
_arguments '*:URL:_urls'
|
|
;;
|
|
/*|./*|\~*|../*)
|
|
_arguments '*:file:_files'
|
|
;;
|
|
*)
|
|
_wanted args expl "Arguments for $ME ${words[2]}" \
|
|
compadd -- $( "$ME" "${words[2]}" "$OPTIONS" )
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
# Local Variables:
|
|
# mode: Shell-Script
|
|
# sh-indentation: 2
|
|
# indent-tabs-mode: nil
|
|
# sh-basic-offset: 2
|
|
# End:
|
|
# vim: ft=zsh sw=2 ts=2 et
|