20250118.1737193804
This commit is contained in:
parent
8a3b7f577a
commit
e6ca1a41e7
17 changed files with 43 additions and 398 deletions
|
@ -1,50 +1,5 @@
|
||||||
local zettelkasten_dir = require("core.options").zettelkasten_dir
|
|
||||||
local pkm_dir = require("core.options").pkm_dir
|
|
||||||
-- inserting a link with a title
|
|
||||||
vim.api.nvim_set_keymap(
|
|
||||||
"n",
|
|
||||||
"<leader>mdp",
|
|
||||||
":lua require('utils.helpers').InsertMarkdownURL()<CR>",
|
|
||||||
{ silent = true, noremap = true }
|
|
||||||
)
|
|
||||||
-- formattig a markdown table
|
-- formattig a markdown table
|
||||||
vim.api.nvim_set_keymap("n", "<leader>ftt", ":TableFormat<CR>", { silent = true, noremap = true })
|
vim.api.nvim_set_keymap("n", "<leader>ftt", ":TableFormat<CR>", { silent = true, noremap = true })
|
||||||
|
|
||||||
-- inserting zettelkasten id (eton)
|
|
||||||
vim.api.nvim_set_keymap(
|
|
||||||
"n",
|
|
||||||
"<leader>fl",
|
|
||||||
":lua require('utils.helpers').insert_zk_id()<CR>",
|
|
||||||
{ silent = true, noremap = true }
|
|
||||||
)
|
|
||||||
|
|
||||||
-- inserting markdown link with uniq name
|
|
||||||
vim.api.nvim_set_keymap(
|
|
||||||
"n",
|
|
||||||
"<leader>vwl",
|
|
||||||
":lua require('utils.wiki_link').insert_link_with_unique_id()<CR>",
|
|
||||||
{ silent = true, noremap = true }
|
|
||||||
)
|
|
||||||
|
|
||||||
-- vim.api.nvim_create_user_command("SearchZettelTitle", function()
|
|
||||||
-- M.search_raw_title({ search_dir = "/Users/fz0x1/Dropbox/TextSync/PKM/00-zettelkasten/" })
|
|
||||||
-- end, {})
|
|
||||||
-- mapvimkey("<leader>fm", "SearchZettelTitle", "Search by zettel title")
|
|
||||||
vim.api.nvim_set_keymap(
|
|
||||||
"n",
|
|
||||||
"<leader>fm",
|
|
||||||
":lua require('utils.telescope_addons').search_raw_title({ search_dir = '"
|
|
||||||
.. zettelkasten_dir
|
|
||||||
.. "', type = 'zettel' })<CR>",
|
|
||||||
{ silent = true, noremap = true }
|
|
||||||
)
|
|
||||||
vim.api.nvim_set_keymap(
|
|
||||||
"n",
|
|
||||||
"<leader>fk",
|
|
||||||
":lua require('utils.telescope_addons').search_raw_title({ search_dir = '" .. pkm_dir .. "' })<CR>",
|
|
||||||
{ silent = true, noremap = true }
|
|
||||||
)
|
|
||||||
|
|
||||||
vim.opt_local.textwidth = 80
|
vim.opt_local.textwidth = 80
|
||||||
vim.opt_local.colorcolumn = "80"
|
vim.opt_local.colorcolumn = "80"
|
||||||
-- vim.opt_local.wrap = true
|
-- vim.opt_local.wrap = true
|
||||||
|
|
|
@ -51,10 +51,3 @@ local api = vim.api
|
||||||
-- Comments
|
-- Comments
|
||||||
api.nvim_set_keymap("n", "<C-_>", "gtc", { noremap = false })
|
api.nvim_set_keymap("n", "<C-_>", "gtc", { noremap = false })
|
||||||
api.nvim_set_keymap("v", "<C-_>", "goc", { noremap = false })
|
api.nvim_set_keymap("v", "<C-_>", "goc", { noremap = false })
|
||||||
|
|
||||||
-- Zen mode
|
|
||||||
api.nvim_set_keymap("n", "<leader>tw", ":Twilight<CR>", {})
|
|
||||||
api.nvim_set_keymap("n", "<leader>zm", ":ZenMode<CR>", {})
|
|
||||||
|
|
||||||
-- back to the "parent" buffer
|
|
||||||
api.nvim_set_keymap("n", "<BS>", "<C-^>", { noremap = true, silent = true })
|
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
if not vim.loop.fs_stat(lazypath) then
|
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||||
vim.fn.system({
|
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||||
"git",
|
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||||
"clone",
|
if vim.v.shell_error ~= 0 then
|
||||||
"--filter=blob:none",
|
vim.api.nvim_echo({
|
||||||
"https://github.com/folke/lazy.nvim.git",
|
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||||
"--branch=stable", -- latest stable release
|
{ out, "WarningMsg" },
|
||||||
lazypath,
|
{ "\nPress any key to exit..." },
|
||||||
})
|
}, true, {})
|
||||||
|
vim.fn.getchar()
|
||||||
|
os.exit(1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
@ -33,6 +36,7 @@ local opts = {
|
||||||
"zipPlugin",
|
"zipPlugin",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
checker = { enabled = true },
|
||||||
change_detection = {
|
change_detection = {
|
||||||
notify = false,
|
notify = false,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
local opt = vim.opt
|
local opt = vim.opt
|
||||||
local api = vim.api
|
-- local api = vim.api
|
||||||
|
|
||||||
local M = {}
|
|
||||||
|
|
||||||
-- Tab / Indentation
|
-- Tab / Indentation
|
||||||
opt.tabstop = 4
|
opt.tabstop = 4
|
||||||
|
@ -47,6 +45,7 @@ vim.opt.wildignore:append({
|
||||||
"*/dist/*",
|
"*/dist/*",
|
||||||
"*/venv/*",
|
"*/venv/*",
|
||||||
"*/__pycache__/*",
|
"*/__pycache__/*",
|
||||||
|
"*/.stfolder/*",
|
||||||
})
|
})
|
||||||
opt.splitkeep = "cursor"
|
opt.splitkeep = "cursor"
|
||||||
opt.shell = "zsh"
|
opt.shell = "zsh"
|
||||||
|
@ -67,8 +66,6 @@ opt.iskeyword:append("-")
|
||||||
opt.mouse = ""
|
opt.mouse = ""
|
||||||
opt.clipboard:append("unnamedplus")
|
opt.clipboard:append("unnamedplus")
|
||||||
opt.modifiable = true
|
opt.modifiable = true
|
||||||
-- opt.guicursor =
|
|
||||||
-- "n-v-c:block,i-ci-ve:block,r-cr:hor20,o:hor50,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor,sm:block-blinkwait175-blinkoff150-blinkon175"
|
|
||||||
opt.encoding = "UTF-8"
|
opt.encoding = "UTF-8"
|
||||||
opt.fileencoding = "utf-8"
|
opt.fileencoding = "utf-8"
|
||||||
opt.cursorline = false
|
opt.cursorline = false
|
||||||
|
@ -150,9 +147,3 @@ vim.opt.langmap = {
|
||||||
"Ю>",
|
"Ю>",
|
||||||
"Ё/",
|
"Ё/",
|
||||||
}
|
}
|
||||||
|
|
||||||
M.zettelkasten_dir = vim.fn.expand("~/PKM/01 - zettelkasten/")
|
|
||||||
M.resources_dir = vim.fn.expand("~/PKM/05 - resources/")
|
|
||||||
M.pkm_dir = vim.fn.expand("~/PKM/")
|
|
||||||
|
|
||||||
return M
|
|
||||||
|
|
|
@ -152,9 +152,9 @@ local config = function()
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
-- ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
-- ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||||
["<Tab>"] = cmp.mapping.select_next_item(cmp_select),
|
["<Tab>"] = cmp.mapping.select_next_item(cmp_select),
|
||||||
["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
|
-- ["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
|
||||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||||
["<C-Space>"] = cmp.mapping.complete(),
|
-- ["<C-Space>"] = cmp.mapping.complete(),
|
||||||
["<C-f>"] = cmp.mapping(function(fallback)
|
["<C-f>"] = cmp.mapping(function(fallback)
|
||||||
if luasnip.jumpable(1) then
|
if luasnip.jumpable(1) then
|
||||||
luasnip.jump(1)
|
luasnip.jump(1)
|
||||||
|
|
|
@ -38,36 +38,6 @@ local config = {
|
||||||
extensions = {},
|
extensions = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- local function ins_left(component)
|
|
||||||
-- table.insert(config.sections.lualine_c, component)
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- local function ins_right(component)
|
|
||||||
-- table.insert(config.sections.lualine_x, 1, component)
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- ins_right({
|
|
||||||
-- -- Lsp server name .
|
|
||||||
-- function()
|
|
||||||
-- local msg = "No Active Lsp"
|
|
||||||
-- -- local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
|
|
||||||
-- local buf_ft = vim.bo.filetype
|
|
||||||
-- local clients = vim.lsp.get_clients()
|
|
||||||
-- if next(clients) == nil then
|
|
||||||
-- return msg
|
|
||||||
-- end
|
|
||||||
-- for _, client in ipairs(clients) do
|
|
||||||
-- local filetypes = client.config.filetypes
|
|
||||||
-- if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
|
||||||
-- return client.name
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- return msg
|
|
||||||
-- end,
|
|
||||||
-- icon = " LSP:",
|
|
||||||
-- color = { fg = "#ff6b6b" },
|
|
||||||
-- })
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"nvim-lualine/lualine.nvim",
|
"nvim-lualine/lualine.nvim",
|
||||||
lazy = false,
|
lazy = false,
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
return {
|
|
||||||
lazy = false,
|
|
||||||
"iamcco/markdown-preview.nvim",
|
|
||||||
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
|
|
||||||
ft = { "markdown" },
|
|
||||||
build = "cd app && yarn install",
|
|
||||||
init = function()
|
|
||||||
vim.g.mkdp_filetypes = { "markdown" }
|
|
||||||
end,
|
|
||||||
}
|
|
|
@ -1,4 +1,3 @@
|
||||||
-- TODO what is it for lol?
|
|
||||||
return {
|
return {
|
||||||
"godlygeek/tabular",
|
"godlygeek/tabular",
|
||||||
lazy = false,
|
lazy = false,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
return {
|
return {
|
||||||
"folke/twilight.nvim",
|
"folke/twilight.nvim",
|
||||||
|
lazy = false,
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,5 +12,4 @@ return {
|
||||||
-- refer to the configuration section below
|
-- refer to the configuration section below
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ "folke/neodev.nvim" },
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
return {
|
|
||||||
{
|
|
||||||
ft = "markdown",
|
|
||||||
"folke/zen-mode.nvim",
|
|
||||||
opts = {
|
|
||||||
window = {
|
|
||||||
backdrop = 1,
|
|
||||||
options = {
|
|
||||||
number = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
plugins = {
|
|
||||||
options = {
|
|
||||||
laststatus = 1,
|
|
||||||
},
|
|
||||||
alacritty = {
|
|
||||||
enabled = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
local mapvimkey = require("utils.keymapper").mapvimkey
|
|
||||||
|
|
||||||
local M = {}
|
|
||||||
|
|
||||||
function M.InsertMarkdownURL()
|
|
||||||
local url = vim.fn.getreg("+")
|
|
||||||
if url == "" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local cmd = "curl -L " .. vim.fn.shellescape(url) .. " 2>/dev/null"
|
|
||||||
local handle = io.popen(cmd)
|
|
||||||
if not handle then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local html = handle:read("*a")
|
|
||||||
handle:close()
|
|
||||||
local title = ""
|
|
||||||
local pattern = "<title[^>]*>(.-)</title>"
|
|
||||||
local m = string.match(html, pattern)
|
|
||||||
if m then
|
|
||||||
title = m
|
|
||||||
end
|
|
||||||
if title ~= "" then
|
|
||||||
title = title:gsub("%[", "(")
|
|
||||||
title = title:gsub("%]", ")")
|
|
||||||
local markdownLink = "[" .. title .. "](" .. url .. ")"
|
|
||||||
vim.api.nvim_put({ markdownLink }, "", true, true)
|
|
||||||
-- vim.api.nvim_command("call append(line('.'), '" .. markdownLink .. "')")
|
|
||||||
else
|
|
||||||
print("Title not found for link")
|
|
||||||
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
|
|
|
@ -1,140 +0,0 @@
|
||||||
local finders = require("telescope.finders")
|
|
||||||
local previewers = require("telescope.previewers")
|
|
||||||
local action_state = require("telescope.actions.state")
|
|
||||||
local conf = require("telescope.config").values
|
|
||||||
local pickers = require("telescope.pickers")
|
|
||||||
local actions = require("telescope.actions")
|
|
||||||
local helpers = require("utils.helpers")
|
|
||||||
|
|
||||||
local M = {}
|
|
||||||
|
|
||||||
local function paste_titled_link()
|
|
||||||
return function(prompt_bufnr)
|
|
||||||
actions.close(prompt_bufnr)
|
|
||||||
local current_file = vim.fn.expand("%:p")
|
|
||||||
local selection = action_state.get_selected_entry()
|
|
||||||
local parts = vim.split(selection.value, ":")
|
|
||||||
local filename_part = parts[1]
|
|
||||||
-- local filename_and_category = vim.split(filename_part, "/")
|
|
||||||
local relative_path = helpers.get_relative_path(current_file, filename_part)
|
|
||||||
local title = parts[#parts]:match("^%s*(.-)%s*$")
|
|
||||||
-- remove `#` from header name if it regular wiki
|
|
||||||
title = title:gsub("^%s*#%s*", "")
|
|
||||||
relative_path = relative_path:gsub(" ", "%%20")
|
|
||||||
local link = "[" .. title .. "](" .. relative_path .. ")"
|
|
||||||
vim.api.nvim_put({ link }, "", true, true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--
|
|
||||||
-- local function paste_link()
|
|
||||||
-- return function(prompt_bufnr)
|
|
||||||
-- actions.close(prompt_bufnr)
|
|
||||||
-- local selection = action_state.get_selected_entry()
|
|
||||||
-- print(selection.value)
|
|
||||||
-- local filename_part = vim.split(selection.value, ":")[1]
|
|
||||||
-- local link = "[[../" .. filename_part .. "]]"
|
|
||||||
-- vim.api.nvim_put({ link }, "", true, true)
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- M.copy_filename_to_clipboard = function(prompt_bufnr)
|
|
||||||
-- local selection = action_state.get_selected_entry()
|
|
||||||
-- local filename_part = vim.split(selection.value, ":")[1]
|
|
||||||
-- vim.fn.setreg("*", filename_part)
|
|
||||||
-- vim.fn.setreg("+", filename_part)
|
|
||||||
-- print("Copied filename: " .. filename_part)
|
|
||||||
-- actions.close(prompt_bufnr)
|
|
||||||
-- end
|
|
||||||
|
|
||||||
M.search_raw_title = function(opts)
|
|
||||||
opts = opts or {}
|
|
||||||
local search_dir = opts.search_dir or "."
|
|
||||||
|
|
||||||
pickers
|
|
||||||
.new(opts, {
|
|
||||||
prompt_title = "Search ETON",
|
|
||||||
finder = finders.new_job(function(prompt)
|
|
||||||
if not prompt then
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Adjust the rg command to search for raw_title in all files
|
|
||||||
local cmd = {
|
|
||||||
"rg",
|
|
||||||
"--no-heading",
|
|
||||||
"--color=never",
|
|
||||||
"--with-filename",
|
|
||||||
"--line-number",
|
|
||||||
"-i",
|
|
||||||
"-m",
|
|
||||||
"1",
|
|
||||||
"title:.*" .. prompt,
|
|
||||||
search_dir,
|
|
||||||
}
|
|
||||||
if opts.type ~= "zettel" then
|
|
||||||
cmd[9] = "^#.*" .. prompt
|
|
||||||
end
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
end, opts.entry_maker or function(entry)
|
|
||||||
local filename, lnum, header
|
|
||||||
|
|
||||||
if opts.type ~= "zettel" then
|
|
||||||
filename, lnum, header = entry:match("([^:]+):(%d+):#%s*(.*)")
|
|
||||||
else
|
|
||||||
filename, lnum, header = entry:match("([^:]+):(%d+):title:(.*)")
|
|
||||||
end
|
|
||||||
|
|
||||||
if not filename then
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Получаем только базовое имя файла
|
|
||||||
local basename = filename:match("^.+/(.+)$") or filename
|
|
||||||
|
|
||||||
return {
|
|
||||||
value = entry,
|
|
||||||
ordinal = basename .. " " .. (header or ""),
|
|
||||||
display = basename .. " - " .. (header or ""),
|
|
||||||
filename = filename,
|
|
||||||
lnum = tonumber(lnum),
|
|
||||||
}
|
|
||||||
end),
|
|
||||||
previewer = previewers.new_buffer_previewer({
|
|
||||||
define_preview = function(self, entry, status)
|
|
||||||
conf.buffer_previewer_maker(entry.filename, self.state.bufnr, {
|
|
||||||
bufname = self.state.bufname,
|
|
||||||
winid = self.state.winid,
|
|
||||||
preview = self.state.preview,
|
|
||||||
})
|
|
||||||
-- vim.api.nvim_buf_call(self.state.bufnr, function()
|
|
||||||
-- vim.fn.cursor(entry.lnum, 0)
|
|
||||||
-- vim.cmd("normal! zz")
|
|
||||||
-- end)
|
|
||||||
end,
|
|
||||||
}),
|
|
||||||
sorter = conf.generic_sorter(opts),
|
|
||||||
attach_mappings = function(_, map)
|
|
||||||
-- map("n", "<c-i>", paste_titled_link())
|
|
||||||
-- map("i", "<c-i>", paste_titled_link())
|
|
||||||
map("n", "<c-u>", paste_titled_link())
|
|
||||||
map("i", "<c-u>", paste_titled_link())
|
|
||||||
actions.select_default:replace(function()
|
|
||||||
local selection = action_state.get_selected_entry()
|
|
||||||
actions.close(_)
|
|
||||||
vim.cmd("vsplit " .. selection.filename)
|
|
||||||
vim.fn.cursor(selection.lnum, 0)
|
|
||||||
end)
|
|
||||||
return true
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
:find()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- vim.api.nvim_create_user_command("SearchZettelTitle", function()
|
|
||||||
-- M.search_raw_title({ search_dir = "/Users/fz0x1/Dropbox/TextSync/PKM/00-zettelkasten/" })
|
|
||||||
-- end, {})
|
|
||||||
-- mapvimkey("<leader>fm", "SearchZettelTitle", "Search by zettel title")
|
|
||||||
|
|
||||||
return M
|
|
|
@ -1,44 +0,0 @@
|
||||||
local options = require("core.options")
|
|
||||||
|
|
||||||
local M = {}
|
|
||||||
|
|
||||||
local function generate_id(length)
|
|
||||||
local chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
|
||||||
local id = ""
|
|
||||||
for i = 1, length do
|
|
||||||
local rand = math.random(#chars)
|
|
||||||
id = id .. chars:sub(rand, rand)
|
|
||||||
end
|
|
||||||
return id
|
|
||||||
end
|
|
||||||
|
|
||||||
local function file_exists(directory, filename)
|
|
||||||
local filepath = directory .. "/" .. filename
|
|
||||||
local file = io.open(filepath, "r")
|
|
||||||
if file then
|
|
||||||
io.close(file)
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function generate_unique_id(directory, length)
|
|
||||||
local id
|
|
||||||
repeat
|
|
||||||
id = generate_id(length)
|
|
||||||
until not file_exists(directory, id .. ".md")
|
|
||||||
return id
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.insert_link_with_unique_id()
|
|
||||||
local id_length = 8
|
|
||||||
|
|
||||||
local unique_id = generate_unique_id(options.resources_dir, id_length)
|
|
||||||
|
|
||||||
local link = string.format("[name](%s.md)", unique_id)
|
|
||||||
|
|
||||||
vim.api.nvim_put({ link }, "c", true, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
|
@ -10,8 +10,8 @@ set -g mode-keys vi
|
||||||
bind-key -T copy-mode-vi v send-keys -X begin-selection
|
bind-key -T copy-mode-vi v send-keys -X begin-selection
|
||||||
bind-key -T copy-mode-vi y send-keys -X copy-pipe "pbcopy"
|
bind-key -T copy-mode-vi y send-keys -X copy-pipe "pbcopy"
|
||||||
|
|
||||||
# set -g default-terminal tmux-256color
|
set -g default-terminal tmux-256color
|
||||||
set -g default-terminal xterm-256color
|
# set -g default-terminal xterm-256color
|
||||||
set -sa terminal-features ',alacritty:RGB'
|
set -sa terminal-features ',alacritty:RGB'
|
||||||
set -ga terminal-overrides ",*256col*:Tc"
|
set -ga terminal-overrides ",*256col*:Tc"
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,11 @@ from pathlib import Path
|
||||||
|
|
||||||
DB_NAME = Path("metadata.db")
|
DB_NAME = Path("metadata.db")
|
||||||
TZ = 1
|
TZ = 1
|
||||||
|
TOOLS = ("jrnl", "sqlite3")
|
||||||
|
|
||||||
|
for t in TOOLS:
|
||||||
|
if not shutil.which(t):
|
||||||
|
raise FileNotFoundError(f"There is no existing path for '{t}'")
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
|
@ -33,6 +38,15 @@ class Config:
|
||||||
def validate(cls):
|
def validate(cls):
|
||||||
if not cls.memo_token or not cls.memo_url:
|
if not cls.memo_token or not cls.memo_url:
|
||||||
sys.exit("Missing MEMOS_TOKEN or MEMOS_URL environment variables.")
|
sys.exit("Missing MEMOS_TOKEN or MEMOS_URL environment variables.")
|
||||||
|
elif not cls.openweathermap_api_key:
|
||||||
|
sys.exit("Missing openweather api key")
|
||||||
|
elif ( # TODO need more complex checking
|
||||||
|
not cls.owntracks_creds
|
||||||
|
or not cls.owntracks_url
|
||||||
|
or not cls.geo_user
|
||||||
|
or not cls.geo_device
|
||||||
|
):
|
||||||
|
sys.exit("Missing OwnTracks data")
|
||||||
|
|
||||||
|
|
||||||
Config.validate()
|
Config.validate()
|
||||||
|
@ -300,7 +314,6 @@ def doctor():
|
||||||
if check_diary:
|
if check_diary:
|
||||||
dt = datetime.fromtimestamp(m[1], tz=timezone(timedelta(hours=TZ)))
|
dt = datetime.fromtimestamp(m[1], tz=timezone(timedelta(hours=TZ)))
|
||||||
diary_datetime = dt.strftime("%Y/%m/%d at %I:%M:%S %p")
|
diary_datetime = dt.strftime("%Y/%m/%d at %I:%M:%S %p")
|
||||||
# print(diary_datetime)
|
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["jrnl", diary_name, "-on", diary_datetime],
|
["jrnl", diary_name, "-on", diary_datetime],
|
||||||
|
@ -386,16 +399,17 @@ def export():
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.run(
|
result = subprocess.run(
|
||||||
f'printf "%s %s" "{convert_diary_date(create_time)}" {content} | jrnl {diary_name}',
|
f'printf "%s %s" "{convert_diary_date(create_time)}" {content} | jrnl {diary_name}',
|
||||||
shell=True,
|
shell=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
check=True,
|
check=True,
|
||||||
)
|
)
|
||||||
|
print(result.stderr)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(f"Error writing to journal: {e.stderr}")
|
print(f"Error writing to journal: {e.stderr}")
|
||||||
continue
|
raise
|
||||||
|
|
||||||
delete_entity(f"{Config.memo_url}/api/v1/{memo['name']}", headers)
|
delete_entity(f"{Config.memo_url}/api/v1/{memo['name']}", headers)
|
||||||
|
|
||||||
|
@ -412,12 +426,7 @@ def insert():
|
||||||
"Usage: script.py insert <diary_name> [bulk|single (default)] 'content'"
|
"Usage: script.py insert <diary_name> [bulk|single (default)] 'content'"
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO is this really need?
|
|
||||||
# if len(sys.argv) == 5 and sys.argv[3] != "single":
|
|
||||||
# sys.exit("Invalid usage for bulk insert.")
|
|
||||||
|
|
||||||
diary_name = sys.argv[2]
|
diary_name = sys.argv[2]
|
||||||
# do backup ever!
|
|
||||||
insert_type = (
|
insert_type = (
|
||||||
"bulk" if len(sys.argv) > 3 and sys.argv[3] == "bulk" else "single"
|
"bulk" if len(sys.argv) > 3 and sys.argv[3] == "bulk" else "single"
|
||||||
)
|
)
|
||||||
|
@ -453,13 +462,14 @@ def insert():
|
||||||
print("There is no text")
|
print("There is no text")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
try:
|
try:
|
||||||
subprocess.run(
|
result = subprocess.run(
|
||||||
f'printf "%s %s" "{convert_diary_date(datenow_timestamp)}" {content} | jrnl {diary_name}',
|
f'printf "%s %s" "{convert_diary_date(datenow_timestamp)}" {content} | jrnl {diary_name}',
|
||||||
shell=True,
|
shell=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
check=True,
|
check=True,
|
||||||
)
|
)
|
||||||
|
print(result.stderr)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(f"Error inserting single entry: {e.stderr}")
|
print(f"Error inserting single entry: {e.stderr}")
|
||||||
raise
|
raise
|
||||||
|
@ -478,13 +488,14 @@ def insert():
|
||||||
content = shlex.quote(file.read())
|
content = shlex.quote(file.read())
|
||||||
if hash != make_hash(temp_file_path):
|
if hash != make_hash(temp_file_path):
|
||||||
try:
|
try:
|
||||||
subprocess.run(
|
result = subprocess.run(
|
||||||
f'printf "%s %s" "{convert_diary_date(datenow_timestamp)}" {content} | jrnl {diary_name}',
|
f'printf "%s %s" "{convert_diary_date(datenow_timestamp)}" {content} | jrnl {diary_name}',
|
||||||
shell=True,
|
shell=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
check=True,
|
check=True,
|
||||||
)
|
)
|
||||||
|
print(result.stderr)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(
|
print(
|
||||||
f"Error during bulk import: {e.stderr}, file: {temp_file_path}"
|
f"Error during bulk import: {e.stderr}, file: {temp_file_path}"
|
||||||
|
@ -505,6 +516,7 @@ def insert():
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
|
# I want to know if I'm connected...
|
||||||
fetch_data(url="https://google.com", rjson=False, log=False)
|
fetch_data(url="https://google.com", rjson=False, log=False)
|
||||||
...
|
...
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Description=Таймер для Promnesia Index
|
Description=Таймер для Promnesia Index
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnUnitActiveSec=60min
|
OnUnitActiveSec=60m
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=timers.target
|
WantedBy=timers.target
|
||||||
|
|
Loading…
Add table
Reference in a new issue