From 24fd8c1e7eb989dba9efa5d174e42870f08da8fb Mon Sep 17 00:00:00 2001 From: Tonitum Date: Wed, 17 Apr 2024 01:33:27 -0600 Subject: [PATCH] feat: Tab autocompletes with folders in notes home directory (#326) * refs 293-tab-complete-fix: feat: changing the current working directory when creating a new note to the configured home directory * refs 293-tab-complete-fix: format(telekasten): removing trailing whitespace in comments closes #293 closes #277 --- lua/telekasten.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index 1daa3fb..233676f 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -2002,9 +2002,16 @@ local function CreateNoteSelectTemplate(opts) return end + -- get the current working directory + local current_dir = vim.fn.getcwd() + -- change the cwd to the configured home directory, so tab completion + -- works for the folders in that directory + vim.fn.chdir(M.Cfg.home) fileutils.prompt_title(M.Cfg.extension, nil, function(title) on_create_with_template(opts, title) end) + -- change back to the original directory + vim.fn.chdir(current_dir) end) end @@ -2085,9 +2092,16 @@ local function CreateNote(opts) return CreateNoteSelectTemplate(opts) end + -- get the current working directory + local current_dir = vim.fn.getcwd() + -- change the cwd to the configured home directory, so tab completion + -- works for the folders in that directory + vim.fn.chdir(M.Cfg.home) fileutils.prompt_title(M.Cfg.extension, nil, function(title) on_create(opts, title) end) + -- change back to the original directory + vim.fn.chdir(current_dir) end) end