doomemacs/modules/completion/helm/config.el

202 lines
7 KiB
EmacsLisp
Raw Normal View History

2017-06-09 13:36:58 +02:00
;;; completion/helm/config.el -*- lexical-binding: t; -*-
2017-02-13 21:12:02 -05:00
;; Posframe (requires +childframe)
(defvar +helm-posframe-handler #'posframe-poshandler-frame-center
"The function that determines the location of the childframe.
It should return a cons cell representing the X and Y coordinates. See
`posframe-poshandler-frame-center' as a reference.")
(defvar +helm-posframe-text-scale 1
"The text-scale to use in the helm childframe. Set to nil for no scaling.
Can be negative.")
(defvar +helm-posframe-parameters
'((internal-border-width . 8)
2021-02-16 11:44:59 -05:00
(width . 0.65)
(height . 0.35)
(min-width . 80)
(min-height . 16))
"Default parameters for the helm childframe.")
2017-02-13 21:12:02 -05:00
;;
;;; Packages
2017-02-13 21:12:02 -05:00
(use-package! helm-mode
Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-14 15:00:23 -04:00
:hook (doom-first-input . helm-mode)
2018-03-02 23:11:49 -05:00
:config
2018-08-21 02:57:40 +02:00
;; helm is too heavy for `find-file-at-point'
(add-to-list 'helm-completing-read-handlers-alist (cons #'find-file-at-point nil)))
2018-03-02 23:11:49 -05:00
(use-package! helm
2018-03-02 23:11:49 -05:00
:after helm-mode
:preface
(setq helm-candidate-number-limit 150
2018-08-05 22:06:46 +02:00
;; Remove extraineous helm UI elements
2017-02-13 21:12:02 -05:00
helm-display-header-line nil
helm-ff-auto-update-initial-value nil
helm-find-files-doc-header nil
;; Default helm window sizes
helm-display-buffer-default-width nil
helm-display-buffer-default-height 0.25
;; When calling `helm-semantic-or-imenu', don't immediately jump to
;; symbol at point.
helm-imenu-execute-action-at-once-if-one nil
;; Disable special behavior for left/right, M-left/right keys.
helm-ff-lynx-style-map nil)
(map! [remap apropos] #'helm-apropos
[remap find-library] #'helm-locate-library
[remap bookmark-jump] #'helm-bookmarks
[remap execute-extended-command] #'helm-M-x
[remap find-file] #'helm-find-files
[remap ibuffer-find-file] #'helm-find-files
[remap locate] #'helm-locate
[remap imenu] #'helm-semantic-or-imenu
[remap noop-show-kill-ring] #'helm-show-kill-ring
[remap persp-switch-to-buffer] #'+helm/workspace-mini
[remap switch-to-buffer] #'helm-buffers-list
[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
[remap yank-pop] #'helm-show-kill-ring)
(when (modulep! :editor evil +everywhere)
(setq helm-default-prompt-display-function #'+helm--set-prompt-display))
:init
(let ((fuzzy (modulep! +fuzzy)))
(setq helm-apropos-fuzzy-match fuzzy
helm-bookmark-show-location fuzzy
helm-buffers-fuzzy-matching fuzzy
helm-ff-fuzzy-matching fuzzy
helm-file-cache-fuzzy-match fuzzy
helm-flx-for-helm-locate fuzzy
helm-imenu-fuzzy-match fuzzy
helm-lisp-fuzzy-completion fuzzy
helm-locate-fuzzy-match fuzzy
helm-projectile-fuzzy-match fuzzy
helm-recentf-fuzzy-match fuzzy
helm-semantic-fuzzy-match fuzzy)
;; Make sure that we have helm-multi-matching or fuzzy matching, (as
;; prescribed by the fuzzy flag) also in the following cases:
;;
;; - helmized commands that use `completion-at-point' and similar functions
;; - native commands that fall back to `completion-styles' like `helm-M-x'
;;
;; However, do not add helm completion styles to the front of
;; `completion-styles', since that would be overly intrusive. E.g., it
;; results in `company-capf' returning far to many completion candidates.
;; Instead, append those styles so that they act as a fallback. Variable
;; completion-styles is ignored unless helm-completion-style is customized
;; to 'emacs.
(setq helm-completion-style 'emacs)
(add-to-list 'completion-styles (if fuzzy 'flex 'helm) t))
2017-02-13 21:12:02 -05:00
:config
(set-popup-rule! "^\\*helm" :vslot -100 :size 0.22 :ttl nil)
;; Hide minibuffer if `helm-echo-input-in-header-line'
(add-hook 'helm-minibuffer-set-up-hook #'helm-hide-minibuffer-maybe)
:boom: revise advice naming convention (1/2) This is first of three big naming convention updates that have been a long time coming. With 2.1 on the horizon, all the breaking updates will batched together in preparation for the long haul. In this commit, we do away with the asterix to communicate that a function is an advice function, and we replace it with the '-a' suffix. e.g. doom*shut-up -> doom-shut-up-a doom*recenter -> doom-recenter-a +evil*static-reindent -> +evil--static-reindent-a The rationale behind this change is: 1. Elisp's own formatting/indenting tools would occasionally struggle with | and * (particularly pp and cl-prettyprint). They have no problem with / and :, fortunately. 2. External syntax highlighters (like pygmentize, discord markdown or github markdown) struggle with it, sometimes refusing to highlight code beyond these symbols. 3. * and | are less expressive than - and -- in communicating the intended visibility, versatility and stability of a function. 4. It complicated the regexps we must use to search for them. 5. They were arbitrary and over-complicated to begin with, decided on haphazardly way back when Doom was simply "my private config". Anyhow, like how predicate functions have the -p suffix, we'll adopt the -a suffix for advice functions, -h for hook functions and -fn for variable functions. Other noteable changes: - Replaces advice-{add,remove}! macro with new def-advice! macro. The old pair weren't as useful. The new def-advice! saves on a lot of space. - Removed "stage" assertions to make sure you were using the right macros in the right place. Turned out to not be necessary, we'll employ better checks later.
2019-07-18 15:42:52 +02:00
;; Use helpful instead of describe-* to display documentation
(dolist (fn '(helm-describe-variable helm-describe-function))
(advice-add fn :around #'doom-use-helpful-a)))
2018-03-02 23:11:49 -05:00
(use-package! helm-posframe
:when (modulep! +childframe)
:hook (helm-mode . helm-posframe-enable)
:config
(setq helm-posframe-poshandler #'posframe-poshandler-frame-center
helm-posframe-width 0.65
helm-posframe-height 0.35
helm-posframe-min-width 80
helm-posframe-min-height 16
helm-posframe-border-width 8))
(use-package! helm-flx
:when (modulep! +fuzzy)
:hook (helm-mode . helm-flx-mode))
2017-02-13 21:12:02 -05:00
(after! helm-rg
2019-12-06 17:16:34 -05:00
(setq helm-rg-display-buffer-normal-method #'pop-to-buffer)
(set-popup-rule! "^helm-rg-" :ttl nil :select t :size 0.45)
(map! :map helm-rg-map
"C-c C-e" #'helm-rg--bounce)
(map! :map helm-rg--bounce-mode-map
"q" #'kill-current-buffer
"C-c C-c" (cmd! (helm-rg--bounce-dump) (kill-current-buffer))
"C-x C-c" #'helm-rg--bounce-dump-current-file
"C-c C-k" #'kill-current-buffer))
2017-02-13 21:12:02 -05:00
;;;###package helm-bookmark
(setq helm-bookmark-show-location t)
2017-02-13 21:12:02 -05:00
(after! helm-files
2017-02-13 21:12:02 -05:00
(setq helm-boring-file-regexp-list
(append (list "\\.projects$" "\\.DS_Store$")
helm-boring-file-regexp-list)))
2017-02-13 21:12:02 -05:00
2018-06-16 15:04:27 +02:00
(defvar helm-generic-files-map (make-sparse-keymap))
(after! helm-locate
(when (and IS-MAC
(null helm-locate-command)
(executable-find "mdfind"))
(setq helm-locate-command "mdfind -name %s"))
(set-keymap-parent helm-generic-files-map helm-map))
2017-02-13 21:12:02 -05:00
(use-package! helm-org
:when (modulep! :lang org)
:defer t
:init
(after! helm-mode
(pushnew! helm-completing-read-handlers-alist
'(org-capture . helm-org-completing-read-tags)
'(org-set-tags . helm-org-completing-read-tags))))
;; DEPRECATED: Remove when projectile is replaced with project.el
(use-package! helm-projectile
2018-06-16 15:04:52 +02:00
:commands (helm-projectile-find-file
helm-projectile-recentf
helm-projectile-switch-project
helm-projectile-switch-to-buffer)
:init
(defvar helm-projectile-find-file-map (make-sparse-keymap))
:config
(set-keymap-parent helm-projectile-find-file-map helm-map))
2017-02-13 21:12:02 -05:00
(use-package! swiper-helm
:defer t
:config
(setq ivy-height 20
swiper-helm-display-function
(lambda (buf &optional _resume) (pop-to-buffer buf)))
Introduce general.el & rewrite map! + Now uses an overriding keymap for leader keys, so that it is always available, even outside of normal/visual states. In insert/emacs states, or in sessions where evil is absent, an alternative prefix is used for leader/localleader keys. See these variables: + doom-leader-prefix + doom-leader-alt-prefix + doom-localleader-prefix + doom-localleader-alt-prefix + Keybinds now support alternative prefixes through the new :alt-prefix property. This is useful for non-evil users and non-normal evil states. By default, this is M-SPC (leader) and M-SPC m (localleader). + Removed +evil-commands flag from config/default (moved to feature/evil/+commands.el). + config/default/+bindings.el has been split into config/default/+{evil,emacs}-bindings.el, which one is loaded depends on whether evil is present or not. The latter is blank, but will soon be populated with a keybinding scheme for non-evil users (perhaps inspired by #641). + The define-key! macro has been replaced; it is now an alias for general-def. + Added unmap! as an alias for general-unbind. + The following modifier key conventions are now enforced for consistency, across all OSes: alt/option = meta windows/command = super It used to be alt/option = alt windows/command = meta Many of the default keybinds have been updated to reflect this switch, but it is likely to affect personal meta/super keybinds! The map! macro has also been rewritten to use general-define-key. Here is what has been changed: + map! no longer works with characters, e.g. (map! ?x #'do-something) is no longer supported. Keys must be kbd-able strings like "C-c x" or vectors like [?C-c ?x]. + The :map and :map* properties are now the same thing. If specified keymaps aren't defined when binding keys, it is automatically deferred. + The way you bind local keybinds has changed: ;; Don't do this (map! :l "a" #'func-a :l "b" #'func-b) ;; Do this (map! :map 'local "a" #'func-a "b" #'func-b) + map! now supports the following new blocks: + (:if COND THEN-FORM ELSE-FORM...) + (:alt-prefix PREFIX KEYS...) -- this prefix will be used for non-normal evil states. Equivalent to :non-normal-prefix in general. + The way you declare a which-key label for a prefix key has changed: ;; before (map! :desc "label" :prefix "a" ...) ;; now (map! :prefix ("a" . "label") ...) + It used to be that map! supported binding a key to a key sequence, like so: (map! "a" [?x]) ; pressing a is like pressing x This functionality was removed *temporarily* while I figure out the implementation. Addresses: #448, #814, #860 Mentioned in: #940
2018-12-22 03:30:04 -05:00
(global-set-key [remap swiper] #'swiper-helm)
(add-to-list 'swiper-font-lock-exclude #'+doom-dashboard-mode nil #'eq))
(use-package! helm-descbinds
:hook (helm-mode . helm-descbinds-mode))
(use-package! helm-icons
:when (modulep! +icons)
:hook (helm-mode . helm-icons-enable)
:init
(setq helm-icons-provider 'all-the-icons)
:config
(when (eq helm-icons-provider 'all-the-icons)
(setq helm-icons-mode->icon nil)))