summaryrefslogtreecommitdiff
path: root/emacs/inits/10-ivy.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/inits/10-ivy.el')
-rw-r--r--emacs/inits/10-ivy.el117
1 files changed, 117 insertions, 0 deletions
diff --git a/emacs/inits/10-ivy.el b/emacs/inits/10-ivy.el
new file mode 100644
index 0000000..8867bb8
--- /dev/null
+++ b/emacs/inits/10-ivy.el
@@ -0,0 +1,117 @@
+;; Time-stamp: <2019-09-09 22:10:08 (tslil@basingstoke)>
+
+(use-package amx :ensure t)
+
+(use-package counsel :ensure t
+ :after amx
+ :demand
+ :defines (counsel-for-files)
+ :bind (("C-s" . counsel-grep-or-swiper)
+ ("C-x f" . counsel-recentf)
+ ("C-x l" . counsel-locate)
+ ("C-c C-r" . ivy-resume)
+ ("C-c g" . counsel-rg)
+ ("M-x" . counsel-M-x)
+ ("C-s" . swiper-isearch)
+ :map ivy-minibuffer-map
+ ("C-m" . ivy-alt-done)
+ :map swiper-map
+ ("M-%" . swiper-query-replace))
+ :config
+ (setq ivy-use-virtual-buffers nil
+ ivy-display-style 'fancy
+ ivy-initial-inputs-alist nil
+ ivy-format-function 'ivy-format-function-line
+ ivy-count-format "")
+
+ (setq swiper-use-visual-line t)
+
+ (setq counsel-find-file-at-point t
+ counsel-grep-base-command
+ "rg -i -M 120 --no-heading --line-number --color never '%s' %s"
+ counsel-describe-function-function 'helpful-function
+ counsel-describe-variable-function 'helpful-variable)
+
+ (ivy-mode t)
+ (counsel-mode t))
+
+
+(use-package ivy-rich :ensure t
+ :config
+ (setq ivy-rich-path-style 'abbrev
+ ivy-rich-display-transformers-list
+ '(ivy-switch-buffer
+ (:columns
+ ((ivy-rich-candidate (:width 20))
+ (ivy-rich-switch-buffer-size (:width 7 :align right))
+ (ivy-rich-switch-buffer-indicators
+ (:width 2 :face error :align right))
+ (ivy-rich-switch-buffer-major-mode (:width 12 :face warning))
+ (ivy-rich-switch-buffer-project (:width 8 :face success))
+ (ivy-rich-switch-buffer-path
+ (:width (lambda (x)
+ (ivy-rich-switch-buffer-shorten-path
+ x (ivy-rich-minibuffer-width 0.3))))))
+ :predicate (lambda (cand) (get-buffer cand)))
+ counsel-M-x
+ (:columns
+ ((counsel-M-x-transformer (:width 40))
+ (ivy-rich-counsel-function-docstring
+ (:face font-lock-doc-face))))
+ counsel-describe-function
+ (:columns
+ ((counsel-describe-function-transformer (:width 40))
+ (ivy-rich-counsel-function-docstring
+ (:face font-lock-doc-face))))
+ counsel-describe-variable
+ (:columns
+ ((counsel-describe-variable-transformer (:width 40))
+ (ivy-rich-counsel-variable-docstring
+ (:face font-lock-doc-face))))
+ counsel-recentf
+ (:columns
+ ((ivy-rich-candidate (:width 0.8))
+ (ivy-rich-file-last-modified-time
+ (:face font-lock-comment-face))))))
+
+ (ivy-rich-mode 1))
+
+;; (defun limited-counsel-locate-cmd (input)
+;; "Return a shell command based on INPUT."
+;; (counsel-require-program "locate")
+;; (format "locate -l 10 -i --regex '%s'"
+;; (counsel-unquote-regex-parens
+;; (ivy--regex input))))
+
+;; (defun bad ()
+;; (interactive)
+;; (let (process buffer)
+;; (ivy-read "File: "
+;; #'(lambda (input)
+;; (append
+;; '("Recent Files\n" . "")
+;; (recentf-elements 10)
+;; (directory-files default-directory "")
+;; (mapcar (lambda (b) (buffer-name b)) (buffer-list))
+;; (if (< (length input) 3) (counsel-more-chars 3)
+;; ;; (counsel--async-command
+;; ;; (funcall #'limited-counsel-locate-cmd input))
+;; (when process (kill-process process))
+;; (setq process (start-file-process-shell-command
+;; "*locate*"
+;; "*locate*"
+;; (funcall #'limited-counsel-locate-cmd input))))
+;; ))
+;; :dynamic-collection t
+;; :unwind #'(progn (kill-buffer))
+;; :sort nil
+;; :action #'(lambda (x)
+;; (with-ivy-window
+;; (if (file-exists-p x) (find-file x)
+;; (switch-to-buffer x)))))))
+
+;; '(helm-source-recentf
+;; helm-source-file-cache
+;; helm-source-files-in-current-dir
+;; helm-source-buffers-list
+;; helm-source-locate)