Skip to content

Commit

Permalink
feat(terminal): better double esc to go to normal mode
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Nov 4, 2024
1 parent 977a3d3 commit a4af729
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lua/snacks/terminal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ local defaults = {
vim.cmd("e " .. f)
end
end,
term_normal = {
"<esc>",
function(self)
self.esc_timer = self.esc_timer or (vim.uv or vim.loop).new_timer()
if self.esc_timer:is_active() then
self.esc_timer:stop()
vim.cmd("stopinsert")
else
self.esc_timer:start(200, 0, function() end)
return "<esc>"
end
end,
mode = "t",
expr = true,
desc = "Double escape to normal mode",
},
},
},
}
Expand Down

0 comments on commit a4af729

Please sign in to comment.