diff options
author | JeeBak Kim <jeebak.kim@gmail.com> | 2019-12-30 07:04:24 -0800 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2021-01-16 14:28:42 +0100 |
commit | 1701bfc97df725b0ca23ed96b974744726e66f0b (patch) | |
tree | ee5c030f4d955673f91e09d080626a01e4654a29 | |
parent | b466a53bc6ad161161c34b56851541bb8747ff82 (diff) | |
download | vis-fzf-open-1701bfc97df725b0ca23ed96b974744726e66f0b.tar.gz |
Add split and vsplit options
-rw-r--r-- | fzf-open.lua | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/fzf-open.lua b/fzf-open.lua index 8c94cf3..2b78d41 100644 --- a/fzf-open.lua +++ b/fzf-open.lua @@ -19,7 +19,10 @@ module.fzf_args = "" vis:command_register("fzf", function(argv, force, win, selection, range) local command = string.gsub([[ - $fzf_path $fzf_args $args + $fzf_path \ + --header="Enter:edit,^s:split,^v:vsplit" \ + --expect="ctrl-s,ctrl-v" \ + $fzf_args $args ]], '%$([%w_]+)', { fzf_path=module.fzf_path, @@ -29,12 +32,20 @@ vis:command_register("fzf", function(argv, force, win, selection, range) ) local file = io.popen(command) - local output = file:read() + local output = {} + for line in file:lines() do + table.insert(output, line) + end local success, msg, status = file:close() - if status == 0 then - -- vis:command(string.format("e '%s'", output)) - vis:feedkeys(string.format(":e '%s'<Enter>", output)) + if status == 0 then + local action = 'e' + + if output[1] == 'ctrl-s' then action = 'split' + elseif output[1] == 'ctrl-v' then action = 'vsplit' + end + + vis:feedkeys(string.format("%s '%s'<Enter>", action, output[2])) elseif status == 1 then vis:info( string.format( |