Rename create_link to make_link
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.
This commit is contained in:
parent
2ff3a0b299
commit
1a58909e94
4 changed files with 21 additions and 16 deletions
|
@ -4,6 +4,12 @@ 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
|
||||
|
||||
## up next
|
||||
|
||||
* automatic switch between follow link / create link
|
||||
* text.lua testing
|
||||
* action.lua testing?
|
||||
|
||||
## TODO: needed functionality
|
||||
|
||||
* [ ] note creation (new anchor)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
local A = {}
|
||||
|
||||
local o = require 'zettelkasten.options'
|
||||
local l = require 'zettelkasten.link'
|
||||
local f = require 'zettelkasten.files'
|
||||
local l = require 'zettelkasten.link'
|
||||
local o = require 'zettelkasten.options'
|
||||
local t = require 'zettelkasten.text'
|
||||
|
||||
-- Opens the link passed in in the editor's current buffer.
|
||||
|
@ -19,15 +19,15 @@ end
|
|||
-- Takes an optional style of link following to use,
|
||||
-- superseding the one set in options.
|
||||
function A.open_selected(style)
|
||||
local st = style or o.link().following
|
||||
style = style or o.link().following
|
||||
|
||||
local curpos = vim.api.nvim_win_get_cursor(0)[2]
|
||||
local links = l.extract_all(vim.api.nvim_get_current_line())
|
||||
|
||||
local ln
|
||||
if st == 'line' then
|
||||
if style == 'line' then
|
||||
ln = t.get_next_link_on_line(links, curpos)
|
||||
elseif st == 'cursor' then
|
||||
elseif style == 'cursor' then
|
||||
ln = t.get_link_under_cursor(links, curpos)
|
||||
end
|
||||
|
||||
|
@ -37,7 +37,7 @@ end
|
|||
-- Replaces the current text context with a link to a new zettel.
|
||||
-- The current context is the visual selection (if called from visual mode)
|
||||
-- or the (big) word under the cursor if called from any other mode.
|
||||
function A.link(visual)
|
||||
function A.make_link(visual)
|
||||
local selection, start_col
|
||||
if visual or vim.api.nvim_get_mode()['mode'] == "v" then
|
||||
selection, start_col = t.get_current_selection()
|
||||
|
@ -48,4 +48,4 @@ function A.link(visual)
|
|||
start_col))
|
||||
end
|
||||
|
||||
return {open = A.open, open_selected = A.open_selected, link = A.link}
|
||||
return {open = A.open, open_selected = A.open_selected, make_link = A.make_link}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
local ZK = {}
|
||||
|
||||
local ls = require 'zettelkasten.files'
|
||||
local o = require 'zettelkasten.options'
|
||||
local f = require 'zettelkasten.files'
|
||||
local anchor = require 'zettelkasten.anchor'
|
||||
local action = require 'zettelkasten.action'
|
||||
|
||||
|
@ -10,7 +9,7 @@ local action = require 'zettelkasten.action'
|
|||
-- table.
|
||||
-- Recurses into subdirectories if recursive argument is true.
|
||||
function ZK.get_zettel_list(path, recursive)
|
||||
return ls.get_anchors_and_paths(ls.get_all_files(path, recursive or false))
|
||||
return f.get_anchors_and_paths(f.get_all_files(path, recursive or false))
|
||||
end
|
||||
|
||||
-- Return a valid zettelkasten anchor for the current time,
|
||||
|
@ -21,11 +20,11 @@ function ZK.get_anchor() return anchor.create() end
|
|||
function ZK.open_link() return action.open_selected() end
|
||||
|
||||
-- Create a new link under cursor
|
||||
function ZK.create_link(visual) return action.link(visual) end
|
||||
function ZK.make_link(visual) return action.make_link(visual) end
|
||||
|
||||
return {
|
||||
get_zettel_list = ZK.get_zettel_list,
|
||||
get_anchor = ZK.get_anchor,
|
||||
open_link = ZK.open_link,
|
||||
create_link = ZK.create_link
|
||||
make_link = ZK.make_link
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ vnoremap <Plug>zettel_link_open :lua require 'zettelkasten'.open_link()<cr>
|
|||
nmap <leader>i <Plug>zettel_link_open
|
||||
vmap <leader>i <Plug>zettel_link_open
|
||||
|
||||
nnoremap <Plug>zettel_link_create :lua require 'zettelkasten'.create_link()<cr>
|
||||
vnoremap <Plug>zettel_link_create :lua require 'zettelkasten'.create_link(true)<cr>
|
||||
nmap <leader>o <Plug>zettel_link_create
|
||||
vmap <leader>o <Plug>zettel_link_create
|
||||
nnoremap <Plug>zettel_link_make :lua require 'zettelkasten'.make_link()<cr>
|
||||
vnoremap <Plug>zettel_link_make :lua require 'zettelkasten'.make_link(true)<cr>
|
||||
nmap <leader>o <Plug>zettel_link_make
|
||||
vmap <leader>o <Plug>zettel_link_make
|
||||
|
||||
let g:loaded_zettelkasten = 1
|
||||
|
|
Loading…
Reference in a new issue