Simple neovim zettelkasten functionality as a lua plugin.
Go to file
Marty Oehme fdcb0f2a93
Add opening zettel by reference if no anchor found
Opens zettel by linked value, most often a direct path link, but will
also look through the root dir to find a(n exactly) matching basename to
open.

If nothing is found in the root dir will open a new file to write with
the corresponding name. Careful, if the reference is a full path
definition, and the file does not exist, it will still open the
corresponding file at the correct location but when attempting to save
will generally complain if parts of the path are missing. They have to
be created manually or in some other place, this is outside the scope of
this plugin.
2021-04-30 16:30:52 +02:00
autoload Initial commit 2020-10-26 15:55:40 +01:00
lua/zettelkasten Add opening zettel by reference if no anchor found 2021-04-30 16:30:52 +02:00
plugin Update readme and debug mappings 2021-04-30 13:28:39 +02:00
.gitignore Fix function formatting getting zettel from dir 2021-04-30 15:26:32 +02:00
.tmux.session Fix tmux session nvim command 2020-11-11 22:30:07 +01:00
README.md Add opening zettel by reference if no anchor found 2021-04-30 16:30:52 +02:00

README.md

Zettelkasten.nvim

To develop / debug:

start neovim with nvim --cmd "set rtp+=$(pwd)" . to automatically load the files in project dir as if they were on path

next up: [ ] fix link following:

  • empty space (e.g. in link text, or link itself) disrupts link regex search
  • line-end following breaks if cursor is in the MIDDLE of the link
  • extract anchor from link/string (anchor.lua)
    • probably stop hardcoding anchor regex, make an option
    • implement custom anchor creation function to go with custom regex
  • opening zettel should use generated link table for full filename anchor search
    • need a default zettel directory to look in
  • link following order should be:
    • look up & follow anchor
    • look for filename in current dir (or relative/absolute link loc)
    • implement fallback to filename in any of zettel subdirs

TODO: needed functionality

  • note creation (new anchor)
    • create anchor
      • unique anchor creation
    • create link (md / wiki)
  • note listing (anchors / titles, no anchor)
    • list anchors
    • list filenames
  • link following (to existing anchor)
    • fallback to filename if anchor invalid / not found
  • link creation (to existing note)
    • list existing
    • create link (md / wiki)
  • link switching (point to another existing note)
  • note search (title / full-text)
  • jump to zettel (open existing anchor)
    • select by anchor
    • select by (fuzzy) title match
  • options
  • zettel anchor separator
  • zettel extension
  • link style (wiki/markdown)
  • custom link style?
  • link detection/following (under word, next on line)
  • recursive dir lookup for zettel
  • zettel anchor regex

TODO: nice-to-haves

  • refactor parsers (md/wiki) to be tables of functions/regex in options, so e.g. valid link detection can call options.parser.isValidLink(link) or transformation options.parser.styleLink(anchor, text)
    • use unified parser model (e.g. containing turn-to-link(), parse-link()) function
    • enable custom parser supply
  • completion engine (e.g. for completion-nvim, look in completion_buffers/completion-tags for reference)
  • zettel caching for big directories
  • backlinks (via rg for filename anchor?)
    • keep tree of notes cached?
  • zettel maintenance
    • fix malformed anchors
      • fix-link function which looks for most similar file to be found and renames file/link automatically (after confirmation)
    • add missing anchors
    • 'rename' anchor (goes against stability?)
    • recognize duplicate anchors (in directory, when listing, etc)
      • provide option to rename and automatically change backlinks
  • zettel 'lens' (preview first headline + content of linked zettel through floating window etc, on keypress)
  • support both md-style and wiki-style links at the same time
  • file/directory exception list for gathering files, which will be ignored
  • 'strict' mode only matching and following valid anchor links

TODO: maintenance

  • remove hard-coding of option vimnames in tests, now that we can dynamically change this through a single table

  • anchor creation

    • must be unique
    • default: 10 digits, usually current date+time (YYMMDDHHmm)
    • but, if multiple links created within one minute (or other circumstances), this would duplicate
    • thus, duplicate-check before creating a new anchor
    • if duplicated, generate first non-duplicated link (recursive?)
    • try to move backwards through minutes not forward
      • i.e. if 2030101200 exists move to 2030101159, 2030101158, ...
      • if moving backwards, we do not take away id space from future note creation
      • if moving forwards, every zettel created within a minute would delay next zettel creation another minute
  • to decide: should zettel creation create a zettel in current working dir or at zettel root dir? or set by option?

  • (CODE) switch -- comments to --- doc comments for function descriptions etc

Options

atm:

anchor_separator = vim.g["zettel_anchor_separator"] or vim.b["zettel_anchor_separator"] or "_",
zettel_extension = vim.g["zettel_extension"] or vim.b["zettel_extension"] or ".md",
zettel_root = vim.g["zettel_root"] or vim.b["zettel_root"] or "~/documents/notes",