Made the names of the functions to invoke the plugin the same.
This is a BREAKING change if using the lua mappings.
On the other hand, it should stay pretty stable for the foreseeable
future, with only new ones added and possibly vim commands added.
Call up `require 'zettelkasten'.open_index()` to open the file.
Pass along a file name `require 'zettelkasten'.open_index('home')` to
open said file at the zettel root instead.
Automatically chooses whether to create a new link or go to an existing
file, depending on the existence of a link in the current context (i.e.
under the cursor or in selection).
Should prepare the differentiation between a 'new' link and linking an
existing zetttel -- one is 'new_link' and one just 'makes_link' to
something else.
Switched out manual BIGNUMBER creation for the lua inbuilt `math.huge`.
Refactored `open_selected` a tiny bit in preparation for automatic link
creation.
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.
Unify the definitions of the two function to take a set of files instead
of different arguments. The list of files has the form:
files = { "full/path/name.md" = "name.md" }
I.e. the complete path is the key and the file basename the value,
leading to a set of files, even if basenames are the same.
Usually it will be created by the get_all_files function of the same
module, but it can be passed in manually as well (e.g. to avoid
duplicate filesystem lookups, etc).
Renamed to 'files.lua' since it is the only module actively working on
the underlying filesystem so far -- gathering existing files and zettel
in the directories.
`anchor.extract(string, anchor)` will find and extract a zettel anchor
from any string passed in.
It can be given an optional anchor regex which will supersede any regex
set in the plugin options.
Both link creation and extraction, all derived from parser
functionality, should run within the link module and actions should only
make use of it to invoke editor functionality.
Open actions now make use of a 'link' data structure containing a text
and ref string, and the respective start and end positions on the line.
Additionally, parsers are now simple objects containing extraction regex
for extracting their text and ref link individually.
Now reads from an existing defaults table, which has the required keys:
'vimname', the setting name in vim itself (for the user)
'default', the value it should contain by default
and the optional key
'valid', if the option should be restricted to a certain valid value set
By choosing 'line' in the `zettel_link_following` option, the link to be
opened will be searched for on the complete rest of the line, meaning
from the cursor to the newline symbol onwards.
`g:zettel_link_following` can be set to `cursor` or `line` to change the
way zk detect the closest link to follow to (or create a new link for).
Setting it to `cursor` will look for the current word under the cursor and
decide if it is a followable link. `line` will look from the current
cursor position to the end of the line instead.
Action module contains the interactions the user can take directly with
the zettelkasten, and which in turn act on the editor.
First action to be taken is the opening of zettel links.
`action.open(mytext)` allows the user to pass in a md/wikilink-formatted
string from which the function will open the first found in the current
buffer.
`action.open_selected()` does the same, but looks at the cursor context
to get its string (the link under current cursor position as of now; in
the future probably also the next link on current line, and the first
link in visual selection)
Function takes an anchor (and optional link text and formatting style)
and transforms the input into a link to an anchor id.
Currently works for markdown and wikilink style link transforms.