mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-22 08:04:20 +01:00
Use upstream consult-fd
and add consult-flycheck
Signed-off-by: magic_rb <magic_rb@redalder.org>
This commit is contained in:
parent
97941f8724
commit
7591491b00
|
@ -30,76 +30,12 @@ Consult provides practical commands based on the Emacs completion function compl
|
|||
consult-find-args "find ."))
|
||||
#+END_SRC
|
||||
|
||||
Also enable ~fd~ support, as that ignores paths listed in .gitignore unlike ~find~..
|
||||
* Flycheck
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package consult-fd
|
||||
:no-require t
|
||||
:after (consult)
|
||||
:init
|
||||
(defvar consult--fd-command "fd")
|
||||
|
||||
(defun list-interject (list separator)
|
||||
(let ((next list))
|
||||
(dotimes (_ (length (cdr list)))
|
||||
(setcdr next (cons separator (cdr next)))
|
||||
(setq next (cddr next)))))
|
||||
|
||||
(defmacro uncons (car-name cdr-name cell)
|
||||
`(progn
|
||||
(setq ,car-name (car ,cell))
|
||||
(setq ,cdr-name (cdr ,cell))
|
||||
nil))
|
||||
|
||||
(defmacro let-uncons-1 (car-name cdr-name cell &rest body)
|
||||
`(let ((--let-uncons-1-- ,cell) ,car-name ,cdr-name)
|
||||
(uncons ,car-name ,cdr-name --let-uncons-1--)
|
||||
,@body))
|
||||
|
||||
(defmacro let-uncons (uncons-list &rest body)
|
||||
(let* ((forms (list 'unused)) (next-form nil) (last-form forms))
|
||||
(while uncons-list
|
||||
(let-unpack-1 (car-name cdr-name cell) uncons-list
|
||||
(setq next-form `(let-uncons-1 ,car-name ,cdr-name ,cell))
|
||||
(setcdr (last last-form) (list next-form))
|
||||
(setq last-form next-form))
|
||||
(setq uncons-list (cdddr uncons-list)))
|
||||
(setcdr (last last-form) body)
|
||||
(cadr forms)))
|
||||
(defmacro unpack (names list)
|
||||
`(let ((--unpack-- ,list))
|
||||
(dolist (name ',names)
|
||||
(eval (list 'setq name '(car --unpack--)))
|
||||
(setq --unpack-- (cdr --unpack--)))))
|
||||
|
||||
(defmacro let-unpack-1 (names list &rest body)
|
||||
`(let ((--let-unpack-1-- ,list) ,@names)
|
||||
(unpack ,names --let-unpack-1--)
|
||||
,@body))
|
||||
(defmacro let-unpack (unpack-list &rest body)
|
||||
(let* ((forms (list 'unused)) (next-form nil) (last-form forms))
|
||||
(while unpack-list
|
||||
(let-unpack-1 (names list) unpack-list
|
||||
(setq next-form `(let-unpack-1 ,names ,list))
|
||||
(setcdr (last last-form) (list next-form))
|
||||
(setq last-form next-form))
|
||||
(setq unpack-list (cddr unpack-list)))
|
||||
(setcdr (last last-form) body)
|
||||
(cadr forms)))
|
||||
(defun consult-fd (&optional directory initial-query) (interactive "P")
|
||||
(let-unpack ((prompt paths directory)
|
||||
(consult--directory-prompt "Fd" directory))
|
||||
(let* ((default-directory directory)
|
||||
(file (consult--find
|
||||
prompt 'consult--fd-builder initial-query)))
|
||||
(find-file file))))
|
||||
(defun consult--fd-builder (query)
|
||||
(let-uncons (patterns options (consult--command-split query)
|
||||
patterns highlight-function (funcall
|
||||
consult--regexp-compiler patterns 'extended t))
|
||||
(when patterns
|
||||
(list-interject patterns "--and")
|
||||
(cons
|
||||
`(,consult--fd-command "--color=never" "--full-path" ,@patterns ,@options)
|
||||
highlight-function)))))
|
||||
(use-package consult-flycheck
|
||||
:straight t)
|
||||
#+end_src
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue