Skip to content

Instantly share code, notes, and snippets.

@felko
Last active August 23, 2020 16:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felko/cdb3fc19b3a60db27eb3c5bd319fc479 to your computer and use it in GitHub Desktop.
Save felko/cdb3fc19b3a60db27eb3c5bd319fc479 to your computer and use it in GitHub Desktop.
doom-emacs configuration for neuron-mode
;;; tools/neuron/config.el -*- lexical-binding: t; -*-
(defface neuron-stub-face
'((((class color) (min-colors 88) (background dark)) :foreground "#C16069" :underline "#C16069")
(((class color) (min-colors 88) (background light)) :foreground "#C16069" :underline "#C16069")
(((class color) :foreground "Red" :underline "Red"))
(t :inherit neuron-title-overlay-face))
"Face for stub links."
:group 'neuron-faces)
(customize-set-variable 'neuron-default-zettelkasten-directory (expand-file-name "~/zettelkasten"))
(customize-set-variable 'neuron-default-tags (list "stub"))
(customize-set-variable 'neuron-tag-specific-title-faces '(("stub" neuron-stub-face)))
(defun search-zettelkasten ()
"Search zettels by content."
(interactive)
(progn
(+ivy-file-search :in (neuron-zettelkasten) :recursive nil :prompt "Search Zettelkasten: ")
(neuron-mode)))
(defun find-file-in-zettelkasten ()
"Find a file in the currently active zettelkasten."
(interactive)
(let ((default-directory (neuron-zettelkasten)))
(counsel-find-file)))
(use-package! neuron-mode
; Enable link autocompletion globally
:hook (neuron-mode . company-neuron-setup)
:init
(map! :leader
(:prefix ("z" . "zettel")
"z" #'neuron-new-zettel
"e" #'neuron-edit-zettel
"w" #'neuron-rib-watch
"g" #'neuron-rib-generate
"o" #'neuron-open-zettel
"O" #'neuron-open-index
"j" #'neuron-open-daily-notes
"t" #'neuron-query-tags
"r" #'neuron-refresh
"c" #'neuron-edit-zettelkasten-configuration
;;; Alternatively, bind all rib commands in a separate prefix
;; (:prefix ("r" . "rib")
;; "w" #'neuron-rib-watch
;; "g" #'neuron-rib-generate
;; "s" #'neuron-rib-serve
;; "o" #'neuron-rib-open-zettel
;; "z" #'neuron-rib-open-z-index
;; "k" #'neuron-rib-kill
;; )
)
)
:config
(map! :map neuron-mode-map
:localleader
;; Override markdown-mode's default behavior to handle neuron links
:ni "o" #'neuron-follow-thing-at-point
;; You can also remove the "z" prefix but
;; be careful not to override default
;; markdown-mode bindings.
(:prefix ("z" . "zettel")
:ni "u" #'neuron-edit-uplink
:ni "t" #'neuron-add-tag
:ni "T" #'neuron-add-tags
:ni "o" #'neuron-open-current-zettel
:ni "l" #'neuron-create-and-insert-zettel-link
:v "L" #'neuron-create-zettel-from-selection
:ni "s" #'neuron-insert-static-link
:ni "c" #'neuron-toggle-connection-type
)
)
(map! :leader "sz" #'search-zettelkasten)
(map! :leader "fz" #'find-file-in-zettelkasten)
)
;; -*- no-byte-compile: t; -*-
;;; tools/neuron/packages.el
(package! neuron-mode)
;; For more reproducibility, pin the repo:
;; (package! neuron-mode :pin e1b3e12c71)
;; or run M-x doom/bump-package-at-point to have the latest commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment