diff --git a/README.md b/README.md index 2785051..bbf4246 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ The plugin defines the following functions. - `find_daily_notes()` : find daily notes by date (file names, sorted, most recent first), via Telescope. If today's daily note is not present, it will be created with a hardcoded template. - `search_notes()`: live grep for word under cursor in all notes (search in notes), via Telescope - `insert_link()` : select a note by name, via Telescope, and place a `[[link]]` at the current cursor position -- `follow_link()`: take word under cursor and open a Telescope file finder with it: selects note to open (incl. preview) +- `follow_link()`: take text between brackets (linked notes) and open a Telescope file finder with it: selects note to open (incl. preview) - `install_daily_finder()` : installs the daily finder tool used by the plugin - `setup(opts)`: used for configuring paths, file extension, etc. diff --git a/lua/telekasten.lua b/lua/telekasten.lua index 4b2dcb3..92fc2b5 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -109,15 +109,19 @@ end -- find the file linked to by the word under the cursor -- follow_link = function(opts) + vim.cmd('normal yi]') + local word = vim.fn.getreg('"0') builtin.find_files({ prompt_title = "Follow link to note...", cwd = zkcfg.home, - default_text = vim.fn.expand(""), + default_text = word, find_command = { zkcfg.daily_finder }, entry_maker = zk_entry_maker, }) end + + -- -- find_notes: --