/modules/init-helm.el

https://github.com/philippe-grenet/exordium · Emacs Lisp · 110 lines · 62 code · 16 blank · 32 comment · 0 complexity · e049b4cfdf27c0e5399010706adab150 MD5 · raw file

  1. ;;;; Helm - see http://tuhdo.github.io/helm-intro.html
  2. ;;;
  3. ;;; ----------------- -------------------------------------------------------
  4. ;;; Key Definition
  5. ;;; ----------------- -------------------------------------------------------
  6. ;;; M-x Remap standard: Execute command with helm.
  7. ;;; M-y Remap standard: Yank with helm.
  8. ;;; C-x b Remap standard: Switch buffer with helm.
  9. ;;; C-x C-f Remap standard: Find file with helm.
  10. ;;; C-x C-r Open recent file with Helm (see also `init-ido.el').
  11. ;;; C-h b Describe keybindings using Helm.
  12. ;;; C-S-r Search with ripgrep: in current project root. (see also`init-helm-porojectile.el')
  13. ;;; C-S-d Search with Ag: ask for directory first.
  14. ;;; C-S-f Search with Ag: this file (like Swoop).
  15. ;;; C-S-a Search with Ag: in current project root. (see also`init-helm-porojectile.el')
  16. ;;; C-S-s Helm Swoop
  17. (require 'init-prefs)
  18. (use-package helm
  19. :diminish
  20. :custom
  21. (helm-split-window-default-side 'other)
  22. (helm-buffer-details-flag nil)
  23. :config
  24. (when exordium-helm-fuzzy-match
  25. ;; following advice from `helm-completion-style' doc
  26. (let ((style (or
  27. (car (assq 'flex completion-styles-alist))
  28. (car (assq 'helm-flex completion-styles-alist)))))
  29. (if style
  30. (add-to-list 'completion-styles style)
  31. (customize-set-variable 'helm-completion-style 'helm-fuzzy)))))
  32. (use-package helm
  33. :diminish
  34. :when exordium-helm-everywhere
  35. :custom
  36. (history-delete-duplicates t)
  37. (helm-M-x-always-save-history t)
  38. :bind
  39. (:map global-map
  40. ([remap execute-extended-command] . #'helm-M-x) ; M-x
  41. ([remap yank-pop] . #'helm-show-kill-ring) ; M-y
  42. ([remap find-file] . #'helm-find-files) ; C-x C-f
  43. ([remap find-file-read-only] . #'helm-recentf)) ; C-x C-r
  44. :config
  45. ;; Do not show these files in helm buffer
  46. (add-to-list 'helm-boring-file-regexp-list "\\.tsk$")
  47. (add-to-list 'helm-boring-file-regexp-list "\\.log\\.")
  48. (helm-mode))
  49. (use-package helm-descbinds
  50. :bind
  51. (:map global-map
  52. ("C-h b". #'helm-descbinds)))
  53. (use-package helm-ag
  54. :custom
  55. (helm-ag-insert-at-point 'symbol)
  56. :bind
  57. (:map global-map
  58. ("C-S-d" . #'helm-do-ag)
  59. ("C-S-f" . #'helm-do-ag-this-file)))
  60. (use-package helm-ag
  61. :unless exordium-helm-projectile
  62. :bind
  63. (:map global-map
  64. ("C-S-a" . #'helm-ag-project-root)))
  65. (use-package helm-rg
  66. :unless exordium-helm-projectile
  67. :bind
  68. (:map global-map
  69. ("C-S-r" . #'helm-rg)))
  70. (use-package helm-swoop
  71. :bind
  72. (:map global-map
  73. ("C-S-s" . #'helm-swoop)
  74. ;; Use similar bindings to `helm-ag-edit'
  75. :map helm-swoop-edit-map
  76. ("C-c C-c" . #'helm-swoop--edit-complete)
  77. ("C-c C-k" . #'helm-swoop--edit-cancel)
  78. ("C-c C-q C-k" . #'helm-swoop--edit-delete-all-lines)))
  79. ;; TODO: work in progress
  80. ;; The intent is to improve the readability of the helm swoop selection line
  81. ;; (in the helm buffer).
  82. ;; (defun fix-helm-swoop-colors (orig-fun &rest args)
  83. ;; "Advice around `helm-swoop' to change the background of the
  84. ;; selected line in the hem buffer, for better readability"
  85. ;; (let ((bg (face-attribute 'helm-selection :background))
  86. ;; (swoop-bg (face-attribute 'helm-swoop-target-line-face :background)))
  87. ;; (set-face-attribute 'helm-selection nil :background swoop-bg)
  88. ;; (let ((res (apply orig-fun args)))
  89. ;; (set-face-attribute 'helm-selection nil :background bg)
  90. ;; res)))
  91. ;; (advice-add 'helm-swoop :around #'fix-helm-swoop-colors)
  92. (provide 'init-helm)