2019-02-21 16:08:27 -05:00
|
|
|
;;; tools/lsp/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
2019-08-15 14:59:53 -04:00
|
|
|
(defvar +lsp-company-backend 'company-lsp
|
|
|
|
"What backend to prepend to `company-backends' when `lsp-mode' is active.
|
|
|
|
|
|
|
|
This can be a single company backend or a list thereof. It can be anything
|
|
|
|
`company-backends' will accept.")
|
|
|
|
|
|
|
|
|
2019-02-26 22:57:34 -05:00
|
|
|
(setq lsp-session-file (concat doom-etc-dir "lsp-session")
|
|
|
|
lsp-auto-guess-root t
|
2019-05-17 02:05:33 -04:00
|
|
|
lsp-keep-workspace-alive nil
|
2019-07-23 16:51:16 +02:00
|
|
|
lsp-groovy-server-install-dir (concat doom-etc-dir "lsp-groovy/")
|
|
|
|
lsp-intelephense-storage-path (concat doom-cache-dir "lsp-intelephense/"))
|
2019-02-24 13:49:12 -05:00
|
|
|
|
2019-07-21 23:31:42 +02:00
|
|
|
|
2019-04-16 20:21:13 -04:00
|
|
|
(after! lsp-mode
|
2019-05-03 20:03:32 -04:00
|
|
|
(set-lookup-handlers! 'lsp-mode :async t
|
2019-06-29 00:33:07 +02:00
|
|
|
:documentation 'lsp-describe-thing-at-point
|
|
|
|
:definition 'lsp-find-definition
|
|
|
|
:references 'lsp-find-references)
|
2019-04-16 20:21:13 -04:00
|
|
|
|
2019-06-29 00:28:13 +02:00
|
|
|
;; The original `lsp' initializes too much, too quickly. Things like flycheck,
|
|
|
|
;; company, and yasnippet. Doom's modules already handle these just fine, so
|
|
|
|
;; leave it to us.
|
|
|
|
(advice-add #'lsp :override #'lsp!)
|
|
|
|
|
2019-04-16 20:21:13 -04:00
|
|
|
;; Don't prompt to restart LSP servers while quitting Emacs
|
|
|
|
(add-hook! 'kill-emacs-hook (setq lsp-restart 'ignore)))
|
2019-02-28 05:01:40 -05:00
|
|
|
|
2019-02-24 13:49:12 -05:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! lsp-ui
|
2019-02-21 16:08:27 -05:00
|
|
|
:hook (lsp-mode . lsp-ui-mode)
|
2019-06-29 00:28:13 +02:00
|
|
|
:init
|
2019-07-26 19:57:13 +02:00
|
|
|
(add-hook! 'lsp-ui-mode-hook
|
2019-07-18 15:27:20 +02:00
|
|
|
(defun +lsp-init-ui-flycheck-or-flymake-h ()
|
|
|
|
"Sets up flymake-mode or flycheck-mode, depending on `lsp-prefer-flymake'."
|
|
|
|
(unless (eq :none lsp-prefer-flymake)
|
|
|
|
(if (and (not (version< emacs-version "26.1"))
|
|
|
|
lsp-prefer-flymake)
|
|
|
|
(lsp--flymake-setup))
|
|
|
|
(require 'lsp-ui-flycheck)
|
|
|
|
(lsp-ui-flycheck-enable t))))
|
2019-02-21 16:08:27 -05:00
|
|
|
:config
|
|
|
|
(setq lsp-prefer-flymake nil
|
|
|
|
lsp-ui-doc-max-height 8
|
|
|
|
lsp-ui-doc-max-width 35
|
2019-05-17 02:05:33 -04:00
|
|
|
lsp-ui-sideline-ignore-duplicate t
|
2019-07-22 00:43:50 +02:00
|
|
|
;; lsp-ui-doc is redundant with and more invasive than
|
2019-05-17 02:05:33 -04:00
|
|
|
;; `+lookup/documentation'
|
2019-07-22 00:43:50 +02:00
|
|
|
lsp-ui-doc-enable nil
|
|
|
|
;; Don't show symbol definitions in the sideline. They are pretty noisy,
|
|
|
|
;; and there is a bug preventing Flycheck errors from being shown (the
|
|
|
|
;; errors flash briefly and then disappear).
|
|
|
|
lsp-ui-sideline-show-hover nil
|
|
|
|
;; `lsp-ui' offers its own eldoc integration, which is redundant with
|
|
|
|
;; lsp-mode's.
|
|
|
|
lsp-eldoc-enable-hover nil)
|
2019-04-16 20:21:13 -04:00
|
|
|
|
2019-05-03 20:03:32 -04:00
|
|
|
(set-lookup-handlers! 'lsp-ui-mode :async t
|
|
|
|
:definition 'lsp-ui-peek-find-definitions
|
|
|
|
:references 'lsp-ui-peek-find-references))
|
2019-02-21 16:08:27 -05:00
|
|
|
|
2019-02-24 13:49:12 -05:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! company-lsp
|
2019-02-21 16:08:27 -05:00
|
|
|
:when (featurep! :completion company)
|
2019-07-05 23:42:06 +02:00
|
|
|
:defer t
|
|
|
|
:init
|
2019-06-29 00:28:13 +02:00
|
|
|
;; Make sure that `company-capf' is disabled since it is incompatible with
|
|
|
|
;; `company-lsp' (see lsp-mode#884)
|
2019-07-26 19:57:13 +02:00
|
|
|
(add-hook! 'lsp-mode-hook
|
2019-07-18 15:27:20 +02:00
|
|
|
(defun +lsp-init-company-h ()
|
|
|
|
(if (not (bound-and-true-p company-mode))
|
|
|
|
(add-hook 'company-mode-hook #'+lsp-init-company-h t t)
|
|
|
|
(setq-local company-backends
|
2019-08-15 14:59:53 -04:00
|
|
|
(cons +lsp-company-backend
|
2019-07-05 23:42:06 +02:00
|
|
|
(remq 'company-capf company-backends)))
|
2019-07-27 04:28:22 +10:00
|
|
|
(remove-hook 'company-mode-hook #'+lsp-init-company-h t))))
|
|
|
|
:config
|
|
|
|
(setq company-lsp-cache-candidates 'auto)) ;; cache candidates for better performance
|