feat(search-node): use vim.ui.input

This commit is contained in:
kiyan
2022-07-18 14:20:55 +02:00
parent 69aec67edb
commit 1b667bc99e

View File

@@ -1,7 +1,6 @@
local api = vim.api local api = vim.api
local uv = vim.loop local uv = vim.loop
local utils = require "nvim-tree.utils"
local core = require "nvim-tree.core" local core = require "nvim-tree.core"
local filters = require "nvim-tree.explorer.filters" local filters = require "nvim-tree.explorer.filters"
local find_file = require("nvim-tree.actions.finders.find-file").fn local find_file = require("nvim-tree.actions.finders.find-file").fn
@@ -56,10 +55,10 @@ function M.fn()
local path_existed, path_opt = pcall(api.nvim_buf_get_option, bufnr, "path") local path_existed, path_opt = pcall(api.nvim_buf_get_option, bufnr, "path")
api.nvim_buf_set_option(bufnr, "path", core.get_cwd() .. "/**") api.nvim_buf_set_option(bufnr, "path", core.get_cwd() .. "/**")
-- completes files/dirs under cwd vim.ui.input({ prompt = "Search: ", completion = "file_in_path" }, function(input_path)
local input_path = vim.fn.input("Search: ", "", "file_in_path") if not input_path or input_path == "" then
utils.clear_prompt() return
end
-- reset &path -- reset &path
if path_existed then if path_existed then
api.nvim_buf_set_option(bufnr, "path", path_opt) api.nvim_buf_set_option(bufnr, "path", path_opt)
@@ -75,6 +74,7 @@ function M.fn()
if found then if found then
find_file(found) find_file(found)
end end
end)
end end
return M return M