nim.zsh-completion 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #compdef nim
  2. # Installation note:
  3. # Please name this file as _nim (with underscore!) and copy it to a
  4. # completions directory, either:
  5. # - system wide one, like /usr/share/zsh/functions/Completion/Unix/ on Linux
  6. # - or to a user directory like ~/scripts. Then you also need to add
  7. # that directory in your ~/.zshrc to `fpath` array like so:
  8. # fpath=( ~/scripts "${fpath[@]}" )
  9. _nim() {
  10. local -a nimCommands=(
  11. {compile,c}:'compile project with default code generator C'
  12. {compileToC,cc}:'compile project with C code generator'
  13. {compileToCpp,cpp}:'compile project to C++ code'
  14. {compileToOC,objc}:'compile project to Objective C code'
  15. 'js:compile project to Javascript'
  16. 'e:run a Nimscript file'
  17. 'doc:generate the HTML documentation for inputfile'
  18. 'rst2html:convert a reStructuredText file to HTML'
  19. 'doc2tex:generate the documentation for inputfile to LaTeX'
  20. 'rst2tex:convert a reStructuredText file to TeX'
  21. 'jsondoc:extract the documentation to a json file'
  22. 'buildIndex:build an index for the whole documentation'
  23. 'genDepend:generate a DOT file containing the module dependency graph'
  24. 'dump:dump all defined conditionals and search paths'
  25. 'check:checks the project for syntax and semantic'
  26. {--help,-h}:'basic help'
  27. '--fullhelp:show all switches'
  28. {-v,--version}:'show version'
  29. )
  30. _arguments '*:: :->anyState' && return 0
  31. if (( CURRENT == 1 )); then
  32. _describe -t commands "Nim commands" nimCommands -V1
  33. return
  34. fi
  35. local -a conditionalSymbols=(
  36. release danger mingw androidNDK useNimRtl useMalloc noSignalHandler ssl
  37. debug leanCompiler gcDestructors)
  38. local -a sharedOpts=(
  39. {--define\\:-,-d\\:-}'[define a conditional symbol]:x:($conditionalSymbols)'
  40. {--undef\\:-,-u\\:-}'[undefine a conditional symbol]:x:($conditionalSymbols)'
  41. {--path\\:-,-p\\:-}'[add path to search paths]:x:_files'
  42. '--verbosity\:-[set verbosity level (default\: 1)]:x:(0 1 2 3)'
  43. '--hints\:-[print compilation hints? (or `list`)]:x:(on off list)'
  44. )
  45. local runOpts=(
  46. {--run,-r}'[run the application]'
  47. )
  48. local docOpts=(
  49. '--index\:-[enable index .idx files?]:x:(on off)'
  50. '--project\:-[output any dependency for doc?]:x:(on off)'
  51. '--docInternal\:-[generate module-private documentation?]:x:(on off)'
  52. )
  53. local -a codeOpts=(
  54. {--forceBuild,-f}'[force rebuilding of all modules]'
  55. '--stackTrace\:-[enable stack tracing?]:x:(on off)'
  56. '--lineTrace\:-[enable line tracing?]:x:(on off)'
  57. '--threads\:-[enable support for multi-threading?]:x:(on off)'
  58. {--checks\\:-,-x\\:-}'[enable/disable all runtime checks?]:x:(on off)'
  59. '--objChecks\:-[enable obj conversion checks]:x:(on off)'
  60. '--fieldChecks\:-[enable case variant field checks?]:x:(on off)'
  61. '--rangeChecks\:-[enable range checks?]:x:(on off)'
  62. '--boundChecks\:-[enable bound checks?]:x:(on off)'
  63. '--overflowChecks\:-[enable integer over-/underflow checks?]:x:(on off)'
  64. {--assertions\\:-,-a\\:-}'[enable assertions?]:x:(on off)'
  65. '--floatChecks\:-[enable floating point (NaN/Inf) checks?]:x:(on off)'
  66. '--nanChecks\:-[enable NaN checks?]:x:(on off)'
  67. '--infChecks\:-[enable Inf checks?]:x:(on off)'
  68. '--nilChecks\:-[enable nil checks?]:x:(on off)'
  69. '--expandArc\:-[show how given proc looks before final backend pass]'
  70. '--expandMacro\:-[dump every generated AST from given macro]'
  71. )
  72. local -a nativeOpts=(
  73. '--opt\:-[optimization mode]:x:(none speed size)'
  74. '--debugger\:native[use native debugger (gdb)]'
  75. '--app\:-[generate this type of app (lib=dynamic)]:x:(console gui lib staticlib)'
  76. '--cpu\:-[target architecture]:x:(alpha amd64 arm arm64 avr e2k esp hppa i386 ia64 js loongarch64 m68k mips mipsel mips64 mips64el msp430 nimvm powerpc powerpc64 powerpc64el riscv32 riscv64 sparc sparc64 vm wasm32)'
  77. '--gc\:-[memory management algorithm to use (default\: refc)]:x:(refc arc orc markAndSweep boehm go regions none)'
  78. '--os\:-[operating system to compile for]:x:(AIX Amiga Android Any Atari DOS DragonFly FreeBSD FreeRTOS Genode Haiku iOS Irix JS Linux MacOS MacOSX MorphOS NetBSD Netware NimVM NintendoSwitch OS2 OpenBSD PalmOS Standalone QNX SkyOS Solaris VxWorks Windows)'
  79. '--panics\:-[turn panics into process termination (default\: off)]:x:(off on)'
  80. )
  81. case "$words[1]" in
  82. compile|c|compileToC|cpp|compileToCpp|compileToOC|objc)
  83. _arguments $codeOpts $runOpts $sharedOpts $nativeOpts \
  84. '*:filename:_files -g"*.nim"'
  85. ;;
  86. js)
  87. _arguments $codeOpts $runOpts $sharedOpts \
  88. '*:filename:_files -g"*.nim"'
  89. ;;
  90. e)
  91. _arguments $codeOpts $runOpts $sharedOpts \
  92. '*:filename:_files -g"*.nims"'
  93. ;;
  94. doc|doc2tex|jsondoc)
  95. _arguments $runOpts $sharedOpts '*:filename:_files -g"*.nim"'
  96. ;;
  97. rst2html|rst2tex)
  98. _arguments $runOpts $sharedOpts $docOpts '*:filename:_files -g"*.rst"'
  99. ;;
  100. buildIndex|genDepend|check)
  101. _arguments $sharedOpts '*:filename:_files -g"*.nim"'
  102. ;;
  103. dump)
  104. _arguments $sharedOpts
  105. ;;
  106. *)
  107. _arguments '*:filename:_files -g"*"'
  108. ;;
  109. esac
  110. return 1
  111. }
  112. _nim "$@"