Skip to content
This repository has been archived by the owner on Dec 25, 2024. It is now read-only.

Integrate keybindings for delve v2 with evil or doom #3

Open
publicimageltd opened this issue Nov 14, 2020 · 9 comments
Open

Integrate keybindings for delve v2 with evil or doom #3

publicimageltd opened this issue Nov 14, 2020 · 9 comments
Labels
enhancement New feature or request

Comments

@publicimageltd
Copy link
Owner

This is an issue thread to add evil keybindings to delve. There has been one proposal yet; if there are any other suggestions or improvements, feel free to post them here. Eventually, I will include the most approved and affirmed solution into the source code. I don't use evil, and I am not really willing to install it and to learn to use it, so please help me to do this "blindly"!

@publicimageltd publicimageltd added the enhancement New feature or request label Nov 14, 2020
@publicimageltd
Copy link
Owner Author

publicimageltd commented Nov 14, 2020

Here's a doom-specific solution posted by @oatmealm:

(use-package! delve
  :bind (("<f12>" . delve-open-or-select))
  :config
  (set-evil-initial-state! 'delve-mode 'insert)
  (map! :map delve-mode-map
        :n "gr"      #'delve-refresh-buffer
        :n "<right>" #'delve-expand-insert-tolinks
        :n "<left>"  #'devle-expand-insert-backlinks
        :localleader
        "RET"  #'lister-key-action
        "TAB"  #'delve-expand-toggle-sublist)
  (use-package! delve-minor-mode
    :hook (org-roam-mode . delve-minor-mode-maybe-activate)))

@oatmealm
Copy link

oatmealm commented Nov 14, 2020

Mind you this is a doom specific code. I think the right way to go would be to add a snippet via the evil-collection package, which is more generic and also supported in doom via the evil-everywhere flag. I've looked at evil-collection once to get an idea, and it seems straight forward enough. I'll see if I can find the time to create a snippet and send them pull request.

@publicimageltd
Copy link
Owner Author

I don't even know the difference between evil and doom that's all greek to me :-) So yes, a more generic solution would be preferable, of course, take your time!

@publicimageltd publicimageltd changed the title Integrate with evil keybindings Integrate keybindings with evil or doom Nov 15, 2020
@natask
Copy link
Contributor

natask commented Mar 10, 2021

more generic until evil-collection.

(evil-define-key* '(normal insert) delve-mode-map
  (kbd "<return>") #'lister-key-action
  (kbd "<tab>") #'delve-expand-toggle-sublist
  (kbd "gr") #'delve-revert
  (kbd "sm") #'delve-sort-buffer-by-mtime
  (kbd "sa") #'delve-sort-buffer-by-atime
  (kbd "sc") #'delve-sort-buffer-by-ctime
  (kbd "<right>") #'delve-expand-insert-tolinks
  (kbd "<left>")  #'delve-expand-insert-backlinks
  (kbd "c") #'delve-collect
  (kbd "q") #'delve-kill-buffer)

@publicimageltd
Copy link
Owner Author

@natask thanks for the snippet! Out of curiosity, you seem to have added a function to sort the buffer contents by {m/a/c}-time. Would you mind sharing it or even add a PR? Seems like a useful extension, didn't think of it.

@natask
Copy link
Contributor

natask commented Mar 10, 2021

@publicimageltd sure. A couple points, ctime isn't supported officially. I have changed the ui to display all three times which clutters the ui but I don't mind. Also sorting doesn't preserve sublists. It maybe possible by using lister-get-all-tree and -treemap but I haven't gotten around to doing that. Feel free to only take stuff you think will be useful for this repo.

(defun delve-sort-buffer-function (buf function)
  "sort all items in BUF by FUNCTION."
  (when-let* ((all-data (lister-get-all-data buf))
              (head (car all-data))
              (tail (cdr all-data)))
    (lister-with-locked-cursor buf
      (with-temp-message "Updating the whole buffer, that might take some time...."
	(lister-set-list buf (cons head (funcall function  tail)))))))

@publicimageltd
Copy link
Owner Author

Closed since this discussion refers to an outdated version

@tefkah
Copy link

tefkah commented Nov 14, 2021

I would also really like some more doom/evil specific integration, as currently I need to set this up myself (haven't taken the time do so, atm just using M-x delve--key--insert-node like a caveman haha).

I will try to find a decent set of keybindings and make PR!

@publicimageltd publicimageltd changed the title Integrate keybindings with evil or doom Integrate keybindings for delve v2 with evil or doom Nov 14, 2021
@publicimageltd
Copy link
Owner Author

I would love to find an abstract way to do this. Maybe the doom map could just remap the original bindings?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants