From 90da494323c8947abfcd654bbbb251afba7144d6 Mon Sep 17 00:00:00 2001 From: Guillaume Chérel Date: Thu, 23 Nov 2017 10:32:12 +0100 Subject: Added configuration for path and defauld args. --- README.md | 15 +++++++++++++++ fzf-open.lua | 16 +++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 82fa5fd..1a5e210 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,18 @@ Use [fzf](https://github.com/junegunn/fzf) to open files in [vis](https://github In vis: - `:fzf`: search all files in the current sub-tree. - You can pass arguments to fzf, e.g. : `:fzf -p !.class` + +## Configuration + +In visrc.lua: + +`` +plugin_vis_open =require('plugins/vis-fzf-open/fzf-open') + +-- Path to the fzf executable (default: "fzf") +plugin_vis_open.fzf_path = "fzf" + +-- Arguments passed to fzf (defaul: "") + plugin_vis_open.fzf_args = "-q '!.class '" +`` + diff --git a/fzf-open.lua b/fzf-open.lua index 8e3e4ca..7a20b0c 100644 --- a/fzf-open.lua +++ b/fzf-open.lua @@ -13,8 +13,12 @@ -- You should have received a copy of the GNU Affero General Public License -- along with this program. If not, see . +module = {} +module.fzf_path = "fzf" +module.fzf_args = "" + vis:command_register("fzf", function(argv, force, win, selection, range) - local command = "fzf " .. table.concat(argv, " ") + local command = module.fzf_path .. " " .. module.fzf_args .. " " .. table.concat(argv, " ") local file = io.popen(command) local output = file:read() @@ -23,16 +27,18 @@ vis:command_register("fzf", function(argv, force, win, selection, range) if status == 0 then vis:command(string.format("e '%s'", output)) elseif status == 1 then - vis:info(string.format("fzf: No match. Command %s exited with return value %i." , command, status)) + vis:info(string.format("fzf-open: No match. Command %s exited with return value %i." , command, status)) elseif status == 2 then - vis:info(string.format("fzf: Error. Command %s exited with return value %i." , command, status)) + vis:info(string.format("fzf-open: Error. Command %s exited with return value %i." , command, status)) elseif status == 130 then - vis:info(string.format("fzf: Interrupted. Command %s exited with return value %i" , command, status)) + vis:info(string.format("fzf-open: Interrupted. Command %s exited with return value %i" , command, status)) else - vis:info(string.format("fzf: Unknown exit status %i. command %s exited with return value %i" , command, status, status)) + vis:info(string.format("fzf-open: Unknown exit status %i. command %s exited with return value %i" , status, command, status, status)) end vis:feedkeys("") return true; end) + +return module -- cgit