Add exclusion lists to nano completion

This commit is contained in:
Oliver Kiddle 2021-04-12 23:53:05 +02:00
parent 43fecdfe87
commit cb4b721ada
1 changed files with 71 additions and 56 deletions

127
src/_nano
View File

@ -1,58 +1,73 @@
#compdef nano #compdef nano
local curcontext="$curcontext" state line local curcontext="$curcontext" state line
typeset -A opt_args local -i ret=1
_arguments -s -C \
'(-)'{-A,--smarthome}'[Enable smart home key]'\ _arguments -s -S -C \
{-B,--backup}'[Save backups of existing files]'\ '(-)'{-A,--smarthome}'[enable smart home key]' \
{-C+,--backupdir=}'[Directory for saving unique backup files]:dir:_dirs'\ '(-B --backup)'{-B,--backup}'[save backups of existing files]' \
{-D,--boldtext}'[Use bold instead of reverse video text]'\ '(-C --backupdir)'{-C+,--backupdir=}'[specify directory for saving unique backup files]:directory:_directories' \
{-E,--tabstospaces}'[Convert typed tabs to spaces]'\ '(-D --boldtext)'{-D,--boldtext}'[use bold instead of reverse video text]' \
{-F,--multibuffer}'[Read a file into a new buffer by default]'\ '(-E --tabstospaces)'{-E,--tabstospaces}'[convert typed tabs to spaces]' \
{-G,--locking}'[Use vim-style lock files]'\ '(-F --multibuffer)'{-F,--multibuffer}'[read a file into a new buffer by default]' \
{-H,--historylog}'[Log & read search replace string history]'\ '(-G --locking)'{-G,--locking}'[use vim-style lock files]' \
{-I,--ignorercfiles}'[Do not look at nanorc files]'\ '(-H --historylog)'{-H,--historylog}'[log & read search replace string history]' \
{-J+,--guidestripe=}'[Show a guiding bar at this column]:number'\ '(-I --ignorercfiles)'{-I,--ignorercfiles}"[don't look at nanorc files]" \
{-K,--rawsequences}'[Fix numeric keypad key confusion problem]'\ '(-J --guidestripe)'{-J+,--guidestripe=}'[show a guide bar at specified column]:number' \
{-L,--nonewlines}'[Do not add an automatic newline]'\ '(-K --rawsequences)'{-K,--rawsequences}'[fix numeric keypad key confusion problem]' \
{-M,--trimblanks}'[Trim tail spaces when hard-wrapping]'\ '(-L --nonewlines)'{-L,--nonewlines}"[don't add an automatic newline]" \
{-N,--noconvert}'[Do not convert files from DOS/Mac format]'\ '(-M --trimblanks)'{-M,--trimblanks}'[trim trailing spaces when hard-wrapping]' \
{-O,--bookstyle}'[Leading whitespace means new paragraph]'\ '(-N --noconvert -u --unix)'{-N,--noconvert}"[don't convert files from DOS/Mac format]" \
{-P,--positionlog}'[Log & read location of cursor position]'\ '(-O --bookstyle)'{-O,--bookstyle}'[leading whitespace means new paragraph]' \
{-Q+,--quotestr=}'[Regular expression to match quoting]:str'\ '(-P --positionlog)'{-P,--positionlog}'[log & read location of cursor position]' \
{-R,--restricted}'[Restricted mode]'\ '(-Q --quotestr)'{-Q+,--quotestr=}'[specify regular expression to match quoted parts of lines]:regex [^([ \t]*([!#%\:;>|}]|//))+]' \
{-S,--softwrap}'[Display overly long lines on multiple rows]'\ '(-R --restricted)'{-R,--restricted}'[restricted mode]' \
{-T+,--tabsize=}'[Set width of a tab to cols columns]:init'\ '(-S --softwrap)'{-S,--softwrap}'[display overly long lines on multiple rows]' \
{-U,--quickblank}'[Do quick statusbar blanking]'\ '(-T --tabsize)'{-T+,--tabsize=}'[set width of a tab]:columns [8]' \
'(- *)'{-V,--version}'[Print version information and exit]'\ '(-U --quickblank -c --constantshow -_ --minibar)'{-U,--quickblank}'[do quick statusbar blanking]' \
{-W,--wordbounds}'[Detect word boundaries more accurately]'\ '(- *)'{-V,--version}'[print version information and exit]' \
{-X+,--wordchars=}'[Which other characters are word parts]:str'\ '(-W --wordbounds -X --wordchars)'{-W,--wordbounds}'[detect word boundaries more accurately]' \
{-Y+,--syntax=}'[Syntax definition to use for coloring]'\ '(-X --wordchars -W --wordbounds)'{-X+,--wordchars=}'[specify which other characters are word parts]:string' \
{-Z,--zap}'[Let Bsp and Del erase a marked region]'\ '(-Y --syntax=)'{-Y+,--syntax=}'[syntax definition to use for coloring]:value' \
{-a,--atblanks}'[When soft-wrapping, do it at whitespace]'\ '(-Z --zap)'{-Z,--zap}'[let backspace and delete erase a marked region]' \
{-b,--breaklonglines}'[Automatically hard-wrap overlong lines]'\ '(-a --atblanks)'{-a,--atblanks}'[when soft-wrapping, do it at whitespace]' \
{-c,--constantshow}'[Constantly show cursor position]'\ '(-b --breaklonglines -w --nowrap)'{-b,--breaklonglines}'[automatically hard-wrap overlong lines]' \
{-d,--rebinddelete}'[Fix Backspace/Delete confusion problem]'\ '(-c --constantshow -U --quickblank)'{-c,--constantshow}'[show cursor position constantly]' \
{-e,--emptyline}'[Keep the line below the title bar empty]'\ '(-d --rebinddelete)'{-d,--rebinddelete}'[fix Backspace/Delete confusion problem]' \
{-f,--rcfile=}'[Use only this file for configuring nano]:file:_files'\ '(-e --emptyline)'{-e,--emptyline}'[keep the line below the title bar empty]' \
{-g,--showcursor}'[Show cursor in file browser & help text]'\ '(-f --rcfile)'{-f,--rcfile=}'[Use only specified file for configuring nano]:file:_files' \
'(- *)'{-h,--help}'[Show help text and exit]'\ '(-g --showcursor)'{-g,--showcursor}'[show cursor in file browser & help text]' \
{-i,--autoindent}'[Automatically indent new lines]'\ '(- *)'{-h,--help}'[show help text and exit]' \
{-j,--jumpyscrolling}'[Scroll per half-screen, not per line]'\ '(-i --autoindent)'{-i,--autoindent}'[automatically indent new lines]' \
{-k,--cutfromcursor}'[Cut from cursor to end of line]'\ '(-j --jumpyscrolling)'{-j,--jumpyscrolling}'[scroll by half-screen, not by line]' \
{-l,--linenumbers}'[Show line numbers in front of the text]'\ '(-k --cutfromcursor)'{-k,--cutfromcursor}'[cut from cursor to end of line]' \
{-m,--mouse}'[Enable the use of the mouse]'\ '(-l --linenumbers)'{-l,--linenumbers}'[show line numbers in front of the text]' \
{-n,--noread}'[Do not read the file (only write it)]'\ '(-m --mouse)'{-m,--mouse}'[enable the use of the mouse]' \
{-o+,--operatingdir=}'[Set operating directory]:dir:_dirs'\ '(-n --noread)'{-n,--noread}"[don't read the file (only write it)]" \
{-p,--preserve}'[Preserve XON (^Q) and XOFF (^S) keys]'\ '(-o --operatingdir)'{-o+,--operatingdir=}'[set operating directory]:directory:_directories' \
{-q,--indicator}'[Show a position+portion indicator]'\ '(-p --preserve)'{-p,--preserve}'[preserve XON (^Q) and XOFF (^S) keys]' \
{-r+,--fill=}'[Set width for hard-wrap and justify]:init'\ '(-q --indicator)'{-q,--indicator}'[show a position+portion indicator]' \
{-s+,--speller=}'[Enable alternate speller]:prog'\ '(-r --fill)'{-r+,--fill=}'[set width for hard-wrap and justification]:width [-8]' \
{-t,--tempfile}'[Auto save on exit, do not prompt]'\ '(-s --speller)'{-s+,--speller=}'[enable alternate speller]:program:_command_names -e' \
{-u,--unix}'[Save a file by default in Unix format]'\ '(-t --tempfile)'{-t,--tempfile}'[auto save on exit, do not prompt]' \
{-v,--view}'[View mode (read-only)]'\ '(-u --unix -N --noconvert)'{-u,--unix}'[save a file by default in Unix format]' \
{-w,--nowrap}'[Do not hard-wrap long lines default]'\ '(-v --view)'{-v,--view}'[view mode (read-only)]' \
{-x,--nohelp}'[Do not show the two help lines]'\ '(-w --nowrap -b --breaklonglines)'{-w,--nowrap}"[don't hard-wrap long lines default]" \
{-y,--afterends}'[Make Ctrl+Right stop at word ends]'\ '(-x --nohelp)'{-x,--nohelp}"[don't show the two help lines]" \
{-z,--suspend}'[Enable suspension]'\ '(-y --afterends)'{-y,--afterends}'[make Ctrl+Right stop at word ends]' \
{-%,--stateflags}'[Show some states on the title bar]'\ '(-z --suspend)'{-z,--suspend}'[enable suspension]' \
'(-t -q)*:file:_files' '(-% --stateflags)'{-%,--stateflags}'[show some states in the title bar]' \
'(-_ --minibar -U --quickblank)'{-_,--minibar}'[suppress the title bar and show information at the bottom of the screen]' \
'(-! --magic)'{-\!,--magic}'[try libmagic to determine applicable syntax]' \
'(-t -q)*: :->args' && ret=0
if [[ -n $state ]]; then
case $PREFIX in
+) _message -e lines "start at a given line" ;;
+[crCR]#[/?]) _message -e 'search string' ;;
+<->,) _message -e 'column number' ;;
*) _files && ret=0 ;;
esac
fi
return ret