2017-08-28 17:49:09 +00:00
#+TITLE : Groovy layer
2019-05-07 08:53:56 +00:00
#+TAGS : general|layer|multi-paradigm|programming
2019-05-05 17:26:40 +00:00
2017-08-28 17:49:09 +00:00
[[file:img/groovy.png ]]
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-08-28 17:49:09 +00:00
- [[#description ][Description ]]
2017-08-28 21:58:10 +00:00
- [[#features ][Features: ]]
2017-08-28 17:49:09 +00:00
- [[#install ][Install ]]
2020-07-05 21:58:55 +00:00
- [[#configuration ][Configuration ]]
- [[#choosing-a-backend ][Choosing a backend ]]
2020-07-12 08:21:50 +00:00
- [[#company-groovy ][Company-groovy ]]
- [[#lsp ][LSP ]]
2017-08-28 17:49:09 +00:00
- [[#key-bindings ][Key bindings ]]
2018-03-10 15:40:57 +00:00
- [[#imports ][Imports ]]
2017-08-28 17:49:09 +00:00
- [[#repl ][REPL ]]
* Description
2017-11-11 03:42:22 +00:00
This layer supports [[http://www.groovy-lang.org/ ][Groovy ]] development in Spacemacs.
2017-08-28 17:49:09 +00:00
2017-08-28 21:58:10 +00:00
** Features:
2020-07-05 21:58:55 +00:00
- Auto-completion
- Syntax-checking
2017-08-28 21:58:10 +00:00
- Auto-generate imports with [[https://github.com/mbezjak/emacs-groovy-imports ][groovy-imports ]]
- Groovy REPL integration
2020-07-05 21:58:55 +00:00
- Syntax highlighting
2017-08-28 17:49:09 +00:00
* Install
To use this configuration layer, add it to your =~/.spacemacs= . You will need to
add =groovy= to the existing =dotspacemacs-configuration-layers= list in this
file.
2020-07-05 21:58:55 +00:00
* Configuration
All layer configurations can be done by setting layer variables in your dotfile.
No custom user config lines are necessary
** Choosing a backend
This layer provides two alternative backends to choose from.
*** Company-groovy
This is the default choice if nothing is set and no lsp layer
is loaded in your dotfile. This mode only provides very
limited IDE capabilities. Used best if only small scripts
are edited. To set explicitly set the following in your
dotfile:
#+BEGIN_SRC emacs-lisp
(groovy :variables groovy-backend 'company-groovy)
#+END_SRC
*** LSP
For proper IDE support this backend should be used. It is
based on an external server which will be started automatically
2020-07-12 08:21:50 +00:00
by emacs, once a groovy file is opened. The key bindings are
2020-07-05 21:58:55 +00:00
the same for all lsp modes so if you are already familiar with
one you should be able to work the same in all modes.
To set explicitly do the following in your dotfile:
#+BEGIN_SRC emacs-lisp
(groovy :variables
groovy-backend 'lsp
2021-03-05 16:04:18 +00:00
groovy-lsp-jar-path "path/to/groovy/lsp/jar-all.jar")
2020-07-05 21:58:55 +00:00
#+END_SRC
For this to work you will also need to obtain
the latest version of the lsp server from [[https://github.com/prominic/groovy-language-server ][here ]].
The path to the server jar must be given in the layer
2020-07-11 23:42:44 +00:00
variable =groovy-lsp-jar-path= .
2020-07-05 21:58:55 +00:00
2020-07-12 08:21:50 +00:00
NOTE: Key bindings for LSP are defined in the
2020-07-05 21:58:55 +00:00
LSP layer. Also it is advisable to have a look
at the autocomplete layer for an optimal
intellisense config for LSP.
2021-03-13 23:57:56 +00:00
NOTE: The build on [[https://github.com/prominic/groovy-language-server ]] will generate two jar files. You will need the ~groovy-language-server-all.jar~ as the ~groovy-lsp-jar-path~ .
2021-03-05 16:04:18 +00:00
2017-08-28 17:49:09 +00:00
* Key bindings
2018-03-10 15:40:57 +00:00
** Imports
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2018-03-10 15:40:57 +00:00
|-------------+------------------------------------|
| ~SPC m r i~ | Add import for symbol around point |
2017-08-28 17:49:09 +00:00
** REPL
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2017-08-28 17:49:09 +00:00
|-------------+-------------------------------------------------------|
| ~SPC m s b~ | send buffer to REPL and stay in buffer |
| ~SPC m s B~ | send buffer and and switch to REPL buffer |
| ~SPC m s e~ | send sexp in front of the cursor to the REPL |
| ~SPC m s f~ | send function to REPL and stay in buffer |
| ~SPC m s F~ | send function to REPL and switch to REPL buffer |
| ~SPC m s r~ | send current region to REPL and stay in buffer |
| ~SPC m s R~ | send current region to REPL and switch to REPL buffer |