This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit of fzf plugin for micro
- Loading branch information
0 parents
commit fe4e18b
Showing
6 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Copyright (c) 2016, Samantha Marshall | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of Samantha Marshall nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function fzf | ||
set -l epoch (date "+%s") | ||
set -l file_path $TMPDIR/fzf-$epoch.result | ||
command fzf $argv >$file_path | ||
if test $status -eq 0 -a -s $file_path | ||
cat $file_path | ||
end | ||
if test -e $file_path | ||
rm $file_path | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
VERSION = "1.0" | ||
|
||
MakeCommand("fzf", "fzf.fzf", 0) | ||
|
||
function removeNewlines(string_value) | ||
if string.find(string_value, "\n") then | ||
return string.gsub(string_value, "\n", "") | ||
else | ||
return string_value | ||
end | ||
end | ||
|
||
function reportedExitCode(string_value) | ||
local exit_code_string = "exit status " | ||
return string.sub(string_value, 1, string.len(exit_code_string)) == exit_code_string | ||
end | ||
|
||
function fzf() | ||
CurView():Save(false) | ||
local fzf_output = HandleShellCommand("fzf", true, false) | ||
if not reportedExitCode(fzf_output) then | ||
local desired_path = removeNewlines(fzf_output) | ||
local working_path = removeNewlines(HandleShellCommand("pwd", false, false)) | ||
local selected_path = working_path .. desired_path | ||
CurView():Open(selected_path) | ||
messenger:Message("Opened "..selected_path) | ||
end | ||
end | ||
|
||
AddRuntimeFile("fzf", "help", "help/fzf.md") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# About the fzf plugin | ||
|
||
This plugin | ||
|
||
# Commands | ||
|
||
The plugin providies the following commands: | ||
|
||
* `fzf`: launch `fzf` to find a file to open. | ||
|
||
|
||
# Troubleshooting | ||
|
||
There is a [known issue](https://github.com/fish-shell/fish-shell/issues/1362) when using fzf with fish shell. To work around this, you should create a new fish shell function called `fzf` to be trigged instead of the `fzf` command directly. You can copy and past the following snippet into the file: | ||
|
||
$FISH_CONFIG_PATH/functions/fzf.fish | ||
|
||
``` | ||
function fzf | ||
set -l epoch (date "+%s") | ||
set -l file_path $TMPDIR/fzf-$epoch.result | ||
command fzf $argv >$file_path | ||
if test $status -eq 0 -a -s $file_path | ||
cat $file_path | ||
end | ||
if test -e $file_path | ||
rm $file_path | ||
end | ||
end | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# fzf plugin for micro | ||
|
||
This repository holds the [fzf](https://github.com/junegunn/fzf) plugin for [micro](https://github.com/zyedidia/micro) | ||
|
||
# Troubleshooting | ||
|
||
There is a [known issue](https://github.com/fish-shell/fish-shell/issues/1362) when using fzf with fish shell. To work around this, you should create a new fish shell function called `fzf` to be trigged instead of the `fzf` command directly. You can copy and past the following snippet into the file: | ||
|
||
$FISH_CONFIG_PATH/functions/fzf.fish | ||
|
||
``` | ||
function fzf | ||
set -l epoch (date "+%s") | ||
set -l file_path $TMPDIR/fzf-$epoch.result | ||
command fzf $argv >$file_path | ||
if test $status -eq 0 -a -s $file_path | ||
cat $file_path | ||
end | ||
if test -e $file_path | ||
rm $file_path | ||
end | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
{ | ||
"Name": "fzf", | ||
"Description": "adds support to opening files via fzf", | ||
"Tags": ["fzf"], | ||
"Versions": [ | ||
{ | ||
"Version "1.0", | ||
"Url": "https://github.com/samdmarshall/micro-fzf-plugin/archive/v1.0.zip", | ||
"Require": { | ||
"micro": ">=1.1.2", | ||
"fzf": ">=0.15.9", | ||
} | ||
} | ||
] | ||
} | ||
] |