e3b6464649
* [core][keybinng] improve minor mode binding This commit added add a new function defun spacemacs/declare-prefix-for-minor-mode and improved spacemacs/set-leader-keys-for-minor-mode. `which-key` package recently introduced a new api which-key-add-keymap-based-replacements which improves perfomance and allows prefix and namings to be stored directly in keymap. This is a great improvement. With this new api we now make change to spacemacs/declare-prefix-for-minor-mode to manage prefix also. For example: (spacemacs/set-leader-keys-for-minor-mode 'lsp-mode "=" "format" "=b" #'lsp-format-buffer) Before we had to use another api to bind prefix spacemacs/declare-prefix-for-mode which only works on major-mode. As lsp-mode is a minor mode this api causes a lot of problems to which-key performance. An example is https://github.com/syl20bnr/spacemacs/issues/12455 which led to my hack in https://github.com/syl20bnr/spacemacs/pull/12474. The improved spacemacs/set-leader-keys-for-minor-mode will take care of both prefix and key naming for the minor mode. This will allows us to have a better set up for dynamic minor modes such as lsp-mode, tide-mode etc. Also another api is created to make prefix for minor mode: spacemacs/declare-prefix-for-minor-mode. Usage: (spacemacs/declare-prefix-for-minor-mode 'tide-mode "E" "errors")" * [tide] improve prefix * [lsp] improve prefix
70 lines
1.9 KiB
EmacsLisp
70 lines
1.9 KiB
EmacsLisp
;;; packages.el --- Language Server Protocol Layer packages file for Spacemacs
|
|
;;
|
|
;; Copyright (c) 2012-2020 Sylvain Benner & Contributors
|
|
;;
|
|
;; Author: Fangrui Song <i@maskray.me>
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
;;
|
|
;; This file is not part of GNU Emacs.
|
|
;;
|
|
;;; License: GPLv3
|
|
|
|
(defconst lsp-packages
|
|
'(
|
|
lsp-mode
|
|
lsp-ui
|
|
(helm-lsp :requires helm)
|
|
(lsp-ivy :requires ivy)
|
|
(lsp-treemacs :requires treemacs)
|
|
(lsp-origami :requires lsp-mode)
|
|
popwin))
|
|
|
|
(defun lsp/init-lsp-mode ()
|
|
(use-package lsp-mode
|
|
:defer t
|
|
:config
|
|
(progn
|
|
(spacemacs/lsp-bind-keys)
|
|
(setq lsp-prefer-capf t)
|
|
(add-hook 'lsp-after-open-hook (lambda ()
|
|
"Setup xref jump handler"
|
|
(spacemacs//setup-lsp-jump-handler))))))
|
|
|
|
(defun lsp/init-lsp-ui ()
|
|
(use-package lsp-ui
|
|
:defer t
|
|
:config
|
|
(progn
|
|
(if lsp-remap-xref-keybindings
|
|
(progn (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
|
|
(define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)))
|
|
|
|
(spacemacs/lsp-define-key
|
|
lsp-ui-peek-mode-map
|
|
"h" #'lsp-ui-peek--select-prev-file
|
|
"j" #'lsp-ui-peek--select-next
|
|
"k" #'lsp-ui-peek--select-prev
|
|
"l" #'lsp-ui-peek--select-next-file
|
|
)
|
|
)))
|
|
|
|
(defun lsp/init-helm-lsp ()
|
|
(use-package helm-lsp :defer t))
|
|
|
|
(defun lsp/init-lsp-ivy ()
|
|
(use-package lsp-ivy :defer t))
|
|
|
|
(defun lsp/init-lsp-treemacs ()
|
|
(use-package lsp-treemacs :defer t))
|
|
|
|
(defun lsp/init-lsp-origami ()
|
|
(use-package lsp-origami
|
|
:defer t
|
|
:init
|
|
(add-hook 'lsp-after-open-hook #'lsp-origami-try-enable)))
|
|
|
|
(defun lsp/pre-init-popwin ()
|
|
(spacemacs|use-package-add-hook popwin
|
|
:post-config
|
|
(push '("*lsp-help*" :dedicated t :position bottom :stick t :noselect t :height 0.4)
|
|
popwin:special-display-config)))
|