<commit_before>;;; completion/ivy/autoload/ivy.el -*- lexical-binding: nil; -*-

(defun +ivy--is-workspace-or-other-buffer-p (buffer)
  (let ((buffer (car buffer)))
    (when (stringp buffer)
      (setq buffer (get-buffer buffer)))
    (and (not (eq buffer (current-buffer)))
         (+workspace-contains-buffer-p buffer))))


;;
;; Library
;;

;;;###autoload
(defun +ivy-buffer-transformer (str)
  (let ((buf (get-buffer str))
        (project-root (doom-project-root)))
    (require 'ivy-rich)
    (cond (buf
           (with-current-buffer buf
             (let* ((indicator  (ivy-rich-switch-buffer-indicators))
                    (size       (ivy-rich-switch-buffer-size))
                    (buf-name   (ivy-rich-switch-buffer-buffer-name))
                    (mode       (ivy-rich-switch-buffer-major-mode))
                    (project    (ivy-rich-switch-buffer-project))
                    (path       (ivy-rich-switch-buffer-path project)))
               (cond ((string-match-p "^ ?\\*" (buffer-name buf))
                      (setq buf-name (propertize buf-name 'face 'font-lock-comment-face)))
                     ((and buffer-file-name
                           (not (file-in-directory-p (buffer-file-name buf) project-root)))
                      (setq buf-name (propertize buf-name 'face 'ivy-remote))))
               (ivy-rich-switch-buffer-format (list buf-name size indicator mode project path)))))
          ((and (eq ivy-virtual-abbreviate 'full)
                ivy-rich-switch-buffer-align-virtual-buffer)
           (ivy-rich-switch-buffer-virtual-buffer))
          ((eq ivy-virtual-abbreviate 'full)
           (propertize (abbreviate-file-name str) 'str 'ivy-virtual))
          (t (propertize str 'face 'ivy-virtual)))))

;;;###autoload
(defun +ivy/switch-workspace-buffer (&optional arg)
  "Switch to another buffer within the current workspace.

If ARG (universal argument), open selection in other-window."
  (interactive "P")
  (ivy-read "Switch to workspace buffer: "
            'internal-complete-buffer
            :predicate #'+ivy--is-workspace-or-other-buffer-p
            :action (if arg
                        #'ivy--switch-buffer-other-window-action
                      #'ivy--switch-buffer-action)
            :matcher #'ivy--switch-buffer-matcher
            :keymap ivy-switch-buffer-map
            :caller #'+ivy/switch-workspace-buffer))

(defun +ivy--tasks-candidates (tasks)
  "Generate a list of task tags (specified by `+ivy-task-tags') for<commit_msg>completion/ivy: use font-lock-doc-face instead of ivy-remote<commit_after>;;; completion/ivy/autoload/ivy.el -*- lexical-binding: nil; -*-

(defun +ivy--is-workspace-or-other-buffer-p (buffer)
  (let ((buffer (car buffer)))
    (when (stringp buffer)
      (setq buffer (get-buffer buffer)))
    (and (not (eq buffer (current-buffer)))
         (+workspace-contains-buffer-p buffer))))


;;
;; Library
;;

;;;###autoload
(defun +ivy-buffer-transformer (str)
  (let ((buf (get-buffer str))
        (project-root (doom-project-root)))
    (require 'ivy-rich)
    (cond (buf
           (with-current-buffer buf
             (let* ((indicator  (ivy-rich-switch-buffer-indicators))
                    (size       (ivy-rich-switch-buffer-size))
                    (buf-name   (ivy-rich-switch-buffer-buffer-name))
                    (mode       (ivy-rich-switch-buffer-major-mode))
                    (project    (ivy-rich-switch-buffer-project))
                    (path       (ivy-rich-switch-buffer-path project)))
               (cond ((string-match-p "^ ?\\*" (buffer-name buf))
                      (setq buf-name (propertize buf-name 'face 'font-lock-comment-face)))
                     ((and buffer-file-name
                           (not (file-in-directory-p (buffer-file-name buf) project-root)))
                      (setq buf-name (propertize buf-name 'face 'font-lock-doc-face))))
               (ivy-rich-switch-buffer-format (list buf-name size indicator mode project path)))))
          ((and (eq ivy-virtual-abbreviate 'full)
                ivy-rich-switch-buffer-align-virtual-buffer)
           (ivy-rich-switch-buffer-virtual-buffer))
          ((eq ivy-virtual-abbreviate 'full)
           (propertize (abbreviate-file-name str) 'str 'ivy-virtual))
          (t (propertize str 'face 'ivy-virtual)))))

;;;###autoload
(defun +ivy/switch-workspace-buffer (&optional arg)
  "Switch to another buffer within the current workspace.

If ARG (universal argument), open selection in other-window."
  (interactive "P")
  (ivy-read "Switch to workspace buffer: "
            'internal-complete-buffer
            :predicate #'+ivy--is-workspace-or-other-buffer-p
            :action (if arg
                        #'ivy--switch-buffer-other-window-action
                      #'ivy--switch-buffer-action)
            :matcher #'ivy--switch-buffer-matcher
            :keymap ivy-switch-buffer-map
            :caller #'+ivy/switch-workspace-buffer))

(defun +ivy--tasks-candidates (tasks)
  "Generate a list of task tags (specified by `+ivy-task-tags') for
{'fraction_non_alphanumeric': 0.1479882237487733, 'fraction_numerical': 0.0, 'mean_word_length': 2.0643415514131087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '235288', 'n_tokens_mistral': 1607, 'n_tokens_neox': 1563, 'n_words': 326}