This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+lang/kotlin/README.org

79 lines
2.5 KiB
Org Mode
Raw Normal View History

2017-08-13 12:19:51 +00:00
#+TITLE: kotlin layer
#+TAGS: general|layer|multi-paradigm|programming
2019-05-05 17:26:40 +00:00
2017-08-13 12:19:51 +00:00
[[file:img/kotlin.png]]
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-08-13 12:19:51 +00:00
- [[#description][Description]]
- [[#features][Features:]]
- [[#install][Install]]
- [[#layer][Layer]]
- [[#ktlint][Ktlint]]
2020-07-11 23:04:02 +00:00
- [[#configuration][Configuration]]
- [[#choosing-a-backend][Choosing a backend]]
- [[#company-kotlin][Company-kotlin]]
- [[#lsp][LSP]]
2017-08-13 12:19:51 +00:00
* Description
2020-07-11 23:04:02 +00:00
This layer adds support for [[http://kotlinlang.org/][Kotlin]] to Spacemacs.
2017-08-13 12:19:51 +00:00
** Features:
2020-07-11 23:04:02 +00:00
- Syntax highlighting
- Auto-completion
- Syntax-checking with [[https://github.com/shyiko/ktlint][ktlint]] and [[https://github.com/whirm/flycheck-kotlin][flycheck-kotlin]]
- Navigation with =ggtags=
2017-08-13 12:19:51 +00:00
* Install
** Layer
2018-09-19 03:54:47 +00:00
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
add =kotlin= to the existing =dotspacemacs-configuration-layers= list in this
file.
2017-12-18 00:10:06 +00:00
2017-08-13 12:19:51 +00:00
** Ktlint
2018-09-19 03:54:47 +00:00
You must install [[https://github.com/shyiko/ktlint][ktlint]] and make sure that the =ktlint= binary is on Emacs
=exec-path=
2020-07-11 23:04:02 +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-kotlin
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 applications
are edited. To set explicitly set the following in your
dotfile:
#+BEGIN_SRC emacs-lisp
(kotlin :variables kotlin-backend 'company-kotlin)
#+END_SRC
*** LSP
For proper IDE support this backend should be used. It is
based on an external server which will be started automatically
by emacs, once a kotlin file is opened. The key bindings are
2020-07-11 23:04:02 +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
(kotlin :variables
kotlin-backend 'lsp
kotlin-lsp-jar-path "path/to/kotlin/installdir/install/server/bin/kotlin-language-server")
#+END_SRC
For this to work you will also need to obtain
the latest version of the lsp server from [[https://github.com/fwcd/kotlin-language-server][here]].
The path to the server jar must be given in the layer
variable =kotlin-lsp-jar-path=.
NOTE: Key bindings for LSP are defined in the
2020-07-11 23:04:02 +00:00
LSP layer. Also it is advisable to have a look
at the autocomplete layer for an optimal
intellisense config for LSP.