Wilfred / deadgrep

fast, friendly searching with ripgrep and Emacs
713 stars 46 forks source link

Compatibility with evil-mode? #8

Open ghost opened 6 years ago

ghost commented 6 years ago

Hi, there seem to be issues with evil-mode. Results are returned fine but jumping to results or collapsing results is not possible. Are there plans for support?

jojojames commented 6 years ago

FWIW, I was planning on adding support for deadgrep to evil-collection once I get it working on my setup if @Wilfred was going to skip on compatibility with evil.

Alexander-Miller commented 6 years ago

IMO the necessary glue code is sufficiently simple that it can be placed into an eval-after-load block in deadgrep itself, there's only a handful of keybinds that need to be adjusted.

(with-eval-after-load 'evil
  (evil-define-state deadgrep
    "Evil deadgrep state"
    :cursor 'bar
    :enable (motion))

  (add-hook 'deadgrep-mode-hook #'evil-deadgrep-state)

  (define-key evil-deadgrep-state-map (kbd "<return>") #'deadgrep-visit-result)
  (define-key evil-deadgrep-state-map (kbd "gr") #'deadgrep-restart))

I just need a good idea where to put deadgrep-forward/backward and I can pack this up as a PR.

jojojames commented 6 years ago

Added support for it on evil-collection: https://github.com/emacs-evil/evil-collection/commit/dab8f3836e8939b1b32cf2ed5d381ae0fdd8fd83 as another approach (evil-make-overriding-map like @b3n went with should work too)

IMO the necessary glue code is sufficiently simple that it can be placed into an eval-after-load block in deadgrep itself, there's only a handful of keybinds that need to be adjusted.

I agree for the most part.

Looking at the snippet above, I think evil-collection will need its own compatibility layer for deadgrep either way since that doesn't exactly match how evil-collection does things.

NightMachinery commented 4 years ago

My settings on top of Doom Emacs (which uses evil-collection):

(after! deadgrep
  (map! :map deadgrep-mode-map

        :n "a" #'deadgrep-backward-match
        :n "d" #'deadgrep-forward-match
        :n "o" #'deadgrep-visit-result-other-window
        :n "g r" #'deadgrep-restart)

  (setq-default deadgrep--context (cons 3 3))
  ;; (add-hook 'deadgrep-mode-hook #'zoom-mode)
  (add-hook 'deadgrep-mode-hook #'+word-wrap-mode)
  (night/set-leader-keys "z d" #'deadgrep))

I think this issue can be closed, though a link to it should be included in the readme.

futpib commented 3 years ago

This was a good enough workaround for me:

(evil-set-initial-state 'deadgrep-mode 'emacs)