completion/ivy: decouple ivy-rich advice from nullable doom--project-root

This commit is contained in:
Henrik Lissner 2018-03-24 15:26:26 -04:00
parent a6cc5a219b
commit 2925f5657b
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -1,7 +1,5 @@
;;; completion/ivy/autoload/ivy.el -*- lexical-binding: t; -*- ;;; completion/ivy/autoload/ivy.el -*- lexical-binding: t; -*-
(defvar doom--project-root nil)
(defun +ivy--is-workspace-or-other-buffer-p (buffer) (defun +ivy--is-workspace-or-other-buffer-p (buffer)
(let ((buffer (car buffer))) (let ((buffer (car buffer)))
(when (stringp buffer) (when (stringp buffer)
@ -15,7 +13,7 @@
'face (cond ((string-match-p "^ *\\*" str) 'face (cond ((string-match-p "^ *\\*" str)
'font-lock-comment-face) 'font-lock-comment-face)
((and buffer-file-truename ((and buffer-file-truename
(not (file-in-directory-p buffer-file-truename doom--project-root))) (not (file-in-directory-p buffer-file-truename (doom-project-root))))
'font-lock-doc-face) 'font-lock-doc-face)
(t nil)))) (t nil))))
(advice-add 'ivy-rich-switch-buffer-buffer-name :override #'+ivy*rich-switch-buffer-buffer-name) (advice-add 'ivy-rich-switch-buffer-buffer-name :override #'+ivy*rich-switch-buffer-buffer-name)
@ -46,8 +44,7 @@ started `counsel-recentf' from. Also uses `abbreviate-file-name'."
(defun +ivy-buffer-transformer (str) (defun +ivy-buffer-transformer (str)
"Dim special buffers, buffers whose file aren't in the current buffer, and "Dim special buffers, buffers whose file aren't in the current buffer, and
virtual buffers. Uses `ivy-rich' under the hood." virtual buffers. Uses `ivy-rich' under the hood."
(let ((buf (get-buffer str)) (let ((buf (get-buffer str)))
(doom--project-root (doom-project-root)))
(require 'ivy-rich) (require 'ivy-rich)
(cond (buf (ivy-rich-switch-buffer-transformer str)) (cond (buf (ivy-rich-switch-buffer-transformer str))
((and (eq ivy-virtual-abbreviate 'full) ((and (eq ivy-virtual-abbreviate 'full)