aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Chérel <guillaume.cherel@iscpif.fr>2017-11-23 10:32:12 +0100
committerGuillaume Chérel <guillaume.cherel@iscpif.fr>2017-11-23 10:43:16 +0100
commit90da494323c8947abfcd654bbbb251afba7144d6 (patch)
tree67215072938ef91ca13be6a558efe24060eb91f1
parent88b745b07ea383078a67b3c09c8c59f067f94b10 (diff)
downloadvis-fzf-open-90da494323c8947abfcd654bbbb251afba7144d6.tar.gz
Added configuration for path and defauld args.
-rw-r--r--README.md15
-rw-r--r--fzf-open.lua16
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 <https://www.gnu.org/licenses/>.
+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("<vis-redraw>")
return true;
end)
+
+return module