root/lang/vim/misc/quicklook.vim @ 12318

Revision 12318, 0.7 kB (checked in by ujihisa, 7 years ago)

lang/vim/misc/quicklook.vim: fix bug

Line 
1command Quicklook :call <SID>QuicklookStart()
2
3function! s:QuicklookStart()
4  ruby quicklook_run
5endfunction
6
7ruby << EOF
8# view :: String -> Bool (with qlmanage)
9def view(filename_like)
10  filename = filename_like
11  filename = File.expand_path(filename)
12  unless FileTest.exists? filename
13    VIM.message "#{filename} not found"
14    return false
15  end
16  fork {
17    pid = fork {
18      STDERR.reopen(File.open('/dev/null', 'w'))
19      exec ['qlmanage']*2, '-p', filename
20    }
21    sleep 2
22    Process.kill(:TERM, pid)
23  }
24  true
25end
26
27def quicklook_run
28  VIM::Buffer.current.line.gsub(/^\s+/, '').split(/\s+/).each do |filename_like|
29    view(filename_like) ||
30      view(File.dirname(VIM::Buffer.current.name) + filename_like)
31  end
32end
33EOF
Note: See TracBrowser for help on using the browser.