Moving to Doom Emacs!

This commit is contained in:
Derek Taylor
2019-12-16 20:21:19 -06:00
parent d9f2f456f1
commit d4b4c33550
683 changed files with 51877 additions and 100 deletions

View File

@@ -0,0 +1,42 @@
;;; completion/helm/autoload/evil.el -*- lexical-binding: t; -*-
;;;###if (featurep! :editor evil)
;;;###autoload (autoload '+helm:project-search "completion/helm/autoload/evil" nil t)
(evil-define-command +helm:project-search (all-files-p query)
"Ex interface for `+helm/grep'"
(interactive "<!><a>")
(+helm/project-search all-files-p query))
;;;###autoload (autoload '+helm:project-search-from-cwd "completion/helm/autoload/evil" nil t)
(evil-define-command +helm:project-search-from-cwd (query &optional recurse-p)
"Ex interface for `+helm/grep-from-cwd'."
(interactive "<a><!>")
(+helm/project-search-from-cwd (not recurse-p) query))
;;;###autoload
(defun +helm--set-prompt-display (pos)
"TODO"
(let (beg state region-active m)
(with-selected-window (minibuffer-window)
(setq beg (save-excursion (vertical-motion 0 (helm-window)) (point))
state evil-state
region-active (region-active-p)
m (mark t)))
(when region-active
(setq m (- m beg))
;; Increment pos to handle the space before prompt (i.e `pref').
(put-text-property (1+ (min m pos)) (+ 2 (max m pos))
'face
(list :background (face-background 'region))
header-line-format))
(put-text-property
;; Increment pos to handle the space before prompt (i.e `pref').
(+ 1 pos) (+ 2 pos)
'face
(if (eq state 'insert)
'underline
;; Don't just use 'cursor, this can hide the current character.
(list :inverse-video t
:foreground (face-background 'cursor)
:background (face-background 'default)))
header-line-format)))

View File

@@ -0,0 +1,96 @@
;;; completion/helm/autoload/helm.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +helm/projectile-find-file ()
"Call `helm-find-files' if called from HOME, otherwise
`helm-projectile-find-file'."
(interactive)
(call-interactively
(if (or (file-equal-p default-directory "~")
(if-let* ((proot (doom-project-root)))
(file-equal-p proot "~")
t))
#'helm-find-files
#'helm-projectile-find-file)))
;;;###autoload
(defun +helm/workspace-buffer-list ()
"A version of `helm-buffers-list' with its buffer list restricted to the
current workspace."
(interactive)
(unless (featurep! :ui workspaces)
(user-error "This command requires the :ui workspaces module"))
(with-no-warnings
(with-persp-buffer-list nil (helm-buffers-list))))
;;;###autoload
(defun +helm/workspace-mini ()
"A version of `helm-mini' with its buffer list restricted to the current
workspace."
(interactive)
(unless (featurep! :ui workspaces)
(user-error "This command requires the :ui workspaces module"))
(with-no-warnings
(with-persp-buffer-list nil (helm-mini))))
;;
;;; Project search
;;;###autoload
(cl-defun +helm-file-search (&key query in all-files (recursive t))
"Conduct a file search using ripgrep.
:query STRING
Determines the initial input to search for.
:in PATH
Sets what directory to base the search out of. Defaults to the current
project's root.
:recursive BOOL
Whether or not to search files recursively from the base directory."
(declare (indent defun))
(unless (executable-find "rg")
(user-error "Couldn't find ripgrep in your PATH"))
(require 'helm-rg)
(let ((helm-rg-default-directory (or in (doom-project-root) default-directory))
(helm-rg-default-extra-args
(delq nil (list (when all-files "-z -uu")
(unless recursive "--maxdepth 1")))))
(helm-rg (or query
(when (use-region-p)
(let ((beg (or (bound-and-true-p evil-visual-beginning) (region-beginning)))
(end (or (bound-and-true-p evil-visual-end) (region-end))))
(when (> (abs (- end beg)) 1)
(buffer-substring-no-properties beg end))))
""))))
;;;###autoload
(defun +helm/project-search (&optional arg initial-query directory)
"Performs a project search from the project root with ripgrep.
ARG (universal argument), include all files, even hidden or compressed ones, in
the search."
(interactive "P")
(+helm-file-search
:query initial-query
:in directory
:all-files (and (not (null arg))
(listp arg))))
;;;###autoload
(defun +helm/project-search-from-cwd (&optional arg initial-query)
"Performs a project search recursively from the current directory.
If ARG (universal argument), include all files, even hidden or compressed ones."
(interactive "P")
(+helm-file-search
:query initial-query
:in default-directory
:all-files (and (not (null arg))
(listp arg))))
;;;###autoload
(defun +helm/jump-list ()
"TODO"
(interactive)
(error "not implemented yet"))

View File

@@ -0,0 +1,59 @@
;;; completion/helm/autoload/posframe.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +helm-poshandler-frame-center-near-bottom-fn (info)
"Display the child frame in the center of the frame, slightly closer to the
bottom, which is easier on the eyes on big displays."
(let ((parent-frame (plist-get info :parent-frame))
(pos (posframe-poshandler-frame-center info)))
(cons (car pos)
(truncate (/ (frame-pixel-height parent-frame)
2)))))
(defvar +helm--posframe-buffer nil)
;;;###autoload
(defun +helm-posframe-display-fn (buffer &optional _resume)
"TODO"
(setq helm--buffer-in-new-frame-p t)
(let ((solaire-p (bound-and-true-p solaire-mode))
(params (copy-sequence +helm-posframe-parameters)))
(let-alist params
(require 'posframe)
(posframe-show
(setq +helm--posframe-buffer buffer)
:position (point)
:poshandler +helm-posframe-handler
:width
(max (cl-typecase .width
(integer .width)
(float (truncate (* (frame-width) .width)))
(function (funcall .width))
(t 0))
.min-width)
:height
(max (cl-typecase .height
(integer .height)
(float (truncate (* (frame-height) .height)))
(function (funcall .height))
(t 0))
.min-height)
:override-parameters
(dolist (p '(width height min-width min-height) params)
(setq params (delq (assq p params) params)))))
;;
(unless (or (null +helm-posframe-text-scale)
(= +helm-posframe-text-scale 0))
(with-current-buffer buffer
(when (and (featurep 'solaire-mode)
(not solaire-p))
(solaire-mode +1))
(text-scale-set +helm-posframe-text-scale)))))
;;;###autoload
(defun +helm-posframe-cleanup-h ()
"TODO"
;; Ensure focus is properly returned to the underlying window. This gives the
;; modeline a chance to refresh.
(switch-to-buffer +helm--posframe-buffer t))
(add-hook 'helm-cleanup-hook #'+helm-posframe-cleanup-h)

View File

@@ -0,0 +1,185 @@
;;; completion/helm/config.el -*- lexical-binding: t; -*-
;; Posframe (requires +childframe)
(defvar +helm-posframe-handler #'+helm-poshandler-frame-center-near-bottom-fn
"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)
(width . 0.5)
(height . 0.35)
(min-width . 80)
(min-height . 16))
"TODO")
;;
;;; Packages
(use-package! helm-mode
:defer t
:after-call pre-command-hook
:init
(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 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)
:config
(helm-mode +1)
;; helm is too heavy for `find-file-at-point'
(add-to-list 'helm-completing-read-handlers-alist (cons #'find-file-at-point nil)))
(use-package! helm
:after helm-mode
:preface
(setq helm-candidate-number-limit 50
;; Remove extraineous helm UI elements
helm-display-header-line nil
helm-mode-line-string 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
;; 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)
(when (featurep! :editor evil +everywhere)
(setq helm-default-prompt-display-function #'+helm--set-prompt-display))
:init
(when (featurep! +childframe)
(setq helm-display-function #'+helm-posframe-display-fn))
(let ((fuzzy (featurep! +fuzzy)))
(setq helm-M-x-fuzzy-match fuzzy
helm-apropos-fuzzy-match fuzzy
helm-apropos-fuzzy-match fuzzy
helm-bookmark-show-location fuzzy
helm-buffers-fuzzy-matching fuzzy
helm-completion-in-region-fuzzy-match fuzzy
helm-completion-in-region-fuzzy-match 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-mode-fuzzy-match fuzzy
helm-projectile-fuzzy-match fuzzy
helm-recentf-fuzzy-match fuzzy
helm-semantic-fuzzy-match fuzzy))
:config
(set-popup-rule! "^\\*helm" :vslot -100 :size 0.22 :ttl nil)
;; HACK Doom doesn't support these commands, which invite the user to install
;; the package via ELPA. Force them to use +helm/* instead, because they work
;; out of the box.
(advice-add #'helm-projectile-rg :override #'+helm/project-search)
(advice-add #'helm-projectile-ag :override #'+helm/project-search)
(advice-add #'helm-projectile-grep :override #'+helm/project-search)
;; Hide the modeline
(defun +helm--hide-mode-line (&rest _)
(with-current-buffer (helm-buffer-get)
(unless helm-mode-line-string
(hide-mode-line-mode +1))))
(add-hook 'helm-after-initialize-hook #'+helm--hide-mode-line)
(advice-add #'helm-display-mode-line :override #'+helm--hide-mode-line)
(advice-add #'helm-ag-show-status-default-mode-line :override #'ignore)
;; Use helpful instead of describe-* to display documentation
(dolist (fn '(helm-describe-variable helm-describe-function))
(advice-add fn :around #'doom-use-helpful-a)))
(use-package! helm-flx
:when (featurep! +fuzzy)
:hook (helm-mode . helm-flx-mode)
:config (helm-flx-mode +1))
(after! helm-rg
(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" (λ! (helm-rg--bounce-dump) (kill-current-buffer))
"C-x C-c" #'helm-rg--bounce-dump-current-file
"C-c C-k" #'kill-current-buffer))
;;;###package helm-bookmark
(setq helm-bookmark-show-location t)
(after! helm-files
(setq helm-boring-file-regexp-list
(append (list "\\.projects$" "\\.DS_Store$")
helm-boring-file-regexp-list)))
(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))
(use-package! helm-org
:when (featurep! :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))))
(use-package! helm-projectile
:commands (helm-projectile-find-file
helm-projectile-recentf
helm-projectile-switch-project
helm-projectile-switch-to-buffer)
:init
(setq projectile-completion-system 'helm)
(defvar helm-projectile-find-file-map (make-sparse-keymap))
:config
(set-keymap-parent helm-projectile-find-file-map helm-map))
(setq ivy-height 20) ; for `swiper-isearch'
(after! swiper-helm
(setq swiper-helm-display-function
(lambda (buf &optional _resume) (pop-to-buffer buf)))
(global-set-key [remap swiper] #'swiper-helm)
(add-to-list 'swiper-font-lock-exclude #'+doom-dashboard-mode nil #'eq))

View File

@@ -0,0 +1,16 @@
;; -*- no-byte-compile: t; -*-
;;; completion/helm/packages.el
(package! helm)
(package! helm-rg)
(package! helm-c-yasnippet)
(package! helm-company)
(package! helm-describe-modes :recipe (:host github :repo "emacs-helm/helm-describe-modes"))
(package! helm-projectile)
(package! swiper-helm)
(when (featurep! +fuzzy)
(package! helm-flx))
(when (featurep! +childframe)
(package! posframe))
(when (featurep! :lang org)
(package! helm-org))