Refactor +ivy--file-search & +ivy docstrings
This commit is contained in:
parent
d3a6a8317b
commit
edeea02de3
2 changed files with 25 additions and 23 deletions
|
@ -20,10 +20,10 @@
|
|||
(defvar +ivy--file-search-all-files-p nil)
|
||||
|
||||
(defun +ivy--file-search (engine beg end query &optional directory)
|
||||
(let* ((directory (or directory (doom-project-root)))
|
||||
(let* ((project-root (doom-project-root))
|
||||
(directory (or directory project-root))
|
||||
(recursion-p +ivy--file-search-recursion-p)
|
||||
(all-files-p +ivy--file-search-all-files-p)
|
||||
(project-root (doom-project-root))
|
||||
(query
|
||||
(or query
|
||||
(and beg end
|
||||
|
@ -40,24 +40,22 @@
|
|||
(t
|
||||
(file-relative-name directory project-root))))))
|
||||
(setq +ivy--file-last-search query)
|
||||
(cond ((eq engine 'ag)
|
||||
(let ((args (concat
|
||||
(if all-files-p " -a")
|
||||
(unless recursion-p " -n"))))
|
||||
(counsel-ag query directory args (format prompt args))))
|
||||
|
||||
((eq engine 'rg)
|
||||
;; smart-case instead of case-insensitive flag
|
||||
(let ((counsel-rg-base-command
|
||||
(replace-regexp-in-string " -i " " -S " counsel-rg-base-command))
|
||||
(args (concat
|
||||
(if all-files-p " -uu")
|
||||
(unless recursion-p " --maxdepth 0"))))
|
||||
(counsel-rg query directory args (format prompt args))))
|
||||
|
||||
((eq engine 'pt)) ; TODO pt search engine (necessary?)
|
||||
|
||||
(t (error "No search engine specified")))))
|
||||
(pcase engine
|
||||
('ag
|
||||
(let ((args (concat
|
||||
(if all-files-p " -a")
|
||||
(unless recursion-p " -n"))))
|
||||
(counsel-ag query directory args (format prompt args))))
|
||||
('rg
|
||||
;; smart-case instead of case-insensitive flag
|
||||
(let ((counsel-rg-base-command
|
||||
(replace-regexp-in-string " -i " " -S " counsel-rg-base-command))
|
||||
(args (concat
|
||||
(if all-files-p " -uu")
|
||||
(unless recursion-p " --maxdepth 0"))))
|
||||
(counsel-rg query directory args (format prompt args))))
|
||||
('pt) ;; TODO pt search engine (necessary?)
|
||||
(_ (error "No search engine specified")))))
|
||||
|
||||
;;;###autoload (autoload '+ivy:ag "completion/ivy/autoload/evil" nil t)
|
||||
(evil-define-operator +ivy:ag (beg end query &optional all-files-p directory)
|
||||
|
|
|
@ -49,14 +49,18 @@
|
|||
|
||||
;;;###autoload
|
||||
(defun +ivy/switch-workspace-buffer (&optional other-window-p)
|
||||
"Switch to an open buffer in the current workspace."
|
||||
"Switch to an open buffer in the current workspace.
|
||||
|
||||
If OTHER-WINDOW-P (universal arg), then open target in other window."
|
||||
(interactive "P")
|
||||
(+ivy/switch-buffer other-window-p t))
|
||||
|
||||
;;;###autoload
|
||||
(defun +ivy/switch-buffer (&optional other-window-p workspace-only-p)
|
||||
"Switch to an open buffer in the global buffer list. If WORKSPACE-ONLY-P,
|
||||
limit to buffers in the current workspace."
|
||||
"Switch to an open buffer in the global buffer list.
|
||||
|
||||
If OTHER-WINDOW-P (universal arg), then open target in other window.
|
||||
If WORKSPACE-ONLY-P (universal arg), limit to buffers in the current workspace."
|
||||
(interactive "P")
|
||||
(ivy-read (format "%s buffers: " (if workspace-only-p "Workspace" "Global"))
|
||||
(+ivy--get-buffers (unless workspace-only-p (buffer-list)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue