Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

591 lines
22 KiB

14 years ago
  1. ;;; groovy-mode.el --- Groovy mode derived mode
  2. ;; Author: Russel Winder <russel@winder.org.uk>
  3. ;; Created: 2006-08-01
  4. ;; Version: 201203310931
  5. ;;;; NB Version number is date and time yyyymmddhhMM in GMT (aka UTC).
  6. ;; Copyright (C) 2006,2009-10,2012 Russel Winder
  7. ;; This program is free software; you can redistribute it and/or modify it under the terms of the GNU
  8. ;; General Public License as published by the Free Software Foundation; either version 2 of the License, or
  9. ;; (at your option) any later version.
  10. ;;
  11. ;; This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
  12. ;; the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  13. ;; License for more details.
  14. ;;
  15. ;; You should have received a copy of the GNU General Public License along with this program; if not, write
  16. ;; to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. ;;; Authors:
  18. ;;
  19. ;; Russel Winder <russel@winder.org.uk>, 2006--
  20. ;; Jim Morris <morris@wolfman.com>, 2009--
  21. ;;; Commentary:
  22. ;;
  23. ;; This mode was initially developed using the Java and Awk modes that are part of CC Mode (the 5.31 source
  24. ;; was used) and C# Mode from Dylan R. E. Moonfire <contact@mfgames.com> (the 0.5.0 source was used). This
  25. ;; code may contain some code fragments from those sources that was cut-and-pasted then edited. All other
  26. ;; code was newly entered by the author. Obviously changes have been made since then.
  27. ;;
  28. ;; NB This derived mode requires CC Mode 5.31 or later for the virtual semicolon code to work.
  29. ;;
  30. ;; There appears to be a problem in CC Mode 5.31 such that csharp-mode and groovy-mode crash XEmacs 21.4 if
  31. ;; the files are byte compiled.
  32. ;;; Bugs:
  33. ;;
  34. ;; Bug tracking is currently (2009-11-26) handled using the Groovy JIRA via the Emacs Mode component.
  35. ;; cf. http://jira.codehaus.org/browse/GROOVY/component/14245
  36. ;;; Versions:
  37. ;;
  38. ;; 0.1.0 - will be the initial release when it is ready :-)
  39. ;;; Notes:
  40. ;;
  41. ;; Need to think about the `*.', `?.', `.&' and `.@' operators. Also, `..' and `..<'. This probably means
  42. ;; changing `c-after-id-concat-ops' but also `c-operators'.
  43. ;;
  44. ;; Need to deal with operator overloading (groovy has this but Java does not) so `c-overloadable-operators'
  45. ;; needs investigating.
  46. ;;
  47. ;; Need to investigate how to support the triple string delimiters for multi-line strings.
  48. ;;
  49. ;; Should we support GString / template markup ( e.g. `<%' and `%>') specially?
  50. ;;
  51. ;; Need to think whether Groovy needs a different c-decl-prefix-re compared to Java. Certainly, Java will
  52. ;; have to change to handle the generics.
  53. ;;
  54. ;; Probably need to change `c-block-prefix-disallowed-chars' as Groovy is not the same as Java.
  55. ;;
  56. ;; Probably need to change `c-type-decl-suffix-key' as Groovy is not the same as Java.
  57. ;;; Changes:
  58. ;;
  59. ;; See the history in the Bazaar branch.
  60. ;;; Code:
  61. (require 'cc-mode)
  62. ;; CSharp mode comment says: These are only required at compile time to get the sources for the language
  63. ;; constants. (The cc-fonts require and the font-lock related constants could additionally be put inside an
  64. ;; (eval-after-load "font-lock" ...) but then some trickery is necessary to get them compiled.)
  65. (eval-when-compile
  66. (let ((load-path
  67. (if (and (boundp 'byte-compile-dest-file)
  68. (stringp byte-compile-dest-file))
  69. (cons (file-name-directory byte-compile-dest-file) load-path)
  70. load-path)))
  71. (load "cc-mode" nil t) ; C# mode has this
  72. (load "cc-fonts" nil t) ; C# mode has this
  73. (load "cc-langs" nil t) ; C# mode has this
  74. (load "cc-bytecomp" nil t) ; Awk mode has this
  75. ))
  76. (eval-and-compile
  77. (c-add-language 'groovy-mode 'java-mode))
  78. ;; Groovy allows `?.' as well as `.' for creating identifiers.
  79. (c-lang-defconst c-identifier-ops
  80. groovy '((left-assoc "." "?.")))
  81. ;; Groovy allows operators such as `*.', `?.', `.&' and `.@'. Java mode puts `*' here to deal with
  82. ;; import statement usage which we need for Groovy.
  83. (c-lang-defconst c-after-id-concat-ops
  84. groovy '( "*" "&" "@" ))
  85. ;;;; Should really do something with `c-string-escaped-newlines' and `c-multiline-string-start-char' to
  86. ;;;; handle the triple delimeter multiline strings.
  87. ;; Because of the above we have to redefine `c_operators' because no other language has `.&' and
  88. ;; `.@' operators.
  89. (c-lang-defconst c-operators
  90. "List describing all operators, along with their precedence and
  91. associativity. The order in the list corresponds to the precedence of
  92. the operators: The operators in each element is a group with the same
  93. precedence, and the group has higher precedence than the groups in all
  94. following elements. The car of each element describes the type of of
  95. the operator group, and the cdr is a list of the operator tokens in
  96. it. The operator group types are:
  97. 'prefix Unary prefix operators.
  98. 'postfix Unary postfix operators.
  99. 'postfix-if-paren
  100. Unary postfix operators if and only if the chars have
  101. parenthesis syntax.
  102. 'left-assoc Binary left associative operators (i.e. a+b+c means (a+b)+c).
  103. 'right-assoc Binary right associative operators (i.e. a=b=c means a=(b=c)).
  104. 'right-assoc-sequence
  105. Right associative operator that constitutes of a
  106. sequence of tokens that separate expressions. All the
  107. tokens in the group are in this case taken as
  108. describing the sequence in one such operator, and the
  109. order between them is therefore significant.
  110. Operators containing a character with paren syntax are taken to match
  111. with a corresponding open/close paren somewhere else. A postfix
  112. operator with close paren syntax is taken to end a postfix expression
  113. started somewhere earlier, rather than start a new one at point. Vice
  114. versa for prefix operators with open paren syntax.
  115. Note that operators like \".\" and \"->\" which in language references
  116. often are described as postfix operators are considered binary here,
  117. since CC Mode treats every identifier as an expression."
  118. groovy `(
  119. ;; Primary.
  120. ,@(c-lang-const c-identifier-ops)
  121. (postfix-if-paren "<" ">") ; Templates.
  122. (prefix "super")
  123. ;; Postfix.
  124. (left-assoc "." "*." "?." ".&" ".@")
  125. (postfix "++" "--" "[" "]" "(" ")" "<:" ":>")
  126. ;; Unary.
  127. (prefix "++" "--" "+" "-" "!" "~" "new" "(" ")")
  128. ;; Multiplicative.
  129. (left-assoc "*" "/" "%")
  130. ;; Additive.
  131. (left-assoc "+" "-")
  132. ;; Shift.
  133. (left-assoc "<<" ">>" ">>>")
  134. ;; Relational.
  135. (left-assoc "<" ">" "<=" ">=" "instanceof" "<=>")
  136. ;; Matching.
  137. (left-assoc "=~" "==~" )
  138. ;; Equality.
  139. (left-assoc "==" "!=" )
  140. ;; Bitwise and.
  141. (left-assoc "&")
  142. ;; Bitwise exclusive or.
  143. (left-assoc "^")
  144. ;; Bitwise or.
  145. (left-assoc "|")
  146. ;; Logical and.
  147. (left-assoc "&&")
  148. ;; Logical or.
  149. (left-assoc "||")
  150. ;; Conditional.
  151. (right-assoc-sequence "?" ":")
  152. ;; Assignment.
  153. (right-assoc ,@(c-lang-const c-assignment-operators))
  154. ;; Exception.
  155. ;(prefix "throw") ; Java mode didn't have this but c++ mode does. Humm...
  156. ;; Sequence.
  157. (left-assoc ",")
  158. ;; Separator for parameter list and code in a closure.
  159. (left-assoc "->")
  160. ))
  161. ;; Groovy can overload operators where Java cannot.
  162. (c-lang-defconst c-overloadable-operators
  163. groovy '("+" "-" "*" "/" "%"
  164. "&" "|" "^" "~" "<<" ">>" ">>>"
  165. "==" "!=" ">" "<" ">=" "<="
  166. "<=>"
  167. "=~" "==~"
  168. "++" "--" "+=" "-=" "*=" "/=" "%="
  169. "&=" "|=" "^=" "~=" "<<=" ">>=" ">>>="
  170. "!" "&&" "||"))
  171. ;; Groovy allows newline to terminate a statement unlike Java and like Awk. We draw on the Awk
  172. ;; Mode `Virtual semicolon material. The idea is to say when an EOL is a `virtual semicolon,
  173. ;; i.e. a statement terminator.
  174. (c-lang-defconst c-stmt-delim-chars
  175. groovy "^;{}\n\r?:")
  176. (c-lang-defconst c-stmt-delim-chars-with-comma
  177. groovy "^;,{}\n\r?:")
  178. ;; Is there a virtual semicolon at POS or point?
  179. ;;
  180. ;; A virtual semicolon is considered to lie just after the last non-syntactic-whitespace
  181. ;; character on a line where the EOL is the statement terminator. A real semicolon never
  182. ;; counts as a virtual one.
  183. (defun groovy-at-vsemi-p ( &optional pos )
  184. (save-excursion
  185. (let ((pos-or-point (if pos (goto-char pos) (point))))
  186. (if (eq pos-or-point (point-min))
  187. nil
  188. (and
  189. (not (char-equal (char-before) ?\;))
  190. (groovy-ws-or-comment-to-eol-p pos-or-point)
  191. (groovy-not-in-statement-p pos-or-point)
  192. (groovy-not-if-or-else-etc-p pos-or-point))))))
  193. (c-lang-defconst c-at-vsemi-p-fn
  194. groovy 'groovy-at-vsemi-p)
  195. ;; see if end of line or comment on rest of line
  196. (defun groovy-ws-or-comment-to-eol-p ( pos )
  197. (save-excursion
  198. (goto-char pos)
  199. (skip-chars-forward " \t")
  200. (or
  201. (char-equal (char-after) ?\n)
  202. (looking-at "/[/*].*"))))
  203. (defun groovy-not-in-statement-p ( pos )
  204. (save-excursion
  205. (goto-char pos)
  206. (if (equal (point) (point-min))
  207. nil
  208. (backward-char 1)
  209. (or
  210. (not (looking-at "[=+*%<{:]"))
  211. (if (char-equal (char-after) ?>)
  212. (if (equal (point) (point-min))
  213. nil
  214. (char-equal (char-before) ?-)))))))
  215. ;; check for case of if(stuff) and nothing else on line
  216. ;; ie
  217. ;; if(x > y)
  218. ;;
  219. ;; if(x < y) do somehting will not match
  220. ;; else blah blah will not match either
  221. (defun groovy-not-if-or-else-etc-p ( pos )
  222. (save-excursion
  223. (goto-char pos)
  224. (back-to-indentation)
  225. (not
  226. (or
  227. (and (looking-at "if") ; make sure nothing else on line
  228. (progn (forward-sexp 2)
  229. (groovy-ws-or-comment-to-eol-p (point))))
  230. (and (looking-at "}?else")
  231. (progn (forward-char)
  232. (forward-sexp 1)
  233. (groovy-ws-or-comment-to-eol-p (point))))))))
  234. (defun groovy-vsemi-status-unknown-p () nil)
  235. (c-lang-defconst c-vsemi-status-unknown-p-fn
  236. groovy 'c-groovy-vsemi-status-unknown-p)
  237. ;; Java does not do this but perhaps it should?
  238. (c-lang-defconst c-type-modifier-kwds
  239. groovy '("volatile" "transient"))
  240. (c-lang-defconst c-typeless-decl-kwds
  241. groovy (append (c-lang-const c-class-decl-kwds)
  242. (c-lang-const c-brace-list-decl-kwds)
  243. '("def")))
  244. ;;;; Should we be tinkering with `c-block-stmt-1-key' or `c-block-stmt-2-key' to deal with closures
  245. ;;;; following what appears to be function calls or even field names?
  246. ;; Groovy allows use of `<%' and `%>' in template expressions.
  247. ;(c-lang-defconst c-other-op-syntax-tokens
  248. ; groovy '( "<%" "%>" ))
  249. ;; Groovy does not allow the full set of Java keywords in the moifier category and, of course, there is the
  250. ;; `def' modifier which Groovy introduces to support dynamic typing. Should `const' be treated
  251. ;; as reserved here as it is in Java?
  252. (c-lang-defconst c-modifier-kwds
  253. groovy '( "abstract" "def" "final" "private" "protected" "public" "static" "synchronized" ))
  254. ;; Java does not define these pseudo-kewords as keywords, why not?
  255. (c-lang-defconst c-constant-kwds
  256. groovy '( "true" "false" "null" ))
  257. ;; Why does Java mode not put `super' into the `c-primary-expr-kwds?
  258. (c-lang-defconst c-primary-expr-kwds
  259. groovy '( "this" "super" ))
  260. ;; Groovy does not allow anonymous classes as Java does.
  261. (c-lang-defconst c-inexpr-class-kwds
  262. groovy nil)
  263. (c-lang-defconst c-inexpr-brace-list-kwds
  264. groovy nil)
  265. ;;;; Should we be changing `c-opt-inexpr-brace-list-key' to deal with closures after function calls and
  266. ;;;; field expressions?
  267. ;; We need to include the "as" for the cast and "in" for for.
  268. (c-lang-defconst c-other-kwds
  269. groovy '( "in" "as" ))
  270. (defconst groovy-font-lock-keywords-1 (c-lang-const c-matchers-1 groovy)
  271. "Minimal highlighting for Groovy mode.
  272. Fontifies nothing except the syntactic fontification of strings and
  273. comments.")
  274. (defconst groovy-font-lock-keywords-2 (c-lang-const c-matchers-2 groovy)
  275. "Fast normal highlighting for Groovy mode.
  276. In addition to `java-font-lock-keywords-1', this adds fontification of
  277. keywords, simple types, declarations that are easy to recognize, the
  278. user defined types on `java-font-lock-extra-types', and the doc
  279. comment styles specified by `c-doc-comment-style'.")
  280. (defconst groovy-font-lock-keywords-3 (c-lang-const c-matchers-3 groovy)
  281. "Accurate normal highlighting for Groovy mode.
  282. Like `java-font-lock-keywords-2' but detects declarations in a more
  283. accurate way that works in most cases for arbitrary types without the
  284. need for `java-font-lock-extra-types'.")
  285. (defvar groovy-font-lock-keywords groovy-font-lock-keywords-3
  286. "Default expressions to highlight in Groovy mode.")
  287. (defun groovy-font-lock-keywords-2 ()
  288. (c-compose-keywords-list groovy-font-lock-keywords-2))
  289. (defun groovy-font-lock-keywords-3 ()
  290. (c-compose-keywords-list groovy-font-lock-keywords-3))
  291. (defun groovy-font-lock-keywords ()
  292. (c-compose-keywords-list groovy-font-lock-keywords))
  293. (defvar groovy-mode-syntax-table nil
  294. "Syntax table used in Groovy mode buffers.")
  295. (or groovy-mode-syntax-table
  296. (setq groovy-mode-syntax-table
  297. (funcall (c-lang-const c-make-mode-syntax-table groovy))))
  298. (defvar groovy-mode-abbrev-table nil
  299. "Abbreviation table used in groovy-mode buffers.")
  300. (c-define-abbrev-table 'groovy-mode-abbrev-table
  301. ;; Keywords that if they occur first on a line might alter the syntactic context, and which
  302. ;; therefore should trigger reindentation when they are completed.
  303. '(("else" "else" c-electric-continued-statement 0)
  304. ("while" "while" c-electric-continued-statement 0)
  305. ("catch" "catch" c-electric-continued-statement 0)
  306. ("finally" "finally" c-electric-continued-statement 0)))
  307. ;; Jim Morris proposed changing to the following definition of groovy-mode-map 2009-11-27, but this change
  308. ;; has not made so as to continue to use the same code structure as still used in the Java mode.
  309. ;(defvar groovy-mode-map (let ((map (c-make-inherited-keymap)))
  310. ; ;; Add bindings which are only useful for Groovy
  311. ; map)
  312. ; "Keymap used in groovy-mode buffers.")
  313. (defvar groovy-mode-map ()
  314. "Keymap used in groovy-mode buffers.")
  315. (if groovy-mode-map
  316. nil
  317. (setq groovy-mode-map (c-make-inherited-keymap))
  318. ;; add bindings which are only useful for Groovy
  319. )
  320. ;(easy-menu-define c-groovy-menu groovy-mode-map "Groovy Mode Commands"
  321. ; (cons "Groovy" (c-lang-const c-mode-menu groovy)))
  322. ;;; Autoload mode trigger
  323. ;;;###autoload
  324. ;(eval-after-load 'groovy-mode
  325. ; (add-to-list 'auto-mode-alist '("\\.groovy" . groovy-mode)))
  326. (add-to-list 'auto-mode-alist '("\\.groovy$" . groovy-mode))
  327. ;; Custom variables
  328. ;;;###autoload
  329. (defcustom groovy-mode-hook nil
  330. "*Hook called by `groovy-mode'."
  331. :type 'hook
  332. :group 'c)
  333. ;;; The following are used to overide cc-mode indentation behavior to match groovy
  334. ;; if we are in a closure that has an argument eg ends with -> (excluding comment) then
  335. ;; change indent else lineup with previous one
  336. (defun groovy-mode-fix-closure-with-argument (langelem)
  337. (save-excursion
  338. (back-to-indentation)
  339. (c-backward-syntactic-ws)
  340. (backward-char 2)
  341. (if (looking-at "->") ; if the line has a -> in it
  342. (vector (+ (current-indentation) c-basic-offset)) ; then indent from base
  343. 0)))
  344. ;; A helper function from: http://mihai.bazon.net/projects/emacs-javascript-mode/javascript.el
  345. ;; Originally named js-lineup-arglist, renamed to groovy-lineup-arglist
  346. (defun groovy-lineup-arglist (langelem)
  347. ;; the "DWIM" in c-mode doesn't Do What I Mean.
  348. ;; see doc of c-lineup-arglist for why I redefined this
  349. (save-excursion
  350. (let ((indent-pos (point)))
  351. ;; Normal case. Indent to the token after the arglist open paren.
  352. (goto-char (c-langelem-2nd-pos c-syntactic-element))
  353. (if (and c-special-brace-lists
  354. (c-looking-at-special-brace-list))
  355. ;; Skip a special brace list opener like "({".
  356. (progn (c-forward-token-2)
  357. (forward-char))
  358. (forward-char))
  359. (let ((arglist-content-start (point)))
  360. (c-forward-syntactic-ws)
  361. (when (< (point) indent-pos)
  362. (goto-char arglist-content-start)
  363. (skip-chars-forward " \t"))
  364. (vector (current-column))))))
  365. (defun is-groovy-mode ()
  366. "return t if we are in groovy mode else nil"
  367. (eq major-mode 'groovy-mode))
  368. ;; use defadvice to override the syntactic type if we have a
  369. ;; statement-cont, see if previous line has a virtual semicolon and if
  370. ;; so make it statement.
  371. (defadvice c-guess-basic-syntax (after c-guess-basic-syntax-groovy activate)
  372. (when (is-groovy-mode)
  373. (save-excursion
  374. (let* ((ankpos (progn
  375. (beginning-of-line)
  376. (c-backward-syntactic-ws)
  377. (beginning-of-line)
  378. (c-forward-syntactic-ws)
  379. (point))) ; position to previous non-blank line
  380. (curelem (c-langelem-sym (car ad-return-value))))
  381. (end-of-line)
  382. (cond
  383. ((eq 'statement-cont curelem)
  384. (when (groovy-at-vsemi-p) ; if there is a virtual semi there then make it a statement
  385. (setq ad-return-value `((statement ,ankpos)))))
  386. ((eq 'topmost-intro-cont curelem)
  387. (when (groovy-at-vsemi-p) ; if there is a virtual semi there then make it a top-most-intro
  388. (setq ad-return-value `((topmost-intro ,ankpos)))))
  389. )))))
  390. ;; This disables bracelists, as most of the time in groovy they are closures
  391. ;; We need to check we are currently in groovy mode
  392. (defadvice c-inside-bracelist-p (around groovy-c-inside-bracelist-p activate)
  393. (if (not (is-groovy-mode))
  394. ad-do-it
  395. (setq ad-return-value nil)))
  396. ;; based on java-function-regexp
  397. ;; Complicated regexp to match method declarations in interfaces or classes
  398. ;; A nasty test case is:
  399. ;; else if(foo instanceof bar) {
  400. ;; which will get mistaken for a function as Groovy does not require types on arguments
  401. ;; so we need to check for empty parens or comma separated list, or type args
  402. (defvar groovy-function-regexp
  403. (concat
  404. "^[ \t]*" ; leading white space
  405. "\\(public\\|private\\|protected\\|" ; some of these 8 keywords
  406. "abstract\\|final\\|static\\|"
  407. "synchronized\\|native|def"
  408. "\\|[ \t\n\r]\\)*" ; or whitespace
  409. "[a-zA-Z0-9_$]*" ; optional return type
  410. "[ \t\n\r]*[[]?[]]?" ; (could be array)
  411. "[ \t\n\r]+" ; whitespace
  412. "\\([a-zA-Z0-9_$]+\\)" ; the name we want
  413. "[ \t\n\r]*" ; optional whitespace
  414. "(" ; open the param list
  415. "[ \t]*" ; optional whitespace
  416. "\\("
  417. "[ \t\n\r]*\\|" ; empty parens or
  418. "[a-zA-Z0-9_$]+\\|" ; single param or
  419. ".+?,.+?\\|" ; multi comma separated params or
  420. "[a-zA-Z0-9_$]+" ; a type
  421. "[ \t\n\r]*[[]?[]]?" ; optional array
  422. "[ \t\n\r]+[a-zA-Z0-9_$]+" ; and param
  423. "\\)"
  424. "[ \t\n\r]*" ; optional whitespace
  425. ")" ; end the param list
  426. "[ \t\n\r]*" ; whitespace
  427. ; "\\(throws\\([, \t\n\r]\\|[a-zA-Z0-9_$]\\)+\\)?{"
  428. "\\(throws[^{;]+\\)?" ; optional exceptions
  429. "[;{]" ; ending ';' (interfaces) or '{'
  430. ; TODO groovy interfaces don't need to end in ;
  431. )
  432. "Matches method names in groovy code, select match 2")
  433. (defvar groovy-class-regexp
  434. "^[ \t\n\r]*\\(final\\|abstract\\|public\\|[ \t\n\r]\\)*class[ \t\n\r]+\\([a-zA-Z0-9_$]+\\)[^;{]*{"
  435. "Matches class names in groovy code, select match 2")
  436. (defvar groovy-interface-regexp
  437. "^[ \t\n\r]*\\(abstract\\|public\\|[ \t\n\r]\\)*interface[ \t\n\r]+\\([a-zA-Z0-9_$]+\\)[^;]*;"
  438. "Matches interface names in groovy code, select match 2")
  439. (defvar groovy-imenu-regexp
  440. (list (list nil groovy-function-regexp 2)
  441. (list ".CLASSES." groovy-class-regexp 2)
  442. (list ".INTERFACES." groovy-interface-regexp 2)
  443. (list ".CLOSURES." "def[ \t]+\\([a-zA-Z_][a-zA-Z0-9_]*\\)[ \t]*=[ \t]*{" 1))
  444. "Imenu expression for Groovy")
  445. ;; Setup imenu to extract functions, classes, interfaces and closures assigned to variables
  446. (defvar cc-imenu-groovy-generic-expression
  447. groovy-imenu-regexp
  448. "Imenu generic expression for Groovy mode. See `imenu-generic-expression'.")
  449. ;;; The entry point into the mode
  450. ;;;###autoload
  451. (defun groovy-mode ()
  452. "Major mode for editing Groovy code.
  453. The hook `c-mode-common-hook' is run with no args at mode
  454. initialization, then `groovy-mode-hook'.
  455. Key bindings:
  456. \\{groovy-mode-map}"
  457. (interactive)
  458. (kill-all-local-variables)
  459. (c-initialize-cc-mode t)
  460. (set-syntax-table groovy-mode-syntax-table)
  461. (setq major-mode 'groovy-mode
  462. mode-name "Groovy"
  463. local-abbrev-table groovy-mode-abbrev-table
  464. abbrev-mode t)
  465. (use-local-map groovy-mode-map)
  466. (c-init-language-vars groovy-mode)
  467. (c-common-init 'groovy-mode)
  468. ;;(easy-menu-add groovy-menu)
  469. (cc-imenu-init cc-imenu-groovy-generic-expression)
  470. (c-run-mode-hooks 'c-mode-common-hook 'groovy-mode-hook)
  471. ;; quick fix for misalignment of statements with =
  472. (setq c-label-minimum-indentation 0)
  473. ;; fix for indentation after a closure param list
  474. (c-set-offset 'statement 'groovy-mode-fix-closure-with-argument)
  475. ;; get arglists (in groovy lists or maps) to align properly
  476. (c-set-offset 'arglist-close '(c-lineup-close-paren))
  477. (c-set-offset 'arglist-cont 0)
  478. (c-set-offset 'arglist-cont-nonempty '(groovy-lineup-arglist))
  479. (c-set-offset 'arglist-intro '+)
  480. (c-update-modeline))
  481. (provide 'groovy-mode)
  482. ;;; groovy-mode.el ends here