finally got search / projectile working as i want it to
This commit is contained in:
parent
0ded2313a3
commit
14b2700fb8
149
emacs/init.el
149
emacs/init.el
|
|
@ -18,21 +18,6 @@
|
||||||
|
|
||||||
(add-hook 'emacs-lisp-mode-hook #'my/setup-elisp-formatting-key)
|
(add-hook 'emacs-lisp-mode-hook #'my/setup-elisp-formatting-key)
|
||||||
|
|
||||||
(defun my/swiper-query-replace ()
|
|
||||||
"Run `query-replace-regexp' on Swiper results."
|
|
||||||
(interactive)
|
|
||||||
(if (not (window-minibuffer-p))
|
|
||||||
(user-error "Call this from swiper")
|
|
||||||
(let* ((enable-recursive-minibuffers t)
|
|
||||||
(from (ivy--regex ivy-text))
|
|
||||||
(to (query-replace-read-to from
|
|
||||||
(concat "Query replace (regexp " from ") with: ")
|
|
||||||
t)))
|
|
||||||
(ivy-exit-with-action
|
|
||||||
(lambda (_)
|
|
||||||
(let ((case-fold-search (ivy--case-fold-p ivy-text)))
|
|
||||||
(query-replace-regexp from to)))))))
|
|
||||||
|
|
||||||
(defun my/visit-todo ()
|
(defun my/visit-todo ()
|
||||||
"Visit TODO.org in home"
|
"Visit TODO.org in home"
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|
@ -55,10 +40,10 @@
|
||||||
(get-text-property 0 'org-hd-marker item)))
|
(get-text-property 0 'org-hd-marker item)))
|
||||||
(line (when marker
|
(line (when marker
|
||||||
(org-with-point-at marker
|
(org-with-point-at marker
|
||||||
(buffer-substring (line-beginning-position) (line-end-position)))))
|
(buffer-substring (line-beginning-position) (line-end-position)))))
|
||||||
(todo-keyword (when marker
|
(todo-keyword (when marker
|
||||||
(org-with-point-at marker
|
(org-with-point-at marker
|
||||||
(org-get-todo-state))))
|
(org-get-todo-state))))
|
||||||
(truncated-line (when line
|
(truncated-line (when line
|
||||||
(replace-regexp-in-string "^\\[#[A-Z]\\] " "" line))))
|
(replace-regexp-in-string "^\\[#[A-Z]\\] " "" line))))
|
||||||
(if truncated-line
|
(if truncated-line
|
||||||
|
|
@ -183,9 +168,6 @@
|
||||||
|
|
||||||
(global-set-key (kbd "<f12>") 'speedbar)
|
(global-set-key (kbd "<f12>") 'speedbar)
|
||||||
(global-set-key (kbd "M-/") 'dabbrev-expand)
|
(global-set-key (kbd "M-/") 'dabbrev-expand)
|
||||||
|
|
||||||
(with-eval-after-load 'swiper
|
|
||||||
(define-key swiper-map (kbd "M-%") #'my/swiper-query-replace))
|
|
||||||
(global-set-key (kbd "C-=") 'multi-vterm-dedicated-toggle)
|
(global-set-key (kbd "C-=") 'multi-vterm-dedicated-toggle)
|
||||||
(global-set-key (kbd "C-x r") 'replace-regexp)
|
(global-set-key (kbd "C-x r") 'replace-regexp)
|
||||||
(global-set-key (kbd "C-x R") 'replace-string)
|
(global-set-key (kbd "C-x R") 'replace-string)
|
||||||
|
|
@ -391,7 +373,6 @@
|
||||||
|
|
||||||
(add-hook 'after-save-hook #'my-compile-init-file)
|
(add-hook 'after-save-hook #'my-compile-init-file)
|
||||||
|
|
||||||
;; fuzzy find
|
|
||||||
(use-package orderless
|
(use-package orderless
|
||||||
:ensure t
|
:ensure t
|
||||||
:custom
|
:custom
|
||||||
|
|
@ -488,51 +469,87 @@
|
||||||
;;(add-to-list 'completion-at-point-functions #'cape-line)
|
;;(add-to-list 'completion-at-point-functions #'cape-line)
|
||||||
)))
|
)))
|
||||||
|
|
||||||
;; better search
|
;; better search
|
||||||
(use-package consult
|
(use-package consult
|
||||||
:ensure t
|
:ensure t
|
||||||
:bind (("C-s" . consult-line)
|
:demand t
|
||||||
("C-r" . consult-line-multi)
|
:bind (("C-s" . consult-line)
|
||||||
("C-c h" . consult-history)
|
("C-r" . consult-line-multi)
|
||||||
("C-c m" . consult-mode-command)
|
("C-c h" . consult-history)
|
||||||
("C-c k" . consult-kmacro)
|
("C-c m" . consult-mode-command)
|
||||||
("C-c C-h" . consult-mode-histories)
|
("C-c k" . consult-kmacro)
|
||||||
;; Add keybindings for ripgrep-related commands
|
("C-c C-h" . consult-mode-histories)
|
||||||
("C-c s" . consult-ripgrep)
|
;; Add keybindings for ripgrep-related commands
|
||||||
("C-c C-s" . consult-ripgrep-multi))
|
("C-c s" . consult-ripgrep)
|
||||||
:custom
|
("C-c C-s" . consult-ripgrep-multi))
|
||||||
(consult-preview-key nil) ; Disable preview
|
:custom
|
||||||
|
(consult-preview-key nil) ; Disable preview
|
||||||
:config
|
|
||||||
;; Configure ripgrep for consult
|
:config
|
||||||
(setq consult-ripgrep-command "rg --null --line-buffered --color=ansi --max-columns=1000 --no-heading --line-number . -e ARG OPTS")
|
;; Configure ripgrep for consult
|
||||||
|
(setq consult-ripgrep-command "rg --null --line-buffered --color=ansi --max-columns=1000 --no-heading --line-number . -e ARG OPTS")
|
||||||
;; Use ripgrep for `consult-grep` as well
|
|
||||||
(setq consult-grep-command "rg --null --line-buffered --color=ansi --max-columns=1000 --no-heading --line-number . -e ARG OPTS")
|
;; Use ripgrep for `consult-grep` as well
|
||||||
|
(setq consult-grep-command "rg --null --line-buffered --color=ansi --max-columns=1000 --no-heading --line-number . -e ARG OPTS")
|
||||||
;; Configure mode-specific histories
|
|
||||||
(setq consult-mode-histories
|
;; Configure mode-specific histories
|
||||||
'((comint-mode . comint-input-ring)
|
(setq consult-mode-histories
|
||||||
(eshell-mode . eshell-history-ring)
|
'((comint-mode . comint-input-ring)
|
||||||
(geiser-repl-mode . geiser-repl--history)
|
(eshell-mode . eshell-history-ring)
|
||||||
(inferior-python-mode . comint-input-ring)
|
(geiser-repl-mode . geiser-repl--history)
|
||||||
(minibuffer-local-map . consult-history)))
|
(inferior-python-mode . comint-input-ring)
|
||||||
|
(minibuffer-local-map . consult-history)))
|
||||||
|
|
||||||
(consult-customize
|
(consult-customize
|
||||||
consult-theme
|
consult-theme
|
||||||
:preview-key '(:debounce 0.2 any)
|
:preview-key '(:debounce 0.2 any)
|
||||||
consult-ripgrep consult-git-grep consult-grep
|
consult-ripgrep consult-git-grep consult-grep
|
||||||
consult-bookmark consult-recent-file consult-xref
|
consult-bookmark consult-recent-file consult-xref
|
||||||
consult--source-bookmark consult--source-recent-file
|
consult--source-bookmark consult--source-recent-file
|
||||||
consult--source-project-recent-file
|
consult--source-project-recent-file
|
||||||
:preview-key '(:debounce 0.4 any))
|
:preview-key '(:debounce 0.4 any))
|
||||||
|
|
||||||
;; Configure async search for better performance
|
;; Configure async search for better performance
|
||||||
(setq consult-async-min-input 2)
|
(setq consult-async-min-input 2)
|
||||||
(setq consult-async-refresh-delay 0.15)
|
(setq consult-async-refresh-delay 0.15)
|
||||||
(setq consult-async-input-throttle 0.2)
|
(setq consult-async-input-throttle 0.2)
|
||||||
(setq consult-async-input-debounce 0.1)
|
(setq consult-async-input-debounce 0.1)
|
||||||
|
|
||||||
;; Use Consult to select xref locations with preview
|
;; Use Consult to select xref locations with preview
|
||||||
(setq xref-show-xrefs-function #'consult-xref
|
(setq xref-show-xrefs-function #'consult-xref
|
||||||
xref-show-definitions-function #'consult-xref))
|
xref-show-definitions-function #'consult-xref))
|
||||||
|
|
||||||
|
(use-package projectile
|
||||||
|
:ensure t
|
||||||
|
:config
|
||||||
|
(projectile-mode +1)
|
||||||
|
:bind-keymap
|
||||||
|
("C-x p" . projectile-command-map)
|
||||||
|
:bind (:map projectile-command-map
|
||||||
|
("f" . consult-projectile-find-file)
|
||||||
|
("d" . consult-projectile-find-dir)
|
||||||
|
("b" . consult-projectile-switch-to-buffer)
|
||||||
|
("s" . consult-projectile-switch-project)
|
||||||
|
("p" . consult-projectile)
|
||||||
|
("g" . consult-ripgrep)))
|
||||||
|
|
||||||
|
(use-package consult-projectile
|
||||||
|
:ensure t
|
||||||
|
:after (consult projectile)
|
||||||
|
:config
|
||||||
|
;; Override projectile functions with consult-projectile functions
|
||||||
|
(advice-add 'projectile-find-file :override #'consult-projectile-find-file)
|
||||||
|
(advice-add 'projectile-find-dir :override #'consult-projectile-find-dir)
|
||||||
|
(advice-add 'projectile-switch-to-buffer :override #'consult-projectile-switch-to-buffer)
|
||||||
|
(advice-add 'projectile-switch-project :override #'consult-projectile-switch-project)
|
||||||
|
|
||||||
|
;; Custom function to always use consult-projectile-find-file
|
||||||
|
(defun my-consult-projectile-find-file ()
|
||||||
|
"Use consult-projectile-find-file, falling back to consult-projectile if not in a project."
|
||||||
|
(interactive)
|
||||||
|
(if (projectile-project-p)
|
||||||
|
(consult-projectile-find-file)
|
||||||
|
(consult-projectile)))
|
||||||
|
|
||||||
|
;; Replace the keybinding in projectile-command-map
|
||||||
|
(define-key projectile-command-map (kbd "f") #'my-consult-projectile-find-file))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue