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
This commit is contained in:
Tonitum
2024-04-17 01:33:27 -06:00
committed by GitHub
parent 3ef86c924b
commit 24fd8c1e7e

View File

@@ -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