2016-05-16 01:55:57 +00:00
|
|
|
;;; packages.el --- Spacemacs Completion Layer packages File
|
|
|
|
;;
|
2018-01-04 07:00:25 +00:00
|
|
|
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
2016-05-16 01:55:57 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
|
|
(setq spacemacs-completion-packages
|
|
|
|
'(
|
2016-05-16 01:58:41 +00:00
|
|
|
(default-helm-config :location built-in)
|
2016-05-16 02:00:44 +00:00
|
|
|
(default-ivy-config :location built-in)
|
2018-06-15 01:09:40 +00:00
|
|
|
flx-ido
|
2016-05-16 01:55:57 +00:00
|
|
|
(ido :location built-in)
|
2017-01-24 04:40:26 +00:00
|
|
|
(ido-vertical-mode :location built-in)
|
2016-05-16 01:55:57 +00:00
|
|
|
))
|
|
|
|
|
2016-05-16 01:58:41 +00:00
|
|
|
(defun spacemacs-completion/init-default-helm-config ()
|
2016-05-18 07:55:16 +00:00
|
|
|
(setq helm-prevent-escaping-from-minibuffer t
|
|
|
|
helm-bookmark-show-location t
|
|
|
|
helm-display-header-line nil
|
2017-12-11 10:48:31 +00:00
|
|
|
helm-split-window-inside-p t
|
2016-05-18 07:55:16 +00:00
|
|
|
helm-always-two-windows t
|
|
|
|
helm-echo-input-in-header-line t
|
|
|
|
helm-imenu-execute-action-at-once-if-one nil
|
|
|
|
helm-org-format-outline-path t
|
|
|
|
helm-display-function 'spacemacs//display-helm-window)
|
2016-05-16 01:58:41 +00:00
|
|
|
(with-eval-after-load 'helm
|
|
|
|
(spacemacs|hide-lighter helm-mode)
|
2017-10-08 14:26:10 +00:00
|
|
|
(when (and helm-enable-auto-resize
|
|
|
|
(or (eq helm-position 'bottom)
|
|
|
|
(eq helm-position 'top)))
|
2016-05-16 01:58:41 +00:00
|
|
|
(setq helm-autoresize-min-height 10)
|
|
|
|
(helm-autoresize-mode 1))
|
|
|
|
;; setup hooks
|
|
|
|
(add-hook 'helm-minibuffer-set-up-hook
|
|
|
|
'spacemacs//helm-hide-minibuffer-maybe)
|
|
|
|
(add-hook 'helm-before-initialize-hook 'helm-toggle-header-line)
|
|
|
|
(spacemacs/add-to-hook 'helm-after-initialize-hook
|
2016-08-02 16:18:28 +00:00
|
|
|
'(spacemacs//prevent-minibuffer-escape
|
2016-05-16 01:58:41 +00:00
|
|
|
spacemacs//hide-cursor-in-helm-buffer))
|
2016-08-02 16:18:28 +00:00
|
|
|
(add-hook 'helm-cleanup-hook #'spacemacs//unprevent-minibuffer-escape)
|
2016-05-16 01:58:41 +00:00
|
|
|
(add-hook 'helm-find-files-before-init-hook
|
|
|
|
'spacemacs//set-dotted-directory)
|
|
|
|
(add-hook 'spacemacs-editing-style-hook 'spacemacs//helm-hjkl-navigation)
|
|
|
|
;; setup advices
|
|
|
|
;; fuzzy matching for all the sourcess
|
2017-10-08 14:26:10 +00:00
|
|
|
(unless (eq helm-use-fuzzy 'source)
|
2016-07-30 21:43:21 +00:00
|
|
|
(advice-add 'helm-make-source :around #'spacemacs//helm-make-source))
|
|
|
|
|
2016-05-16 01:58:41 +00:00
|
|
|
(defadvice spacemacs/post-theme-init
|
|
|
|
(after spacemacs/helm-header-line-adv activate)
|
|
|
|
"Update defaults for `helm' header line whenever a new theme is loaded"
|
|
|
|
;; TODO factorize face definition with those defined in config.el
|
|
|
|
(setq helm-source-header-default-foreground
|
|
|
|
(face-attribute 'helm-source-header :foreground)
|
|
|
|
helm-source-header-default-background
|
|
|
|
(face-attribute 'helm-source-header :background)
|
|
|
|
helm-source-header-default-box
|
|
|
|
(face-attribute 'helm-source-header :box)
|
|
|
|
helm-source-header-default-height
|
|
|
|
(face-attribute 'helm-source-header :height)))
|
|
|
|
;; ensure that the correct bindings are set at startup
|
|
|
|
(spacemacs//helm-hjkl-navigation dotspacemacs-editing-style)
|
|
|
|
;; Transient state
|
|
|
|
(spacemacs//define-helm-action-functions)
|
|
|
|
(spacemacs|define-transient-state helm-navigation
|
|
|
|
:title "Helm Transient State"
|
|
|
|
:doc "
|
2019-05-22 21:33:00 +00:00
|
|
|
[_j_/_k_] next/prev candidate [_v_]^^ persistent action [_e_]^^ edit occurrences
|
|
|
|
[_h_/_l_] prev/next source [_1_.._0_] action 1..10 [_t_/_T_] toggle visible/all mark
|
|
|
|
[_g_/_G_] first/last candidate [_a_]^^ action selection pg [_q_]^^ quit"
|
2016-05-16 01:58:41 +00:00
|
|
|
:foreign-keys run
|
|
|
|
:on-enter (spacemacs//helm-navigation-ts-on-enter)
|
|
|
|
:on-exit (spacemacs//helm-navigation-ts-on-exit)
|
|
|
|
:bindings
|
|
|
|
("1" spacemacs/helm-action-1 :exit t)
|
|
|
|
("2" spacemacs/helm-action-2 :exit t)
|
|
|
|
("3" spacemacs/helm-action-3 :exit t)
|
|
|
|
("4" spacemacs/helm-action-4 :exit t)
|
|
|
|
("5" spacemacs/helm-action-5 :exit t)
|
|
|
|
("6" spacemacs/helm-action-6 :exit t)
|
|
|
|
("7" spacemacs/helm-action-7 :exit t)
|
|
|
|
("8" spacemacs/helm-action-8 :exit t)
|
|
|
|
("9" spacemacs/helm-action-9 :exit t)
|
|
|
|
("0" spacemacs/helm-action-10 :exit t)
|
|
|
|
("<tab>" helm-select-action :exit t)
|
|
|
|
("TAB" helm-select-action :exit t)
|
|
|
|
("<RET>" helm-maybe-exit-minibuffer :exit t)
|
|
|
|
;; ("?" nil :doc (spacemacs//helm-navigation-ts-full-doc))
|
|
|
|
("a" spacemacs/helm-transient-state-select-action)
|
|
|
|
("e" spacemacs/helm-ts-edit)
|
|
|
|
("g" helm-beginning-of-buffer)
|
|
|
|
("G" helm-end-of-buffer)
|
|
|
|
("h" helm-previous-source)
|
|
|
|
("j" helm-next-line)
|
|
|
|
("k" helm-previous-line)
|
|
|
|
("l" helm-next-source)
|
|
|
|
("q" nil :exit t)
|
2016-12-11 20:31:42 +00:00
|
|
|
("M-SPC" nil :exit t)
|
2016-05-16 01:58:41 +00:00
|
|
|
("t" helm-toggle-visible-mark)
|
|
|
|
("T" helm-toggle-all-marks)
|
|
|
|
("v" helm-execute-persistent-action))
|
|
|
|
(define-key helm-map (kbd "M-SPC")
|
|
|
|
'spacemacs/helm-navigation-transient-state/body)
|
|
|
|
(define-key helm-map (kbd "s-M-SPC")
|
|
|
|
'spacemacs/helm-navigation-transient-state/body)
|
|
|
|
;; Swap default TAB and C-z commands.
|
|
|
|
;; For GUI.
|
|
|
|
(with-eval-after-load 'helm-files
|
|
|
|
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action)
|
|
|
|
(define-key helm-find-files-map
|
|
|
|
(kbd "S-<tab>") 'helm-find-files-up-one-level)
|
|
|
|
(define-key helm-find-files-map
|
|
|
|
(kbd "<backtab>") 'helm-find-files-up-one-level)
|
|
|
|
;; For terminal.
|
|
|
|
(define-key helm-map (kbd "TAB") 'helm-execute-persistent-action)
|
|
|
|
(define-key helm-find-files-map
|
|
|
|
(kbd "S-TAB") 'helm-find-files-up-one-level)
|
|
|
|
(define-key helm-map (kbd "C-z") 'helm-select-action))))
|
2016-05-16 02:00:44 +00:00
|
|
|
|
|
|
|
(defun spacemacs-completion/init-default-ivy-config ()
|
|
|
|
(with-eval-after-load 'ivy
|
|
|
|
(setq ivy-height 15
|
2018-08-29 18:16:30 +00:00
|
|
|
ivy-re-builders-alist '((spacemacs/counsel-search . spacemacs/ivy--regex-plus)
|
|
|
|
(t . ivy--regex-ignore-order)))
|
2016-05-16 02:00:44 +00:00
|
|
|
(spacemacs|hide-lighter ivy-mode)
|
|
|
|
;; setup hooks
|
|
|
|
(add-hook 'spacemacs-editing-style-hook 'spacemacs//ivy-hjkl-navigation)
|
|
|
|
;; key bindings
|
|
|
|
;; ensure that the correct bindings are set at startup
|
|
|
|
(spacemacs//ivy-hjkl-navigation dotspacemacs-editing-style)
|
|
|
|
;; Transient state
|
|
|
|
;; ivy-hydra disabled for now, waiting to see how the dependency management
|
|
|
|
;; evolves upstream
|
|
|
|
;; (require 'ivy-hydra)
|
|
|
|
(spacemacs|define-transient-state ivy
|
|
|
|
:doc "
|
|
|
|
Move/Resize^^^^ | Select Action^^^^ | Call^^ | Cancel^^ | Toggles
|
|
|
|
--^-^-^-^-------------|--^-^-^-^------------|--^---^-----------|--^-^---------|---------------------
|
|
|
|
[_j_/_k_] by line | [_s_/_w_] next/prev | [_RET_] & done | [_i_] & ins | [_C_] calling: %s(if ivy-calling \"on\" \"off\")
|
2016-12-11 20:31:42 +00:00
|
|
|
[_g_/_G_] first/last | [_a_]^ ^ list all | [_TAB_] alt done | [_q_] & quit | [_m_] matcher: %s(spacemacs//ivy-matcher-desc)
|
2016-05-16 02:00:44 +00:00
|
|
|
[_d_/_u_] pg down/up | ^ ^ ^ ^ | [_c_] & cont | ^ ^ | [_f_] case-fold: %`ivy-case-fold-search
|
|
|
|
[_<_/_>_] resize | ^ ^ ^ ^ | [_o_] occur | ^ ^ | [_t_] truncate: %`truncate-lines
|
|
|
|
[_h_/_l_] out/in dir | ^ ^ ^ ^ | ^ ^ | ^ ^ | ^ ^
|
|
|
|
|
|
|
|
Current Action: %s(ivy-action-name)
|
|
|
|
"
|
|
|
|
:foreign-keys run
|
|
|
|
:bindings
|
|
|
|
;; arrows
|
|
|
|
("j" ivy-next-line)
|
|
|
|
("k" ivy-previous-line)
|
|
|
|
("l" ivy-alt-done)
|
|
|
|
("h" spacemacs/counsel-up-directory-no-error)
|
|
|
|
("g" ivy-beginning-of-buffer)
|
|
|
|
("G" ivy-end-of-buffer)
|
|
|
|
("d" ivy-scroll-up-command)
|
|
|
|
("u" ivy-scroll-down-command)
|
|
|
|
;; actions
|
|
|
|
("q" keyboard-escape-quit :exit t)
|
|
|
|
("C-g" keyboard-escape-quit :exit t)
|
|
|
|
("<escape>" keyboard-escape-quit :exit t)
|
|
|
|
("i" nil)
|
|
|
|
("C-o" nil)
|
2016-12-11 20:31:42 +00:00
|
|
|
("M-SPC" nil)
|
2016-05-16 02:00:44 +00:00
|
|
|
("TAB" ivy-alt-done :exit nil)
|
|
|
|
;; ("C-j" ivy-alt-done :exit nil)
|
|
|
|
;; ("d" ivy-done :exit t)
|
|
|
|
("RET" ivy-done :exit t)
|
|
|
|
("c" ivy-call)
|
|
|
|
("C-m" ivy-done :exit t)
|
|
|
|
("C" ivy-toggle-calling)
|
2017-12-17 16:25:05 +00:00
|
|
|
("m" ivy-rotate-preferred-builders)
|
2016-05-16 02:00:44 +00:00
|
|
|
(">" ivy-minibuffer-grow)
|
|
|
|
("<" ivy-minibuffer-shrink)
|
|
|
|
("w" ivy-prev-action)
|
|
|
|
("s" ivy-next-action)
|
|
|
|
("a" ivy-read-action)
|
|
|
|
("t" (setq truncate-lines (not truncate-lines)))
|
|
|
|
("f" ivy-toggle-case-fold)
|
|
|
|
("o" ivy-occur :exit t))
|
|
|
|
(define-key ivy-minibuffer-map "\C-o" 'spacemacs/ivy-transient-state/body)
|
2016-12-11 20:31:42 +00:00
|
|
|
(define-key ivy-minibuffer-map (kbd "M-SPC")
|
|
|
|
'spacemacs/ivy-transient-state/body)
|
|
|
|
(define-key ivy-minibuffer-map (kbd "s-M-SPC")
|
|
|
|
'spacemacs/ivy-transient-state/body)
|
2019-09-17 12:33:30 +00:00
|
|
|
(define-key ivy-minibuffer-map (kbd "s-M-SPC")
|
|
|
|
'spacemacs/ivy-transient-state/body)))
|
2016-05-16 02:00:44 +00:00
|
|
|
|
2018-06-15 01:09:40 +00:00
|
|
|
(defun spacemacs-completion/init-flx-ido ()
|
|
|
|
(use-package flx-ido
|
|
|
|
:defer t
|
|
|
|
:init (add-hook 'ido-vertical-mode-hook 'flx-ido-mode)))
|
|
|
|
|
2016-05-16 01:55:57 +00:00
|
|
|
(defun spacemacs-completion/init-ido ()
|
|
|
|
(setq ido-save-directory-list-file
|
|
|
|
(concat spacemacs-cache-directory "ido.last")
|
|
|
|
;; enable fuzzy matching
|
|
|
|
ido-enable-flex-matching t)
|
|
|
|
(ido-mode t))
|
|
|
|
|
|
|
|
(defun spacemacs-completion/init-ido-vertical-mode ()
|
|
|
|
(use-package ido-vertical-mode
|
2018-06-15 01:23:59 +00:00
|
|
|
:defer t
|
2016-05-16 01:55:57 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2018-06-15 01:23:59 +00:00
|
|
|
(add-hook 'ido-minibuffer-setup-hook ido-vertical-mode)
|
2016-05-16 01:55:57 +00:00
|
|
|
(add-hook 'ido-minibuffer-setup-hook 'spacemacs//ido-minibuffer-setup)
|
|
|
|
(add-hook 'ido-setup-hook 'spacemacs//ido-setup)
|
|
|
|
|
|
|
|
(defadvice ido-read-internal
|
|
|
|
(around ido-read-internal-with-minibuffer-other-window activate)
|
|
|
|
(let* (ido-exit-minibuffer-target-window
|
|
|
|
(this-buffer (current-buffer))
|
|
|
|
(result ad-do-it))
|
|
|
|
(cond
|
|
|
|
((equal ido-exit-minibuffer-target-window 'other)
|
|
|
|
(if (= 1 (count-windows))
|
|
|
|
(spacemacs/split-window-horizontally-and-switch)
|
|
|
|
(other-window 1)))
|
|
|
|
((equal ido-exit-minibuffer-target-window 'horizontal)
|
|
|
|
(spacemacs/split-window-horizontally-and-switch))
|
|
|
|
|
|
|
|
((equal ido-exit-minibuffer-target-window 'vertical)
|
|
|
|
(spacemacs/split-window-vertically-and-switch))
|
|
|
|
((equal ido-exit-minibuffer-target-window 'frame)
|
|
|
|
(make-frame)))
|
|
|
|
;; why? Some ido commands, such as textmate.el's
|
|
|
|
;; textmate-goto-symbol don't switch the current buffer
|
|
|
|
(switch-to-buffer this-buffer)
|
|
|
|
result))
|
|
|
|
|
2016-09-02 07:45:06 +00:00
|
|
|
(defvar spacemacs--ido-navigation-ts-enabled nil
|
2016-05-16 01:55:57 +00:00
|
|
|
"Flag which is non nil when ido navigation transient-state is enabled.")
|
|
|
|
|
2016-09-02 07:45:06 +00:00
|
|
|
(defvar spacemacs--ido-navigation-ts-face-cookie-minibuffer nil
|
2016-05-16 01:55:57 +00:00
|
|
|
"Cookie pointing to the local face remapping.")
|
|
|
|
|
2016-09-02 07:45:06 +00:00
|
|
|
(defface spacemacs-ido-navigation-ts-face
|
2016-05-16 01:55:57 +00:00
|
|
|
`((t :background ,(face-attribute 'error :foreground)
|
|
|
|
:foreground "black"
|
|
|
|
:weight bold))
|
|
|
|
"Face for ido minibuffer prompt when ido transient-state is activated."
|
|
|
|
:group 'spacemacs)
|
|
|
|
|
|
|
|
(spacemacs|define-transient-state ido-navigation
|
|
|
|
:title "ido Transient State"
|
|
|
|
:foreign-keys run
|
2016-09-02 07:45:06 +00:00
|
|
|
:on-enter (spacemacs//ido-navigation-ts-on-enter)
|
|
|
|
:on-exit (spacemacs//ido-navigation-ts-on-exit)
|
2016-05-16 01:55:57 +00:00
|
|
|
:bindings
|
2016-09-02 07:45:06 +00:00
|
|
|
;;("?" nil (spacemacs//ido-navigation-ts-full-doc))
|
2016-05-16 01:55:57 +00:00
|
|
|
("<RET>" ido-exit-minibuffer :exit t)
|
|
|
|
("<escape>" nil :exit t)
|
|
|
|
("e" ido-select-text :exit t)
|
|
|
|
("h" ido-delete-backward-updir)
|
|
|
|
("j" ido-next-match)
|
|
|
|
("J" ido-next-match-dir)
|
|
|
|
("k" ido-prev-match)
|
|
|
|
("K" ido-prev-match-dir)
|
|
|
|
("l" ido-exit-minibuffer :exit t)
|
|
|
|
("n" ido-next-match-dir)
|
|
|
|
("o" spacemacs/ido-invoke-in-other-window :exit t)
|
|
|
|
("p" ido-prev-match-dir)
|
|
|
|
("q" nil :exit t)
|
|
|
|
("s" spacemacs/ido-invoke-in-vertical-split :exit t)
|
|
|
|
("t" spacemacs/ido-invoke-in-new-frame :exit t)
|
|
|
|
("v" spacemacs/ido-invoke-in-horizontal-split :exit t)))))
|