doomemacs/modules/completion/helm/config.el

127 lines
4.3 KiB
EmacsLisp
Raw Normal View History

2017-06-09 19:36:58 +08:00
;;; completion/helm/config.el -*- lexical-binding: t; -*-
2017-02-14 10:12:02 +08:00
;; Warning: since I don't use helm, this may be out of date.
2017-02-14 10:12:02 +08:00
(defvar +helm-global-prompt " "
"The helm text prompt prefix string is globally replaced with this string.")
2017-02-14 10:12:02 +08:00
;;
;; Packages
;;
2018-03-03 12:11:49 +08:00
(def-package! helm-mode
:defer 1
:after-call pre-command-hook
:init
(map! :map global-map
[remap apropos] #'helm-apropos
[remap bookmark-jump] #'helm-bookmarks
[remap bookmark-jump] #'helm-bookmarks
[remap execute-extended-command] #'helm-M-x
[remap find-file] #'helm-find-files
[remap imenu-anywhere] #'helm-imenu-anywhere
[remap imenu-anywhere] #'helm-imenu-anywhere
[remap imenu] #'helm-semantic-or-imenu
[remap noop-show-kill-ring] #'helm-show-kill-ring
[remap projectile-find-file] #'helm-projectile-find-file
[remap projectile-recentf] #'helm-projectile-recentf
[remap projectile-switch-project] #'helm-projectile-switch-project
[remap projectile-switch-to-buffer] #'helm-projectile-switch-to-buffer
[remap recentf-open-files] #'helm-recentf)
2018-03-03 12:11:49 +08:00
:config
(helm-mode +1)
2018-03-03 12:11:49 +08:00
;; helm is too heavy for find-file-at-point
(map-put helm-completing-read-handlers-alist 'find-file-at-point nil))
2018-03-03 12:11:49 +08:00
2017-06-09 19:36:58 +08:00
(def-package! helm
2018-03-03 12:11:49 +08:00
:after helm-mode
2017-02-14 10:12:02 +08:00
:init
(setq
;; Fuzzy matching is pretty handy!
helm-mode-fuzzy-match t
helm-buffers-fuzzy-matching t
helm-apropos-fuzzy-match t
helm-M-x-fuzzy-match t
helm-recentf-fuzzy-match t
helm-projectile-fuzzy-match t
;; Display extraineous helm UI elements
helm-display-header-line nil
helm-ff-auto-update-initial-value nil
helm-find-files-doc-header nil
;; Don't override evil-ex's completion
helm-mode-handle-completion-in-region nil
helm-candidate-number-limit 50)
2017-02-14 10:12:02 +08:00
:config
2018-03-03 12:11:49 +08:00
(setq projectile-completion-system 'helm)
2017-06-09 19:36:58 +08:00
(defvar helm-projectile-find-file-map (make-sparse-keymap))
(require 'helm-projectile)
(set-keymap-parent helm-projectile-find-file-map helm-map)
2017-06-09 19:36:58 +08:00
;;; Helm hacks
(defun +helm*replace-prompt (plist)
"Globally replace helm prompts with `+helm-global-prompt'."
2017-06-09 19:36:58 +08:00
(if (keywordp (car plist))
(plist-put plist :prompt +helm-global-prompt)
(setf (nth 2 plist) +helm-global-prompt)
plist))
(advice-add #'helm :filter-args #'+helm*replace-prompt)
2017-02-14 10:12:02 +08:00
(defun +helm*hide-header (&rest _)
"Hide header-line & mode-line in helm windows."
(setq mode-line-format nil))
2017-06-09 19:36:58 +08:00
(advice-add #'helm-display-mode-line :override #'+helm*hide-header)
2018-03-03 12:11:49 +08:00
(defun +helm*hide-minibuffer-maybe ()
"Hide minibuffer in Helm session if we use the header line as input field."
(when (with-current-buffer (helm-buffer-get) helm-echo-input-in-header-line)
2018-03-03 12:11:49 +08:00
(let ((ov (make-overlay (point-min) (point-max) nil nil t)))
(overlay-put ov 'window (selected-window))
(overlay-put ov 'face
(let ((bg-color (face-background 'default nil)))
`(:background ,bg-color :foreground ,bg-color)))
(setq-local cursor-type nil))))
(add-hook 'helm-minibuffer-set-up-hook #'+helm*hide-minibuffer-maybe))
2017-02-14 10:12:02 +08:00
(def-package! helm-locate
:defer t
2017-06-09 19:36:58 +08:00
:init (defvar helm-generic-files-map (make-sparse-keymap))
2017-02-14 10:12:02 +08:00
:config (set-keymap-parent helm-generic-files-map helm-map))
(after! helm-bookmark
(setq-default helm-bookmark-show-location t))
2017-02-14 10:12:02 +08:00
(after! helm-files
2017-02-14 10:12:02 +08:00
(setq helm-boring-file-regexp-list
(append (list "\\.projects$" "\\.DS_Store$")
helm-boring-file-regexp-list)))
2017-02-14 10:12:02 +08:00
;; `helm-ag'
(map! :after helm-ag
:map helm-ag-edit-map [remap quit-window] #'helm-ag--edit-abort)
2017-02-14 10:12:02 +08:00
(after! helm-css-scss ; https://github.com/ShingoFukuyama/helm-css-scss
(setq helm-css-scss-split-direction #'split-window-vertically
2017-02-14 10:12:02 +08:00
helm-css-scss-split-with-multiple-windows t))
(def-package! helm-swoop ; https://github.com/ShingoFukuyama/helm-swoop
:commands helm-multi-swoop-all
2017-02-14 10:12:02 +08:00
:config
(setq helm-swoop-use-line-number-face t
helm-swoop-candidate-number-limit 200
helm-swoop-speed-or-color t
helm-swoop-pre-input-function (lambda () "")))
(def-package! wgrep
:commands wgrep-change-to-wgrep-mode
:config (setq wgrep-auto-save-buffer t))