Klimi's new dotfiles with stow.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

306 wiersze
18 KiB

4 lat temu
  1. ;;; company-keywords.el --- A company backend for programming language keywords
  2. ;; Copyright (C) 2009-2011, 2016 Free Software Foundation, Inc.
  3. ;; Author: Nikolaj Schumacher
  4. ;; This file is part of GNU Emacs.
  5. ;; GNU Emacs is free software: you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; GNU Emacs is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Commentary:
  16. ;;
  17. ;;; Code:
  18. (require 'company)
  19. (require 'cl-lib)
  20. (defun company-keywords-upper-lower (&rest lst)
  21. ;; Upcase order is different for _.
  22. (nconc (sort (mapcar 'upcase lst) 'string<) lst))
  23. (defvar company-keywords-alist
  24. ;; Please contribute corrections or additions.
  25. `((c++-mode
  26. "alignas" "alignof" "asm" "auto" "bool" "break" "case" "catch" "char"
  27. "char16_t" "char32_t" "class" "const" "const_cast" "constexpr" "continue"
  28. "decltype" "default" "delete" "do" "double" "dynamic_cast" "else" "enum"
  29. "explicit" "export" "extern" "false" "final" "float" "for" "friend"
  30. "goto" "if" "inline" "int" "long" "mutable" "namespace" "new" "noexcept"
  31. "nullptr" "operator" "override"
  32. "private" "protected" "public" "register" "reinterpret_cast"
  33. "return" "short" "signed" "sizeof" "static" "static_assert"
  34. "static_cast" "struct" "switch" "template" "this" "thread_local"
  35. "throw" "true" "try" "typedef" "typeid" "typename"
  36. "union" "unsigned" "using" "virtual" "void" "volatile" "wchar_t" "while")
  37. (c-mode
  38. "auto" "break" "case" "char" "const" "continue" "default" "do"
  39. "double" "else" "enum" "extern" "float" "for" "goto" "if" "int" "long"
  40. "register" "return" "short" "signed" "sizeof" "static" "struct"
  41. "switch" "typedef" "union" "unsigned" "void" "volatile" "while")
  42. (csharp-mode
  43. "abstract" "add" "alias" "as" "base" "bool" "break" "byte" "case"
  44. "catch" "char" "checked" "class" "const" "continue" "decimal" "default"
  45. "delegate" "do" "double" "else" "enum" "event" "explicit" "extern"
  46. "false" "finally" "fixed" "float" "for" "foreach" "get" "global" "goto"
  47. "if" "implicit" "in" "int" "interface" "internal" "is" "lock" "long"
  48. "namespace" "new" "null" "object" "operator" "out" "override" "params"
  49. "partial" "private" "protected" "public" "readonly" "ref" "remove"
  50. "return" "sbyte" "sealed" "set" "short" "sizeof" "stackalloc" "static"
  51. "string" "struct" "switch" "this" "throw" "true" "try" "typeof" "uint"
  52. "ulong" "unchecked" "unsafe" "ushort" "using" "value" "var" "virtual"
  53. "void" "volatile" "where" "while" "yield")
  54. (d-mode
  55. ;; from http://www.digitalmars.com/d/2.0/lex.html
  56. "abstract" "alias" "align" "asm"
  57. "assert" "auto" "body" "bool" "break" "byte" "case" "cast" "catch"
  58. "cdouble" "cent" "cfloat" "char" "class" "const" "continue" "creal"
  59. "dchar" "debug" "default" "delegate" "delete" "deprecated" "do"
  60. "double" "else" "enum" "export" "extern" "false" "final" "finally"
  61. "float" "for" "foreach" "foreach_reverse" "function" "goto" "idouble"
  62. "if" "ifloat" "import" "in" "inout" "int" "interface" "invariant"
  63. "ireal" "is" "lazy" "long" "macro" "mixin" "module" "new" "nothrow"
  64. "null" "out" "override" "package" "pragma" "private" "protected"
  65. "public" "pure" "real" "ref" "return" "scope" "short" "static" "struct"
  66. "super" "switch" "synchronized" "template" "this" "throw" "true" "try"
  67. "typedef" "typeid" "typeof" "ubyte" "ucent" "uint" "ulong" "union"
  68. "unittest" "ushort" "version" "void" "volatile" "wchar" "while" "with")
  69. (f90-mode .
  70. ;; from f90.el
  71. ;; ".AND." ".GE." ".GT." ".LT." ".LE." ".NE." ".OR." ".TRUE." ".FALSE."
  72. ,(company-keywords-upper-lower
  73. "abs" "abstract" "achar" "acos" "adjustl" "adjustr" "aimag" "aint"
  74. "align" "all" "all_prefix" "all_scatter" "all_suffix" "allocatable"
  75. "allocate" "allocated" "and" "anint" "any" "any_prefix" "any_scatter"
  76. "any_suffix" "asin" "assign" "assignment" "associate" "associated"
  77. "asynchronous" "atan" "atan2" "backspace" "bind" "bit_size" "block"
  78. "btest" "c_alert" "c_associated" "c_backspace" "c_bool"
  79. "c_carriage_return" "c_char" "c_double" "c_double_complex" "c_f_pointer"
  80. "c_f_procpointer" "c_float" "c_float_complex" "c_form_feed" "c_funloc"
  81. "c_funptr" "c_horizontal_tab" "c_int" "c_int16_t" "c_int32_t" "c_int64_t"
  82. "c_int8_t" "c_int_fast16_t" "c_int_fast32_t" "c_int_fast64_t"
  83. "c_int_fast8_t" "c_int_least16_t" "c_int_least32_t" "c_int_least64_t"
  84. "c_int_least8_t" "c_intmax_t" "c_intptr_t" "c_loc" "c_long"
  85. "c_long_double" "c_long_double_complex" "c_long_long" "c_new_line"
  86. "c_null_char" "c_null_funptr" "c_null_ptr" "c_ptr" "c_short"
  87. "c_signed_char" "c_size_t" "c_vertical_tab" "call" "case" "ceiling"
  88. "char" "character" "character_storage_size" "class" "close" "cmplx"
  89. "command_argument_count" "common" "complex" "conjg" "contains" "continue"
  90. "copy_prefix" "copy_scatter" "copy_suffix" "cos" "cosh" "count"
  91. "count_prefix" "count_scatter" "count_suffix" "cpu_time" "cshift"
  92. "cycle" "cyclic" "data" "date_and_time" "dble" "deallocate" "deferred"
  93. "digits" "dim" "dimension" "distribute" "do" "dot_product" "double"
  94. "dprod" "dynamic" "elemental" "else" "elseif" "elsewhere" "end" "enddo"
  95. "endfile" "endif" "entry" "enum" "enumerator" "eoshift" "epsilon" "eq"
  96. "equivalence" "eqv" "error_unit" "exit" "exp" "exponent" "extends"
  97. "extends_type_of" "external" "extrinsic" "false" "file_storage_size"
  98. "final" "floor" "flush" "forall" "format" "fraction" "function" "ge"
  99. "generic" "get_command" "get_command_argument" "get_environment_variable"
  100. "goto" "grade_down" "grade_up" "gt" "hpf_alignment" "hpf_distribution"
  101. "hpf_template" "huge" "iachar" "iall" "iall_prefix" "iall_scatter"
  102. "iall_suffix" "iand" "iany" "iany_prefix" "iany_scatter" "iany_suffix"
  103. "ibclr" "ibits" "ibset" "ichar" "ieee_arithmetic" "ieee_exceptions"
  104. "ieee_features" "ieee_get_underflow_mode" "ieee_set_underflow_mode"
  105. "ieee_support_underflow_control" "ieor" "if" "ilen" "implicit"
  106. "import" "include" "independent" "index" "inherit" "input_unit"
  107. "inquire" "int" "integer" "intent" "interface" "intrinsic" "ior"
  108. "iostat_end" "iostat_eor" "iparity" "iparity_prefix" "iparity_scatter"
  109. "iparity_suffix" "ishft" "ishftc" "iso_c_binding" "iso_fortran_env"
  110. "kind" "lbound" "le" "leadz" "len" "len_trim" "lge" "lgt" "lle" "llt"
  111. "log" "log10" "logical" "lt" "matmul" "max" "maxexponent" "maxloc"
  112. "maxval" "maxval_prefix" "maxval_scatter" "maxval_suffix" "merge"
  113. "min" "minexponent" "minloc" "minval" "minval_prefix" "minval_scatter"
  114. "minval_suffix" "mod" "module" "modulo" "move_alloc" "mvbits" "namelist"
  115. "ne" "nearest" "neqv" "new" "new_line" "nint" "non_intrinsic"
  116. "non_overridable" "none" "nopass" "not" "null" "nullify"
  117. "number_of_processors" "numeric_storage_size" "only" "onto" "open"
  118. "operator" "optional" "or" "output_unit" "pack" "parameter" "parity"
  119. "parity_prefix" "parity_scatter" "parity_suffix" "pass" "pause"
  120. "pointer" "popcnt" "poppar" "precision" "present" "print" "private"
  121. "procedure" "processors" "processors_shape" "product" "product_prefix"
  122. "product_scatter" "product_suffix" "program" "protected" "public"
  123. "pure" "radix" "random_number" "random_seed" "range" "read" "real"
  124. "realign" "recursive" "redistribute" "repeat" "reshape" "result"
  125. "return" "rewind" "rrspacing" "same_type_as" "save" "scale" "scan"
  126. "select" "selected_char_kind" "selected_int_kind" "selected_real_kind"
  127. "sequence" "set_exponent" "shape" "sign" "sin" "sinh" "size" "spacing"
  128. "spread" "sqrt" "stop" "subroutine" "sum" "sum_prefix" "sum_scatter"
  129. "sum_suffix" "system_clock" "tan" "tanh" "target" "template" "then"
  130. "tiny" "transfer" "transpose" "trim" "true" "type" "ubound" "unpack"
  131. "use" "value" "verify" "volatile" "wait" "where" "while" "with" "write"))
  132. (go-mode
  133. ;; 1. Keywords ref: https://golang.org/ref/spec#Keywords
  134. ;; 2. Builtin functions and types ref: https://golang.org/pkg/builtin/
  135. "append" "bool" "break" "byte" "cap" "case" "chan" "close" "complex" "complex128"
  136. "complex64" "const" "continue" "copy" "default" "defer" "delete" "else" "error"
  137. "fallthrough" "false" "float32" "float64" "for" "func" "go" "goto" "if" "imag"
  138. "import" "int" "int16" "int32" "int64" "int8" "interface" "len" "make"
  139. "map" "new" "nil" "package" "panic" "print" "println" "range" "real" "recover"
  140. "return" "rune" "select" "string" "struct" "switch" "true" "type" "uint" "uint16"
  141. "uint32" "uint64" "uint8" "uintptr" "var")
  142. (java-mode
  143. "abstract" "assert" "boolean" "break" "byte" "case" "catch" "char" "class"
  144. "continue" "default" "do" "double" "else" "enum" "extends" "final"
  145. "finally" "float" "for" "if" "implements" "import" "instanceof" "int"
  146. "interface" "long" "native" "new" "package" "private" "protected" "public"
  147. "return" "short" "static" "strictfp" "super" "switch" "synchronized"
  148. "this" "throw" "throws" "transient" "try" "void" "volatile" "while")
  149. (javascript-mode
  150. ;; https://tc39.github.io/ecma262/ + async, static and undefined
  151. "async" "await" "break" "case" "catch" "class" "const" "continue"
  152. "debugger" "default" "delete" "do" "else" "enum" "export" "extends" "false"
  153. "finally" "for" "function" "if" "import" "in" "instanceof" "let" "new"
  154. "null" "return" "static" "super" "switch" "this" "throw" "true" "try"
  155. "typeof" "undefined" "var" "void" "while" "with" "yield")
  156. (kotlin-mode
  157. "abstract" "annotation" "as" "break" "by" "catch" "class" "companion"
  158. "const" "constructor" "continue" "data" "do" "else" "enum" "false" "final"
  159. "finally" "for" "fun" "if" "import" "in" "init" "inner" "interface"
  160. "internal" "is" "lateinit" "nested" "null" "object" "open" "out" "override"
  161. "package" "private" "protected" "public" "return" "super" "this" "throw"
  162. "trait" "true" "try" "typealias" "val" "var" "when" "while")
  163. (objc-mode
  164. "@catch" "@class" "@encode" "@end" "@finally" "@implementation"
  165. "@interface" "@private" "@protected" "@protocol" "@public"
  166. "@selector" "@synchronized" "@throw" "@try" "alloc" "autorelease"
  167. "bycopy" "byref" "in" "inout" "oneway" "out" "release" "retain")
  168. (perl-mode
  169. ;; from cperl.el
  170. "AUTOLOAD" "BEGIN" "CHECK" "CORE" "DESTROY" "END" "INIT" "__END__"
  171. "__FILE__" "__LINE__" "abs" "accept" "alarm" "and" "atan2" "bind"
  172. "binmode" "bless" "caller" "chdir" "chmod" "chomp" "chop" "chown" "chr"
  173. "chroot" "close" "closedir" "cmp" "connect" "continue" "cos"
  174. "crypt" "dbmclose" "dbmopen" "defined" "delete" "die" "do" "dump" "each"
  175. "else" "elsif" "endgrent" "endhostent" "endnetent" "endprotoent"
  176. "endpwent" "endservent" "eof" "eq" "eval" "exec" "exists" "exit" "exp"
  177. "fcntl" "fileno" "flock" "for" "foreach" "fork" "format" "formline"
  178. "ge" "getc" "getgrent" "getgrgid" "getgrnam" "gethostbyaddr"
  179. "gethostbyname" "gethostent" "getlogin" "getnetbyaddr" "getnetbyname"
  180. "getnetent" "getpeername" "getpgrp" "getppid" "getpriority"
  181. "getprotobyname" "getprotobynumber" "getprotoent" "getpwent" "getpwnam"
  182. "getpwuid" "getservbyname" "getservbyport" "getservent" "getsockname"
  183. "getsockopt" "glob" "gmtime" "goto" "grep" "gt" "hex" "if" "index" "int"
  184. "ioctl" "join" "keys" "kill" "last" "lc" "lcfirst" "le" "length"
  185. "link" "listen" "local" "localtime" "lock" "log" "lstat" "lt" "map"
  186. "mkdir" "msgctl" "msgget" "msgrcv" "msgsnd" "my" "ne" "next" "no"
  187. "not" "oct" "open" "opendir" "or" "ord" "our" "pack" "package" "pipe"
  188. "pop" "pos" "print" "printf" "push" "q" "qq" "quotemeta" "qw" "qx"
  189. "rand" "read" "readdir" "readline" "readlink" "readpipe" "recv" "redo"
  190. "ref" "rename" "require" "reset" "return" "reverse" "rewinddir" "rindex"
  191. "rmdir" "scalar" "seek" "seekdir" "select" "semctl" "semget" "semop"
  192. "send" "setgrent" "sethostent" "setnetent" "setpgrp" "setpriority"
  193. "setprotoent" "setpwent" "setservent" "setsockopt" "shift" "shmctl"
  194. "shmget" "shmread" "shmwrite" "shutdown" "sin" "sleep" "socket"
  195. "socketpair" "sort" "splice" "split" "sprintf" "sqrt" "srand" "stat"
  196. "study" "sub" "substr" "symlink" "syscall" "sysopen" "sysread" "system"
  197. "syswrite" "tell" "telldir" "tie" "time" "times" "tr" "truncate" "uc"
  198. "ucfirst" "umask" "undef" "unless" "unlink" "unpack" "unshift" "untie"
  199. "until" "use" "utime" "values" "vec" "wait" "waitpid"
  200. "wantarray" "warn" "while" "write" "x" "xor" "y")
  201. (php-mode
  202. "__CLASS__" "__DIR__" "__FILE__" "__FUNCTION__" "__LINE__" "__METHOD__"
  203. "__NAMESPACE__" "_once" "abstract" "and" "array" "as" "break" "case"
  204. "catch" "cfunction" "class" "clone" "const" "continue" "declare"
  205. "default" "die" "do" "echo" "else" "elseif" "empty" "enddeclare"
  206. "endfor" "endforeach" "endif" "endswitch" "endwhile" "eval" "exception"
  207. "exit" "extends" "final" "for" "foreach" "function" "global"
  208. "goto" "if" "implements" "include" "instanceof" "interface"
  209. "isset" "list" "namespace" "new" "old_function" "or" "php_user_filter"
  210. "print" "private" "protected" "public" "require" "require_once" "return"
  211. "static" "switch" "this" "throw" "try" "unset" "use" "var" "while" "xor")
  212. (python-mode
  213. ;; https://docs.python.org/3/reference/lexical_analysis.html#keywords
  214. "False" "None" "True" "and" "as" "assert" "break" "class" "continue" "def"
  215. "del" "elif" "else" "except" "exec" "finally" "for" "from" "global" "if"
  216. "import" "in" "is" "lambda" "nonlocal" "not" "or" "pass" "print" "raise"
  217. "return" "try" "while" "with" "yield")
  218. (ruby-mode
  219. "BEGIN" "END" "alias" "and" "begin" "break" "case" "class" "def" "defined?"
  220. "do" "else" "elsif" "end" "ensure" "false" "for" "if" "in" "module"
  221. "next" "nil" "not" "or" "redo" "rescue" "retry" "return" "self" "super"
  222. "then" "true" "undef" "unless" "until" "when" "while" "yield")
  223. ;; From https://doc.rust-lang.org/grammar.html#keywords
  224. ;; but excluding unused reserved words: https://www.reddit.com/r/rust/comments/34fq0k/is_there_a_good_list_of_rusts_keywords/cqucvnj
  225. (rust-mode
  226. "Self"
  227. "as" "box" "break" "const" "continue" "crate" "else" "enum" "extern"
  228. "false" "fn" "for" "if" "impl" "in" "let" "loop" "macro" "match" "mod"
  229. "move" "mut" "pub" "ref" "return" "self" "static" "struct" "super"
  230. "trait" "true" "type" "unsafe" "use" "where" "while")
  231. (scala-mode
  232. "abstract" "case" "catch" "class" "def" "do" "else" "extends" "false"
  233. "final" "finally" "for" "forSome" "if" "implicit" "import" "lazy" "match"
  234. "new" "null" "object" "override" "package" "private" "protected"
  235. "return" "sealed" "super" "this" "throw" "trait" "true" "try" "type" "val"
  236. "var" "while" "with" "yield")
  237. (swift-mode
  238. "Protocol" "Self" "Type" "and" "as" "assignment" "associatedtype"
  239. "associativity" "available" "break" "case" "catch" "class" "column" "continue"
  240. "convenience" "default" "defer" "deinit" "didSet" "do" "dynamic" "dynamicType"
  241. "else" "elseif" "endif" "enum" "extension" "fallthrough" "false" "file"
  242. "fileprivate" "final" "for" "func" "function" "get" "guard" "higherThan" "if"
  243. "import" "in" "indirect" "infix" "init" "inout" "internal" "is" "lazy" "left"
  244. "let" "line" "lowerThan" "mutating" "nil" "none" "nonmutating" "open"
  245. "operator" "optional" "override" "postfix" "precedence" "precedencegroup"
  246. "prefix" "private" "protocol" "public" "repeat" "required" "rethrows" "return"
  247. "right" "selector" "self" "set" "static" "struct" "subscript" "super" "switch"
  248. "throw" "throws" "true" "try" "typealias" "unowned" "var" "weak" "where"
  249. "while" "willSet")
  250. (julia-mode
  251. "abstract" "break" "case" "catch" "const" "continue" "do" "else" "elseif"
  252. "end" "eval" "export" "false" "finally" "for" "function" "global" "if"
  253. "ifelse" "immutable" "import" "importall" "in" "let" "macro" "module"
  254. "otherwise" "quote" "return" "switch" "throw" "true" "try" "type"
  255. "typealias" "using" "while"
  256. )
  257. ;; From https://github.com/apache/thrift/blob/master/contrib/thrift.el
  258. (thrift-mode
  259. "binary" "bool" "byte" "const" "double" "enum" "exception" "extends"
  260. "i16" "i32" "i64" "include" "list" "map" "oneway" "optional" "required"
  261. "service" "set" "string" "struct" "throws" "typedef" "void"
  262. )
  263. ;; aliases
  264. (js2-mode . javascript-mode)
  265. (js2-jsx-mode . javascript-mode)
  266. (espresso-mode . javascript-mode)
  267. (js-mode . javascript-mode)
  268. (js-jsx-mode . javascript-mode)
  269. (rjsx-mode . javascript-mode)
  270. (cperl-mode . perl-mode)
  271. (jde-mode . java-mode)
  272. (ess-julia-mode . julia-mode)
  273. (enh-ruby-mode . ruby-mode))
  274. "Alist mapping major-modes to sorted keywords for `company-keywords'.")
  275. ;;;###autoload
  276. (defun company-keywords (command &optional arg &rest ignored)
  277. "`company-mode' backend for programming language keywords."
  278. (interactive (list 'interactive))
  279. (cl-case command
  280. (interactive (company-begin-backend 'company-keywords))
  281. (prefix (and (assq major-mode company-keywords-alist)
  282. (not (company-in-string-or-comment))
  283. (or (company-grab-symbol) 'stop)))
  284. (candidates
  285. (let ((completion-ignore-case nil)
  286. (symbols (cdr (assq major-mode company-keywords-alist))))
  287. (all-completions arg (if (consp symbols)
  288. symbols
  289. (cdr (assq symbols company-keywords-alist))))))
  290. (sorted t)))
  291. (provide 'company-keywords)
  292. ;;; company-keywords.el ends here