mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
style: run stylua
This commit is contained in:
@@ -756,8 +756,7 @@ function Pinfo:resolve_path(p, opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- now work out subdir relative to root
|
-- now work out subdir relative to root
|
||||||
self.sub_dir = p
|
self.sub_dir = p:gsub(escape(self.root_dir .. "/"), "")
|
||||||
:gsub(escape(self.root_dir .. "/"), "")
|
|
||||||
:gsub(escape(self.filename), "")
|
:gsub(escape(self.filename), "")
|
||||||
:gsub("/$", "")
|
:gsub("/$", "")
|
||||||
:gsub("^/", "")
|
:gsub("^/", "")
|
||||||
@@ -873,9 +872,7 @@ function Pinfo:resolve_link(title, opts)
|
|||||||
if opts.new_note_location == "smart" then
|
if opts.new_note_location == "smart" then
|
||||||
self.filepath = opts.home .. "/" .. self.filename -- default
|
self.filepath = opts.home .. "/" .. self.filename -- default
|
||||||
self.is_daily, self.is_weekly, self.calendar_info =
|
self.is_daily, self.is_weekly, self.calendar_info =
|
||||||
check_if_daily_or_weekly(
|
check_if_daily_or_weekly(self.title)
|
||||||
self.title
|
|
||||||
)
|
|
||||||
if self.is_daily == true then
|
if self.is_daily == true then
|
||||||
self.root_dir = opts.dailies
|
self.root_dir = opts.dailies
|
||||||
self.filepath = opts.dailies .. "/" .. self.filename
|
self.filepath = opts.dailies .. "/" .. self.filename
|
||||||
@@ -997,23 +994,25 @@ local media_preview = defaulter(function(opts)
|
|||||||
return conf.file_previewer(opts)
|
return conf.file_previewer(opts)
|
||||||
end
|
end
|
||||||
return previewers.new_termopen_previewer({
|
return previewers.new_termopen_previewer({
|
||||||
get_command = opts.get_command or function(entry)
|
get_command = opts.get_command
|
||||||
local tmp_table = vim.split(entry.value, "\t")
|
or function(entry)
|
||||||
local preview = opts.get_preview_window()
|
local tmp_table = vim.split(entry.value, "\t")
|
||||||
opts.cwd = opts.cwd and vim.fn.expand(opts.cwd) or vim.loop.cwd()
|
local preview = opts.get_preview_window()
|
||||||
if vim.tbl_isempty(tmp_table) then
|
opts.cwd = opts.cwd and vim.fn.expand(opts.cwd)
|
||||||
return { "echo", "" }
|
or vim.loop.cwd()
|
||||||
end
|
if vim.tbl_isempty(tmp_table) then
|
||||||
print(tmp_table[1])
|
return { "echo", "" }
|
||||||
return {
|
end
|
||||||
preview_cmd,
|
print(tmp_table[1])
|
||||||
tmp_table[1],
|
return {
|
||||||
preview.col,
|
preview_cmd,
|
||||||
preview.line + 1,
|
tmp_table[1],
|
||||||
preview.width,
|
preview.col,
|
||||||
preview.height,
|
preview.line + 1,
|
||||||
}
|
preview.width,
|
||||||
end,
|
preview.height,
|
||||||
|
}
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end, {})
|
end, {})
|
||||||
|
|
||||||
@@ -1064,11 +1063,8 @@ 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, hl_group =
|
||||||
display_entry.value,
|
utils.transform_devicons(display_entry.value, display, false)
|
||||||
display,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
if hl_group then
|
if hl_group then
|
||||||
return display, { { { 1, 3 }, hl_group } }
|
return display, { { { 1, 3 }, hl_group } }
|
||||||
@@ -2277,17 +2273,12 @@ local function FollowLink(opts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
local hl_group
|
local hl_group
|
||||||
local display = utils.transform_path(
|
local display =
|
||||||
display_opts,
|
utils.transform_path(display_opts, display_entry.value)
|
||||||
display_entry.value
|
|
||||||
)
|
|
||||||
|
|
||||||
display_entry.filn = display_entry.filn or display:gsub(":.*", "")
|
display_entry.filn = display_entry.filn or display:gsub(":.*", "")
|
||||||
display, hl_group = utils.transform_devicons(
|
display, hl_group =
|
||||||
display_entry.filn,
|
utils.transform_devicons(display_entry.filn, display, false)
|
||||||
display,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
if hl_group then
|
if hl_group then
|
||||||
return display, { { { 1, 3 }, hl_group } }
|
return display, { { { 1, 3 }, hl_group } }
|
||||||
@@ -2368,10 +2359,8 @@ local function FollowLink(opts)
|
|||||||
local find = (function()
|
local find = (function()
|
||||||
if Path.path.sep == "\\" then
|
if Path.path.sep == "\\" then
|
||||||
return function(t)
|
return function(t)
|
||||||
local start, _, filn, lnum, col, text = string.find(
|
local start, _, filn, lnum, col, text =
|
||||||
t,
|
string.find(t, [[([^:]+):(%d+):(%d+):(.*)]])
|
||||||
[[([^:]+):(%d+):(%d+):(.*)]]
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Handle Windows drive letter (e.g. "C:") at the beginning (if present)
|
-- Handle Windows drive letter (e.g. "C:") at the beginning (if present)
|
||||||
if start == 3 then
|
if start == 3 then
|
||||||
@@ -2382,10 +2371,8 @@ local function FollowLink(opts)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
return function(t)
|
return function(t)
|
||||||
local _, _, filn, lnum, col, text = string.find(
|
local _, _, filn, lnum, col, text =
|
||||||
t,
|
string.find(t, [[([^:]+):(%d+):(%d+):(.*)]])
|
||||||
[[([^:]+):(%d+):(%d+):(.*)]]
|
|
||||||
)
|
|
||||||
return filn, lnum, col, text
|
return filn, lnum, col, text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2792,47 +2779,50 @@ local function FindAllTags(opts)
|
|||||||
opts.cwd = M.Cfg.home
|
opts.cwd = M.Cfg.home
|
||||||
opts.tag_notation = M.Cfg.tag_notation
|
opts.tag_notation = M.Cfg.tag_notation
|
||||||
opts.i = i
|
opts.i = i
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "Tags",
|
.new(opts, {
|
||||||
finder = finders.new_table({
|
prompt_title = "Tags",
|
||||||
results = taglist,
|
finder = finders.new_table({
|
||||||
entry_maker = function(entry)
|
results = taglist,
|
||||||
return {
|
entry_maker = function(entry)
|
||||||
value = entry,
|
return {
|
||||||
-- display = entry.tag .. ' \t (' .. #entry.details .. ' matches)',
|
value = entry,
|
||||||
display = string.format(
|
-- display = entry.tag .. ' \t (' .. #entry.details .. ' matches)',
|
||||||
"%" .. max_tag_len .. "s ... (%3d matches)",
|
display = string.format(
|
||||||
entry.tag,
|
"%" .. max_tag_len .. "s ... (%3d matches)",
|
||||||
#entry.details
|
entry.tag,
|
||||||
),
|
#entry.details
|
||||||
ordinal = entry.tag,
|
),
|
||||||
}
|
ordinal = entry.tag,
|
||||||
end,
|
}
|
||||||
}),
|
end,
|
||||||
sorter = conf.generic_sorter(opts),
|
}),
|
||||||
attach_mappings = function(prompt_bufnr, map)
|
sorter = conf.generic_sorter(opts),
|
||||||
actions.select_default:replace(function()
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
-- actions for insert tag, default action: search for tag
|
actions.select_default:replace(function()
|
||||||
local selection = action_state.get_selected_entry().value.tag
|
-- actions for insert tag, default action: search for tag
|
||||||
local follow_opts = {
|
local selection =
|
||||||
follow_tag = selection,
|
action_state.get_selected_entry().value.tag
|
||||||
show_link_counts = true,
|
local follow_opts = {
|
||||||
templateDir = templateDir,
|
follow_tag = selection,
|
||||||
}
|
show_link_counts = true,
|
||||||
actions._close(prompt_bufnr, false)
|
templateDir = templateDir,
|
||||||
vim.schedule(function()
|
}
|
||||||
FollowLink(follow_opts)
|
actions._close(prompt_bufnr, false)
|
||||||
|
vim.schedule(function()
|
||||||
|
FollowLink(follow_opts)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
map("i", "<c-y>", picker_actions.yank_tag(opts))
|
||||||
map("i", "<c-y>", picker_actions.yank_tag(opts))
|
map("i", "<c-i>", picker_actions.paste_tag(opts))
|
||||||
map("i", "<c-i>", picker_actions.paste_tag(opts))
|
map("n", "<c-y>", picker_actions.yank_tag(opts))
|
||||||
map("n", "<c-y>", picker_actions.yank_tag(opts))
|
map("n", "<c-i>", picker_actions.paste_tag(opts))
|
||||||
map("n", "<c-i>", picker_actions.paste_tag(opts))
|
map("n", "<c-c>", picker_actions.close(opts))
|
||||||
map("n", "<c-c>", picker_actions.close(opts))
|
map("n", "<esc>", picker_actions.close(opts))
|
||||||
map("n", "<esc>", picker_actions.close(opts))
|
return true
|
||||||
return true
|
end,
|
||||||
end,
|
})
|
||||||
}):find()
|
:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Setup(cfg)
|
-- Setup(cfg)
|
||||||
@@ -3043,32 +3033,35 @@ local TelekastenCmd = {
|
|||||||
TelekastenCmd.command = function(subcommand)
|
TelekastenCmd.command = function(subcommand)
|
||||||
local show = function(opts)
|
local show = function(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "Command palette",
|
.new(opts, {
|
||||||
finder = finders.new_table({
|
prompt_title = "Command palette",
|
||||||
results = TelekastenCmd.commands(),
|
finder = finders.new_table({
|
||||||
entry_maker = function(entry)
|
results = TelekastenCmd.commands(),
|
||||||
return {
|
entry_maker = function(entry)
|
||||||
value = entry,
|
return {
|
||||||
display = entry[1],
|
value = entry,
|
||||||
ordinal = entry[2],
|
display = entry[1],
|
||||||
}
|
ordinal = entry[2],
|
||||||
end,
|
}
|
||||||
}),
|
end,
|
||||||
sorter = conf.generic_sorter(opts),
|
}),
|
||||||
attach_mappings = function(prompt_bufnr, _)
|
sorter = conf.generic_sorter(opts),
|
||||||
actions.select_default:replace(function()
|
attach_mappings = function(prompt_bufnr, _)
|
||||||
-- important: actions.close(bufnr) is not enough
|
actions.select_default:replace(function()
|
||||||
-- it resulted in: preview_img NOT receiving the prompt as default text
|
-- important: actions.close(bufnr) is not enough
|
||||||
-- apparently it has sth to do with keeping insert mode
|
-- it resulted in: preview_img NOT receiving the prompt as default text
|
||||||
actions._close(prompt_bufnr, true)
|
-- apparently it has sth to do with keeping insert mode
|
||||||
|
actions._close(prompt_bufnr, true)
|
||||||
|
|
||||||
local selection = action_state.get_selected_entry().value[3]
|
local selection =
|
||||||
selection()
|
action_state.get_selected_entry().value[3]
|
||||||
end)
|
selection()
|
||||||
return true
|
end)
|
||||||
end,
|
return true
|
||||||
}):find()
|
end,
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
if subcommand then
|
if subcommand then
|
||||||
-- print("trying subcommand " .. "`" .. subcommand .. "`")
|
-- print("trying subcommand " .. "`" .. subcommand .. "`")
|
||||||
|
|||||||
Reference in New Issue
Block a user