Skip to content

Commit

Permalink
feat(config): stay_on_exec (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
BZ committed Dec 14, 2023
1 parent 9b0251c commit 9c4ffe7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local defaults = {

mode = "hybrid", -- "modal" | "hold" | "hybrid" | "forever"
smart_modifiers = true, -- like smartcase but for all root key modifiers
stay_on_exec = true, -- stay on tree level or reset tree after executing
stop_on_unknown_key = false,
timeout = 0, -- ms
labels = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&'()*+,-./:;<=>?@\\^_`{|}~",
Expand Down
11 changes: 10 additions & 1 deletion modal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,9 @@ function trunner:step_into(node)

node:remove_temp_successors()

if node:is_leaf() then
local is_exec = node:is_leaf()

if is_exec then
next_tree = self:execute(node)
else
next_tree = node
Expand All @@ -571,6 +573,13 @@ function trunner:step_into(node)
return
end

if is_exec then
local opts = node:opts()
if not opts.stay_on_exec then
self:set_tree(node:get_root_tree())
end
end

self.continue_external = false
end

Expand Down
9 changes: 9 additions & 0 deletions tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,15 @@ function M:successors()
return tree_objects
end

function M:get_root_tree()
local t = self
while t:pred() do
t = t:pred()
end

return t
end

function M:is_leaf()
local succs = self._succs
if not succs or vim.tbl_isempty(succs) then
Expand Down

0 comments on commit 9c4ffe7

Please sign in to comment.