From 5ede2c55f144593c16498c3131a76e188114a9c6 Mon Sep 17 00:00:00 2001 From: Jacob Gelbman Date: Wed, 24 Feb 2021 01:20:24 -0600 Subject: [PATCH] 48105: Update ctags completion with format fix --- ChangeLog | 5 + Completion/Unix/Command/_ctags | 389 ++++++++++++++++----------------- 2 files changed, 196 insertions(+), 198 deletions(-) diff --git a/ChangeLog b/ChangeLog index ba5510aac..417a63797 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2021-02-24 Peter Stephenson + + * 48105: Jacob Gelbman:Completion/Unix/Command/_ctags: update and + fix formatting nad import. + 2021-02-23 Peter Stephenson * 48096: Jacob Gelbman: Completion/Unix/Command/_ctags: new diff --git a/Completion/Unix/Command/_ctags b/Completion/Unix/Command/_ctags index 53d4d8f12..30c631d37 100644 --- a/Completion/Unix/Command/_ctags +++ b/Completion/Unix/Command/_ctags @@ -1,204 +1,197 @@ #compdef ctags -local state +local context state line expl +local -A opt_args -_arguments \ - "-?[help text]" \ - "-a[append the tags to an existing tag file]" \ - "-B[use backward searching patterns (?...?)]" \ - "-D[give definition for macro]:macro definition:" \ - "-e[output tag file for use with emacs]" \ - "-f[write tags to specified file. - is stdout]:file:_files" \ - "-F[use forward searching patterns]" \ - "-G[equivalent to --guess-language-eagerly]" \ - "-h[specify list of file extensions to be treated as include files]:" \ - "-I[a list of tokens to be specifically handled is read from either the command line or the specified file]:" \ - "-L[a list of input file names is read from the specified file. - is stdin]:file:_files" \ - "-n[equivalent to --excmd=number]" \ - "-N[equivalent to --excmd=pattern]" \ - "-o[alternative to -f]:file:_files" \ - "-R[equivalent to --recurse]" \ - "-u[equivalent to --sort=no]" \ - "-V[equivalent to --verbose]" \ - -I wrote a completion script for the ctags program. Someone might be able to use it: - -#compdef ctags - -local state - -_arguments \ - "-?[help text]" \ - "-a[append the tags to an existing tag file]" \ - "-B[use backward searching patterns (?...?)]" \ - "-D[give definition for macro]:macro definition:" \ - "-e[output tag file for use with emacs]" \ - "-f[write tags to specified file. - is stdout]:file:_files" \ - "-F[use forward searching patterns]" \ - "-G[equivalent to --guess-language-eagerly]" \ - "-h[specify list of file extensions to be treated as include files]:" \ - "-I[a list of tokens to be specifically handled is read from either the command line or the specified file]:" \ - "-L[a list of input file names is read from the specified file. - is stdin]:file:_files" \ - "-n[equivalent to --excmd=number]" \ - "-N[equivalent to --excmd=pattern]" \ - "-o[alternative to -f]:file:_files" \ - "-R[equivalent to --recurse]" \ - "-u[equivalent to --sort=no]" \ - "-V[equivalent to --verbose]" \ - "-x[print a tabular cross reference file to stdout]" \ - "--alias-=[add a pattern detecting a name, can be used as an alt name for lang]:pattern" \ - "--append=[should tags be appended to existing tag file]:bool:(yes no)" \ - "--etags-include=[include reference to file in emacs style tag file]:file:_files" \ - "--exclude=[exclude files and directories matching pattern]:pattern" \ - "--exclude-exception=[don't exclude files and directories matching pattern even if they match the pattern specified with --exclude]:pattern" \ - "--excmd=[uses the specified type of ex command to locate tags]:ex command type:(number pattern mix combine)" \ - "--extras=[include extra tag entries for selected information (flags fFgpqrs)]:flags" \ - "--extras-=[include own extra tag entries for selected information]:flags" \ - "--fields=[include selected extension fields (flags aCeEfFikKlmnNpPrRsStxzZ)]:flags" \ - "--fields-=[include selected own extension fields]:flags" \ - "--filter=[behave as a filter, reading file names from stdin and writing tags to stdout]:bool:(yes no)" \ - "--filter-terminator=[specify string to print to stdout following the tags for each file parsed when --filter is enabled]:string" \ - "--format=[force output of specified tag file format]:level" \ - "--guess-language-eagerly[guess the language of input file more eagerly]" \ - "--help[help text]" \ - "--help-full[help text with experimental features]" \ - "--if0=[should code within #if 0 conditionals be parsed]:bool:(yes no)" \ - "--input-encoding=[specify encoding of all input files]:encoding" \ - "--input-encoding-=[specify encoding of the input files]:encoding" \ - "--kinddef-=[define new kind for ]:kind" \ - "--kinds-=[enable/disable tag kinds for ]:kind" \ - "--langdef=[define a new language to be parsed with regular expressions]:name" \ - "--langmap=[override default mapping of language to input file extension]:maps" \ - "--language-force=[force all files to be interpreted using specified language]:language:->language" \ - "--languages=[restrict files scanned to these comma-separated languages]:language:->languages" \ - "--license[print details of software license]" \ - "--line-directives=[should #line directives be processed]:bool:(yes no)" \ - "--links=[indicate whether symlinks should be followed]:bool:(yes no)" \ - "--list-aliases=[list of alias patterns]:language:->language" \ - "--list-excludes[list of exclude patterns for files/dirs]" \ - "--list-extras=[list of extra tag flags]:language:->language" \ - "--list-features[list of compiled features]" \ - "--list-fields=[list of fields]:language:->language" \ - "--list-kinds=[list of all tag kinds for lang]:language:->language" \ - "--list-kinds-full=[list details of all tag kinds for lang]:language:->language" \ - "--list-languages[list of supported languages]" \ - "--list-map-extensions=[list of language extensions in mapping]:language:->language" \ - "--list-map-patterns=[list of language patterns in mapping]:language:->language" \ - "--list-maps=[list of language mappings (both extensions and patterns)]:language:->language" \ - "--list-mline-regex-flags[list of flags which can be used in a multiline regex parser definition]" \ - "--list-params=[list of language parameters. works with --machinable]:language:->language" \ - "--list-pseudo-tags[list of pseudo tags]" \ - "--list-regex-flags[list of flags which can be used in a regex parser definition]" \ - "--list-roles=[list of all roles of tag kinds specified for langs]:language:->language" \ - "--list-subparsers=[list of subparsers for the base lang]:language:->language" \ - "--machinable=[use tab separated representation in --list-* output]:bool:(yes no)" \ - "--map-=[set, add(+), or remove(-) the map for ]:pattern" \ - "--maxdepth=[specify maximum recursion depth]:depth" \ - "--mline-regex-=[define multiline regex for locating tags in ]:pattern" \ - "--options=[specify file (or dir) from which command line options should be read]:file:_files" \ - "--options-maybe=[same as --options but doesn't error]:file:_files" \ - "--optlib-dir=[add or set dir to optlib search path]:dir:_files -/" \ - "--output-encoding=[the encoding to write the tag file in]:encoding" \ - "--output-format=[specify the output format]:format:(u-ctags e-ctags etags xref)" \ - "--param-=[set specific parameter]:argument" \ - "--pattern-length-limit=[cutoff patterns of tag entries after N characters]:number" \ - "--print-language[don't make tags file but just print the guessed lang name for input file]" \ - "--pseudo-tags=[enable/disable emitting pseudo tag named ptag. if *, enable emitting all pseudo tags]:ptag" \ - "--put-field-prefix[put UCTAGS as prefix for the name of fields newly introducted in universal ctags]" \ - "--quiet=[don't print notice class messages]:bool:(yes no)" \ - "--recurse=[recurse]:bool:(yes no)" \ - "--regex-=[define regex for locating tags in specific lang]:pattern" \ - "--roles-.=[enable/disable tag roles for kinds of ]:role" \ - "--sort=[should tags be sorted]:argument:(yes no foldcase)" \ - "--tag-relative=[should paths be relative to location of tag file]:argument:(yes no always never)" \ - "--totals=[print stats about input and tag files]:arguments:(yes no extra)" \ - "--verbose=[enable verbose messages describing actions]:bool:(yes no)" \ - "--version[print version]" \ - "--with-list-header=[prepend the column descriptions in --list-* output]:bool:(yes no)" \ - "*:file:_files" - -if [ "$state" = "language" ]; then - compadd `ctags --list-languages | cut -d" " -f1` -elif [ "$state" = "languages" ]; then - _values -s , "languages" `ctags --list-languages | cut -d" " -f1` +if [ -z "$_ctags_type" ]; then + local output=`ctags --version 2>&1` + if [[ "$output" = *Universal\ Ctags* ]]; then + _ctags_type="universal" + elif [[ "$output" = *Exuberant\ Ctags* ]]; then + _ctags_type="exuberant" + elif [[ "$output" = *usage:\ ctags* ]]; then + _ctags_type="bsd" + elif [[ "$output" = *Emacs* ]]; then + _ctags_type="etags" + else + _ctags_type="universal" + fi fi - - - "-x[print a tabular cross reference file to stdout]" \ - "--alias-=[add a pattern detecting a name, can be used as an alt name for lang]:pattern" \ - "--append=[should tags be appended to existing tag file]:bool:(yes no)" \ - "--etags-include=[include reference to file in emacs style tag file]:file:_files" \ - "--exclude=[exclude files and directories matching pattern]:pattern" \ - "--exclude-exception=[don't exclude files and directories matching pattern even if they match the pattern specified with --exclude]:pattern" \ - "--excmd=[uses the specified type of ex command to locate tags]:ex command type:(number pattern mix combine)" \ - "--extras=[include extra tag entries for selected information (flags fFgpqrs)]:flags" \ - "--extras-=[include own extra tag entries for selected information]:flags" \ - "--fields=[include selected extension fields (flags aCeEfFikKlmnNpPrRsStxzZ)]:flags" \ - "--fields-=[include selected own extension fields]:flags" \ - "--filter=[behave as a filter, reading file names from stdin and writing tags to stdout]:bool:(yes no)" \ - "--filter-terminator=[specify string to print to stdout following the tags for each file parsed when --filter is enabled]:string" \ - "--format=[force output of specified tag file format]:level" \ - "--guess-language-eagerly[guess the language of input file more eagerly]" \ - "--help[help text]" \ - "--help-full[help text with experimental features]" \ - "--if0=[should code within #if 0 conditionals be parsed]:bool:(yes no)" \ - "--input-encoding=[specify encoding of all input files]:encoding" \ - "--input-encoding-=[specify encoding of the input files]:encoding" \ - "--kinddef-=[define new kind for ]:kind" \ - "--kinds-=[enable/disable tag kinds for ]:kind" \ - "--langdef=[define a new language to be parsed with regular expressions]:name" \ - "--langmap=[override default mapping of language to input file extension]:maps" \ - "--language-force=[force all files to be interpreted using specified language]:language:->language" \ - "--languages=[restrict files scanned to these comma-separated languages]:language:->languages" \ - "--license[print details of software license]" \ - "--line-directives=[should #line directives be processed]:bool:(yes no)" \ - "--links=[indicate whether symlinks should be followed]:bool:(yes no)" \ - "--list-aliases=[list of alias patterns]:language:->language" \ - "--list-excludes[list of exclude patterns for files/dirs]" \ - "--list-extras=[list of extra tag flags]:language:->language" \ - "--list-features[list of compiled features]" \ - "--list-fields=[list of fields]:language:->language" \ - "--list-kinds=[list of all tag kinds for lang]:language:->language" \ - "--list-kinds-full=[list details of all tag kinds for lang]:language:->language" \ - "--list-languages[list of supported languages]" \ - "--list-map-extensions=[list of language extensions in mapping]:language:->language" \ - "--list-map-patterns=[list of language patterns in mapping]:language:->language" \ - "--list-maps=[list of language mappings (both extensions and patterns)]:language:->language" \ - "--list-mline-regex-flags[list of flags which can be used in a multiline regex parser definition]" \ - "--list-params=[list of language parameters. works with --machinable]:language:->language" \ - "--list-pseudo-tags[list of pseudo tags]" \ - "--list-regex-flags[list of flags which can be used in a regex parser definition]" \ - "--list-roles=[list of all roles of tag kinds specified for langs]:language:->language" \ - "--list-subparsers=[list of subparsers for the base lang]:language:->language" \ - "--machinable=[use tab separated representation in --list-* output]:bool:(yes no)" \ - "--map-=[set, add(+), or remove(-) the map for ]:pattern" \ - "--maxdepth=[specify maximum recursion depth]:depth" \ - "--mline-regex-=[define multiline regex for locating tags in ]:pattern" \ - "--options=[specify file (or dir) from which command line options should be read]:file:_files" \ - "--options-maybe=[same as --options but doesn't error]:file:_files" \ - "--optlib-dir=[add or set dir to optlib search path]:dir:_files -/" \ - "--output-encoding=[the encoding to write the tag file in]:encoding" \ - "--output-format=[specify the output format]:format:(u-ctags e-ctags etags xref)" \ - "--param-=[set specific parameter]:argument" \ - "--pattern-length-limit=[cutoff patterns of tag entries after N characters]:number" \ - "--print-language[don't make tags file but just print the guessed lang name for input file]" \ - "--pseudo-tags=[enable/disable emitting pseudo tag named ptag. if *, enable emitting all pseudo tags]:ptag" \ - "--put-field-prefix[put UCTAGS as prefix for the name of fields newly introducted in universal ctags]" \ - "--quiet=[don't print notice class messages]:bool:(yes no)" \ - "--recurse=[recurse]:bool:(yes no)" \ - "--regex-=[define regex for locating tags in specific lang]:pattern" \ - "--roles-.=[enable/disable tag roles for kinds of ]:role" \ - "--sort=[should tags be sorted]:argument:(yes no foldcase)" \ - "--tag-relative=[should paths be relative to location of tag file]:argument:(yes no always never)" \ - "--totals=[print stats about input and tag files]:arguments:(yes no extra)" \ - "--verbose=[enable verbose messages describing actions]:bool:(yes no)" \ - "--version[print version]" \ - "--with-list-header=[prepend the column descriptions in --list-* output]:bool:(yes no)" \ - "*:file:_files" - -if [ "$state" = "language" ]; then - compadd `ctags --list-languages | cut -d" " -f1` -elif [ "$state" = "languages" ]; then - _values -s , "languages" `ctags --list-languages | cut -d" " -f1` +if [ "$_ctags_type" = "etags" ]; then + _etags + return $? fi + +local -a arguments + +if [ "$_ctags_type" = "universal" ]; then + arguments=( + "-?[help text]" + "-a[append to tags file]" + "-B[use backward searching patterns (?...?)]" + "-D[give definition for macro]:macro definition:" + "-e[output tag file for use with emacs]" + "-f[write tags to specified file. - is stdout]:file:_files" + "-F[use forward searching patterns (/.../)]" + "-G[equivalent to --guess-language-eagerly]" + "-h[specify list of file extensions to be treated as include files]:" + "-I[a list of tokens to be specifically handled is read from either the command line or the specified file]:" + "-L[a list of input file names is read from the specified file. - is stdin]:file:_files" + "-n[equivalent to --excmd=number]" + "-N[equivalent to --excmd=pattern]" + "-o[alternative to -f]:file:_files" + "-R[equivalent to --recurse]" + "-u[equivalent to --sort=no]" + "-V[equivalent to --verbose]" + "-x[print a tabular cross reference file to stdout]" + "--alias-=[add a pattern detecting a name, can be used as an alt name for lang]:pattern" + "--append=[should tags be appended to existing tag file]:bool:(yes no)" + "--etags-include=[include reference to file in emacs style tag file]:file:_files" + "--exclude=[exclude files and directories matching pattern]:pattern" + "--exclude-exception=[don't exclude files and directories matching pattern even if they match the pattern specified with --exclude]:pattern" + "--excmd=[uses the specified type of ex command to locate tags]:ex command type:(number pattern mix combine)" + "--extras=[include extra tag entries for selected information (flags fFgpqrs)]:flags" + "--extras-=[include own extra tag entries for selected information]:flags" + "--fields=[include selected extension fields (flags aCeEfFikKlmnNpPrRsStxzZ)]:flags" + "--fields-=[include selected own extension fields]:flags" + "--filter=[behave as a filter, reading file names from stdin and writing tags to stdout]:bool:(yes no)" + "--filter-terminator=[specify string to print to stdout following the tags for each file parsed when --filter is enabled]:string" + "--format=[force output of specified tag file format]:level" + "--guess-language-eagerly[guess the language of input file more eagerly]" + "--help[help text]" + "--help-full[help text with experimental features]" + "--if0=[should code within #if 0 conditionals be parsed]:bool:(yes no)" + "--input-encoding=[specify encoding of all input files]:encoding" + "--input-encoding-=[specify encoding of the input files]:encoding" + "--kinddef-=[define new kind for ]:kind" + "--kinds-=[enable/disable tag kinds for ]:kind" + "--langdef=[define a new language to be parsed with regular expressions]:name" + "--langmap=[override default mapping of language to input file extension]:maps" + "--language-force=[force all files to be interpreted using specified language]:language:->language" + "--languages=[restrict files scanned to these comma-separated languages]:language:->languages" + "--license[print details of software license]" + "--line-directives=[should #line directives be processed]:bool:(yes no)" + "--links=[indicate whether symlinks should be followed]:bool:(yes no)" + "--list-aliases=[list of alias patterns]:language:->language" + "--list-excludes[list of exclude patterns for files/dirs]" + "--list-extras=[list of extra tag flags]:language:->language" + "--list-features[list of compiled features]" + "--list-fields=[list of fields]:language:->language" + "--list-kinds=[list of all tag kinds for lang]:language:->language" + "--list-kinds-full=[list details of all tag kinds for lang]:language:->language" + "--list-languages[list of supported languages]" + "--list-map-extensions=[list of language extensions in mapping]:language:->language" + "--list-map-patterns=[list of language patterns in mapping]:language:->language" + "--list-maps=[list of language mappings (both extensions and patterns)]:language:->language" + "--list-mline-regex-flags[list of flags which can be used in a multiline regex parser definition]" + "--list-params=[list of language parameters. works with --machinable]:language:->language" + "--list-pseudo-tags[list of pseudo tags]" + "--list-regex-flags[list of flags which can be used in a regex parser definition]" + "--list-roles=[list of all roles of tag kinds specified for langs]:language:->language" + "--list-subparsers=[list of subparsers for the base lang]:language:->language" + "--machinable=[use tab separated representation in --list-* output]:bool:(yes no)" + "--map-=[set, add(+), or remove(-) the map for ]:pattern" + "--maxdepth=[specify maximum recursion depth]:depth" + "--mline-regex-=[define multiline regex for locating tags in ]:pattern" + "--options=[specify file (or dir) from which command line options should be read]:file:_files" + "--options-maybe=[same as --options but doesn't error]:file:_files" + "--optlib-dir=[add or set dir to optlib search path]:dir:_files -/" + "--output-encoding=[the encoding to write the tag file in]:encoding" + "--output-format=[specify the output format]:format:(u-ctags e-ctags etags xref)" + "--param-=[set specific parameter]:argument" + "--pattern-length-limit=[cutoff patterns of tag entries after N characters]:number" + "--print-language[don't make tags file but just print the guessed lang name for input file]" + "--pseudo-tags=[enable/disable emitting pseudo tag named ptag. if *, enable emitting all pseudo tags]:ptag" + "--put-field-prefix[put UCTAGS as prefix for the name of fields newly introducted in universal ctags]" + "--quiet=[don't print notice class messages]:bool:(yes no)" + "--recurse=[recurse]:bool:(yes no)" + "--regex-=[define regex for locating tags in specific lang]:pattern" + "--roles-.=[enable/disable tag roles for kinds of ]:role" + "--sort=[should tags be sorted]:argument:(yes no foldcase)" + "--tag-relative=[should paths be relative to location of tag file]:argument:(yes no always never)" + "--totals=[print stats about input and tag files]:arguments:(yes no extra)" + "--verbose=[enable verbose messages describing actions]:bool:(yes no)" + "--version[print version]" + "--with-list-header=[prepend the column descriptions in --list-* output]:bool:(yes no)" + "*:file:_files" + ) +elif [ "$_ctags_type" = "exuberant" ]; then + arguments=( + "-a[append to tags file]" + "-B[use backward searching patterns (?...?)]" + "-e[output tag file for use with emacs]" + "-f[write tags to specified file. - is stdout]:file:_files" + "-F[use forward searching patterns (/.../)]" + "-h[specify list of file extensions to be treated as include files]:" + "-I[a list of tokens to be specifically handled is read from either the command line or the specified file]:" + "-L[a list of input file names is read from the specified file. - is stdin]:file:_files" + "-n[equivalent to --excmd=number]" + "-N[equivalent to --excmd=pattern]" + "-o[alternative to -f]:file:_files" + "-R[equivalent to --recurse]" + "-u[equivalent to --sort=no]" + "-V[equivalent to --verbose]" + "-x[print a tabular cross reference file to stdout]" + "--append=[should tags be appended to existing tag file]:bool:(yes no)" + "--etags-include=[include reference to file in emacs style tag file]:file:_files" + "--exclude=[exclude files and directories matching pattern]:pattern" + "--excmd=[uses the specified type of ex command to locate tags]:ex command type:(number pattern mix)" + "--extra=[include extra tag entries for selected information (flags fq)]:flags" + "--fields=[include selected extension fields (flags afmikKlnsStz)]:flags" + "--file-scope=[should tags scoped only for a single file be included in output]:bool:(yes no)" + "--filter=[behave as a filter, reading file names from stdin and writing tags to stdout]:bool:(yes no)" + "--filter-terminator=[specify string to print to stdout following the tags for each file parsed when --filter is enabled]:string" + "--format=[force output of specified tag file format]:level" + "--help[help text]" + "--if0=[should code within #if 0 conditionals be parsed]:bool:(yes no)" + "---kinds=[enable/disable tag kinds for ]:kind" + "--langdef=[define a new language to be parsed with regular expressions]:name" + "--langmap=[override default mapping of language to input file extension]:maps" + "--language-force=[force all files to be interpreted using specified language]:language:->language" + "--languages=[restrict files scanned to these comma-separated languages]:language:->languages" + "--license[print details of software license]" + "--line-directives=[should #line directives be processed]:bool:(yes no)" + "--links=[indicate whether symlinks should be followed]:bool:(yes no)" + "--list-kinds=[list of all tag kinds for lang]:language:->language" + "--list-languages[list of supported languages]" + "--list-maps=[list of language mappings (both extensions and patterns)]:language:->language" + "--options=[specify file (or dir) from which command line options should be read]:file:_files" + "--recurse=[recurse]:bool:(yes no)" + "--regex-=[define regex for locating tags in specific lang]:pattern" + "--sort=[should tags be sorted]:argument:(yes no foldcase)" + "--tag-relative=[should paths be relative to location of tag file]:argument:(yes no)" + "--totals=[print stats about input and tag files]:arguments:(yes no)" + "--verbose=[enable verbose messages describing actions]:bool:(yes no)" + "--version[print version]” + "*:file:_files" + ) +elif [ "$_ctags_type" = "bsd" ]; then + arguments=( + "-a[append to tags file]" + "-B[use backward searching patterns (?...?)]" + "-d[create tags for #defines that don't take arguments]" + "-F[use forward searching patterns (/.../)]" + "-f[write tags to specified file]:file:_files" + "-t[create tags for typedefs, structs, unions, and enums]" + "-u[update the specified files in the tags file]" + "-v[an index of the form expected by vgrind(1) is produced]" + "-w[suppress warning diagnostics]" + "-x[ctags produces a simple function index]" + "*:file:_files" + ) +fi + +_arguments $arguments + +if [[ "$state" = language* ]]; then + local -a languages + languages=(`ctags --list-languages | cut -d" " -f1`) + if [ "$state" = "language" ]; then + _wanted languages expl language compadd $languages + elif [ "$state" = "languages" ]; then + _values -s , languages $languages + fi +fi + +return $(( compstate[nmatches] > 0 ? 0 : 1 ))