mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
new feature: find_friends(): friend notes are note that reference the
same note as the link under the cursor
This commit is contained in:
@@ -13,6 +13,7 @@ A Neovim (lua) plugin for working with a text-based, markdown [zettelkasten](htt
|
||||
- calendar support
|
||||
- paste images from clipboard
|
||||
- toggle [ ] todo status of line
|
||||
- show back-links and notes also referencing links
|
||||
|
||||
---
|
||||
|
||||
@@ -225,6 +226,7 @@ The plugin defines the following functions.
|
||||
- `paste_img_and_link()` : pastes an image from the clipboard into a file under `image_subdir` and inserts a link to it at the current cursor position
|
||||
- `toggle_todo()` : turn a line into a `- [ ] ` line, or toggle between `- [ ]`, `- [x]`, and `- `.
|
||||
- `show_backlinks()` : opens a telescope search for notes that `[[link]]` back to the current note.
|
||||
- `find_friends()` : opens a telescope search for notes that also `[[link]]` to the link under the cursor.
|
||||
- `setup(opts)`: used for configuring paths, file extension, etc.
|
||||
|
||||
To use one of the functions above, just run them with the `:lua ...` command.
|
||||
|
||||
@@ -413,6 +413,11 @@ telekasten.toggle_todo()~
|
||||
telekasten.show_backlinks()~
|
||||
Opens a telescope search for notes that `[[link]]` back to the current note.
|
||||
|
||||
*telekasten.find_friends()*
|
||||
telekasten.find_friends()~
|
||||
Opens a telescope search for notes that also `[[link]]` to the link under the
|
||||
cursor.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Section 3.1: Templates *telekasten.templates*
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ local function file_exists(fname)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- ----------------------------------------------------------------------------
|
||||
-- image stuff
|
||||
local imgFromClipboard = function()
|
||||
@@ -352,6 +351,24 @@ local FollowLink = function(opts)
|
||||
})
|
||||
end
|
||||
|
||||
--
|
||||
-- FindFriends:
|
||||
-- -----------
|
||||
--
|
||||
-- Find notes also linking to the link under cursor
|
||||
--
|
||||
local FindFriends = function()
|
||||
vim.cmd("normal yi]")
|
||||
local title = vim.fn.getreg('"0')
|
||||
|
||||
builtin.live_grep({
|
||||
prompt_title = "Notes referencing `" .. title .. "`",
|
||||
cwd = M.Cfg.home,
|
||||
default_text = "\\[\\[" .. title .. "\\]\\]",
|
||||
find_command = M.Cfg.find_command,
|
||||
})
|
||||
end
|
||||
|
||||
--
|
||||
-- YankLink:
|
||||
-- -----------
|
||||
@@ -440,14 +457,14 @@ end
|
||||
-- Find all notes linking to this one
|
||||
--
|
||||
local ShowBacklinks = function(_)
|
||||
local title = path_to_linkname(vim.fn.expand('%'))
|
||||
local title = path_to_linkname(vim.fn.expand("%"))
|
||||
-- or vim.api.nvim_buf_get_name(0)
|
||||
builtin.live_grep({
|
||||
results_title = "Backlinks to " .. title,
|
||||
prompt_title = "Search",
|
||||
cwd = M.Cfg.home,
|
||||
search_dirs = { M.Cfg.home },
|
||||
default_text = '\\[\\[' .. title .. '\\]\\]',
|
||||
default_text = "\\[\\[" .. title .. "\\]\\]",
|
||||
find_command = M.Cfg.find_command,
|
||||
})
|
||||
end
|
||||
@@ -737,5 +754,6 @@ M.CalendarAction = CalendarAction
|
||||
M.paste_img_and_link = imgFromClipboard
|
||||
M.toggle_todo = ToggleTodo
|
||||
M.show_backlinks = ShowBacklinks
|
||||
M.find_friends = FindFriends
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user