about summary refs log tree commit diff
path: root/Completion/Unix/Command/_vim
blob: 0429743380ca470203b4829c7acde017667d4c35 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#compdef vim gvim gex gview nvim rvim rview rgvim rgview evim eview vimdiff gvimdiff mvim

(( $+functions[_vim_files] )) ||
_vim_files () {
  case $PREFIX in
    (+*) _files -P './' $* && return 0 ;;
    ((scp|http(|s)|(|s)ftp):*) _urls ;;
    (*) _files $* ;;
  esac
  case $PREFIX in
    (+) _message -e 'start at a given line (default: end of file)' ;;
    (+<1->) _message -e 'line number' ;;
  esac
}

local curcontext="$curcontext" state line expl ret=1
typeset -A opt_args

local arguments

arguments=(
  '(   -e -E -s -d -y)-v[vi mode]'
  '(-v    -E    -d -y)-e[ex mode]'
  '(-v -e       -d -y)-E[improved ex mode]'
  '(-v -e -E -s -d   )-y[easy mode]'
  '-m[modifications (writing files) not allowed]'
  '-M[modifications in text not allowed]'
  '-b[binary mode]'
  '-l[lisp mode]'
  '-C[start in compatible mode]'
  '-N[start in incompatible mode]'
  '(--nofork -f)'{--nofork,-f}'[do not detach the GUI version from the shell]'
  '-V-[verbosity level]::verbosity [10]:->verbosity'
  '-D[debugging mode]'
  '-n[no swap file (memory only)]'
  '-nb[start as NetBean server]'
  {-r,-L}'[list swap files and exit or recover from a swap file]::swap file:_vim_files -g "*.sw?(-.)"'
  '(   -H -F)-A[start in Arabic mode]'
  '(-A    -F)-H[start in Hebrew mode]'
  '(-A -H   )-F[start in Farsi mode]'
  '-T[set terminal type]:::_terminals'
  '--not-a-term[skip warning for input/output not being a terminal]'
  '--ttyfail[exit if input or output is not a terminal]'
  '-u[use given vimrc file instead of default .vimrc]::rc file:_files'
  "--noplugin[don't load plugin scripts]"
  '-o-[number of windows to open (default: one for each file)]::window count: '
  '-O-[number of windows to vertically split open (default is one for each file)]::window count: '
  '-p-[number of tabs to open (default: one for each file)]::tab count: '
  '(* -t)-q-[quickfix file]:*:file:_vim_files'
  '*--cmd[execute given command before loading any RC files]:command: '
  '-c[execute given command after loading the first file]:command: '
  '-S[source a session file after loading the first file]:session file:_files'
  '-s[read normal-mode commands from script file]:script file:_files'
  '-w[append all typed commands to given file]:output file:_files'
  '-W[write all typed commands to given file, overwriting existing file]:output file:_files'
  '-x[edit encrypted files]'
  '-X[do not connect to X server]'
  '--remote[edit given files in a vim server if possible]:*:file:_vim_files'
  '--remote-silent[as --remote but without complaining if not possible]:*:file:_vim_files'
  '--remote-wait[as --remote but wait for files to have been edited]:*:file:_vim_files'
  '--remote-wait-silent[as --remote-wait but without complaining if not possible]:*:file:_vim_files'
  '--remote-send[send given keys to vim server if possible]:keys: '
  '--remote-tab[as --remote but open tab page for each file]:*:file:_vim_files'
  '--remote-tab-silent[as --remote-silent but open tab page for each file]:*:file:_vim_files'
  '--remote-tab-wait[as --remote-wait but open tab page for each file]:*:file:_vim_files'
  '--remote-tab-wait-silent[as --remote-wait-silent but open tab page for each file]:*:file:_vim_files'
  '--remote-expr[evaluate given expression in a vim server and print result]:expression: '
  '--literal[do not expand wildcards in arguments (this is useless with ZSH)]'
  '(- *)--serverlist[list available vim servers and exit]'
  '--servername[name of vim server to send to or name of server to become]:server name:->server'
  '--startuptime[write startup timing messages to given file]:log file:_files'
  '--socketid[run GVIM in another window]'
  '-i[use specified viminfo file]:viminfo file [~/.viminfo]:_files'
  '--clean[defaults, no plugins, no viminfo]'
  '(- *)'{-h,--help}'[print help and exit]'
  '(- *)--version[print version information and exit]'
  '(* -q)-t[edit file where tag is defined]:tag:_complete_tag'
  '(-t -q)*:file:_vim_files'
  '--clean[start with defaults in non-compatible mode]'
)
[[ $service != *g* ]] && arguments+='-g[start with GUI]'
[[ $service != r* ]] && arguments+='-Z[restricted mode]'
[[ $service != *diff ]] && arguments+='(-v -e -E -s -y)-d[diff mode]'
[[ $service != *view ]] && arguments+='-R[readonly mode]'
[[ $service = *g* ]] || (( ${words[(I)-g]} )) && arguments+=(
  '-font:font:_xft_fonts'
  '-geometry:geometry:_x_geometry'
  '(-rv -reverse)'{-rv,-reverse}'[use reverse video]'
  '-display:display:_x_display'
  '--role[set unique role to identify main window]:role'
  '--socketid[open vim inside another GTK widget]:xid'
  '--echo-wid[echo window ID on stdout]'
  '-U[use given gvimrc file instead of default .gvimrc]::rc file:_files'
)

_arguments -C -S $arguments && ret=0

if [[ "$state" = server ]]; then
  local -a servers
  servers=( ${(f)"$(_call_program servers $words[1] --serverlist 2>/dev/null)"} )
  _wanted servers expl server compadd -M 'm:{a-z}={A-Z}' -a servers && ret=0
elif [[ $state = verbosity ]]; then
  _tags numbers files
  while _tags; do
    _requested numbers && _describe -V 'verbosity [10]' "(
      0:don\'t' display any messages'
      1:'display when viminfo file is read or written'
      2:'display sourced files'
      5:'display every searched tag-file'
      8:'display files that trigger autocommands'
      9:'display every triggered autocommand'
      12:'display every executed function'
      13:'report every thrown, caught, finished, or discarded exception'
      14:'display anything pending in a :finally clause'
      15:'display every executed ex-command'
    )" && ret=0
    if _requested files expl 'file for verbose output'; then
      compset -P '[0-9]#'
      _files "$expl[@]" && ret=0
    fi
    (( ret )) || break
  done
fi

return ret