Last active
May 13, 2017 15:55
-
-
Save igemnace/9a2cec96a93b9e713827791751fa4ea6 to your computer and use it in GitHub Desktop.
A hack for fzf.vim to allow a preview window for :Lines
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
diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim | |
index 7ec7b92..dee6d81 100644 | |
--- a/autoload/fzf/vim.vim | |
+++ b/autoload/fzf/vim.vim | |
@@ -281,11 +281,11 @@ function! fzf#vim#_lines(all) | |
if display_bufnames | |
let bufnames = {} | |
for b in s:buflisted() | |
- let bufnames[b] = pathshorten(fnamemodify(bufname(b), ":~:.")) | |
+ let bufnames[b] = fnamemodify(bufname(b), ":~:.") | |
let longest_name = max([longest_name, len(bufnames[b])]) | |
endfor | |
endif | |
- let len_bufnames = min([15, longest_name]) | |
+ let len_bufnames = longest_name | |
for b in s:buflisted() | |
let lines = getbufline(b, 1, "$") | |
if empty(lines) | |
diff --git a/bin/preview.rb b/bin/preview.rb | |
index a7886ef..4b5a9df 100755 | |
--- a/bin/preview.rb | |
+++ b/bin/preview.rb | |
@@ -21,12 +21,20 @@ usage if ARGV.empty? | |
file, center = ARGV.first.split(':') | |
usage unless file | |
-path = File.expand_path(file) | |
-unless File.readable? path | |
- puts "File not found: #{file}" | |
- exit 1 | |
+def checkpath(file) | |
+ path = File.expand_path(file) | |
+ File.readable? path | |
end | |
+unless checkpath(file) | |
+ bufnum, file, center = ARGV.first.split(' ') | |
+ unless checkpath(file) | |
+ puts "File not found: #{file}" | |
+ end | |
+end | |
+ | |
+path = File.expand_path(file) | |
+ | |
if `file --mime "#{file}"` =~ /binary/ | |
puts "#{file} is a binary file" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment