Files
dot-emacs/lisp/init-lsp.el

120 lines
3.7 KiB
EmacsLisp
Raw Normal View History

2023-05-16 11:18:38 +02:00
;; LSP mode
(use-package lsp-mode
:config
(lsp-register-custom-settings
'(("gopls.completeUnimported" t t)
("gopls.staticcheck" t t)
("pyls.plugins.pyls_mypy.enabled" t t)
("pyls.plugins.pyls_mypy.live_mode" nil t)
("pyls.plugins.pyls_black.enabled" t t)
("pyls.plugins.pyls_isort.enabled" t t)))
2023-05-16 11:18:38 +02:00
;; disable infantile nonsense
2026-07-28 23:46:59 +02:00
(setq lsp-headerline-breadcrumb-enable t
2023-05-19 19:02:45 +02:00
lsp-modeline-code-actions-enable nil)
2023-05-16 11:18:38 +02:00
2026-07-28 23:46:59 +02:00
;; (lsp-enable-which-key-integration t)
:bind
2026-07-28 23:46:59 +02:00
("C-c n". #'lsp-rename)
;; I am using lsp-ui for this, see below
;; ("C-c r" . #'lsp-find-references) ; default: C-c C-l g r
;; ("C-c d" . #'lsp-find-definition) ; default: C-c C-l g g
;; ;; same as above, but directly within prefix, not 'g neede
;; ("C-c C-l r" . #'lsp-find-references) ; default: C-c C-l g r
;; ("C-c C-l d" . #'lsp-find-definition) ; default: C-c C-l g g
2023-05-16 11:18:38 +02:00
:init
;; I'm not using any of th lsp commands, but better define a prefix
;; than being unable to reach it
2023-08-17 19:12:54 +02:00
;; FIXME: add at least lsp-find-definition
2026-07-28 23:46:59 +02:00
(setq lsp-keymap-prefix "C-c C-l"
lsp-log-io nil
lsp-enable-indentation t
lsp-enable-imenu t
lsp-file-watch-threshold 500
lsp-prefer-flymake nil)
2023-05-16 11:18:38 +02:00
:commands lsp)
2026-07-28 23:46:59 +02:00
;; for lsp code lenses etc
;; https://emacs-lsp.github.io/lsp-ui/
;; FIXME: ⛔ Error (use-package): Failed to install lsp-ui: https://melpa.org/packages/lsp-ui-20250804.2109.tar: Not found
;; manually installed using package-install
(use-package lsp-ui
:ensure t
:after (lsp-mode)
:commands lsp-ui-doc-hide
:bind (:map lsp-ui-mode-map
("C-c d" . #'lsp-ui-peek-find-definitions)
("C-c r" . #'lsp-ui-peek-find-references)
([remap xref-find-definitions] . lsp-ui-peek-find-definitions)
([remap xref-find-references] . lsp-ui-peek-find-references)
;;; ("C-c u" . lsp-ui-imenu) ;; using treemacs for this
("C-c D" . tvd-lsp-doc-toggle))
:init
2026-07-30 00:22:28 +02:00
(setq lsp-ui-doc-enable t ;; enable on the fly with "C-c D"
2026-07-28 23:46:59 +02:00
lsp-ui-doc-use-webkit nil
lsp-ui-doc-header t
lsp-ui-doc-delay 0.2
lsp-ui-doc-position 'top
lsp-ui-doc-side 'right
lsp-ui-doc-include-signature t
lsp-ui-doc-alignment 'at-point
lsp-ui-doc-use-childframe t
lsp-ui-doc-border (face-foreground 'default)
;; C-c r
lsp-ui-peek-enable t
lsp-ui-peek-show-directory t
lsp-ui-peek-peek-height 40
;; FIXME: maybe this is too much, check at work
lsp-ui-sideline-enable t
lsp-ui-sideline-update-mode 'point
lsp-ui-sideline-show-code-actions nil
lsp-ui-sideline-show-hover t
lsp-ui-sideline-delay 2
lsp-ui-sideline-show-diagnostics nil
lsp-ui-sideline-diagnostic-max-lines t
lsp-ui-sideline-ignore-duplicate t)
:config
(add-to-list 'lsp-ui-doc-frame-parameters '(right-fringe . 8))
(defun tvd-lsp-doc-toggle()
"Toggle lsp-ui-doc, takes effect only on buffer start.
So in order to change in a buffer, reload the buffer after
the toggle with shift-F5."
(interactive)
(setq lsp-ui-doc-enable (not lsp-ui-doc-enable))
(tvd-buffer-reload))
;; `C-g'to close doc
(advice-add #'keyboard-quit :before #'lsp-ui-doc-hide))
;; better recursive refs, symbols, etc
;; see also https://github.com/Alexander-Miller/treemacs
(use-package lsp-treemacs
:after lsp
:bind
("C-c u" . #'lsp-treemacs-symbols)
("C-c C-l c" . #'lsp-treemacs-call-hierarchy))
(use-package treemacs
:bind
("C-c t" . #'treemacs)
2023-05-16 11:18:38 +02:00
2026-07-28 23:46:59 +02:00
:init
(setq
treemacs-project-follow-mode t
treemacs-extra-wide-toggle t
treemacs-follow-mode t))
2023-05-16 11:18:38 +02:00
(provide 'init-lsp)
;;; init-lsp.el ends here