== Configuration

Once `lsp-mode` is installed, a minimal configuration would consist of
xref:lang-support[installing] the language server(s) for your preferred
languages, and enabling `lsp-mode` for the respective major-mode with:
[source,elisp]
----
(require 'lsp-mode)
(add-hook '<major-mode-hook> #'lsp)
;; Major mode hooks tend to be named as xxx-mode-hook (python-mode-hook,
;; c++-mode-hook, etc)
----

If <<lsp-auto-configure, `lsp-auto-configure`>> and
<<lsp-auto-require-clients,`lsp-auto-require-clients`>> are non-nil, then
`lsp-mode` loads all the clients that have been bundled with the package.
Otherwise, or if you're using an external package for LSP support, you might
need to `require` it as well. For instance, if you want to use
https://github.com/emacs-lsp/lsp-java/[`lsp-java`]:
[source,elisp]
----
(require 'lsp-mode)
(require 'lsp-java)
(add-hook 'java-mode-hook 'lsp)
----

Alternatively, `lsp-mode` can be hooked to `prog-mode-hook`, which
will cause it to try initialising LSP support for all supported programming
languages.

=== use-package

A minimal `use-package` configuration for `lsp-mode` might look like this:
[source,elisp]
----
(use-package lsp-mode
  :commands lsp
  :hook (XXX-mode . lsp)
  :init
  (setq ...))
----

=== Spacemacs

`lsp-mode` is included in Spacemacs' `develop` branch. Documentation for the
`lsp` layer is available
http://develop.spacemacs.org/layers/+tools/lsp/README.html[here].

=== Doom Emacs

`lsp-mode` is included in the `lsp` module. Documentation for it is available
https://github.com/hlissner/doom-emacs/blob/develop/modules/tools/lsp/README.org[here].

=== Deferred startup
To defer `lsp` startup (server initialization, `didOpen` notifications, etc) until the
buffer is visible, you can use `lsp-deferred` instead of `lsp`:
[source,elisp]
----
(add-hook 'java-mode-hook 'lsp-deferred)
----

=== Docker
To run `lsp-mode` in a docker container, refer to the https://github.com/emacs-lsp/lsp-docker/[lsp-docker] README.

include::lsp-mode-vars.adoc[]
