mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
Ctrl-n to create new note out of finding (closes #141)
* chore(picker): create new note out of finding * chore(format): format with stylua
This commit is contained in:
@@ -37,38 +37,30 @@ local function defaultConfig(home)
|
|||||||
|
|
||||||
local cfg = {
|
local cfg = {
|
||||||
home = home,
|
home = home,
|
||||||
|
|
||||||
-- if true, telekasten will be enabled when opening a note within the configured home
|
-- if true, telekasten will be enabled when opening a note within the configured home
|
||||||
take_over_my_home = true,
|
take_over_my_home = true,
|
||||||
|
|
||||||
-- auto-set telekasten filetype: if false, the telekasten filetype will not be used
|
-- auto-set telekasten filetype: if false, the telekasten filetype will not be used
|
||||||
-- and thus the telekasten syntax will not be loaded either
|
-- and thus the telekasten syntax will not be loaded either
|
||||||
auto_set_filetype = true,
|
auto_set_filetype = true,
|
||||||
|
|
||||||
-- auto-set telekasten syntax: if false, the telekasten syntax will not be set
|
-- auto-set telekasten syntax: if false, the telekasten syntax will not be set
|
||||||
-- this syntax setting is independent from auto-set filetype
|
-- this syntax setting is independent from auto-set filetype
|
||||||
auto_set_syntax = true,
|
auto_set_syntax = true,
|
||||||
|
|
||||||
-- dir names for special notes (absolute path or subdir name)
|
-- dir names for special notes (absolute path or subdir name)
|
||||||
dailies = home .. "/" .. "daily",
|
dailies = home .. "/" .. "daily",
|
||||||
weeklies = home .. "/" .. "weekly",
|
weeklies = home .. "/" .. "weekly",
|
||||||
templates = home .. "/" .. "templates",
|
templates = home .. "/" .. "templates",
|
||||||
|
|
||||||
-- image (sub)dir for pasting
|
-- image (sub)dir for pasting
|
||||||
-- dir name (absolute path or subdir name)
|
-- dir name (absolute path or subdir name)
|
||||||
-- or nil if pasted images shouldn't go into a special subdir
|
-- or nil if pasted images shouldn't go into a special subdir
|
||||||
image_subdir = nil,
|
image_subdir = nil,
|
||||||
|
|
||||||
-- markdown file extension
|
-- markdown file extension
|
||||||
extension = ".md",
|
extension = ".md",
|
||||||
|
|
||||||
-- Generate note filenames. One of:
|
-- Generate note filenames. One of:
|
||||||
-- "title" (default) - Use title if supplied, uuid otherwise
|
-- "title" (default) - Use title if supplied, uuid otherwise
|
||||||
-- "uuid" - Use uuid
|
-- "uuid" - Use uuid
|
||||||
-- "uuid-title" - Prefix title by uuid
|
-- "uuid-title" - Prefix title by uuid
|
||||||
-- "title-uuid" - Suffix title with uuid
|
-- "title-uuid" - Suffix title with uuid
|
||||||
new_note_filename = "title",
|
new_note_filename = "title",
|
||||||
|
|
||||||
--[[ file UUID type
|
--[[ file UUID type
|
||||||
- "rand"
|
- "rand"
|
||||||
- string input for os.date()
|
- string input for os.date()
|
||||||
@@ -77,18 +69,14 @@ local function defaultConfig(home)
|
|||||||
uuid_type = "%Y%m%d%H%M",
|
uuid_type = "%Y%m%d%H%M",
|
||||||
-- UUID separator
|
-- UUID separator
|
||||||
uuid_sep = "-",
|
uuid_sep = "-",
|
||||||
|
|
||||||
-- if not nil, replaces any spaces in the title when it is used in filename generation
|
-- if not nil, replaces any spaces in the title when it is used in filename generation
|
||||||
filename_space_subst = nil,
|
filename_space_subst = nil,
|
||||||
|
|
||||||
-- following a link to a non-existing note will create it
|
-- following a link to a non-existing note will create it
|
||||||
follow_creates_nonexisting = true,
|
follow_creates_nonexisting = true,
|
||||||
dailies_create_nonexisting = true,
|
dailies_create_nonexisting = true,
|
||||||
weeklies_create_nonexisting = true,
|
weeklies_create_nonexisting = true,
|
||||||
|
|
||||||
-- skip telescope prompt for goto_today and goto_thisweek
|
-- skip telescope prompt for goto_today and goto_thisweek
|
||||||
journal_auto_open = false,
|
journal_auto_open = false,
|
||||||
|
|
||||||
-- templates for new notes
|
-- templates for new notes
|
||||||
-- template_new_note = home .. "/" .. "templates/new_note.md",
|
-- template_new_note = home .. "/" .. "templates/new_note.md",
|
||||||
-- template_new_daily = home .. "/" .. "templates/daily_tk.md",
|
-- template_new_daily = home .. "/" .. "templates/daily_tk.md",
|
||||||
@@ -98,14 +86,11 @@ local function defaultConfig(home)
|
|||||||
-- wiki: ![[image name]]
|
-- wiki: ![[image name]]
|
||||||
-- markdown: 
|
-- markdown: 
|
||||||
image_link_style = "markdown",
|
image_link_style = "markdown",
|
||||||
|
|
||||||
-- default sort option: 'filename', 'modified'
|
-- default sort option: 'filename', 'modified'
|
||||||
sort = "filename",
|
sort = "filename",
|
||||||
|
|
||||||
-- when linking to a note in subdir/, create a [[subdir/title]] link
|
-- when linking to a note in subdir/, create a [[subdir/title]] link
|
||||||
-- instead of a [[title only]] link
|
-- instead of a [[title only]] link
|
||||||
subdirs_in_links = true,
|
subdirs_in_links = true,
|
||||||
|
|
||||||
-- integrate with calendar-vim
|
-- integrate with calendar-vim
|
||||||
plug_into_calendar = true,
|
plug_into_calendar = true,
|
||||||
calendar_opts = {
|
calendar_opts = {
|
||||||
@@ -118,17 +103,13 @@ local function defaultConfig(home)
|
|||||||
},
|
},
|
||||||
close_after_yanking = false,
|
close_after_yanking = false,
|
||||||
insert_after_inserting = true,
|
insert_after_inserting = true,
|
||||||
|
|
||||||
-- tag notation: '#tag', ':tag:', 'yaml-bare'
|
-- tag notation: '#tag', ':tag:', 'yaml-bare'
|
||||||
tag_notation = "#tag",
|
tag_notation = "#tag",
|
||||||
|
|
||||||
-- command palette theme: dropdown (window) or ivy (bottom panel)
|
-- command palette theme: dropdown (window) or ivy (bottom panel)
|
||||||
command_palette_theme = "ivy",
|
command_palette_theme = "ivy",
|
||||||
|
|
||||||
-- tag list theme:
|
-- tag list theme:
|
||||||
-- get_cursor: small tag list at cursor; ivy and dropdown like above
|
-- get_cursor: small tag list at cursor; ivy and dropdown like above
|
||||||
show_tags_theme = "ivy",
|
show_tags_theme = "ivy",
|
||||||
|
|
||||||
-- template_handling
|
-- template_handling
|
||||||
-- What to do when creating a new note via `new_note()` or `follow_link()`
|
-- What to do when creating a new note via `new_note()` or `follow_link()`
|
||||||
-- to a non-existing note
|
-- to a non-existing note
|
||||||
@@ -136,7 +117,6 @@ local function defaultConfig(home)
|
|||||||
-- - smart: if day or week is detected in title, use daily / weekly templates (default)
|
-- - smart: if day or week is detected in title, use daily / weekly templates (default)
|
||||||
-- - always_ask: always ask before creating a note
|
-- - always_ask: always ask before creating a note
|
||||||
template_handling = "smart",
|
template_handling = "smart",
|
||||||
|
|
||||||
-- path handling:
|
-- path handling:
|
||||||
-- this applies to:
|
-- this applies to:
|
||||||
-- - new_note()
|
-- - new_note()
|
||||||
@@ -159,16 +139,13 @@ local function defaultConfig(home)
|
|||||||
-- present or else in home
|
-- present or else in home
|
||||||
-- except for notes/with/subdirs/in/title.
|
-- except for notes/with/subdirs/in/title.
|
||||||
new_note_location = "smart",
|
new_note_location = "smart",
|
||||||
|
|
||||||
-- should all links be updated when a file is renamed
|
-- should all links be updated when a file is renamed
|
||||||
rename_update_links = true,
|
rename_update_links = true,
|
||||||
|
|
||||||
-- how to preview media files
|
-- how to preview media files
|
||||||
-- "telescope-media-files" if you have telescope-media-files.nvim installed
|
-- "telescope-media-files" if you have telescope-media-files.nvim installed
|
||||||
-- "catimg-previewer" if you have catimg installed
|
-- "catimg-previewer" if you have catimg installed
|
||||||
-- "viu-previewer" if you have viu installed
|
-- "viu-previewer" if you have viu installed
|
||||||
media_previewer = "telescope-media-files",
|
media_previewer = "telescope-media-files",
|
||||||
|
|
||||||
-- A customizable fallback handler for urls.
|
-- A customizable fallback handler for urls.
|
||||||
follow_url_fallback = nil,
|
follow_url_fallback = nil,
|
||||||
}
|
}
|
||||||
@@ -1188,7 +1165,6 @@ local function find_files_sorted(opts)
|
|||||||
entry_maker = entry_maker,
|
entry_maker = entry_maker,
|
||||||
}),
|
}),
|
||||||
sorter = conf.generic_sorter(opts),
|
sorter = conf.generic_sorter(opts),
|
||||||
|
|
||||||
previewer = previewer,
|
previewer = previewer,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -1566,7 +1542,6 @@ local function PreviewImg(opts)
|
|||||||
".webm",
|
".webm",
|
||||||
},
|
},
|
||||||
preview_type = "media",
|
preview_type = "media",
|
||||||
|
|
||||||
attach_mappings = function(prompt_bufnr, map)
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
actions.select_default:replace(function()
|
actions.select_default:replace(function()
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
@@ -1617,7 +1592,6 @@ local function BrowseImg(opts)
|
|||||||
".webm",
|
".webm",
|
||||||
},
|
},
|
||||||
preview_type = "media",
|
preview_type = "media",
|
||||||
|
|
||||||
attach_mappings = function(prompt_bufnr, map)
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
actions.select_default:replace(function()
|
actions.select_default:replace(function()
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
@@ -1873,6 +1847,8 @@ local function FindNotes(opts)
|
|||||||
map("n", "<c-i>", picker_actions.paste_link(opts))
|
map("n", "<c-i>", picker_actions.paste_link(opts))
|
||||||
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
map("i", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
map("n", "<c-cr>", picker_actions.paste_link(opts))
|
||||||
|
map("i", "<c-n>", picker_actions.create_new(opts))
|
||||||
|
map("n", "<c-n>", picker_actions.create_new(opts))
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1922,7 +1898,6 @@ local function InsertImgLink(opts)
|
|||||||
".webm",
|
".webm",
|
||||||
},
|
},
|
||||||
preview_type = "media",
|
preview_type = "media",
|
||||||
|
|
||||||
attach_mappings = function(prompt_bufnr, map)
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
actions.select_default:replace(function()
|
actions.select_default:replace(function()
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
@@ -2474,19 +2449,15 @@ local function FollowLink(opts)
|
|||||||
return Path:new({ t.cwd, t.filename }):absolute(), false
|
return Path:new({ t.cwd, t.filename }):absolute(), false
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
filename = function(t)
|
filename = function(t)
|
||||||
return parse(t)[1], true
|
return parse(t)[1], true
|
||||||
end,
|
end,
|
||||||
|
|
||||||
lnum = function(t)
|
lnum = function(t)
|
||||||
return parse(t)[2], true
|
return parse(t)[2], true
|
||||||
end,
|
end,
|
||||||
|
|
||||||
col = function(t)
|
col = function(t)
|
||||||
return parse(t)[3], true
|
return parse(t)[3], true
|
||||||
end,
|
end,
|
||||||
|
|
||||||
text = function(t)
|
text = function(t)
|
||||||
return parse(t)[4], true
|
return parse(t)[4], true
|
||||||
end,
|
end,
|
||||||
@@ -2501,7 +2472,6 @@ local function FollowLink(opts)
|
|||||||
|
|
||||||
mt_vimgrep_entry = {
|
mt_vimgrep_entry = {
|
||||||
cwd = vim.fn.expand(opts.cwd or vim.loop.cwd()),
|
cwd = vim.fn.expand(opts.cwd or vim.loop.cwd()),
|
||||||
|
|
||||||
__index = function(t, k)
|
__index = function(t, k)
|
||||||
local raw = rawget(mt_vimgrep_entry, k)
|
local raw = rawget(mt_vimgrep_entry, k)
|
||||||
if raw then
|
if raw then
|
||||||
@@ -3168,6 +3138,17 @@ TelekastenCmd.command = function(subcommand)
|
|||||||
show(theme)
|
show(theme)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function picker_actions.create_new(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.subdirs_in_links = opts.subdirs_in_links or M.Cfg.subdirs_in_links
|
||||||
|
return function(prompt_bufnr)
|
||||||
|
local prompt =
|
||||||
|
action_state.get_current_picker(prompt_bufnr).sorter._discard_state.prompt
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
on_create(opts, prompt)
|
||||||
|
-- local selection = action_state.get_selected_entry()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- nvim completion function for completing :Telekasten sub-commands
|
-- nvim completion function for completing :Telekasten sub-commands
|
||||||
TelekastenCmd.complete = function()
|
TelekastenCmd.complete = function()
|
||||||
|
|||||||
Reference in New Issue
Block a user