This commit is contained in:
foozzi 2024-08-18 16:57:33 +02:00
parent 4396724c36
commit bbf6f65419
20 changed files with 359 additions and 114 deletions

View file

@ -1,3 +1,5 @@
local mapvimkey = require("utils.keymapper").mapvimkey
local M = {}
function M.InsertMarkdownURL()
@ -29,4 +31,33 @@ function M.InsertMarkdownURL()
end
end
-- inserting zettelkasten link with an id
function M.insert_zk_id()
local handle = io.popen("eton zk id")
local id = handle:read("*a")
handle:close()
id = id:gsub("%s+", "")
local insert_text = string.format("[](%s.md)", id)
vim.api.nvim_put({ insert_text }, "c", true, true)
vim.api.nvim_feedkeys("i", "n", true)
end
function M.get_relative_path(from, to)
local from_dir = vim.fn.fnamemodify(from, ":p:h")
local to_file = vim.fn.fnamemodify(to, ":p")
local from_parts = vim.split(from_dir, "/")
local to_parts = vim.split(to_file, "/")
while #from_parts > 0 and #to_parts > 0 and from_parts[1] == to_parts[1] do
table.remove(from_parts, 1)
table.remove(to_parts, 1)
end
local relative_path = string.rep("../", #from_parts) .. table.concat(to_parts, "/")
return relative_path
end
return M