diff --git a/README.md b/README.md index d8115b0..54bb2cc 100644 --- a/README.md +++ b/README.md @@ -32,13 +32,15 @@ but there's not much here yet. ## Usage -The one mapping you probably want to undertake (replacing the mapping as needed) is: +All exposed functionality of the plugin can be reached either through lua bindings or through vim `` mappings. + +The one mapping you probably want to undertake (replacing the mapping as needed) is the following link mapping: ### Linking ```vim -nnoremap :lua require 'zettelkasten'.open_or_make_link() -vnoremap :lua require 'zettelkasten'.open_or_make_link(true) +nnoremap :lua require 'zettelkasten'.link_follow() +vnoremap :lua require 'zettelkasten'.link_follow(true) ``` This will allow you to create new links when over any text, @@ -52,8 +54,8 @@ The function is also exposed as vim mapping `zettel_link_follow`, so can b set via `map zettel_link_follow` to get the same result as above. ```vim -:lua require 'zettelkasten'.open_link() -:lua require 'zettelkasten'.make_link(visualmode) +:lua require 'zettelkasten'.link_open() +:lua require 'zettelkasten'.link_make(visualmode) ``` allows you to separate the link following and creation set by one function above. @@ -66,7 +68,7 @@ The functions are again exposed as `zettel_link_open` and ### Index ```vim -nnoremap w :lua require 'zettelkasten'.open_index() +nnoremap w :lua require 'zettelkasten'.index_open() ``` allows you to map going to your defined zettel index file. diff --git a/lua/zettelkasten/init.lua b/lua/zettelkasten/init.lua index 40f0c99..2d36c6e 100644 --- a/lua/zettelkasten/init.lua +++ b/lua/zettelkasten/init.lua @@ -17,26 +17,26 @@ end function ZK.get_anchor() return anchor.create() end -- Open link under cursor, or next on line -function ZK.open_link() return action.open_selected() end +function ZK.link_open() return action.open_selected() end -- Create a new link under cursor -function ZK.make_link(visual) return action.make_link(visual) end +function ZK.link_make(visual) return action.make_link(visual) end -- If invoked in reach of a valid link will try to follow said link. -- Otherwise will take the current context and make a link out of it. -function ZK.open_or_make_link(visual) - if not ZK.open_link() then ZK.make_link(visual) end +function ZK.link_follow(visual) + if not ZK.link_open() then ZK.link_make(visual) end end -- Open index file at zettel root directory. If title is passed in opens -- `title`. file, otherwise defaults to `index`.. -function ZK.open_index(title) return action.open_index_file(title) end +function ZK.index_open(title) return action.open_index_file(title) end return { get_zettel_list = ZK.get_zettel_list, get_anchor = ZK.get_anchor, - open_link = ZK.open_link, - make_link = ZK.make_link, - open_or_make_link = ZK.open_or_make_link, - open_index = ZK.open_index + link_open = ZK.link_open, + link_make = ZK.link_make, + link_follow = ZK.link_follow, + index_open = ZK.index_open } diff --git a/plugin/zettelkasten.vim b/plugin/zettelkasten.vim index e0ff01d..53be749 100644 --- a/plugin/zettelkasten.vim +++ b/plugin/zettelkasten.vim @@ -2,14 +2,14 @@ if exists('g:loaded_zettelkasten') finish endif -noremap zettel_link_open :lua require 'zettelkasten'.open_link() +noremap zettel_link_open :lua require 'zettelkasten'.link_open() -nnoremap zettel_link_make :lua require 'zettelkasten'.make_link() -vnoremap zettel_link_make :lua require 'zettelkasten'.make_link(true) +nnoremap zettel_link_make :lua require 'zettelkasten'.link_make() +vnoremap zettel_link_make :lua require 'zettelkasten'.link_make(true) -nnoremap zettel_link_follow :lua require 'zettelkasten'.open_or_make_link() -vnoremap zettel_link_follow :lua require 'zettelkasten'.open_or_make_link(true) +nnoremap zettel_link_follow :lua require 'zettelkasten'.link_follow() +vnoremap zettel_link_follow :lua require 'zettelkasten'.link_follow(true) -nnoremap zettel_index_open :lua require 'zettelkasten'.open_index() +nnoremap zettel_index_open :lua require 'zettelkasten'.index_open() let g:loaded_zettelkasten = 1