mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
reformatted lua
This commit is contained in:
7
.stylua.toml
Normal file
7
.stylua.toml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
column_width = 80
|
||||||
|
line_endings = "Unix"
|
||||||
|
indent_type = "Spaces"
|
||||||
|
indent_width = 4
|
||||||
|
quote_style = "AutoPreferDouble"
|
||||||
|
no_call_parentheses = false
|
||||||
|
|
||||||
@@ -147,7 +147,15 @@ local function daysuffix(day)
|
|||||||
return "th"
|
return "th"
|
||||||
end
|
end
|
||||||
|
|
||||||
local daymap = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }
|
local daymap = {
|
||||||
|
"Monday",
|
||||||
|
"Tuesday",
|
||||||
|
"Wednesday",
|
||||||
|
"Thursday",
|
||||||
|
"Friday",
|
||||||
|
"Saturday",
|
||||||
|
"Sunday",
|
||||||
|
}
|
||||||
local monthmap = {
|
local monthmap = {
|
||||||
"January",
|
"January",
|
||||||
"February",
|
"February",
|
||||||
@@ -205,7 +213,12 @@ local function linesubst(line, title, calendar_info)
|
|||||||
return line
|
return line
|
||||||
end
|
end
|
||||||
|
|
||||||
local function create_note_from_template(title, filepath, templatefn, calendar_info)
|
local function create_note_from_template(
|
||||||
|
title,
|
||||||
|
filepath,
|
||||||
|
templatefn,
|
||||||
|
calendar_info
|
||||||
|
)
|
||||||
-- first, read the template file
|
-- first, read the template file
|
||||||
local lines = {}
|
local lines = {}
|
||||||
if file_exists(templatefn) then
|
if file_exists(templatefn) then
|
||||||
@@ -336,7 +349,11 @@ local function find_files_sorted(opts)
|
|||||||
local hl_group
|
local hl_group
|
||||||
local display = utils.transform_path(display_opts, display_entry.value)
|
local display = utils.transform_path(display_opts, display_entry.value)
|
||||||
|
|
||||||
display, hl_group = utils.transform_devicons(display_entry.value, display, false)
|
display, hl_group = utils.transform_devicons(
|
||||||
|
display_entry.value,
|
||||||
|
display,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
if hl_group then
|
if hl_group then
|
||||||
return display, { { { 1, 3 }, hl_group } }
|
return display, { { { 1, 3 }, hl_group } }
|
||||||
@@ -397,7 +414,11 @@ local function FindDailyNotes(opts)
|
|||||||
local fname = M.Cfg.dailies .. "/" .. today .. M.Cfg.extension
|
local fname = M.Cfg.dailies .. "/" .. today .. M.Cfg.extension
|
||||||
local fexists = file_exists(fname)
|
local fexists = file_exists(fname)
|
||||||
if
|
if
|
||||||
(fexists ~= true) and ((opts.dailies_create_nonexisting == true) or M.Cfg.dailies_create_nonexisting == true)
|
(fexists ~= true)
|
||||||
|
and (
|
||||||
|
(opts.dailies_create_nonexisting == true)
|
||||||
|
or M.Cfg.dailies_create_nonexisting == true
|
||||||
|
)
|
||||||
then
|
then
|
||||||
create_note_from_template(today, fname, M.note_type_templates.daily)
|
create_note_from_template(today, fname, M.note_type_templates.daily)
|
||||||
end
|
end
|
||||||
@@ -423,7 +444,10 @@ local function FindWeeklyNotes(opts)
|
|||||||
local fexists = file_exists(fname)
|
local fexists = file_exists(fname)
|
||||||
if
|
if
|
||||||
(fexists ~= true)
|
(fexists ~= true)
|
||||||
and ((opts.weeklies_create_nonexisting == true) or M.Cfg.weeklies_create_nonexisting == true)
|
and (
|
||||||
|
(opts.weeklies_create_nonexisting == true)
|
||||||
|
or M.Cfg.weeklies_create_nonexisting == true
|
||||||
|
)
|
||||||
then
|
then
|
||||||
create_note_from_template(title, fname, M.note_type_templates.weekly)
|
create_note_from_template(title, fname, M.note_type_templates.weekly)
|
||||||
end
|
end
|
||||||
@@ -492,7 +516,9 @@ local function FollowLink(opts)
|
|||||||
|
|
||||||
if #filename > 0 then
|
if #filename > 0 then
|
||||||
local fexists = false
|
local fexists = false
|
||||||
if file_exists(M.Cfg.weeklies .. "/" .. filename .. M.Cfg.extension) then
|
if
|
||||||
|
file_exists(M.Cfg.weeklies .. "/" .. filename .. M.Cfg.extension)
|
||||||
|
then
|
||||||
filename = M.Cfg.weeklies .. "/" .. filename .. M.Cfg.extension
|
filename = M.Cfg.weeklies .. "/" .. filename .. M.Cfg.extension
|
||||||
fexists = true
|
fexists = true
|
||||||
end
|
end
|
||||||
@@ -513,16 +539,27 @@ local function FollowLink(opts)
|
|||||||
|
|
||||||
if search_mode == "files" then
|
if search_mode == "files" then
|
||||||
-- check if fname exists anywhere
|
-- check if fname exists anywhere
|
||||||
local fexists = file_exists(M.Cfg.weeklies .. "/" .. title .. M.Cfg.extension)
|
local fexists = file_exists(
|
||||||
fexists = fexists or file_exists(M.Cfg.dailies .. "/" .. title .. M.Cfg.extension)
|
M.Cfg.weeklies .. "/" .. title .. M.Cfg.extension
|
||||||
fexists = fexists or file_exists(M.Cfg.home .. "/" .. title .. M.Cfg.extension)
|
)
|
||||||
|
fexists = fexists
|
||||||
|
or file_exists(M.Cfg.dailies .. "/" .. title .. M.Cfg.extension)
|
||||||
|
fexists = fexists
|
||||||
|
or file_exists(M.Cfg.home .. "/" .. title .. M.Cfg.extension)
|
||||||
|
|
||||||
if
|
if
|
||||||
(fexists ~= true)
|
(fexists ~= true)
|
||||||
and ((opts.follow_creates_nonexisting == true) or M.Cfg.follow_creates_nonexisting == true)
|
and (
|
||||||
|
(opts.follow_creates_nonexisting == true)
|
||||||
|
or M.Cfg.follow_creates_nonexisting == true
|
||||||
|
)
|
||||||
then
|
then
|
||||||
local fname = M.Cfg.home .. "/" .. title .. M.Cfg.extension
|
local fname = M.Cfg.home .. "/" .. title .. M.Cfg.extension
|
||||||
create_note_from_template(title, fname, M.note_type_templates.normal)
|
create_note_from_template(
|
||||||
|
title,
|
||||||
|
fname,
|
||||||
|
M.note_type_templates.normal
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
find_files_sorted({
|
find_files_sorted({
|
||||||
@@ -544,9 +581,21 @@ local function FollowLink(opts)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local search_command = { "rg", "--vimgrep", "-e", "^#+\\s" .. prompt, "--" }
|
local search_command = {
|
||||||
|
"rg",
|
||||||
|
"--vimgrep",
|
||||||
|
"-e",
|
||||||
|
"^#+\\s" .. prompt,
|
||||||
|
"--",
|
||||||
|
}
|
||||||
if search_mode == "para" then
|
if search_mode == "para" then
|
||||||
search_command = { "rg", "--vimgrep", "-e", "\\^" .. prompt, "--" }
|
search_command = {
|
||||||
|
"rg",
|
||||||
|
"--vimgrep",
|
||||||
|
"-e",
|
||||||
|
"\\^" .. prompt,
|
||||||
|
"--",
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if #filename > 0 then
|
if #filename > 0 then
|
||||||
@@ -592,7 +641,15 @@ local function PreviewImg(_)
|
|||||||
cwd = M.Cfg.home,
|
cwd = M.Cfg.home,
|
||||||
default_text = fname,
|
default_text = fname,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
filter_extensions = { ".png", ".jpg", ".bmp", ".gif", ".pdf", ".mp4", ".webm" },
|
filter_extensions = {
|
||||||
|
".png",
|
||||||
|
".jpg",
|
||||||
|
".bmp",
|
||||||
|
".gif",
|
||||||
|
".pdf",
|
||||||
|
".mp4",
|
||||||
|
".webm",
|
||||||
|
},
|
||||||
preview_type = "media",
|
preview_type = "media",
|
||||||
|
|
||||||
attach_mappings = function(prompt_bufnr, _)
|
attach_mappings = function(prompt_bufnr, _)
|
||||||
@@ -651,9 +708,18 @@ local function GotoToday(opts)
|
|||||||
local fname = M.Cfg.dailies .. "/" .. word .. M.Cfg.extension
|
local fname = M.Cfg.dailies .. "/" .. word .. M.Cfg.extension
|
||||||
local fexists = file_exists(fname)
|
local fexists = file_exists(fname)
|
||||||
if
|
if
|
||||||
(fexists ~= true) and ((opts.follow_creates_nonexisting == true) or M.Cfg.follow_creates_nonexisting == true)
|
(fexists ~= true)
|
||||||
|
and (
|
||||||
|
(opts.follow_creates_nonexisting == true)
|
||||||
|
or M.Cfg.follow_creates_nonexisting == true
|
||||||
|
)
|
||||||
then
|
then
|
||||||
create_note_from_template(word, fname, M.note_type_templates.daily, opts)
|
create_note_from_template(
|
||||||
|
word,
|
||||||
|
fname,
|
||||||
|
M.note_type_templates.daily,
|
||||||
|
opts
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
find_files_sorted({
|
find_files_sorted({
|
||||||
@@ -702,7 +768,15 @@ local function InsertImgLink(opts)
|
|||||||
prompt_title = "Find image/media",
|
prompt_title = "Find image/media",
|
||||||
cwd = M.Cfg.home,
|
cwd = M.Cfg.home,
|
||||||
find_command = M.Cfg.find_command,
|
find_command = M.Cfg.find_command,
|
||||||
filter_extensions = { ".png", ".jpg", ".bmp", ".gif", ".pdf", ".mp4", ".webm" },
|
filter_extensions = {
|
||||||
|
".png",
|
||||||
|
".jpg",
|
||||||
|
".bmp",
|
||||||
|
".gif",
|
||||||
|
".pdf",
|
||||||
|
".mp4",
|
||||||
|
".webm",
|
||||||
|
},
|
||||||
preview_type = "media",
|
preview_type = "media",
|
||||||
|
|
||||||
attach_mappings = function(prompt_bufnr, _)
|
attach_mappings = function(prompt_bufnr, _)
|
||||||
@@ -853,7 +927,10 @@ local function GotoThisWeek(opts)
|
|||||||
local fexists = file_exists(fname)
|
local fexists = file_exists(fname)
|
||||||
if
|
if
|
||||||
(fexists ~= true)
|
(fexists ~= true)
|
||||||
and ((opts.weeklies_create_nonexisting == true) or M.Cfg.weeklies_create_nonexisting == true)
|
and (
|
||||||
|
(opts.weeklies_create_nonexisting == true)
|
||||||
|
or M.Cfg.weeklies_create_nonexisting == true
|
||||||
|
)
|
||||||
then
|
then
|
||||||
create_note_from_template(title, fname, M.note_type_templates.weekly)
|
create_note_from_template(title, fname, M.note_type_templates.weekly)
|
||||||
end
|
end
|
||||||
@@ -872,7 +949,10 @@ end
|
|||||||
|
|
||||||
-- return if a daily 'note exists' indicator (sign) should be displayed for a particular day
|
-- return if a daily 'note exists' indicator (sign) should be displayed for a particular day
|
||||||
local function CalendarSignDay(day, month, year)
|
local function CalendarSignDay(day, month, year)
|
||||||
local fn = M.Cfg.dailies .. "/" .. string.format("%04d-%02d-%02d", year, month, day) .. M.Cfg.extension
|
local fn = M.Cfg.dailies
|
||||||
|
.. "/"
|
||||||
|
.. string.format("%04d-%02d-%02d", year, month, day)
|
||||||
|
.. M.Cfg.extension
|
||||||
if file_exists(fn) then
|
if file_exists(fn) then
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
@@ -885,7 +965,14 @@ local function CalendarAction(day, month, year, weekday, _)
|
|||||||
local today = string.format("%04d-%02d-%02d", year, month, day)
|
local today = string.format("%04d-%02d-%02d", year, month, day)
|
||||||
local opts = {}
|
local opts = {}
|
||||||
opts.date = today
|
opts.date = today
|
||||||
opts.hdate = daymap[weekday] .. ", " .. monthmap[tonumber(month)] .. " " .. day .. daysuffix(day) .. ", " .. year
|
opts.hdate = daymap[weekday]
|
||||||
|
.. ", "
|
||||||
|
.. monthmap[tonumber(month)]
|
||||||
|
.. " "
|
||||||
|
.. day
|
||||||
|
.. daysuffix(day)
|
||||||
|
.. ", "
|
||||||
|
.. year
|
||||||
opts.week = "n/a" -- TODO: calculate the week somehow
|
opts.week = "n/a" -- TODO: calculate the week somehow
|
||||||
opts.month = month
|
opts.month = month
|
||||||
opts.year = year
|
opts.year = year
|
||||||
@@ -958,7 +1045,9 @@ local function ToggleTodo(opts)
|
|||||||
local curline = vim.api.nvim_buf_get_lines(0, linenr - 1, linenr, false)[1]
|
local curline = vim.api.nvim_buf_get_lines(0, linenr - 1, linenr, false)[1]
|
||||||
local stripped = vim.trim(curline)
|
local stripped = vim.trim(curline)
|
||||||
local repline
|
local repline
|
||||||
if vim.startswith(stripped, "- ") and not vim.startswith(stripped, "- [") then
|
if
|
||||||
|
vim.startswith(stripped, "- ") and not vim.startswith(stripped, "- [")
|
||||||
|
then
|
||||||
repline = curline:gsub("- ", "- [ ] ", 1)
|
repline = curline:gsub("- ", "- [ ] ", 1)
|
||||||
else
|
else
|
||||||
if vim.startswith(stripped, "- [ ]") then
|
if vim.startswith(stripped, "- [ ]") then
|
||||||
@@ -990,7 +1079,13 @@ local function Setup(cfg)
|
|||||||
if k ~= "calendar_opts" then
|
if k ~= "calendar_opts" then
|
||||||
M.Cfg[k] = v
|
M.Cfg[k] = v
|
||||||
if debug then
|
if debug then
|
||||||
print("Setup() setting `" .. k .. "` -> `" .. tostring(v) .. "`")
|
print(
|
||||||
|
"Setup() setting `"
|
||||||
|
.. k
|
||||||
|
.. "` -> `"
|
||||||
|
.. tostring(v)
|
||||||
|
.. "`"
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1006,7 +1101,9 @@ local function Setup(cfg)
|
|||||||
if M.Cfg.plug_into_calendar then
|
if M.Cfg.plug_into_calendar then
|
||||||
cfg.calendar_opts = cfg.calendar_opts or {}
|
cfg.calendar_opts = cfg.calendar_opts or {}
|
||||||
M.Cfg.calendar_opts = M.Cfg.calendar_opts or {}
|
M.Cfg.calendar_opts = M.Cfg.calendar_opts or {}
|
||||||
M.Cfg.calendar_opts.weeknm = cfg.calendar_opts.weeknm or M.Cfg.calendar_opts.weeknm or 1
|
M.Cfg.calendar_opts.weeknm = cfg.calendar_opts.weeknm
|
||||||
|
or M.Cfg.calendar_opts.weeknm
|
||||||
|
or 1
|
||||||
M.Cfg.calendar_opts.calendar_monday = cfg.calendar_opts.calendar_monday
|
M.Cfg.calendar_opts.calendar_monday = cfg.calendar_opts.calendar_monday
|
||||||
or M.Cfg.calendar_opts.calendar_monday
|
or M.Cfg.calendar_opts.calendar_monday
|
||||||
or 1
|
or 1
|
||||||
|
|||||||
Reference in New Issue
Block a user