Skip to content

Commit

Permalink
feat(ui/inputs): enable normal mode in rename popup (#1043)
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneExile authored Jul 13, 2023
1 parent fb5636d commit a64419d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ use {
popup_border_style = "rounded",
enable_git_status = true,
enable_diagnostics = true,
enable_normal_mode_for_inputs = false, -- Enable normal mode for input dialogs.
open_files_do_not_replace_types = { "terminal", "trouble", "qf" }, -- when opening files, do not use windows containing these filetypes or buftypes
sort_case_insensitive = false, -- used when sorting files and directories in the tree
sort_function = nil , -- use a custom function for sorting files and directories in the tree
Expand Down
1 change: 1 addition & 0 deletions lua/neo-tree/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local config = {
enable_modified_markers = true, -- Show markers for files with unsaved changes.
enable_opened_markers = true, -- Enable tracking of opened files. Required for `components.name.highlight_opened_files`
enable_refresh_on_write = true, -- Refresh the tree when a file is written. Only used if `use_libuv_file_watcher` is false.
enable_normal_mode_for_inputs = false, -- Enable normal mode for input dialogs.
git_status_async = true,
-- These options are for people with VERY large git repos
git_status_async_options = {
Expand Down
18 changes: 18 additions & 0 deletions lua/neo-tree/ui/inputs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,27 @@ local should_use_popup_input = function()
end

M.show_input = function(input, callback)
local config = require("neo-tree").config
input:mount()

if config.enable_normal_mode_for_inputs and input.prompt_type ~= "confirm" then
vim.schedule(function()
vim.cmd("stopinsert")
end)
end

input:map("i", "<esc>", function()
vim.cmd("stopinsert")
if not config.enable_normal_mode_for_inputs or input.prompt_type == "confirm" then
input:unmount()
end
end, { noremap = true })

input:map("n", "<esc>", function()
input:unmount()
end, { noremap = true })

input:map("n", "q", function()
input:unmount()
end, { noremap = true })

Expand Down Expand Up @@ -66,6 +83,7 @@ M.confirm = function(message, callback)
end,
})

input.prompt_type = "confirm"
M.show_input(input)
else
local opts = {
Expand Down

0 comments on commit a64419d

Please sign in to comment.