20240818
This commit is contained in:
parent
4396724c36
commit
bbf6f65419
20 changed files with 359 additions and 114 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue