mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
refact: replace vim.fn.input by vim.ui.select
The vim.ui.select allows style customizations for the users. This is much more modern and in phase with the general spirit of neovim.
This commit is contained in:
@@ -229,18 +229,15 @@ end
|
||||
local function check_dir_and_ask(dir, purpose)
|
||||
local ret = false
|
||||
if dir ~= nil and Path:new(dir):exists() == false then
|
||||
vim.cmd("echohl ErrorMsg")
|
||||
local answer = vim.fn.input(
|
||||
"Telekasten.nvim: "
|
||||
vim.ui.select({ "No (default)", "Yes" }, {
|
||||
prompt = "Telekasten.nvim: "
|
||||
.. purpose
|
||||
.. " folder "
|
||||
.. dir
|
||||
.. " does not exist!"
|
||||
.. " Shall I create it? [y/N] "
|
||||
)
|
||||
vim.cmd("echohl None")
|
||||
answer = vim.fn.trim(answer)
|
||||
if answer == "y" or answer == "Y" then
|
||||
.. " Shall I create it? ",
|
||||
}, function(answer)
|
||||
if answer == "Yes" then
|
||||
if Path:new(dir):mkdir({ exists_ok = false }) then
|
||||
vim.cmd('echomsg " "')
|
||||
vim.cmd('echomsg "' .. dir .. ' created"')
|
||||
@@ -251,6 +248,7 @@ local function check_dir_and_ask(dir, purpose)
|
||||
ret = false
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
ret = true
|
||||
end
|
||||
@@ -1714,14 +1712,14 @@ local function RenameNote()
|
||||
#(vim.fn.getbufinfo({ bufmodified = 1 })) > 1
|
||||
and M.Cfg.auto_set_filetype == true
|
||||
then
|
||||
local answer = vim.fn.input(
|
||||
"Telekasten.nvim:"
|
||||
.. "Save all telekasten buffers before updating links? [Y/n]"
|
||||
)
|
||||
answer = vim.fn.trim(answer)
|
||||
if answer ~= "n" and answer ~= "N" then
|
||||
vim.ui.select({ "Yes (default)", "No" }, {
|
||||
prompt = "Telekasten.nvim: "
|
||||
.. "Save all telekasten buffers before updating links?",
|
||||
}, function(answer)
|
||||
if answer ~= "No" then
|
||||
save_all_tk_buffers()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
recursive_substitution(M.Cfg.home, oldlink, newlink)
|
||||
|
||||
Reference in New Issue
Block a user