Add a bunch of stuff, change leader key
git-svn-id: http://photonzero.com/dotfiles/trunk@70 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
parent
410560d54e
commit
c47f86d55b
90 changed files with 9641 additions and 1653 deletions
4
.gvimrc
4
.gvimrc
|
|
@ -1,7 +1,7 @@
|
||||||
winsize 115 45
|
winsize 115 45
|
||||||
"set expandtab
|
"set expandtab
|
||||||
set guifont=DejaVu\ Sans\ Mono:h15.00
|
"set guifont=DejaVu\ Sans\ Mono:h15.00
|
||||||
"set guifont=Inconsolata:h18.00
|
set guifont=Inconsolata:h18.00
|
||||||
|
|
||||||
"call AppleTSetPath("~/work/client")
|
"call AppleTSetPath("~/work/client")
|
||||||
"map gg :CmdT
|
"map gg :CmdT
|
||||||
|
|
|
||||||
6
.npmrc
6
.npmrc
|
|
@ -1,4 +1,2 @@
|
||||||
root =/home/barak/.node_libraries
|
root =/Users/barak/.node_libraries
|
||||||
binroot=/home/barak/bin
|
binroot=/Users/barak/bin
|
||||||
gzipbin=/usr/local/bin/gzip
|
|
||||||
tar=/usr/local/bin/gtar
|
|
||||||
|
|
|
||||||
|
|
@ -59,3 +59,4 @@ command! -bang -nargs=* -complete=file AckFromSearch call s:AckFromSearch('grep<
|
||||||
command! -bang -nargs=* -complete=file LAck call s:Ack('lgrep<bang>', <q-args>)
|
command! -bang -nargs=* -complete=file LAck call s:Ack('lgrep<bang>', <q-args>)
|
||||||
command! -bang -nargs=* -complete=file LAckAdd call s:Ack('lgrepadd<bang>', <q-args>)
|
command! -bang -nargs=* -complete=file LAckAdd call s:Ack('lgrepadd<bang>', <q-args>)
|
||||||
command! -bang -nargs=* -complete=file AckFile call s:Ack('grep<bang> -g', <q-args>)
|
command! -bang -nargs=* -complete=file AckFile call s:Ack('grep<bang> -g', <q-args>)
|
||||||
|
command! -bang -nargs=* -complete=file AckWord call s:Ack('grep<bang>', expand("<cword>"))
|
||||||
|
|
|
||||||
83
.vim/bundle/lusty/Makefile
Normal file
83
.vim/bundle/lusty/Makefile
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
# Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
EXPLORER_VIM_FILE = src/explorer.vim
|
||||||
|
|
||||||
|
# Order matters.
|
||||||
|
EXPLORER_RUBY_FILES = src/vim.rb \
|
||||||
|
src/lusty.rb \
|
||||||
|
src/mercury.rb \
|
||||||
|
src/lusty/entry.rb \
|
||||||
|
src/lusty/explorer.rb \
|
||||||
|
src/lusty/buffer-explorer.rb \
|
||||||
|
src/lusty/filesystem-explorer.rb \
|
||||||
|
src/lusty/buffer-grep.rb \
|
||||||
|
src/lusty/prompt.rb \
|
||||||
|
src/lusty/window.rb \
|
||||||
|
src/lusty/saved-settings.rb \
|
||||||
|
src/lusty/display.rb \
|
||||||
|
src/lusty/file-masks.rb \
|
||||||
|
src/lusty/vim-swaps.rb \
|
||||||
|
src/lusty/buffer-stack.rb
|
||||||
|
|
||||||
|
JUGGLER_VIM_FILE = src/juggler.vim
|
||||||
|
|
||||||
|
# Order matters.
|
||||||
|
JUGGLER_RUBY_FILES = src/vim.rb \
|
||||||
|
src/lusty.rb \
|
||||||
|
src/lusty/juggler.rb \
|
||||||
|
src/lusty/bar-item.rb \
|
||||||
|
src/lusty/name-bar.rb \
|
||||||
|
src/lusty/buffer-stack.rb
|
||||||
|
|
||||||
|
all: plugin/lusty-explorer.vim plugin/lusty-juggler.vim
|
||||||
|
|
||||||
|
UNAME := $(shell uname)
|
||||||
|
|
||||||
|
# OS X's sed doesn't have \< or \b for word boundaries.
|
||||||
|
ifeq ($(UNAME), Darwin)
|
||||||
|
LEFT_BOUND = [[:<:]]
|
||||||
|
RIGHT_BOUND = [[:>:]]
|
||||||
|
else
|
||||||
|
LEFT_BOUND = \<
|
||||||
|
RIGHT_BOUND = \>
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Concatenate the Ruby files, removing redundant copyrights, and insert
|
||||||
|
# the results into the vimscript files. Change LustyM module references to
|
||||||
|
# LustyE or LustyJ, so that using out-of-sync versions of lusty-explorer and
|
||||||
|
# lusty-juggler is less likely to cause monkey patching issues.
|
||||||
|
|
||||||
|
plugin/lusty-explorer.vim: $(EXPLORER_VIM_FILE) $(EXPLORER_RUBY_FILES)
|
||||||
|
for file in $(EXPLORER_RUBY_FILES); do \
|
||||||
|
cat $$file | sed '1,/^$$/d' ;\
|
||||||
|
echo ; \
|
||||||
|
done | sed 's/$(LEFT_BOUND)LustyM$(RIGHT_BOUND)/LustyE/g' > \
|
||||||
|
ruby-content.tmp
|
||||||
|
( sed '/{{RUBY_CODE_INSERTION_POINT}}/,$$d' $(EXPLORER_VIM_FILE) ; \
|
||||||
|
cat ruby-content.tmp ; \
|
||||||
|
sed '1,/{{RUBY_CODE_INSERTION_POINT}}/d' $(EXPLORER_VIM_FILE) ) > \
|
||||||
|
plugin/lusty-explorer.vim
|
||||||
|
rm -f ruby-content.tmp
|
||||||
|
|
||||||
|
plugin/lusty-juggler.vim: $(JUGGLER_VIM_FILE) $(JUGGLER_RUBY_FILES)
|
||||||
|
for file in $(JUGGLER_RUBY_FILES); do \
|
||||||
|
cat $$file | sed '1,/^$$/d' ;\
|
||||||
|
echo ; \
|
||||||
|
done | sed 's/$(LEFT_BOUND)LustyM$(RIGHT_BOUND)/LustyJ/g' > \
|
||||||
|
ruby-content.tmp
|
||||||
|
( sed '/{{RUBY_CODE_INSERTION_POINT}}/,$$d' $(JUGGLER_VIM_FILE) ; \
|
||||||
|
cat ruby-content.tmp ; \
|
||||||
|
sed '1,/{{RUBY_CODE_INSERTION_POINT}}/d' $(JUGGLER_VIM_FILE) ) > \
|
||||||
|
plugin/lusty-juggler.vim
|
||||||
|
rm -f ruby-content.tmp
|
||||||
|
clean:
|
||||||
|
rm -f ruby-content.tmp plugin/lusty-explorer.vim \
|
||||||
|
plugin/lusty-juggler.vim
|
||||||
|
|
||||||
13
.vim/bundle/lusty/README
Normal file
13
.vim/bundle/lusty/README
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
These are a set of plugins for Vim. You can download released versions here:
|
||||||
|
|
||||||
|
lusty-explorer.vim: http://www.vim.org/scripts/script.php?script_id=1890
|
||||||
|
lusty-juggler.vim: http://www.vim.org/scripts/script.php?script_id=2050
|
||||||
|
|
||||||
|
The Emacs version of this plugin used to be here, too, but now it has its own
|
||||||
|
repository:
|
||||||
|
|
||||||
|
http://github.com/sjbach/lusty-emacs
|
||||||
|
|
||||||
|
NOTE: lusty-explorer.vim and lusty-juggler.vim are generated files; modify
|
||||||
|
src/ if you'd like to submit a patch.
|
||||||
|
|
||||||
2
.vim/bundle/lusty/doc/explorer-vim.changes
Normal file
2
.vim/bundle/lusty/doc/explorer-vim.changes
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
Don't throw an error when looking up special non-file buffers.
|
||||||
|
New and improved fuzzy matching algorithm.
|
||||||
38
.vim/bundle/lusty/doc/explorer-vim.writeup
Normal file
38
.vim/bundle/lusty/doc/explorer-vim.writeup
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
LustyExplorer is a fast and responsive way to manage files and buffers in Vim. It includes a filesystem explorer, a buffer switcher, and a buffer grep for searching through and switching between files and buffers quickly, all through a mostly common interface.
|
||||||
|
|
||||||
|
A short video someone made:
|
||||||
|
|
||||||
|
http://www.youtube.com/watch?v=dLMKVYqdarY
|
||||||
|
|
||||||
|
Some old stuff (pre v2.0 - we now use fuzzy matching instead of tab completion):
|
||||||
|
http://viewglob.sourceforge.net/lusty-explorer-animated.gif
|
||||||
|
http://viewglob.sourceforge.net/lusty-explorer-annotated.png
|
||||||
|
|
||||||
|
Instructions:
|
||||||
|
|
||||||
|
:LustyFilesystemExplorer
|
||||||
|
:LustyFilesystemExplorerFromHere
|
||||||
|
:LustyBufferExplorer
|
||||||
|
:LustyBufferGrep (for searching through all open buffers)
|
||||||
|
|
||||||
|
<Leader>lf - Opens filesystem explorer.
|
||||||
|
<Leader>lr - Opens filesystem explorer at the directory of the current file.
|
||||||
|
<Leader>lb - Opens buffer explorer.
|
||||||
|
<Leader>lg - Opens buffer grep.
|
||||||
|
|
||||||
|
When one of the explorers is launched, a new window appears at bottom presenting a table of files/dirs or buffers, and in the status bar is a prompt:
|
||||||
|
|
||||||
|
>>
|
||||||
|
|
||||||
|
As you type a name, the table updates using a fuzzy matching algorithm (or regex matching in the case of grep). Press enter to open the selected match, <C-n>/<C-p> to select the next/previous match, or press <ESC> or <Ctrl-c> to cancel.
|
||||||
|
|
||||||
|
See the "Usage:" section of the script for other tricks and features.
|
||||||
|
|
||||||
|
If you like LustyExplorer, you may also like LustyJuggler: vimscript #2050
|
||||||
|
|
||||||
|
Development repository: http://github.com/sjbach/lusty
|
||||||
|
|
||||||
|
install details
|
||||||
|
Copy the script into your $HOME/.vim/plugin directory so that it will be sourced on startup.
|
||||||
|
|
||||||
|
NOTE: This plugin requires Vim be compiled with Ruby interpretation. If you do not currently have this functionality, see the "Install Details:" section of the script for directions to add it.
|
||||||
3
.vim/bundle/lusty/doc/juggler-vim.changes
Normal file
3
.vim/bundle/lusty/doc/juggler-vim.changes
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
- don't error if ENTER is pressed before selection
|
||||||
|
- avoid a "Press ENTER to continue" message. (Thanks to Bartosz Leper)
|
||||||
|
- don't error when the QuickFix buffer is open. (Thanks to Marco Barberis)
|
||||||
42
.vim/bundle/lusty/doc/juggler-vim.writeup
Normal file
42
.vim/bundle/lusty/doc/juggler-vim.writeup
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
LustyJuggler is a high speed buffer juggler. Having to consciously think about which buffer you need to switch to sucks, so use this instead.
|
||||||
|
|
||||||
|
Here's an animated gif showing it in action:
|
||||||
|
|
||||||
|
http://viewglob.sourceforge.net/lusty-juggler-animated.gif
|
||||||
|
|
||||||
|
Annotated snapshot progression:
|
||||||
|
|
||||||
|
http://viewglob.sourceforge.net/lusty-juggler-annotated.png
|
||||||
|
|
||||||
|
Launch the juggler with this key combo:
|
||||||
|
|
||||||
|
<Leader>lj
|
||||||
|
|
||||||
|
The command bar at bottom is replaced with a new bar showing the names of your currently opened buffers in most-recently-used order.
|
||||||
|
|
||||||
|
The buffer names are mapped to these keys:
|
||||||
|
|
||||||
|
1st --> a or 1
|
||||||
|
2nd --> s or 2
|
||||||
|
3rd --> d or 3
|
||||||
|
4th --> f or 4
|
||||||
|
5th --> g or 5
|
||||||
|
6th --> h or 6
|
||||||
|
7th --> j or 7
|
||||||
|
8th --> k or 8
|
||||||
|
9th --> l or 9
|
||||||
|
10th --> ; or 0
|
||||||
|
|
||||||
|
So if you type "f" or "4", the fourth buffer name will be highlighted and the bar will shift to center it as necessary (and show more of the buffer names on the right).
|
||||||
|
|
||||||
|
If you want to switch to that buffer, press "f" or "4" again or press "<ENTER>". Alternatively, press one of the other mapped keys to highlight another buffer.
|
||||||
|
|
||||||
|
If you changed your mind, cancel the juggler with any of "q", "<ESC>", "<C-c", "<BS>", "<Del>", or "<C-h>".
|
||||||
|
|
||||||
|
If you like LustyJuggler, you may also like LustyExplorer: vimscript #1890
|
||||||
|
|
||||||
|
install details
|
||||||
|
Copy the script into your $HOME/.vim/plugin directory so that it will be sourced on startup.
|
||||||
|
|
||||||
|
NOTE: This plugin requires Vim be compiled with Ruby interpretation. If you do not currently have this functionality, see the "Install Details:" section of the script for directions on adding it. It's not too tough.
|
||||||
|
|
||||||
2291
.vim/bundle/lusty/plugin/lusty-explorer.vim
Normal file
2291
.vim/bundle/lusty/plugin/lusty-explorer.vim
Normal file
File diff suppressed because it is too large
Load diff
1041
.vim/bundle/lusty/plugin/lusty-juggler.vim
Normal file
1041
.vim/bundle/lusty/plugin/lusty-juggler.vim
Normal file
File diff suppressed because it is too large
Load diff
347
.vim/bundle/lusty/src/explorer.vim
Normal file
347
.vim/bundle/lusty/src/explorer.vim
Normal file
|
|
@ -0,0 +1,347 @@
|
||||||
|
" Copyright: Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
" Permission is hereby granted to use and distribute this code,
|
||||||
|
" with or without modifications, provided that this copyright
|
||||||
|
" notice is copied with it. Like anything else that's free,
|
||||||
|
" lusty-explorer.vim is provided *as is* and comes with no
|
||||||
|
" warranty of any kind, either expressed or implied. In no
|
||||||
|
" event will the copyright holder be liable for any damages
|
||||||
|
" resulting from the use of this software.
|
||||||
|
"
|
||||||
|
" Name Of File: lusty-explorer.vim
|
||||||
|
" Description: Dynamic Filesystem and Buffer Explorer Vim Plugin
|
||||||
|
" Maintainers: Stephen Bach <this-file@sjbach.com>
|
||||||
|
" Matt Tolton <matt-lusty-explorer@tolton.com>
|
||||||
|
" Contributors: Raimon Grau, Sergey Popov, Yuichi Tateno, Bernhard Walle,
|
||||||
|
" Rajendra Badapanda, cho45, Simo Salminen, Sami Samhuri,
|
||||||
|
" Matt Tolton, Björn Winckler, sowill, David Brown
|
||||||
|
" Brett DiFrischia, Ali Asad Lotia, Kenneth Love, Ben Boeckel,
|
||||||
|
" robquant
|
||||||
|
"
|
||||||
|
" Release Date: July 21, 2010
|
||||||
|
" Version: 3.1.1
|
||||||
|
"
|
||||||
|
" Usage:
|
||||||
|
" <Leader>lf - Opens the filesystem explorer.
|
||||||
|
" <Leader>lr - Opens the filesystem explorer from the
|
||||||
|
" directory of the current file.
|
||||||
|
" <Leader>lb - Opens the buffer explorer.
|
||||||
|
" <Leader>lg - Opens the buffer grep, for searching through
|
||||||
|
" all loaded buffers
|
||||||
|
"
|
||||||
|
" You can also use the commands:
|
||||||
|
"
|
||||||
|
" ":LustyFilesystemExplorer"
|
||||||
|
" ":LustyFilesystemExplorerFromHere"
|
||||||
|
" ":LustyBufferExplorer"
|
||||||
|
" ":LustyBufferGrep"
|
||||||
|
"
|
||||||
|
" (Personally, I map these to ,f ,r ,b and ,g)
|
||||||
|
"
|
||||||
|
" When launched, a new window appears at bottom presenting a
|
||||||
|
" table of files/dirs or buffers, and in the status bar a
|
||||||
|
" prompt:
|
||||||
|
"
|
||||||
|
" >>
|
||||||
|
"
|
||||||
|
" As you type, the table updates for possible matches using a
|
||||||
|
" fuzzy matching algorithm (or regex matching, in the case of
|
||||||
|
" grep). Special keys include:
|
||||||
|
"
|
||||||
|
" <Enter> open selected match
|
||||||
|
" <Tab> open selected match
|
||||||
|
" <Esc> cancel
|
||||||
|
" <C-c> cancel
|
||||||
|
" <C-g> cancel
|
||||||
|
"
|
||||||
|
" <C-t> open selected match in a new [t]ab
|
||||||
|
" <C-o> open selected match in a new h[o]rizontal split
|
||||||
|
" <C-v> open selected match in a new [v]ertical split
|
||||||
|
"
|
||||||
|
" <C-n> select [n]ext match
|
||||||
|
" <C-p> select [p]revious match
|
||||||
|
"
|
||||||
|
" <C-u> clear prompt
|
||||||
|
"
|
||||||
|
" Additional shortcuts for the filesystem explorer:
|
||||||
|
"
|
||||||
|
" <C-w> ascend one directory at prompt
|
||||||
|
" <C-r> [r]efresh directory contents
|
||||||
|
" <C-a> open [a]ll files in current table
|
||||||
|
" <C-e> create new buffer with the given name and path
|
||||||
|
"
|
||||||
|
" Filesystem Explorer:
|
||||||
|
"
|
||||||
|
" - Directory contents are memoized. (<C-r> to refresh.)
|
||||||
|
" - You can recurse into and out of directories by typing the directory name
|
||||||
|
" and a slash, e.g. "stuff/" or "../".
|
||||||
|
" - Variable expansion, e.g. "$D" -> "/long/dir/path/".
|
||||||
|
" - Tilde (~) expansion, e.g. "~/" -> "/home/steve/".
|
||||||
|
" - Dotfiles are hidden by default, but are shown if the current search term
|
||||||
|
" begins with a '.'. To show these file at all times, set this option:
|
||||||
|
"
|
||||||
|
" let g:LustyExplorerAlwaysShowDotFiles = 1
|
||||||
|
"
|
||||||
|
" You can prevent certain files from appearing in the table with the
|
||||||
|
" following variable:
|
||||||
|
"
|
||||||
|
" set wildignore=*.o,*.fasl,CVS
|
||||||
|
"
|
||||||
|
" The above will mask all object files, compiled lisp files, and
|
||||||
|
" files/directories named CVS from appearing in the table. Note that they
|
||||||
|
" can still be opened by being named explicitly.
|
||||||
|
"
|
||||||
|
" See :help 'wildignore' for more information.
|
||||||
|
"
|
||||||
|
" Buffer Explorer:
|
||||||
|
"
|
||||||
|
" - Buffers are sorted first by fuzzy match and then by most-recently used.
|
||||||
|
" - The currently active buffer is highlighted.
|
||||||
|
"
|
||||||
|
" Buffer Grep:
|
||||||
|
"
|
||||||
|
" - Searches all loaded buffers.
|
||||||
|
" - Uses Ruby-style regexes instead of Vim style. This means:
|
||||||
|
"
|
||||||
|
" - \b instead of \< or \> for beginning/end of word.
|
||||||
|
" - (foo|bar) instead of \(foo\|bar\)
|
||||||
|
" - {2,5} instead of \{2,5}
|
||||||
|
" - + instead of \+
|
||||||
|
" - Generally, fewer backslashes. :-)
|
||||||
|
"
|
||||||
|
" - For now, searches are always case-insensitive.
|
||||||
|
" - Matches from the previous grep are remembered upon relaunch; clear with
|
||||||
|
" <C-u>.
|
||||||
|
"
|
||||||
|
"
|
||||||
|
" Install Details:
|
||||||
|
"
|
||||||
|
" Copy this file into $HOME/.vim/plugin directory so that it will be sourced
|
||||||
|
" on startup automatically.
|
||||||
|
"
|
||||||
|
" Note! This plugin requires Vim be compiled with Ruby interpretation. If you
|
||||||
|
" don't know if your build of Vim has this functionality, you can check by
|
||||||
|
" running "vim --version" from the command line and looking for "+ruby".
|
||||||
|
" Alternatively, just try sourcing this script.
|
||||||
|
"
|
||||||
|
" If your version of Vim does not have "+ruby" but you would still like to
|
||||||
|
" use this plugin, you can fix it. See the "Check for Ruby functionality"
|
||||||
|
" comment below for instructions.
|
||||||
|
"
|
||||||
|
" If you are using the same Vim configuration and plugins for multiple
|
||||||
|
" machines, some of which have Ruby and some of which don't, you may want to
|
||||||
|
" turn off the "Sorry, LustyExplorer requires ruby" warning. You can do so
|
||||||
|
" like this (in .vimrc):
|
||||||
|
"
|
||||||
|
" let g:LustyExplorerSuppressRubyWarning = 1
|
||||||
|
"
|
||||||
|
"
|
||||||
|
" Contributing:
|
||||||
|
"
|
||||||
|
" Patches and suggestions welcome. Note: lusty-explorer.vim is a generated
|
||||||
|
" file; if you'd like to submit a patch, check out the Github development
|
||||||
|
" repository:
|
||||||
|
"
|
||||||
|
" http://github.com/sjbach/lusty
|
||||||
|
"
|
||||||
|
"
|
||||||
|
" GetLatestVimScripts: 1890 1 :AutoInstall: lusty-explorer.vim
|
||||||
|
"
|
||||||
|
" TODO:
|
||||||
|
" - when an edited file is in nowrap mode and the explorer is called while the
|
||||||
|
" current window is scrolled to the right, name truncation occurs.
|
||||||
|
" - enable VimSwaps stuff
|
||||||
|
" - set callback when pipe is ready for read and force refresh()
|
||||||
|
" - uppercase character should make matching case-sensitive
|
||||||
|
" - FilesystemGrep
|
||||||
|
" - C-jhkl navigation to highlight a file?
|
||||||
|
|
||||||
|
" Exit quickly when already loaded.
|
||||||
|
if exists("g:loaded_lustyexplorer")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
if &compatible
|
||||||
|
echohl ErrorMsg
|
||||||
|
echo "LustyExplorer is not designed to run in &compatible mode;"
|
||||||
|
echo "To use this plugin, first disable vi-compatible mode like so:\n"
|
||||||
|
|
||||||
|
echo " :set nocompatible\n"
|
||||||
|
|
||||||
|
echo "Or even better, just create an empty .vimrc file."
|
||||||
|
echohl none
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
if exists("g:FuzzyFinderMode.TextMate")
|
||||||
|
echohl WarningMsg
|
||||||
|
echo "Warning: LustyExplorer detects the presence of fuzzyfinder_textmate;"
|
||||||
|
echo "that plugin often interacts poorly with other Ruby plugins."
|
||||||
|
echo "If LustyExplorer gives you an error, you can probably fix it by"
|
||||||
|
echo "renaming fuzzyfinder_textmate.vim to zzfuzzyfinder_textmate.vim so"
|
||||||
|
echo "that it is last in the load order."
|
||||||
|
echohl none
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Check for Ruby functionality.
|
||||||
|
if !has("ruby") || version < 700
|
||||||
|
if !exists("g:LustyExplorerSuppressRubyWarning") ||
|
||||||
|
\ g:LustyExplorerSuppressRubyWarning == "0"
|
||||||
|
if !exists("g:LustyJugglerSuppressRubyWarning") ||
|
||||||
|
\ g:LustyJugglerSuppressRubyWarning == "0"
|
||||||
|
echohl ErrorMsg
|
||||||
|
echon "Sorry, LustyExplorer requires ruby. "
|
||||||
|
echon "Here are some tips for adding it:\n"
|
||||||
|
|
||||||
|
echo "Debian / Ubuntu:"
|
||||||
|
echo " # apt-get install vim-ruby\n"
|
||||||
|
|
||||||
|
echo "Fedora:"
|
||||||
|
echo " # yum install vim-enhanced\n"
|
||||||
|
|
||||||
|
echo "Gentoo:"
|
||||||
|
echo " # USE=\"ruby\" emerge vim\n"
|
||||||
|
|
||||||
|
echo "FreeBSD:"
|
||||||
|
echo " # pkg_add -r vim+ruby\n"
|
||||||
|
|
||||||
|
echo "Windows:"
|
||||||
|
echo " 1. Download and install Ruby from here:"
|
||||||
|
echo " http://www.ruby-lang.org/"
|
||||||
|
echo " 2. Install a Vim binary with Ruby support:"
|
||||||
|
echo " http://segfault.hasno.info/vim/gvim72.zip\n"
|
||||||
|
|
||||||
|
echo "Manually (including Cygwin):"
|
||||||
|
echo " 1. Install Ruby."
|
||||||
|
echo " 2. Download the Vim source package (say, vim-7.0.tar.bz2)"
|
||||||
|
echo " 3. Build and install:"
|
||||||
|
echo " # tar -xvjf vim-7.0.tar.bz2"
|
||||||
|
echo " # ./configure --enable-rubyinterp"
|
||||||
|
echo " # make && make install"
|
||||||
|
|
||||||
|
echo "(If you just wish to stifle this message, set the following option:"
|
||||||
|
echo " let g:LustyExplorerSuppressRubyWarning = 1)"
|
||||||
|
echohl none
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ! &hidden
|
||||||
|
echohl WarningMsg
|
||||||
|
echo "You are running with 'hidden' mode off. LustyExplorer may"
|
||||||
|
echo "sometimes emit error messages in this mode -- you should turn"
|
||||||
|
echo "it on, like so:\n"
|
||||||
|
|
||||||
|
echo " :set hidden\n"
|
||||||
|
|
||||||
|
echo "Even better, put this in your .vimrc file."
|
||||||
|
echohl none
|
||||||
|
endif
|
||||||
|
|
||||||
|
let g:loaded_lustyexplorer = "yep"
|
||||||
|
|
||||||
|
" Commands.
|
||||||
|
command LustyBufferExplorer :call <SID>LustyBufferExplorerStart()
|
||||||
|
command LustyFilesystemExplorer :call <SID>LustyFilesystemExplorerStart()
|
||||||
|
command LustyFilesystemExplorerFromHere :call <SID>LustyFilesystemExplorerFromHereStart()
|
||||||
|
command LustyBufferGrep :call <SID>LustyBufferGrepStart()
|
||||||
|
|
||||||
|
" Deprecated command names.
|
||||||
|
command BufferExplorer :call
|
||||||
|
\ <SID>deprecated('BufferExplorer', 'LustyBufferExplorer')
|
||||||
|
command FilesystemExplorer :call
|
||||||
|
\ <SID>deprecated('FilesystemExplorer', 'LustyFilesystemExplorer')
|
||||||
|
command FilesystemExplorerFromHere :call
|
||||||
|
\ <SID>deprecated('FilesystemExplorerFromHere',
|
||||||
|
\ 'LustyFilesystemExplorerFromHere')
|
||||||
|
|
||||||
|
function! s:deprecated(old, new)
|
||||||
|
echohl WarningMsg
|
||||||
|
echo ":" . a:old . " is deprecated; use :" . a:new . " instead."
|
||||||
|
echohl none
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
" Default mappings.
|
||||||
|
nmap <silent> <Leader>lf :LustyFilesystemExplorer<CR>
|
||||||
|
nmap <silent> <Leader>lr :LustyFilesystemExplorerFromHere<CR>
|
||||||
|
nmap <silent> <Leader>lb :LustyBufferExplorer<CR>
|
||||||
|
nmap <silent> <Leader>lg :LustyBufferGrep<CR>
|
||||||
|
|
||||||
|
" Vim-to-ruby function calls.
|
||||||
|
function! s:LustyFilesystemExplorerStart()
|
||||||
|
ruby LustyE::profile() { $lusty_filesystem_explorer.run_from_wd }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:LustyFilesystemExplorerFromHereStart()
|
||||||
|
ruby LustyE::profile() { $lusty_filesystem_explorer.run_from_here }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:LustyBufferExplorerStart()
|
||||||
|
ruby LustyE::profile() { $lusty_buffer_explorer.run }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:LustyBufferGrepStart()
|
||||||
|
ruby LustyE::profile() { $lusty_buffer_grep.run }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:LustyFilesystemExplorerCancel()
|
||||||
|
ruby LustyE::profile() { $lusty_filesystem_explorer.cancel }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:LustyBufferExplorerCancel()
|
||||||
|
ruby LustyE::profile() { $lusty_buffer_explorer.cancel }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:LustyBufferGrepCancel()
|
||||||
|
ruby LustyE::profile() { $lusty_buffer_grep.cancel }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:LustyFilesystemExplorerKeyPressed(code_arg)
|
||||||
|
ruby LustyE::profile() { $lusty_filesystem_explorer.key_pressed }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:LustyBufferExplorerKeyPressed(code_arg)
|
||||||
|
ruby LustyE::profile() { $lusty_buffer_explorer.key_pressed }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:LustyBufferGrepKeyPressed(code_arg)
|
||||||
|
ruby LustyE::profile() { $lusty_buffer_grep.key_pressed }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Setup the autocommands that handle buffer MRU ordering.
|
||||||
|
augroup LustyExplorer
|
||||||
|
autocmd!
|
||||||
|
autocmd BufEnter * ruby LustyE::profile() { $le_buffer_stack.push }
|
||||||
|
autocmd BufDelete * ruby LustyE::profile() { $le_buffer_stack.pop }
|
||||||
|
autocmd BufWipeout * ruby LustyE::profile() { $le_buffer_stack.pop }
|
||||||
|
augroup End
|
||||||
|
|
||||||
|
ruby << EOF
|
||||||
|
|
||||||
|
require 'pathname'
|
||||||
|
# For IO#ready -- but Cygwin doesn't have io/wait.
|
||||||
|
require 'io/wait' unless RUBY_PLATFORM =~ /cygwin/
|
||||||
|
# Needed for String#each_char in Ruby 1.8 on some platforms.
|
||||||
|
require 'jcode' unless "".respond_to? :each_char
|
||||||
|
# Needed for Array#each_slice in Ruby 1.8 on some platforms.
|
||||||
|
require 'enumerator' unless [].respond_to? :each_slice
|
||||||
|
|
||||||
|
$LUSTY_PROFILING = false
|
||||||
|
|
||||||
|
if $LUSTY_PROFILING
|
||||||
|
require 'rubygems'
|
||||||
|
require 'ruby-prof'
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
{{RUBY_CODE_INSERTION_POINT}}
|
||||||
|
|
||||||
|
$lusty_buffer_explorer = LustyE::BufferExplorer.new
|
||||||
|
$lusty_filesystem_explorer = LustyE::FilesystemExplorer.new
|
||||||
|
$lusty_buffer_grep = LustyE::BufferGrep.new
|
||||||
|
$le_buffer_stack = LustyE::BufferStack.new
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
" vim: set sts=2 sw=2:
|
||||||
247
.vim/bundle/lusty/src/juggler.vim
Normal file
247
.vim/bundle/lusty/src/juggler.vim
Normal file
|
|
@ -0,0 +1,247 @@
|
||||||
|
" Copyright: Copyright (C) 2008-2010 Stephen Bach
|
||||||
|
" Permission is hereby granted to use and distribute this code,
|
||||||
|
" with or without modifications, provided that this copyright
|
||||||
|
" notice is copied with it. Like anything else that's free,
|
||||||
|
" lusty-juggler.vim is provided *as is* and comes with no
|
||||||
|
" warranty of any kind, either expressed or implied. In no
|
||||||
|
" event will the copyright holder be liable for any damages
|
||||||
|
" resulting from the use of this software.
|
||||||
|
"
|
||||||
|
" Name Of File: lusty-juggler.vim
|
||||||
|
" Description: Dynamic Buffer Switcher Vim Plugin
|
||||||
|
" Maintainer: Stephen Bach <this-file@sjbach.com>
|
||||||
|
" Contributors: Juan Frias, Bartosz Leper, Marco Barberis
|
||||||
|
"
|
||||||
|
" Release Date: June 2, 2010
|
||||||
|
" Version: 1.1.4
|
||||||
|
"
|
||||||
|
" Usage:
|
||||||
|
" <Leader>lj - Opens the buffer juggler.
|
||||||
|
"
|
||||||
|
" You can also use this command:
|
||||||
|
"
|
||||||
|
" ":LustyJuggler"
|
||||||
|
"
|
||||||
|
" (Personally, I map this to ,j)
|
||||||
|
"
|
||||||
|
" When launched, the command bar at bottom is replaced with a
|
||||||
|
" new bar showing the names of currently-opened buffers in
|
||||||
|
" most-recently-used order.
|
||||||
|
"
|
||||||
|
" The buffers are mapped to these keys:
|
||||||
|
"
|
||||||
|
" 1st|2nd|3rd|4th|5th|6th|7th|8th|9th|10th
|
||||||
|
" ----------------------------------------
|
||||||
|
" a s d f g h j k l ;
|
||||||
|
" 1 2 3 4 5 6 7 8 9 0
|
||||||
|
"
|
||||||
|
" So if you type "f" or "4", the fourth buffer name will be
|
||||||
|
" highlighted and the bar will shift to center it as necessary
|
||||||
|
" (and show more of the buffer names on the right).
|
||||||
|
"
|
||||||
|
" If you want to switch to that buffer, press "f" or "4" again
|
||||||
|
" or press "<ENTER>". Alternatively, press one of the other
|
||||||
|
" mapped keys to highlight another buffer.
|
||||||
|
"
|
||||||
|
" To display the key with the name of the buffer, add one of
|
||||||
|
" the following lines to your .vimrc:
|
||||||
|
"
|
||||||
|
" let g:LustyJugglerShowKeys = 'a' (for alpha characters)
|
||||||
|
" let g:LustyJugglerShowKeys = 1 (for digits)
|
||||||
|
"
|
||||||
|
" To cancel the juggler, press any of "q", "<ESC>", "<C-c",
|
||||||
|
" "<BS>", "<Del>", or "<C-h>".
|
||||||
|
"
|
||||||
|
"
|
||||||
|
" Bonus: This plugin also includes the following command, which will
|
||||||
|
" immediately switch to your previously used buffer:
|
||||||
|
"
|
||||||
|
" ":LustyJugglePrevious"
|
||||||
|
"
|
||||||
|
" This is similar to the ":b#" command, but accounts for the
|
||||||
|
" common situation where the previously used buffer (#) has
|
||||||
|
" been killed and is thus inaccessible. In that case, it will
|
||||||
|
" instead switch to the buffer used before that one (and on down
|
||||||
|
" the line if that buffer has been killed too).
|
||||||
|
"
|
||||||
|
"
|
||||||
|
" Install Details:
|
||||||
|
"
|
||||||
|
" Copy this file into $HOME/.vim/plugin directory so that it will be sourced
|
||||||
|
" on startup automatically.
|
||||||
|
"
|
||||||
|
" Note! This plugin requires Vim be compiled with Ruby interpretation. If you
|
||||||
|
" don't know if your build of Vim has this functionality, you can check by
|
||||||
|
" running "vim --version" from the command line and looking for "+ruby".
|
||||||
|
" Alternatively, just try sourcing this script.
|
||||||
|
"
|
||||||
|
" If your version of Vim does not have "+ruby" but you would still like to
|
||||||
|
" use this plugin, you can fix it. See the "Check for Ruby functionality"
|
||||||
|
" comment below for instructions.
|
||||||
|
"
|
||||||
|
" If you are using the same Vim configuration and plugins for multiple
|
||||||
|
" machines, some of which have Ruby and some of which don't, you may want to
|
||||||
|
" turn off the "Sorry, LustyJuggler requires ruby" warning. You can do so
|
||||||
|
" like this (in .vimrc):
|
||||||
|
"
|
||||||
|
" let g:LustyJugglerSuppressRubyWarning = 1
|
||||||
|
"
|
||||||
|
"
|
||||||
|
" Contributing:
|
||||||
|
"
|
||||||
|
" Patches and suggestions welcome. Note: lusty-juggler.vim is a generated
|
||||||
|
" file; if you'd like to submit a patch, check out the Github development
|
||||||
|
" repository:
|
||||||
|
"
|
||||||
|
" http://github.com/sjbach/lusty
|
||||||
|
"
|
||||||
|
"
|
||||||
|
" GetLatestVimScripts: 2050 1 :AutoInstall: lusty-juggler.vim
|
||||||
|
"
|
||||||
|
" TODO:
|
||||||
|
" - save and restore mappings
|
||||||
|
" - Add TAB recognition back.
|
||||||
|
" - Add option to open buffer immediately when mapping is pressed (but not
|
||||||
|
" release the juggler until the confirmation press).
|
||||||
|
" - Have the delimiter character settable.
|
||||||
|
" - have colours settable?
|
||||||
|
|
||||||
|
" Exit quickly when already loaded.
|
||||||
|
if exists("g:loaded_lustyjuggler")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
if &compatible
|
||||||
|
echohl ErrorMsg
|
||||||
|
echo "LustyJuggler is not designed to run in &compatible mode;"
|
||||||
|
echo "To use this plugin, first disable vi-compatible mode like so:\n"
|
||||||
|
|
||||||
|
echo " :set nocompatible\n"
|
||||||
|
|
||||||
|
echo "Or even better, just create an empty .vimrc file."
|
||||||
|
echohl none
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
if exists("g:FuzzyFinderMode.TextMate")
|
||||||
|
echohl WarningMsg
|
||||||
|
echo "Warning: LustyJuggler detects the presence of fuzzyfinder_textmate;"
|
||||||
|
echo "that plugin often interacts poorly with other Ruby plugins."
|
||||||
|
echo "If LustyJuggler gives you an error, you can probably fix it by"
|
||||||
|
echo "renaming fuzzyfinder_textmate.vim to zzfuzzyfinder_textmate.vim so"
|
||||||
|
echo "that it is last in the load order."
|
||||||
|
echohl none
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Check for Ruby functionality.
|
||||||
|
if !has("ruby")
|
||||||
|
if !exists("g:LustyExplorerSuppressRubyWarning") ||
|
||||||
|
\ g:LustyExplorerSuppressRubyWarning == "0"
|
||||||
|
if !exists("g:LustyJugglerSuppressRubyWarning") ||
|
||||||
|
\ g:LustyJugglerSuppressRubyWarning == "0"
|
||||||
|
echohl ErrorMsg
|
||||||
|
echon "Sorry, LustyJuggler requires ruby. "
|
||||||
|
echon "Here are some tips for adding it:\n"
|
||||||
|
|
||||||
|
echo "Debian / Ubuntu:"
|
||||||
|
echo " # apt-get install vim-ruby\n"
|
||||||
|
|
||||||
|
echo "Fedora:"
|
||||||
|
echo " # yum install vim-enhanced\n"
|
||||||
|
|
||||||
|
echo "Gentoo:"
|
||||||
|
echo " # USE=\"ruby\" emerge vim\n"
|
||||||
|
|
||||||
|
echo "FreeBSD:"
|
||||||
|
echo " # pkg_add -r vim+ruby\n"
|
||||||
|
|
||||||
|
echo "Windows:"
|
||||||
|
echo " 1. Download and install Ruby from here:"
|
||||||
|
echo " http://www.ruby-lang.org/"
|
||||||
|
echo " 2. Install a Vim binary with Ruby support:"
|
||||||
|
echo " http://segfault.hasno.info/vim/gvim72.zip\n"
|
||||||
|
|
||||||
|
echo "Manually (including Cygwin):"
|
||||||
|
echo " 1. Install Ruby."
|
||||||
|
echo " 2. Download the Vim source package (say, vim-7.0.tar.bz2)"
|
||||||
|
echo " 3. Build and install:"
|
||||||
|
echo " # tar -xvjf vim-7.0.tar.bz2"
|
||||||
|
echo " # ./configure --enable-rubyinterp"
|
||||||
|
echo " # make && make install\n"
|
||||||
|
|
||||||
|
echo "(If you just wish to stifle this message, set the following option:"
|
||||||
|
echo " let g:LustyJugglerSuppressRubyWarning = 1)"
|
||||||
|
echohl none
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let g:loaded_lustyjuggler = "yep"
|
||||||
|
|
||||||
|
" Commands.
|
||||||
|
command LustyJuggler :call <SID>LustyJugglerStart()
|
||||||
|
command LustyJugglePrevious :call <SID>LustyJugglePreviousRun()
|
||||||
|
|
||||||
|
" Deprecated command names.
|
||||||
|
command JugglePrevious :call
|
||||||
|
\ <SID>deprecated('JugglePrevious', 'LustyJugglePrevious')
|
||||||
|
|
||||||
|
function! s:deprecated(old, new)
|
||||||
|
echohl WarningMsg
|
||||||
|
echo ":" . a:old . " is deprecated; use :" . a:new . " instead."
|
||||||
|
echohl none
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
" Default mappings.
|
||||||
|
nmap <silent> <Leader>lj :LustyJuggler<CR>
|
||||||
|
|
||||||
|
" Vim-to-ruby function calls.
|
||||||
|
function! s:LustyJugglerStart()
|
||||||
|
ruby LustyJ::profile() { $lusty_juggler.run }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:LustyJugglerKeyPressed(code_arg)
|
||||||
|
ruby LustyJ::profile() { $lusty_juggler.key_pressed }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:LustyJugglerCancel()
|
||||||
|
ruby LustyJ::profile() { $lusty_juggler.cleanup }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:LustyJugglePreviousRun()
|
||||||
|
ruby LustyJ::profile() { $lj_buffer_stack.juggle_previous }
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Setup the autocommands that handle buffer MRU ordering.
|
||||||
|
augroup LustyJuggler
|
||||||
|
autocmd!
|
||||||
|
autocmd BufEnter * ruby LustyJ::profile() { $lj_buffer_stack.push }
|
||||||
|
autocmd BufDelete * ruby LustyJ::profile() { $lj_buffer_stack.pop }
|
||||||
|
autocmd BufWipeout * ruby LustyJ::profile() { $lj_buffer_stack.pop }
|
||||||
|
augroup End
|
||||||
|
|
||||||
|
" Used to work around a flaw in Vim's ruby bindings.
|
||||||
|
let s:maparg_holder = 0
|
||||||
|
|
||||||
|
ruby << EOF
|
||||||
|
|
||||||
|
require 'pathname'
|
||||||
|
|
||||||
|
$LUSTY_PROFILING = false
|
||||||
|
|
||||||
|
if $LUSTY_PROFILING
|
||||||
|
require 'rubygems'
|
||||||
|
require 'ruby-prof'
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
{{RUBY_CODE_INSERTION_POINT}}
|
||||||
|
|
||||||
|
$lusty_juggler = LustyJ::LustyJuggler.new
|
||||||
|
$lj_buffer_stack = LustyJ::BufferStack.new
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
" vim: set sts=2 sw=2:
|
||||||
122
.vim/bundle/lusty/src/lusty.rb
Normal file
122
.vim/bundle/lusty/src/lusty.rb
Normal file
|
|
@ -0,0 +1,122 @@
|
||||||
|
# Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
# Utility functions.
|
||||||
|
module LustyM
|
||||||
|
|
||||||
|
unless const_defined? "MOST_POSITIVE_FIXNUM"
|
||||||
|
MOST_POSITIVE_FIXNUM = 2**(0.size * 8 -2) -1
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.simplify_path(s)
|
||||||
|
s = s.gsub(/\/+/, '/') # Remove redundant '/' characters
|
||||||
|
begin
|
||||||
|
if s[0] == ?~
|
||||||
|
# Tilde expansion - First expand the ~ part (e.g. '~' or '~steve')
|
||||||
|
# and then append the rest of the path. We can't just call
|
||||||
|
# expand_path() or it'll throw on bad paths.
|
||||||
|
s = File.expand_path(s.sub(/\/.*/,'')) + \
|
||||||
|
s.sub(/^[^\/]+/,'')
|
||||||
|
end
|
||||||
|
|
||||||
|
if s == '/'
|
||||||
|
# Special-case root so we don't add superfluous '/' characters,
|
||||||
|
# as this can make Cygwin choke.
|
||||||
|
s
|
||||||
|
elsif ends_with?(s, File::SEPARATOR)
|
||||||
|
File.expand_path(s) + File::SEPARATOR
|
||||||
|
else
|
||||||
|
dirname_expanded = File.expand_path(File.dirname(s))
|
||||||
|
if dirname_expanded == '/'
|
||||||
|
dirname_expanded + File.basename(s)
|
||||||
|
else
|
||||||
|
dirname_expanded + File::SEPARATOR + File.basename(s)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue ArgumentError
|
||||||
|
s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.longest_common_prefix(paths)
|
||||||
|
prefix = paths[0]
|
||||||
|
paths.each do |path|
|
||||||
|
for i in 0...prefix.length
|
||||||
|
if path.length <= i or prefix[i] != path[i]
|
||||||
|
prefix = prefix[0...i]
|
||||||
|
prefix = prefix[0..(prefix.rindex('/') or -1)]
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
prefix
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.ready_for_read?(io)
|
||||||
|
if io.respond_to? :ready?
|
||||||
|
ready?
|
||||||
|
else
|
||||||
|
result = IO.select([io], nil, nil, 0)
|
||||||
|
result && (result.first.first == io)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.ends_with?(s1, s2)
|
||||||
|
tail = s1[-s2.length, s2.length]
|
||||||
|
tail == s2
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.starts_with?(s1, s2)
|
||||||
|
head = s1[0, s2.length]
|
||||||
|
head == s2
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.option_set?(opt_name)
|
||||||
|
opt_name = "g:LustyExplorer" + opt_name
|
||||||
|
VIM::evaluate_bool("exists('#{opt_name}') && #{opt_name} != '0'")
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.profile
|
||||||
|
# Profile (if enabled) and provide better
|
||||||
|
# backtraces when there's an error.
|
||||||
|
|
||||||
|
if $LUSTY_PROFILING
|
||||||
|
if not RubyProf.running?
|
||||||
|
RubyProf.measure_mode = RubyProf::WALL_TIME
|
||||||
|
RubyProf.start
|
||||||
|
else
|
||||||
|
RubyProf.resume
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
yield
|
||||||
|
rescue Exception => e
|
||||||
|
puts e
|
||||||
|
puts e.backtrace
|
||||||
|
end
|
||||||
|
|
||||||
|
if $LUSTY_PROFILING and RubyProf.running?
|
||||||
|
RubyProf.pause
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class AssertionError < StandardError ; end
|
||||||
|
|
||||||
|
def self.assert(condition, message = 'assertion failure')
|
||||||
|
raise AssertionError.new(message) unless condition
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.d(s)
|
||||||
|
# (Debug print)
|
||||||
|
$stderr.puts s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
133
.vim/bundle/lusty/src/lusty/bar-item.rb
Normal file
133
.vim/bundle/lusty/src/lusty/bar-item.rb
Normal file
|
|
@ -0,0 +1,133 @@
|
||||||
|
# Copyright (C) 2008-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
# An item (delimiter/separator or buffer name) on the NameBar.
|
||||||
|
module LustyM
|
||||||
|
class BarItem
|
||||||
|
def initialize(str, color)
|
||||||
|
@str = str
|
||||||
|
@color = color
|
||||||
|
end
|
||||||
|
|
||||||
|
def length
|
||||||
|
@str.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def pretty_print_input
|
||||||
|
[@color, @str]
|
||||||
|
end
|
||||||
|
|
||||||
|
def [](*rest)
|
||||||
|
return BarItem.new(@str[*rest], @color)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.full_length(array)
|
||||||
|
if array
|
||||||
|
array.inject(0) { |sum, el| sum + el.length }
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class BufferItem < BarItem
|
||||||
|
def initialize(str, highlighted)
|
||||||
|
@str = str
|
||||||
|
@highlighted = highlighted
|
||||||
|
destructure()
|
||||||
|
end
|
||||||
|
|
||||||
|
def [](*rest)
|
||||||
|
return BufferItem.new(@str[*rest], @highlighted)
|
||||||
|
end
|
||||||
|
|
||||||
|
def pretty_print_input
|
||||||
|
@array
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
@@BUFFER_COLOR = "PreProc"
|
||||||
|
#@@BUFFER_COLOR = "None"
|
||||||
|
@@DIR_COLOR = "Directory"
|
||||||
|
@@SLASH_COLOR = "Function"
|
||||||
|
@@HIGHLIGHTED_COLOR = "Question"
|
||||||
|
|
||||||
|
# Breakdown the string to colourize each part.
|
||||||
|
def destructure
|
||||||
|
if @highlighted
|
||||||
|
buf_color = @@HIGHLIGHTED_COLOR
|
||||||
|
dir_color = @@HIGHLIGHTED_COLOR
|
||||||
|
slash_color = @@HIGHLIGHTED_COLOR
|
||||||
|
else
|
||||||
|
buf_color = @@BUFFER_COLOR
|
||||||
|
dir_color = @@DIR_COLOR
|
||||||
|
slash_color = @@SLASH_COLOR
|
||||||
|
end
|
||||||
|
|
||||||
|
pieces = @str.split(File::SEPARATOR, -1)
|
||||||
|
|
||||||
|
@array = []
|
||||||
|
@array << dir_color
|
||||||
|
@array << pieces.shift
|
||||||
|
pieces.each { |piece|
|
||||||
|
@array << slash_color
|
||||||
|
@array << File::SEPARATOR
|
||||||
|
@array << dir_color
|
||||||
|
@array << piece
|
||||||
|
}
|
||||||
|
|
||||||
|
# Last piece is the actual name.
|
||||||
|
@array[-2] = buf_color
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class SeparatorItem < BarItem
|
||||||
|
public
|
||||||
|
def initialize
|
||||||
|
super(@@TEXT, @@COLOR)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
@@TEXT = "|"
|
||||||
|
#@@COLOR = "NonText"
|
||||||
|
@@COLOR = "None"
|
||||||
|
end
|
||||||
|
|
||||||
|
class LeftContinuerItem < BarItem
|
||||||
|
public
|
||||||
|
def initialize
|
||||||
|
super(@@TEXT, @@COLOR)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.length
|
||||||
|
@@TEXT.length
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
@@TEXT = "<"
|
||||||
|
@@COLOR = "NonText"
|
||||||
|
end
|
||||||
|
|
||||||
|
class RightContinuerItem < BarItem
|
||||||
|
public
|
||||||
|
def initialize
|
||||||
|
super(@@TEXT, @@COLOR)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.length
|
||||||
|
@@TEXT.length
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
@@TEXT = ">"
|
||||||
|
@@COLOR = "NonText"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
126
.vim/bundle/lusty/src/lusty/buffer-explorer.rb
Normal file
126
.vim/bundle/lusty/src/lusty/buffer-explorer.rb
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
# Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
module LustyM
|
||||||
|
class BufferExplorer < Explorer
|
||||||
|
public
|
||||||
|
def initialize
|
||||||
|
super
|
||||||
|
@prompt = Prompt.new
|
||||||
|
@buffer_entries = []
|
||||||
|
end
|
||||||
|
|
||||||
|
def run
|
||||||
|
unless @running
|
||||||
|
@prompt.clear!
|
||||||
|
@curbuf_at_start = VIM::Buffer.current
|
||||||
|
@buffer_entries = BufferEntry::compute_buffer_entries()
|
||||||
|
@buffer_entries.each do |e|
|
||||||
|
# Show modification indicator
|
||||||
|
e.label = e.short_name
|
||||||
|
e.label << " [+]" if e.vim_buffer.modified?
|
||||||
|
# Disabled: show buffer number next to name
|
||||||
|
#e.label << " #{buffer.number.to_s}"
|
||||||
|
end
|
||||||
|
|
||||||
|
@selected_index = 0
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def title
|
||||||
|
'[LustyExplorer-Buffers]'
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_syntax_matching
|
||||||
|
# Base highlighting -- more is set on refresh.
|
||||||
|
if VIM::has_syntax?
|
||||||
|
VIM::command 'syn match LustySlash "/" contained'
|
||||||
|
VIM::command 'syn match LustyDir "\%(\S\+ \)*\S\+/" ' \
|
||||||
|
'contains=LustySlash'
|
||||||
|
VIM::command 'syn match LustyModified " \[+\]"'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def curbuf_match_string
|
||||||
|
curbuf = @buffer_entries.find { |x| x.vim_buffer == @curbuf_at_start }
|
||||||
|
if curbuf
|
||||||
|
escaped = VIM::regex_escape(curbuf.label)
|
||||||
|
Display.entry_syntaxify(escaped, @prompt.insensitive?)
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_refresh
|
||||||
|
# Highlighting for the current buffer name.
|
||||||
|
if VIM::has_syntax?
|
||||||
|
VIM::command 'syn clear LustyCurrentBuffer'
|
||||||
|
VIM::command 'syn match LustyCurrentBuffer ' \
|
||||||
|
"\"#{curbuf_match_string()}\" " \
|
||||||
|
'contains=LustyModified'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_abbreviation
|
||||||
|
@prompt.input
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_sorted_matches
|
||||||
|
abbrev = current_abbreviation()
|
||||||
|
|
||||||
|
if abbrev.length == 0
|
||||||
|
# Take (current) MRU order if we have no abbreviation.
|
||||||
|
@buffer_entries
|
||||||
|
else
|
||||||
|
matching_entries = \
|
||||||
|
@buffer_entries.select { |x|
|
||||||
|
x.current_score = Mercury.score(x.short_name, abbrev)
|
||||||
|
x.current_score != 0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Sort by score.
|
||||||
|
matching_entries.sort! { |x, y|
|
||||||
|
if x.current_score == y.current_score
|
||||||
|
x.mru_placement <=> y.mru_placement
|
||||||
|
else
|
||||||
|
y.current_score <=> x.current_score
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def open_entry(entry, open_mode)
|
||||||
|
cleanup()
|
||||||
|
LustyM::assert($curwin == @calling_window)
|
||||||
|
|
||||||
|
number = entry.vim_buffer.number
|
||||||
|
LustyM::assert(number)
|
||||||
|
|
||||||
|
cmd = case open_mode
|
||||||
|
when :current_tab
|
||||||
|
"b"
|
||||||
|
when :new_tab
|
||||||
|
# For some reason just using tabe or e gives an error when
|
||||||
|
# the alternate-file isn't set.
|
||||||
|
"tab split | b"
|
||||||
|
when :new_split
|
||||||
|
"sp | b"
|
||||||
|
when :new_vsplit
|
||||||
|
"vs | b"
|
||||||
|
else
|
||||||
|
LustyM::assert(false, "bad open mode")
|
||||||
|
end
|
||||||
|
|
||||||
|
VIM::command "silent #{cmd} #{number}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
203
.vim/bundle/lusty/src/lusty/buffer-grep.rb
Normal file
203
.vim/bundle/lusty/src/lusty/buffer-grep.rb
Normal file
|
|
@ -0,0 +1,203 @@
|
||||||
|
# Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
# TODO:
|
||||||
|
# - some way for user to indicate case-sensitive regex
|
||||||
|
# - add slash highlighting back to file name?
|
||||||
|
|
||||||
|
module LustyM
|
||||||
|
class BufferGrep < Explorer
|
||||||
|
public
|
||||||
|
def initialize
|
||||||
|
super
|
||||||
|
@display.single_column_mode = true
|
||||||
|
@prompt = Prompt.new
|
||||||
|
@buffer_entries = []
|
||||||
|
@matched_strings = []
|
||||||
|
|
||||||
|
# State from previous run, so you don't have to retype
|
||||||
|
# your search each time to get the previous entries.
|
||||||
|
@previous_input = ''
|
||||||
|
@previous_grep_entries = []
|
||||||
|
@previous_matched_strings = []
|
||||||
|
@previous_selected_index = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def run
|
||||||
|
return if @running
|
||||||
|
|
||||||
|
@prompt.set! @previous_input
|
||||||
|
@buffer_entries = GrepEntry::compute_buffer_entries()
|
||||||
|
|
||||||
|
@selected_index = @previous_selected_index
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def title
|
||||||
|
'[LustyExplorer-BufferGrep]'
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_syntax_matching
|
||||||
|
VIM::command 'syn clear LustyGrepFileName'
|
||||||
|
VIM::command 'syn clear LustyGrepLineNumber'
|
||||||
|
VIM::command 'syn clear LustyGrepContext'
|
||||||
|
|
||||||
|
# Base syntax matching -- others are set on refresh.
|
||||||
|
|
||||||
|
VIM::command \
|
||||||
|
'syn match LustyGrepFileName "^\zs.\{-}\ze:\d\+:" ' \
|
||||||
|
'contains=NONE ' \
|
||||||
|
'nextgroup=LustyGrepLineNumber'
|
||||||
|
|
||||||
|
VIM::command \
|
||||||
|
'syn match LustyGrepLineNumber ":\d\+:" ' \
|
||||||
|
'contained ' \
|
||||||
|
'contains=NONE ' \
|
||||||
|
'nextgroup=LustyGrepContext'
|
||||||
|
|
||||||
|
VIM::command \
|
||||||
|
'syn match LustyGrepContext ".*" ' \
|
||||||
|
'transparent ' \
|
||||||
|
'contained ' \
|
||||||
|
'contains=LustyGrepMatch'
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_refresh
|
||||||
|
if VIM::has_syntax?
|
||||||
|
|
||||||
|
VIM::command 'syn clear LustyGrepMatch'
|
||||||
|
|
||||||
|
if not @matched_strings.empty?
|
||||||
|
sub_regexes = @matched_strings.map { |s| VIM::regex_escape(s) }
|
||||||
|
syntax_regex = '\%(' + sub_regexes.join('\|') + '\)'
|
||||||
|
VIM::command "syn match LustyGrepMatch \"#{syntax_regex}\" " \
|
||||||
|
"contained " \
|
||||||
|
"contains=NONE"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def highlight_selected_index
|
||||||
|
VIM::command 'syn clear LustySelected'
|
||||||
|
|
||||||
|
entry = @current_sorted_matches[@selected_index]
|
||||||
|
return if entry.nil?
|
||||||
|
|
||||||
|
match_string = "#{entry.short_name}:#{entry.line_number}:"
|
||||||
|
escaped = VIM::regex_escape(match_string)
|
||||||
|
VIM::command "syn match LustySelected \"^#{match_string}\" " \
|
||||||
|
'contains=NONE ' \
|
||||||
|
'nextgroup=LustyGrepContext'
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_abbreviation
|
||||||
|
@prompt.input
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_sorted_matches
|
||||||
|
abbrev = current_abbreviation()
|
||||||
|
|
||||||
|
grep_entries = @previous_grep_entries
|
||||||
|
@matched_strings = @previous_matched_strings
|
||||||
|
|
||||||
|
@previous_input = ''
|
||||||
|
@previous_grep_entries = []
|
||||||
|
@previous_matched_strings = []
|
||||||
|
@previous_selected_index = 0
|
||||||
|
|
||||||
|
if not grep_entries.empty?
|
||||||
|
return grep_entries
|
||||||
|
elsif abbrev == ''
|
||||||
|
@buffer_entries.each do |e|
|
||||||
|
e.label = e.short_name
|
||||||
|
end
|
||||||
|
return @buffer_entries
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
regex = Regexp.compile(abbrev, Regexp::IGNORECASE)
|
||||||
|
rescue RegexpError => e
|
||||||
|
return []
|
||||||
|
end
|
||||||
|
|
||||||
|
max_visible_entries = Display.max_height
|
||||||
|
|
||||||
|
# Used to avoid duplicating match strings, which slows down refresh.
|
||||||
|
highlight_hash = {}
|
||||||
|
|
||||||
|
# Search through every line of every open buffer for the
|
||||||
|
# given expression.
|
||||||
|
@buffer_entries.each do |entry|
|
||||||
|
vim_buffer = entry.vim_buffer
|
||||||
|
line_count = vim_buffer.count
|
||||||
|
(1..line_count). each do |i|
|
||||||
|
line = vim_buffer[i]
|
||||||
|
match = regex.match(line)
|
||||||
|
if match
|
||||||
|
matched_str = match.to_s
|
||||||
|
|
||||||
|
grep_entry = entry.clone()
|
||||||
|
grep_entry.line_number = i
|
||||||
|
grep_entry.label = "#{grep_entry.short_name}:#{i}:#{line}"
|
||||||
|
grep_entries << grep_entry
|
||||||
|
|
||||||
|
# Keep track of all matched strings
|
||||||
|
unless highlight_hash[matched_str]
|
||||||
|
@matched_strings << matched_str
|
||||||
|
highlight_hash[matched_str] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if grep_entries.length > max_visible_entries
|
||||||
|
return grep_entries
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return grep_entries
|
||||||
|
end
|
||||||
|
|
||||||
|
def open_entry(entry, open_mode)
|
||||||
|
cleanup()
|
||||||
|
LustyM::assert($curwin == @calling_window)
|
||||||
|
|
||||||
|
number = entry.vim_buffer.number
|
||||||
|
LustyM::assert(number)
|
||||||
|
|
||||||
|
cmd = case open_mode
|
||||||
|
when :current_tab
|
||||||
|
"b"
|
||||||
|
when :new_tab
|
||||||
|
# For some reason just using tabe or e gives an error when
|
||||||
|
# the alternate-file isn't set.
|
||||||
|
"tab split | b"
|
||||||
|
when :new_split
|
||||||
|
"sp | b"
|
||||||
|
when :new_vsplit
|
||||||
|
"vs | b"
|
||||||
|
else
|
||||||
|
LustyM::assert(false, "bad open mode")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Open buffer and go to the line number.
|
||||||
|
VIM::command "silent #{cmd} #{number}"
|
||||||
|
VIM::command "#{entry.line_number}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def cleanup
|
||||||
|
@previous_input = @prompt.input
|
||||||
|
@previous_grep_entries = @current_sorted_matches
|
||||||
|
@previous_matched_strings = @matched_strings
|
||||||
|
@previous_selected_index = @selected_index
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
113
.vim/bundle/lusty/src/lusty/buffer-stack.rb
Normal file
113
.vim/bundle/lusty/src/lusty/buffer-stack.rb
Normal file
|
|
@ -0,0 +1,113 @@
|
||||||
|
# Copyright (C) 2008-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
# Maintain MRU ordering.
|
||||||
|
module LustyM
|
||||||
|
class BufferStack
|
||||||
|
public
|
||||||
|
def initialize
|
||||||
|
@stack = []
|
||||||
|
|
||||||
|
(0..VIM::Buffer.count-1).each do |i|
|
||||||
|
@stack << VIM::Buffer[i].number
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Switch to the previous buffer (the one you were using before the
|
||||||
|
# current one). This is basically a smarter replacement for :b#,
|
||||||
|
# accounting for the situation where your previous buffer no longer
|
||||||
|
# exists.
|
||||||
|
def juggle_previous
|
||||||
|
buf = num_at_pos(2)
|
||||||
|
VIM::command "b #{buf}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def names(n = :all)
|
||||||
|
# Get the last n buffer names by MRU. Show only as much of
|
||||||
|
# the name as necessary to differentiate between buffers of
|
||||||
|
# the same name.
|
||||||
|
cull!
|
||||||
|
names = @stack.collect { |i| VIM::bufname(i) }.reverse
|
||||||
|
if n != :all
|
||||||
|
names = names[0,n]
|
||||||
|
end
|
||||||
|
shorten_paths(names)
|
||||||
|
end
|
||||||
|
|
||||||
|
def numbers(n = :all)
|
||||||
|
# Get the last n buffer numbers by MRU.
|
||||||
|
cull!
|
||||||
|
numbers = @stack.reverse
|
||||||
|
if n == :all
|
||||||
|
numbers
|
||||||
|
else
|
||||||
|
numbers[0,n]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def num_at_pos(i)
|
||||||
|
cull!
|
||||||
|
return @stack[-i] ? @stack[-i] : @stack.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def length
|
||||||
|
cull!
|
||||||
|
return @stack.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def push
|
||||||
|
@stack.delete $curbuf.number
|
||||||
|
@stack << $curbuf.number
|
||||||
|
end
|
||||||
|
|
||||||
|
def pop
|
||||||
|
number = VIM::evaluate('bufnr(expand("<afile>"))')
|
||||||
|
@stack.delete number
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def cull!
|
||||||
|
# Remove empty buffers.
|
||||||
|
@stack.delete_if { |x| not VIM::evaluate_bool("bufexists(#{x})") }
|
||||||
|
end
|
||||||
|
|
||||||
|
# NOTE: very similar to Entry::compute_buffer_entries()
|
||||||
|
def shorten_paths(buffer_names)
|
||||||
|
# Shorten each buffer name by removing all path elements which are not
|
||||||
|
# needed to differentiate a given name from other names. This usually
|
||||||
|
# results in only the basename shown, but if several buffers of the
|
||||||
|
# same basename are opened, there will be more.
|
||||||
|
|
||||||
|
# Group the buffers by common basename
|
||||||
|
common_base = Hash.new { |hash, k| hash[k] = [] }
|
||||||
|
buffer_names.each do |name|
|
||||||
|
basename = Pathname.new(name).basename.to_s
|
||||||
|
common_base[basename] << name
|
||||||
|
end
|
||||||
|
|
||||||
|
# Determine the longest common prefix for each basename group.
|
||||||
|
basename_to_prefix = {}
|
||||||
|
common_base.each do |k, names|
|
||||||
|
if names.length > 1
|
||||||
|
basename_to_prefix[k] = LustyM::longest_common_prefix(names)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Shorten each buffer_name by removing the prefix.
|
||||||
|
buffer_names.map { |name|
|
||||||
|
base = Pathname.new(name).basename.to_s
|
||||||
|
prefix = basename_to_prefix[base]
|
||||||
|
prefix ? name[prefix.length..-1] \
|
||||||
|
: base
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
437
.vim/bundle/lusty/src/lusty/display.rb
Normal file
437
.vim/bundle/lusty/src/lusty/display.rb
Normal file
|
|
@ -0,0 +1,437 @@
|
||||||
|
# Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
# Manage the explorer buffer.
|
||||||
|
module LustyM
|
||||||
|
|
||||||
|
class Display
|
||||||
|
private
|
||||||
|
@@COLUMN_SEPARATOR = " "
|
||||||
|
@@NO_MATCHES_STRING = "-- NO MATCHES --"
|
||||||
|
@@TRUNCATED_STRING = "-- TRUNCATED --"
|
||||||
|
|
||||||
|
public
|
||||||
|
ENTRY_START_VIM_REGEX = '\%(^\|' + @@COLUMN_SEPARATOR + '\)'
|
||||||
|
ENTRY_END_VIM_REGEX = '\%(\s*$\|' + @@COLUMN_SEPARATOR + '\)'
|
||||||
|
|
||||||
|
def self.entry_syntaxify(s, case_insensitive)
|
||||||
|
# Create a match regex string for the given s. This is for a Vim regex,
|
||||||
|
# not for a Ruby regex.
|
||||||
|
|
||||||
|
str = "#{ENTRY_START_VIM_REGEX}\\zs#{s}\\ze#{ENTRY_END_VIM_REGEX}"
|
||||||
|
|
||||||
|
str << '\c' if case_insensitive
|
||||||
|
|
||||||
|
return str
|
||||||
|
end
|
||||||
|
|
||||||
|
attr_writer :single_column_mode
|
||||||
|
def initialize(title)
|
||||||
|
@title = title
|
||||||
|
@window = nil
|
||||||
|
@buffer = nil
|
||||||
|
@single_column_mode = false
|
||||||
|
end
|
||||||
|
|
||||||
|
def create(prefix)
|
||||||
|
|
||||||
|
# Make a window for the display and move there.
|
||||||
|
# Start at size 1 to mitigate flashing effect when
|
||||||
|
# we resize the window later.
|
||||||
|
VIM::command "silent! botright 1split #{@title}"
|
||||||
|
|
||||||
|
@window = $curwin
|
||||||
|
@buffer = $curbuf
|
||||||
|
|
||||||
|
#
|
||||||
|
# Display buffer is special -- set options.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Buffer-local.
|
||||||
|
VIM::command "setlocal bufhidden=delete"
|
||||||
|
VIM::command "setlocal buftype=nofile"
|
||||||
|
VIM::command "setlocal nomodifiable"
|
||||||
|
VIM::command "setlocal noswapfile"
|
||||||
|
VIM::command "setlocal nowrap"
|
||||||
|
VIM::command "setlocal nonumber"
|
||||||
|
VIM::command "setlocal foldcolumn=0"
|
||||||
|
VIM::command "setlocal nocursorline"
|
||||||
|
VIM::command "setlocal nospell"
|
||||||
|
VIM::command "setlocal nobuflisted"
|
||||||
|
VIM::command "setlocal textwidth=0"
|
||||||
|
VIM::command "setlocal noreadonly"
|
||||||
|
|
||||||
|
# Non-buffer-local (Vim is annoying).
|
||||||
|
# (Update SavedSettings if adding to below.)
|
||||||
|
VIM::set_option "timeoutlen=0"
|
||||||
|
VIM::set_option "noinsertmode"
|
||||||
|
VIM::set_option "noshowcmd"
|
||||||
|
VIM::set_option "nolist"
|
||||||
|
VIM::set_option "report=9999"
|
||||||
|
VIM::set_option "sidescroll=0"
|
||||||
|
VIM::set_option "sidescrolloff=0"
|
||||||
|
|
||||||
|
# TODO -- cpoptions?
|
||||||
|
|
||||||
|
#
|
||||||
|
# Syntax highlighting.
|
||||||
|
#
|
||||||
|
|
||||||
|
if VIM::has_syntax?
|
||||||
|
# General syntax matching.
|
||||||
|
VIM::command 'syn match LustyNoEntries "\%^\s*' \
|
||||||
|
"#{@@NO_MATCHES_STRING}" \
|
||||||
|
'\s*\%$"'
|
||||||
|
VIM::command 'syn match LustyTruncated "^\s*' \
|
||||||
|
"#{@@TRUNCATED_STRING}" \
|
||||||
|
'\s*$"'
|
||||||
|
|
||||||
|
# Colour highlighting.
|
||||||
|
VIM::command 'highlight link LustyDir Directory'
|
||||||
|
VIM::command 'highlight link LustySlash Function'
|
||||||
|
VIM::command 'highlight link LustySelected Type'
|
||||||
|
VIM::command 'highlight link LustyModified Special'
|
||||||
|
VIM::command 'highlight link LustyCurrentBuffer Constant'
|
||||||
|
VIM::command 'highlight link LustyGrepMatch IncSearch'
|
||||||
|
VIM::command 'highlight link LustyGrepLineNumber Directory'
|
||||||
|
VIM::command 'highlight link LustyGrepFileName Comment'
|
||||||
|
VIM::command 'highlight link LustyGrepContext None' # transparent
|
||||||
|
VIM::command 'highlight link LustyOpenedFile PreProc'
|
||||||
|
VIM::command 'highlight link LustyFileWithSwap WarningMsg'
|
||||||
|
VIM::command 'highlight link LustyNoEntries ErrorMsg'
|
||||||
|
VIM::command 'highlight link LustyTruncated Visual'
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Key mappings - we need to reroute user input.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Non-special printable characters.
|
||||||
|
printables = '/!"#$%&\'()*+,-.0123456789:<=>?#@"' \
|
||||||
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' \
|
||||||
|
'[]^_`abcdefghijklmnopqrstuvwxyz{}~'
|
||||||
|
|
||||||
|
map = "noremap <silent> <buffer>"
|
||||||
|
|
||||||
|
printables.each_byte do |b|
|
||||||
|
VIM::command "#{map} <Char-#{b}> :call <SID>#{prefix}KeyPressed(#{b})<CR>"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Special characters
|
||||||
|
VIM::command "#{map} <Tab> :call <SID>#{prefix}KeyPressed(9)<CR>"
|
||||||
|
VIM::command "#{map} <Bslash> :call <SID>#{prefix}KeyPressed(92)<CR>"
|
||||||
|
VIM::command "#{map} <Space> :call <SID>#{prefix}KeyPressed(32)<CR>"
|
||||||
|
VIM::command "#{map} \026| :call <SID>#{prefix}KeyPressed(124)<CR>"
|
||||||
|
|
||||||
|
VIM::command "#{map} <BS> :call <SID>#{prefix}KeyPressed(8)<CR>"
|
||||||
|
VIM::command "#{map} <Del> :call <SID>#{prefix}KeyPressed(8)<CR>"
|
||||||
|
VIM::command "#{map} <C-h> :call <SID>#{prefix}KeyPressed(8)<CR>"
|
||||||
|
|
||||||
|
VIM::command "#{map} <CR> :call <SID>#{prefix}KeyPressed(13)<CR>"
|
||||||
|
VIM::command "#{map} <S-CR> :call <SID>#{prefix}KeyPressed(10)<CR>"
|
||||||
|
VIM::command "#{map} <C-a> :call <SID>#{prefix}KeyPressed(1)<CR>"
|
||||||
|
|
||||||
|
VIM::command "#{map} <Esc> :call <SID>#{prefix}Cancel()<CR>"
|
||||||
|
VIM::command "#{map} <C-c> :call <SID>#{prefix}Cancel()<CR>"
|
||||||
|
VIM::command "#{map} <C-g> :call <SID>#{prefix}Cancel()<CR>"
|
||||||
|
|
||||||
|
VIM::command "#{map} <C-w> :call <SID>#{prefix}KeyPressed(23)<CR>"
|
||||||
|
VIM::command "#{map} <C-n> :call <SID>#{prefix}KeyPressed(14)<CR>"
|
||||||
|
VIM::command "#{map} <C-p> :call <SID>#{prefix}KeyPressed(16)<CR>"
|
||||||
|
VIM::command "#{map} <C-o> :call <SID>#{prefix}KeyPressed(15)<CR>"
|
||||||
|
VIM::command "#{map} <C-t> :call <SID>#{prefix}KeyPressed(20)<CR>"
|
||||||
|
VIM::command "#{map} <C-v> :call <SID>#{prefix}KeyPressed(22)<CR>"
|
||||||
|
VIM::command "#{map} <C-e> :call <SID>#{prefix}KeyPressed(5)<CR>"
|
||||||
|
VIM::command "#{map} <C-r> :call <SID>#{prefix}KeyPressed(18)<CR>"
|
||||||
|
VIM::command "#{map} <C-u> :call <SID>#{prefix}KeyPressed(21)<CR>"
|
||||||
|
end
|
||||||
|
|
||||||
|
def print(strings)
|
||||||
|
Window.select(@window) || return
|
||||||
|
|
||||||
|
if strings.empty?
|
||||||
|
print_no_entries()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
row_count, col_count, col_widths, truncated = \
|
||||||
|
compute_optimal_layout(strings)
|
||||||
|
|
||||||
|
# Slice the strings into rows.
|
||||||
|
rows = Array.new(row_count){[]}
|
||||||
|
col_index = 0
|
||||||
|
strings.each_slice(row_count) do |column|
|
||||||
|
column_width = col_widths[col_index]
|
||||||
|
column.each_index do |i|
|
||||||
|
string = column[i]
|
||||||
|
|
||||||
|
rows[i] << string
|
||||||
|
|
||||||
|
if col_index < col_count - 1
|
||||||
|
# Add spacer to the width of the column
|
||||||
|
rows[i] << (" " * (column_width - string.length))
|
||||||
|
rows[i] << @@COLUMN_SEPARATOR
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
col_index += 1
|
||||||
|
break if col_index >= col_count
|
||||||
|
end
|
||||||
|
|
||||||
|
print_rows(rows, truncated)
|
||||||
|
end
|
||||||
|
|
||||||
|
def close
|
||||||
|
# Only wipe the buffer if we're *sure* it's the explorer.
|
||||||
|
if Window.select @window and \
|
||||||
|
$curbuf == @buffer and \
|
||||||
|
$curbuf.name =~ /#{Regexp.escape(@title)}$/
|
||||||
|
VIM::command "bwipeout!"
|
||||||
|
@window = nil
|
||||||
|
@buffer = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.max_height
|
||||||
|
stored_height = $curwin.height
|
||||||
|
$curwin.height = VIM::MOST_POSITIVE_INTEGER
|
||||||
|
highest_allowable = $curwin.height
|
||||||
|
$curwin.height = stored_height
|
||||||
|
highest_allowable
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.max_width
|
||||||
|
VIM::columns()
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def compute_optimal_layout(strings)
|
||||||
|
# Compute optimal row count and corresponding column count.
|
||||||
|
# The display attempts to fit `strings' on as few rows as
|
||||||
|
# possible.
|
||||||
|
|
||||||
|
max_width = Display.max_width()
|
||||||
|
max_height = Display.max_height()
|
||||||
|
displayable_string_upper_bound = compute_displayable_upper_bound(strings)
|
||||||
|
|
||||||
|
# Determine optimal row count.
|
||||||
|
optimal_row_count, truncated = \
|
||||||
|
if @single_column_mode
|
||||||
|
if strings.length <= max_height
|
||||||
|
[strings.length, false]
|
||||||
|
else
|
||||||
|
[max_height - 1, true]
|
||||||
|
end
|
||||||
|
elsif strings.length > displayable_string_upper_bound
|
||||||
|
# Use all available rows and truncate results.
|
||||||
|
# The -1 is for the truncation indicator.
|
||||||
|
[Display.max_height - 1, true]
|
||||||
|
else
|
||||||
|
single_row_width = \
|
||||||
|
strings.inject(0) { |len, s|
|
||||||
|
len + @@COLUMN_SEPARATOR.length + s.length
|
||||||
|
}
|
||||||
|
if single_row_width <= max_width or \
|
||||||
|
strings.length == 1
|
||||||
|
# All fits on a single row
|
||||||
|
[1, false]
|
||||||
|
else
|
||||||
|
compute_optimal_row_count(strings)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Compute column_count and column_widths.
|
||||||
|
column_count = 0
|
||||||
|
column_widths = []
|
||||||
|
total_width = 0
|
||||||
|
strings.each_slice(optimal_row_count) do |column|
|
||||||
|
column_width = column.max { |a, b| a.length <=> b.length }.length
|
||||||
|
total_width += column_width
|
||||||
|
|
||||||
|
break if total_width > max_width
|
||||||
|
|
||||||
|
column_count += 1
|
||||||
|
column_widths << column_width
|
||||||
|
total_width += @@COLUMN_SEPARATOR.length
|
||||||
|
end
|
||||||
|
|
||||||
|
[optimal_row_count, column_count, column_widths, truncated]
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_rows(rows, truncated)
|
||||||
|
unlock_and_clear()
|
||||||
|
|
||||||
|
# Grow/shrink the window as needed
|
||||||
|
$curwin.height = rows.length + (truncated ? 1 : 0)
|
||||||
|
|
||||||
|
# Print the rows.
|
||||||
|
rows.each_index do |i|
|
||||||
|
$curwin.cursor = [i+1, 1]
|
||||||
|
$curbuf.append(i, rows[i].join(''))
|
||||||
|
end
|
||||||
|
|
||||||
|
# Print a TRUNCATED indicator, if needed.
|
||||||
|
if truncated
|
||||||
|
$curbuf.append($curbuf.count - 1, \
|
||||||
|
@@TRUNCATED_STRING.center($curwin.width, " "))
|
||||||
|
end
|
||||||
|
|
||||||
|
# Stretch the last line to the length of the window with whitespace so
|
||||||
|
# that we can "hide" the cursor in the corner.
|
||||||
|
last_line = $curbuf[$curbuf.count - 1]
|
||||||
|
last_line << (" " * [$curwin.width - last_line.length,0].max)
|
||||||
|
$curbuf[$curbuf.count - 1] = last_line
|
||||||
|
|
||||||
|
# There's a blank line at the end of the buffer because of how
|
||||||
|
# VIM::Buffer.append works.
|
||||||
|
$curbuf.delete $curbuf.count
|
||||||
|
lock()
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_no_entries
|
||||||
|
unlock_and_clear()
|
||||||
|
$curwin.height = 1
|
||||||
|
$curbuf[1] = @@NO_MATCHES_STRING.center($curwin.width, " ")
|
||||||
|
lock()
|
||||||
|
end
|
||||||
|
|
||||||
|
def unlock_and_clear
|
||||||
|
VIM::command "setlocal modifiable"
|
||||||
|
|
||||||
|
# Clear the explorer (black hole register)
|
||||||
|
VIM::command "silent %d _"
|
||||||
|
end
|
||||||
|
|
||||||
|
def lock
|
||||||
|
VIM::command "setlocal nomodifiable"
|
||||||
|
|
||||||
|
# Hide the cursor
|
||||||
|
VIM::command "normal! Gg$"
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_displayable_upper_bound(strings)
|
||||||
|
# Compute an upper-bound on the number of displayable matches.
|
||||||
|
# Basically: find the length of the longest string, then keep
|
||||||
|
# adding shortest strings until we pass the width of the Vim
|
||||||
|
# window. This is the maximum possible column-count assuming
|
||||||
|
# all strings can fit. Then multiply by the number of rows.
|
||||||
|
|
||||||
|
sorted_by_shortest = strings.sort { |x, y| x.length <=> y.length }
|
||||||
|
longest_length = sorted_by_shortest.pop.length
|
||||||
|
|
||||||
|
row_width = longest_length + @@COLUMN_SEPARATOR.length
|
||||||
|
|
||||||
|
max_width = Display.max_width()
|
||||||
|
column_count = 1
|
||||||
|
|
||||||
|
sorted_by_shortest.each do |str|
|
||||||
|
row_width += str.length
|
||||||
|
if row_width > max_width
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
column_count += 1
|
||||||
|
row_width += @@COLUMN_SEPARATOR.length
|
||||||
|
end
|
||||||
|
|
||||||
|
column_count * Display.max_height()
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_optimal_row_count(strings)
|
||||||
|
max_width = Display.max_width
|
||||||
|
max_height = Display.max_height
|
||||||
|
|
||||||
|
# Hashes by range, e.g. 0..2, representing the width
|
||||||
|
# of the column bounded by that range.
|
||||||
|
col_range_widths = {}
|
||||||
|
|
||||||
|
# Binary search; find the lowest number of rows at which we
|
||||||
|
# can fit all the strings.
|
||||||
|
|
||||||
|
# We've already failed for a single row, so start at two.
|
||||||
|
lower = 1 # (1 = 2 - 1)
|
||||||
|
upper = max_height + 1
|
||||||
|
while lower + 1 != upper
|
||||||
|
row_count = (lower + upper) / 2 # Mid-point
|
||||||
|
|
||||||
|
col_start_index = 0
|
||||||
|
col_end_index = row_count - 1
|
||||||
|
total_width = 0
|
||||||
|
|
||||||
|
while col_end_index < strings.length
|
||||||
|
total_width += \
|
||||||
|
compute_column_width(col_start_index..col_end_index,
|
||||||
|
strings, col_range_widths)
|
||||||
|
|
||||||
|
if total_width > max_width
|
||||||
|
# Early exit.
|
||||||
|
total_width = LustyM::MOST_POSITIVE_FIXNUM
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
total_width += @@COLUMN_SEPARATOR.length
|
||||||
|
|
||||||
|
col_start_index += row_count
|
||||||
|
col_end_index += row_count
|
||||||
|
|
||||||
|
if col_end_index >= strings.length and \
|
||||||
|
col_start_index < strings.length
|
||||||
|
# Remainder; last iteration will not be a full column.
|
||||||
|
col_end_index = strings.length - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# The final column doesn't need a separator.
|
||||||
|
total_width -= @@COLUMN_SEPARATOR.length
|
||||||
|
|
||||||
|
if total_width <= max_width
|
||||||
|
# This row count fits.
|
||||||
|
upper = row_count
|
||||||
|
else
|
||||||
|
# This row count doesn't fit.
|
||||||
|
lower = row_count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if upper > max_height
|
||||||
|
# No row count can accomodate all strings; have to truncate.
|
||||||
|
# (-1 for the truncate indicator)
|
||||||
|
[max_height - 1, true]
|
||||||
|
else
|
||||||
|
[upper, false]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_column_width(range, strings, col_range_widths)
|
||||||
|
|
||||||
|
if (range.first == range.last)
|
||||||
|
return strings[range.first].length
|
||||||
|
end
|
||||||
|
|
||||||
|
width = col_range_widths[range]
|
||||||
|
|
||||||
|
if width.nil?
|
||||||
|
# Recurse for each half of the range.
|
||||||
|
split_point = range.first + ((range.last - range.first) >> 1)
|
||||||
|
|
||||||
|
first_half = compute_column_width(range.first..split_point,
|
||||||
|
strings, col_range_widths)
|
||||||
|
second_half = compute_column_width(split_point+1..range.last,
|
||||||
|
strings, col_range_widths)
|
||||||
|
|
||||||
|
width = [first_half, second_half].max
|
||||||
|
col_range_widths[range] = width
|
||||||
|
end
|
||||||
|
|
||||||
|
width
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
111
.vim/bundle/lusty/src/lusty/entry.rb
Normal file
111
.vim/bundle/lusty/src/lusty/entry.rb
Normal file
|
|
@ -0,0 +1,111 @@
|
||||||
|
# Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
module LustyM
|
||||||
|
|
||||||
|
# Abstract base class.
|
||||||
|
class Entry
|
||||||
|
attr_accessor :full_name, :short_name, :label
|
||||||
|
def initialize(full_name, short_name, label)
|
||||||
|
@full_name = full_name
|
||||||
|
@short_name = short_name
|
||||||
|
@label = label
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.compute_buffer_entries()
|
||||||
|
buffer_entries = []
|
||||||
|
|
||||||
|
$le_buffer_stack.numbers.each do |n|
|
||||||
|
o = VIM::Buffer.obj_for_bufnr(n)
|
||||||
|
next if o.nil?
|
||||||
|
buffer_entries << self.new(o, n)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Put the current buffer at the end of the list.
|
||||||
|
buffer_entries << buffer_entries.shift
|
||||||
|
|
||||||
|
# Shorten each buffer name by removing all path elements which are not
|
||||||
|
# needed to differentiate a given name from other names. This usually
|
||||||
|
# results in only the basename shown, but if several buffers of the
|
||||||
|
# same basename are opened, there will be more.
|
||||||
|
|
||||||
|
# Group the buffers by common basename
|
||||||
|
common_base = Hash.new { |hash, k| hash[k] = [] }
|
||||||
|
buffer_entries.each do |entry|
|
||||||
|
if entry.full_name
|
||||||
|
basename = Pathname.new(entry.full_name).basename.to_s
|
||||||
|
common_base[basename] << entry
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Determine the longest common prefix for each basename group.
|
||||||
|
basename_to_prefix = {}
|
||||||
|
common_base.each do |base, entries|
|
||||||
|
if entries.length > 1
|
||||||
|
full_names = entries.map { |e| e.full_name }
|
||||||
|
basename_to_prefix[base] = LustyM::longest_common_prefix(full_names)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Compute shortened buffer names by removing prefix, if possible.
|
||||||
|
buffer_entries.each do |entry|
|
||||||
|
full_name = entry.full_name
|
||||||
|
|
||||||
|
short_name = if full_name.nil?
|
||||||
|
'[No Name]'
|
||||||
|
elsif LustyM::starts_with?(full_name, "scp://")
|
||||||
|
full_name
|
||||||
|
else
|
||||||
|
base = Pathname.new(full_name).basename.to_s
|
||||||
|
prefix = basename_to_prefix[base]
|
||||||
|
|
||||||
|
prefix ? full_name[prefix.length..-1] \
|
||||||
|
: base
|
||||||
|
end
|
||||||
|
|
||||||
|
entry.short_name = short_name
|
||||||
|
end
|
||||||
|
|
||||||
|
buffer_entries
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Used in FilesystemExplorer
|
||||||
|
class FilesystemEntry < Entry
|
||||||
|
attr_accessor :current_score
|
||||||
|
def initialize(label)
|
||||||
|
super("::UNSET::", "::UNSET::", label)
|
||||||
|
@current_score = 0.0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Used in BufferExplorer
|
||||||
|
class BufferEntry < Entry
|
||||||
|
attr_accessor :vim_buffer, :mru_placement, :current_score
|
||||||
|
def initialize(vim_buffer, mru_placement)
|
||||||
|
super(vim_buffer.name, "::UNSET::", "::UNSET::")
|
||||||
|
@vim_buffer = vim_buffer
|
||||||
|
@mru_placement = mru_placement
|
||||||
|
@current_score = 0.0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Used in BufferGrep
|
||||||
|
class GrepEntry < Entry
|
||||||
|
attr_accessor :vim_buffer, :mru_placement, :line_number
|
||||||
|
def initialize(vim_buffer, mru_placement)
|
||||||
|
super(vim_buffer.name, "::UNSET::", "::UNSET::")
|
||||||
|
@vim_buffer = vim_buffer
|
||||||
|
@mru_placement = mru_placement
|
||||||
|
@line_number = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
153
.vim/bundle/lusty/src/lusty/explorer.rb
Normal file
153
.vim/bundle/lusty/src/lusty/explorer.rb
Normal file
|
|
@ -0,0 +1,153 @@
|
||||||
|
# Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
# Abstract base class; extended as BufferExplorer, FilesystemExplorer
|
||||||
|
module LustyM
|
||||||
|
class Explorer
|
||||||
|
public
|
||||||
|
def initialize
|
||||||
|
@settings = SavedSettings.new
|
||||||
|
@display = Display.new title()
|
||||||
|
@prompt = nil
|
||||||
|
@current_sorted_matches = []
|
||||||
|
@running = false
|
||||||
|
end
|
||||||
|
|
||||||
|
def run
|
||||||
|
return if @running
|
||||||
|
|
||||||
|
@settings.save
|
||||||
|
@running = true
|
||||||
|
@calling_window = $curwin
|
||||||
|
@saved_alternate_bufnum = if VIM::evaluate_bool("expand('#') == ''")
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
VIM::evaluate("bufnr(expand('#'))")
|
||||||
|
end
|
||||||
|
create_explorer_window()
|
||||||
|
refresh(:full)
|
||||||
|
end
|
||||||
|
|
||||||
|
def key_pressed()
|
||||||
|
# Grab argument from the Vim function.
|
||||||
|
i = VIM::evaluate("a:code_arg").to_i
|
||||||
|
refresh_mode = :full
|
||||||
|
|
||||||
|
case i
|
||||||
|
when 32..126 # Printable characters
|
||||||
|
c = i.chr
|
||||||
|
@prompt.add! c
|
||||||
|
@selected_index = 0
|
||||||
|
when 8 # Backspace/Del/C-h
|
||||||
|
@prompt.backspace!
|
||||||
|
@selected_index = 0
|
||||||
|
when 9, 13 # Tab and Enter
|
||||||
|
choose(:current_tab)
|
||||||
|
when 23 # C-w (delete 1 dir backward)
|
||||||
|
@prompt.up_one_dir!
|
||||||
|
@selected_index = 0
|
||||||
|
when 14 # C-n (select next)
|
||||||
|
@selected_index = \
|
||||||
|
(@selected_index + 1) % @current_sorted_matches.size
|
||||||
|
refresh_mode = :no_recompute
|
||||||
|
when 16 # C-p (select previous)
|
||||||
|
@selected_index = \
|
||||||
|
(@selected_index - 1) % @current_sorted_matches.size
|
||||||
|
refresh_mode = :no_recompute
|
||||||
|
when 15 # C-o choose in new horizontal split
|
||||||
|
choose(:new_split)
|
||||||
|
when 20 # C-t choose in new tab
|
||||||
|
choose(:new_tab)
|
||||||
|
when 21 # C-u clear prompt
|
||||||
|
@prompt.clear!
|
||||||
|
@selected_index = 0
|
||||||
|
when 22 # C-v choose in new vertical split
|
||||||
|
choose(:new_vsplit)
|
||||||
|
end
|
||||||
|
|
||||||
|
refresh(refresh_mode)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cancel
|
||||||
|
if @running
|
||||||
|
cleanup()
|
||||||
|
# fix alternate file
|
||||||
|
if @saved_alternate_bufnum
|
||||||
|
cur = $curbuf
|
||||||
|
VIM::command "silent b #{@saved_alternate_bufnum}"
|
||||||
|
VIM::command "silent b #{cur.number}"
|
||||||
|
end
|
||||||
|
|
||||||
|
if $LUSTY_PROFILING
|
||||||
|
outfile = File.new('lusty-explorer-rbprof.html', 'a')
|
||||||
|
#RubyProf::CallTreePrinter.new(RubyProf.stop).print(outfile)
|
||||||
|
RubyProf::GraphHtmlPrinter.new(RubyProf.stop).print(outfile)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def refresh(mode)
|
||||||
|
return if not @running
|
||||||
|
|
||||||
|
if mode == :full
|
||||||
|
@current_sorted_matches = compute_sorted_matches()
|
||||||
|
end
|
||||||
|
|
||||||
|
on_refresh()
|
||||||
|
highlight_selected_index() if VIM::has_syntax?
|
||||||
|
@display.print @current_sorted_matches.map { |x| x.label }
|
||||||
|
@prompt.print
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_explorer_window
|
||||||
|
# Trim out the "::" in "LustyM::FooExplorer"
|
||||||
|
key_binding_prefix = 'Lusty' + self.class.to_s.sub(/.*::/,'')
|
||||||
|
|
||||||
|
@display.create(key_binding_prefix)
|
||||||
|
set_syntax_matching()
|
||||||
|
end
|
||||||
|
|
||||||
|
def highlight_selected_index
|
||||||
|
# Note: overridden by BufferGrep
|
||||||
|
VIM::command 'syn clear LustySelected'
|
||||||
|
|
||||||
|
entry = @current_sorted_matches[@selected_index]
|
||||||
|
return if entry.nil?
|
||||||
|
|
||||||
|
escaped = VIM::regex_escape(entry.label)
|
||||||
|
label_match_string = Display.entry_syntaxify(escaped, false)
|
||||||
|
VIM::command "syn match LustySelected \"#{label_match_string}\" " \
|
||||||
|
'contains=LustyGrepMatch'
|
||||||
|
end
|
||||||
|
|
||||||
|
def choose(open_mode)
|
||||||
|
entry = @current_sorted_matches[@selected_index]
|
||||||
|
return if entry.nil?
|
||||||
|
open_entry(entry, open_mode)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cleanup
|
||||||
|
@display.close
|
||||||
|
Window.select @calling_window
|
||||||
|
@settings.restore
|
||||||
|
@running = false
|
||||||
|
VIM::message ""
|
||||||
|
LustyM::assert(@calling_window == $curwin)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Pure virtual methods
|
||||||
|
# - set_syntax_matching
|
||||||
|
# - on_refresh
|
||||||
|
# - open_entry
|
||||||
|
# - compute_sorted_matches
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
37
.vim/bundle/lusty/src/lusty/file-masks.rb
Normal file
37
.vim/bundle/lusty/src/lusty/file-masks.rb
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
module LustyM
|
||||||
|
class FileMasks
|
||||||
|
private
|
||||||
|
@@glob_masks = []
|
||||||
|
|
||||||
|
public
|
||||||
|
def FileMasks.create_glob_masks
|
||||||
|
@@glob_masks = \
|
||||||
|
if VIM::exists? "g:LustyExplorerFileMasks"
|
||||||
|
# Note: this variable deprecated.
|
||||||
|
VIM::evaluate("g:LustyExplorerFileMasks").split(',')
|
||||||
|
elsif VIM::exists? "&wildignore"
|
||||||
|
VIM::evaluate("&wildignore").split(',')
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def FileMasks.masked?(str)
|
||||||
|
@@glob_masks.each do |mask|
|
||||||
|
return true if File.fnmatch(mask, str)
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
252
.vim/bundle/lusty/src/lusty/filesystem-explorer.rb
Normal file
252
.vim/bundle/lusty/src/lusty/filesystem-explorer.rb
Normal file
|
|
@ -0,0 +1,252 @@
|
||||||
|
# Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
module LustyM
|
||||||
|
class FilesystemExplorer < Explorer
|
||||||
|
public
|
||||||
|
def initialize
|
||||||
|
super
|
||||||
|
@prompt = FilesystemPrompt.new
|
||||||
|
@memoized_dir_contents = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
def run
|
||||||
|
return if @running
|
||||||
|
|
||||||
|
FileMasks.create_glob_masks()
|
||||||
|
@vim_swaps = VimSwaps.new
|
||||||
|
@selected_index = 0
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def run_from_here
|
||||||
|
return if @running
|
||||||
|
start_path = if $curbuf.name.nil?
|
||||||
|
VIM::getcwd()
|
||||||
|
else
|
||||||
|
VIM::evaluate("expand('%:p:h')")
|
||||||
|
end
|
||||||
|
|
||||||
|
@prompt.set!(start_path + File::SEPARATOR)
|
||||||
|
run()
|
||||||
|
end
|
||||||
|
|
||||||
|
def run_from_wd
|
||||||
|
return if @running
|
||||||
|
@prompt.set!(VIM::getcwd() + File::SEPARATOR)
|
||||||
|
run()
|
||||||
|
end
|
||||||
|
|
||||||
|
def key_pressed()
|
||||||
|
i = VIM::evaluate("a:code_arg").to_i
|
||||||
|
|
||||||
|
case i
|
||||||
|
when 1, 10 # <C-a>, <Shift-Enter>
|
||||||
|
cleanup()
|
||||||
|
# Open all non-directories currently in view.
|
||||||
|
@current_sorted_matches.each do |e|
|
||||||
|
path_str = \
|
||||||
|
if @prompt.at_dir?
|
||||||
|
@prompt.input + e.label
|
||||||
|
else
|
||||||
|
dir = @prompt.dirname
|
||||||
|
if dir == '/'
|
||||||
|
dir + e.label
|
||||||
|
else
|
||||||
|
dir + File::SEPARATOR + e.label
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
load_file(path_str, :current_tab) unless File.directory?(path_str)
|
||||||
|
end
|
||||||
|
when 5 # <C-e> edit file, create it if necessary
|
||||||
|
if not @prompt.at_dir?
|
||||||
|
cleanup()
|
||||||
|
# Force a reread of this directory so that the new file will
|
||||||
|
# show up (as long as it is saved before the next run).
|
||||||
|
@memoized_dir_contents.delete(view_path())
|
||||||
|
load_file(@prompt.input, :current_tab)
|
||||||
|
end
|
||||||
|
when 18 # <C-r> refresh
|
||||||
|
@memoized_dir_contents.delete(view_path())
|
||||||
|
refresh(:full)
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def title
|
||||||
|
'[LustyExplorer-Files]'
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_syntax_matching
|
||||||
|
# Base highlighting -- more is set on refresh.
|
||||||
|
if VIM::has_syntax?
|
||||||
|
VIM::command 'syn match LustySlash "/" contained'
|
||||||
|
VIM::command 'syn match LustyDir "\%(\S\+ \)*\S\+/" ' \
|
||||||
|
'contains=LustySlash'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def on_refresh
|
||||||
|
if VIM::has_syntax?
|
||||||
|
VIM::command 'syn clear LustyFileWithSwap'
|
||||||
|
|
||||||
|
view = view_path()
|
||||||
|
@vim_swaps.file_names.each do |file_with_swap|
|
||||||
|
if file_with_swap.dirname == view
|
||||||
|
base = file_with_swap.basename
|
||||||
|
escaped = VIM::regex_escape(base.to_s)
|
||||||
|
match_str = Display.entry_syntaxify(escaped, false)
|
||||||
|
VIM::command "syn match LustyFileWithSwap \"#{match_str}\""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO: restore highlighting for open buffers?
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_abbreviation
|
||||||
|
if @prompt.at_dir?
|
||||||
|
""
|
||||||
|
else
|
||||||
|
File.basename(@prompt.input)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def view_path
|
||||||
|
input = @prompt.input
|
||||||
|
|
||||||
|
path = \
|
||||||
|
if @prompt.at_dir? and \
|
||||||
|
input.length > 1 # Not root
|
||||||
|
# The last element in the path is a directory + '/' and we want to
|
||||||
|
# see what's in it instead of what's in its parent directory.
|
||||||
|
|
||||||
|
Pathname.new(input[0..-2]) # Canonicalize by removing trailing '/'
|
||||||
|
else
|
||||||
|
Pathname.new(input).dirname
|
||||||
|
end
|
||||||
|
|
||||||
|
return path
|
||||||
|
end
|
||||||
|
|
||||||
|
def all_files_at_view
|
||||||
|
view = view_path()
|
||||||
|
|
||||||
|
unless @memoized_dir_contents.has_key?(view)
|
||||||
|
|
||||||
|
if not view.directory?
|
||||||
|
return []
|
||||||
|
elsif not view.readable?
|
||||||
|
# TODO: show "-- PERMISSION DENIED --"
|
||||||
|
return []
|
||||||
|
end
|
||||||
|
|
||||||
|
# Generate an array of the files
|
||||||
|
entries = []
|
||||||
|
view_str = view.to_s
|
||||||
|
unless LustyM::ends_with?(view_str, File::SEPARATOR)
|
||||||
|
# Don't double-up on '/' -- makes Cygwin sad.
|
||||||
|
view_str << File::SEPARATOR
|
||||||
|
end
|
||||||
|
|
||||||
|
Dir.foreach(view_str) do |name|
|
||||||
|
next if name == "." # Skip pwd
|
||||||
|
next if name == ".." and LustyM::option_set?("AlwaysShowDotFiles")
|
||||||
|
|
||||||
|
# Hide masked files.
|
||||||
|
next if FileMasks.masked?(name)
|
||||||
|
|
||||||
|
if FileTest.directory?(view_str + name)
|
||||||
|
name << File::SEPARATOR
|
||||||
|
end
|
||||||
|
entries << FilesystemEntry.new(name)
|
||||||
|
end
|
||||||
|
@memoized_dir_contents[view] = entries
|
||||||
|
end
|
||||||
|
|
||||||
|
all = @memoized_dir_contents[view]
|
||||||
|
|
||||||
|
if LustyM::option_set?("AlwaysShowDotFiles") or \
|
||||||
|
current_abbreviation()[0] == ?.
|
||||||
|
all
|
||||||
|
else
|
||||||
|
# Filter out dotfiles if the current abbreviation doesn't start with
|
||||||
|
# '.'.
|
||||||
|
all.select { |x| x.label[0] != ?. }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def compute_sorted_matches
|
||||||
|
abbrev = current_abbreviation()
|
||||||
|
|
||||||
|
unsorted = all_files_at_view()
|
||||||
|
|
||||||
|
if abbrev.length == 0
|
||||||
|
# Sort alphabetically if we have no abbreviation.
|
||||||
|
unsorted.sort { |x, y| x.label <=> y.label }
|
||||||
|
else
|
||||||
|
matches = \
|
||||||
|
unsorted.select { |x|
|
||||||
|
x.current_score = Mercury.score(x.label, abbrev)
|
||||||
|
x.current_score != 0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
if abbrev == '.'
|
||||||
|
# Sort alphabetically, otherwise it just looks weird.
|
||||||
|
matches.sort! { |x, y| x.label <=> y.label }
|
||||||
|
else
|
||||||
|
# Sort by score.
|
||||||
|
matches.sort! { |x, y| y.current_score <=> x.current_score }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def open_entry(entry, open_mode)
|
||||||
|
path = view_path() + entry.label
|
||||||
|
|
||||||
|
if File.directory?(path)
|
||||||
|
# Recurse into the directory instead of opening it.
|
||||||
|
@prompt.set!(path.to_s)
|
||||||
|
@selected_index = 0
|
||||||
|
elsif entry.label.include?(File::SEPARATOR)
|
||||||
|
# Don't open a fake file/buffer with "/" in its name.
|
||||||
|
return
|
||||||
|
else
|
||||||
|
cleanup()
|
||||||
|
load_file(path.to_s, open_mode)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def load_file(path_str, open_mode)
|
||||||
|
LustyM::assert($curwin == @calling_window)
|
||||||
|
# Escape for Vim and remove leading ./ for files in pwd.
|
||||||
|
filename_escaped = VIM::filename_escape(path_str).sub(/^\.\//,"")
|
||||||
|
single_quote_escaped = VIM::single_quote_escape(filename_escaped)
|
||||||
|
sanitized = VIM::evaluate "fnamemodify('#{single_quote_escaped}', ':.')"
|
||||||
|
cmd = case open_mode
|
||||||
|
when :current_tab
|
||||||
|
"e"
|
||||||
|
when :new_tab
|
||||||
|
"tabe"
|
||||||
|
when :new_split
|
||||||
|
"sp"
|
||||||
|
when :new_vsplit
|
||||||
|
"vs"
|
||||||
|
else
|
||||||
|
LustyM::assert(false, "bad open mode")
|
||||||
|
end
|
||||||
|
|
||||||
|
VIM::command "silent #{cmd} #{sanitized}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
180
.vim/bundle/lusty/src/lusty/juggler.rb
Normal file
180
.vim/bundle/lusty/src/lusty/juggler.rb
Normal file
|
|
@ -0,0 +1,180 @@
|
||||||
|
# Copyright (C) 2008-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
module LustyM
|
||||||
|
class LustyJuggler
|
||||||
|
private
|
||||||
|
@@KEYS = { "a" => 1,
|
||||||
|
"s" => 2,
|
||||||
|
"d" => 3,
|
||||||
|
"f" => 4,
|
||||||
|
"g" => 5,
|
||||||
|
"h" => 6,
|
||||||
|
"j" => 7,
|
||||||
|
"k" => 8,
|
||||||
|
"l" => 9,
|
||||||
|
";" => 10,
|
||||||
|
"1" => 1,
|
||||||
|
"2" => 2,
|
||||||
|
"3" => 3,
|
||||||
|
"4" => 4,
|
||||||
|
"5" => 5,
|
||||||
|
"6" => 6,
|
||||||
|
"7" => 7,
|
||||||
|
"8" => 8,
|
||||||
|
"9" => 9,
|
||||||
|
"0" => 10 }
|
||||||
|
|
||||||
|
public
|
||||||
|
def initialize
|
||||||
|
@running = false
|
||||||
|
@last_pressed = nil
|
||||||
|
@name_bar = NameBar.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def run
|
||||||
|
return if @running
|
||||||
|
|
||||||
|
if $lj_buffer_stack.length <= 1
|
||||||
|
VIM::pretty_msg("PreProc", "No other buffers")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
@running = true
|
||||||
|
|
||||||
|
# Need to zero the timeout length or pressing 'g' will hang.
|
||||||
|
@ruler = VIM::evaluate_bool("&ruler")
|
||||||
|
@showcmd = VIM::evaluate_bool("&showcmd")
|
||||||
|
@showmode = VIM::evaluate_bool("&showmode")
|
||||||
|
@timeoutlen = VIM::evaluate("&timeoutlen")
|
||||||
|
VIM::set_option 'timeoutlen=0'
|
||||||
|
VIM::set_option 'noruler'
|
||||||
|
VIM::set_option 'noshowcmd'
|
||||||
|
VIM::set_option 'noshowmode'
|
||||||
|
|
||||||
|
@key_mappings_map = Hash.new { |hash, k| hash[k] = [] }
|
||||||
|
|
||||||
|
# Selection keys.
|
||||||
|
@@KEYS.keys.each do |c|
|
||||||
|
map_key(c, ":call <SID>LustyJugglerKeyPressed('#{c}')<CR>")
|
||||||
|
end
|
||||||
|
# Can't use '<CR>' as an argument to :call func for some reason.
|
||||||
|
map_key("<CR>", ":call <SID>LustyJugglerKeyPressed('ENTER')<CR>")
|
||||||
|
map_key("<Tab>", ":call <SID>LustyJugglerKeyPressed('TAB')<CR>")
|
||||||
|
|
||||||
|
# Cancel keys.
|
||||||
|
map_key("q", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
|
map_key("<Esc>", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
|
map_key("<C-c>", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
|
map_key("<BS>", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
|
map_key("<Del>", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
|
map_key("<C-h>", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
|
|
||||||
|
print_buffer_list()
|
||||||
|
end
|
||||||
|
|
||||||
|
def key_pressed()
|
||||||
|
c = VIM::evaluate("a:code_arg")
|
||||||
|
|
||||||
|
if @last_pressed.nil? and c == 'ENTER'
|
||||||
|
cleanup()
|
||||||
|
elsif @last_pressed and (c == @last_pressed or c == 'ENTER')
|
||||||
|
choose(@@KEYS[@last_pressed])
|
||||||
|
cleanup()
|
||||||
|
else
|
||||||
|
print_buffer_list(@@KEYS[c])
|
||||||
|
@last_pressed = c
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Restore settings, mostly.
|
||||||
|
def cleanup
|
||||||
|
@last_pressed = nil
|
||||||
|
|
||||||
|
VIM::set_option "timeoutlen=#{@timeoutlen}"
|
||||||
|
VIM::set_option "ruler" if @ruler
|
||||||
|
VIM::set_option "showcmd" if @showcmd
|
||||||
|
VIM::set_option "showmode" if @showmode
|
||||||
|
|
||||||
|
@@KEYS.keys.each do |c|
|
||||||
|
unmap_key(c)
|
||||||
|
end
|
||||||
|
unmap_key("<CR>")
|
||||||
|
unmap_key("<Tab>")
|
||||||
|
|
||||||
|
unmap_key("q")
|
||||||
|
unmap_key("<Esc>")
|
||||||
|
unmap_key("<C-c>")
|
||||||
|
unmap_key("<BS>")
|
||||||
|
unmap_key("<Del>")
|
||||||
|
unmap_key("<C-h>")
|
||||||
|
|
||||||
|
@running = false
|
||||||
|
VIM::message ''
|
||||||
|
VIM::command 'redraw' # Prevents "Press ENTER to continue" message.
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def print_buffer_list(highlighted_entry = nil)
|
||||||
|
# If the user pressed a key higher than the number of open buffers,
|
||||||
|
# highlight the highest (see also BufferStack.num_at_pos()).
|
||||||
|
|
||||||
|
@name_bar.selected_buffer = \
|
||||||
|
if highlighted_entry
|
||||||
|
# Correct for zero-based array.
|
||||||
|
[highlighted_entry, $lj_buffer_stack.length].min - 1
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
@name_bar.print
|
||||||
|
end
|
||||||
|
|
||||||
|
def choose(i)
|
||||||
|
buf = $lj_buffer_stack.num_at_pos(i)
|
||||||
|
VIM::command "b #{buf}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def map_key(key, action)
|
||||||
|
['n','v','o','i','c','l'].each do |mode|
|
||||||
|
VIM::command "let s:maparg_holder = maparg('#{key}', '#{mode}')"
|
||||||
|
if VIM::evaluate_bool("s:maparg_holder != ''")
|
||||||
|
@key_mappings_map[key] << [mode, VIM::evaluate('s:maparg_holder')]
|
||||||
|
end
|
||||||
|
VIM::command "#{mode}noremap <silent> #{key} #{action}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def unmap_key(key)
|
||||||
|
modes_with_mappings_for_key = \
|
||||||
|
{ 'n' => false,
|
||||||
|
'v' => false,
|
||||||
|
'o' => false,
|
||||||
|
'i' => false,
|
||||||
|
'c' => false,
|
||||||
|
'l' => false }
|
||||||
|
|
||||||
|
if @key_mappings_map.has_key?(key)
|
||||||
|
@key_mappings_map[key].each do |a|
|
||||||
|
mode = a[0]
|
||||||
|
action = a[1]
|
||||||
|
VIM::command "#{mode}noremap <silent> #{key} #{action}"
|
||||||
|
modes_with_mappings_for_key[mode] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
modes_with_mappings_for_key.each_pair do |mode, had_mapping|
|
||||||
|
unless had_mapping
|
||||||
|
VIM::command "#{mode}unmap <silent> #{key}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
183
.vim/bundle/lusty/src/lusty/name-bar.rb
Normal file
183
.vim/bundle/lusty/src/lusty/name-bar.rb
Normal file
|
|
@ -0,0 +1,183 @@
|
||||||
|
# Copyright (C) 2008-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
# A one-line display of the open buffers, appearing in the command display.
|
||||||
|
module LustyM
|
||||||
|
class NameBar
|
||||||
|
public
|
||||||
|
def initialize
|
||||||
|
@selected_buffer = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
attr_writer :selected_buffer
|
||||||
|
|
||||||
|
def print
|
||||||
|
items = create_items()
|
||||||
|
|
||||||
|
selected_item = \
|
||||||
|
if @selected_buffer
|
||||||
|
# Account for the separators we've added.
|
||||||
|
[@selected_buffer * 2, (items.length - 1)].min
|
||||||
|
end
|
||||||
|
|
||||||
|
clipped = clip(items, selected_item)
|
||||||
|
NameBar.do_pretty_print(clipped)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
@@LETTERS = ["a", "s", "d", "f", "g", "h", "j", "k", "l", ";"]
|
||||||
|
|
||||||
|
|
||||||
|
def create_items
|
||||||
|
names = $lj_buffer_stack.names(10)
|
||||||
|
|
||||||
|
items = names.inject([]) { |array, name|
|
||||||
|
key = if VIM::exists?("g:LustyJugglerShowKeys")
|
||||||
|
case VIM::evaluate("g:LustyJugglerShowKeys").to_s
|
||||||
|
when /[[:alpha:]]/
|
||||||
|
@@LETTERS[array.size / 2] + ":"
|
||||||
|
when /[[:digit:]]/
|
||||||
|
"#{((array.size / 2) + 1) % 10}:"
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
|
||||||
|
array << BufferItem.new("#{key}#{name}",
|
||||||
|
(@selected_buffer and \
|
||||||
|
name == names[@selected_buffer]))
|
||||||
|
array << SeparatorItem.new
|
||||||
|
}
|
||||||
|
items.pop # Remove last separator.
|
||||||
|
|
||||||
|
return items
|
||||||
|
end
|
||||||
|
|
||||||
|
# Clip the given array of items to the available display width.
|
||||||
|
def clip(items, selected)
|
||||||
|
# This function is pretty hard to follow...
|
||||||
|
|
||||||
|
# Note: Vim gives the annoying "Press ENTER to continue" message if we
|
||||||
|
# use the full width.
|
||||||
|
columns = VIM::columns() - 1
|
||||||
|
|
||||||
|
if BarItem.full_length(items) <= columns
|
||||||
|
return items
|
||||||
|
end
|
||||||
|
|
||||||
|
selected = 0 if selected.nil?
|
||||||
|
half_displayable_len = columns / 2
|
||||||
|
|
||||||
|
# The selected buffer is excluded since it's basically split between
|
||||||
|
# the sides.
|
||||||
|
left_len = BarItem.full_length items[0, selected - 1]
|
||||||
|
right_len = BarItem.full_length items[selected + 1, items.length - 1]
|
||||||
|
|
||||||
|
right_justify = (left_len > half_displayable_len) and \
|
||||||
|
(right_len < half_displayable_len)
|
||||||
|
|
||||||
|
selected_str_half_len = (items[selected].length / 2) + \
|
||||||
|
(items[selected].length % 2 == 0 ? 0 : 1)
|
||||||
|
|
||||||
|
if right_justify
|
||||||
|
# Right justify the bar.
|
||||||
|
first_layout = self.method :layout_right
|
||||||
|
second_layout = self.method :layout_left
|
||||||
|
first_adjustment = selected_str_half_len
|
||||||
|
second_adjustment = -selected_str_half_len
|
||||||
|
else
|
||||||
|
# Left justify (sort-of more likely).
|
||||||
|
first_layout = self.method :layout_left
|
||||||
|
second_layout = self.method :layout_right
|
||||||
|
first_adjustment = -selected_str_half_len
|
||||||
|
second_adjustment = selected_str_half_len
|
||||||
|
end
|
||||||
|
|
||||||
|
# Layout the first side.
|
||||||
|
allocation = half_displayable_len + first_adjustment
|
||||||
|
first_side, remainder = first_layout.call(items,
|
||||||
|
selected,
|
||||||
|
allocation)
|
||||||
|
|
||||||
|
# Then layout the second side, also grabbing any unused space.
|
||||||
|
allocation = half_displayable_len + \
|
||||||
|
second_adjustment + \
|
||||||
|
remainder
|
||||||
|
second_side, remainder = second_layout.call(items,
|
||||||
|
selected,
|
||||||
|
allocation)
|
||||||
|
|
||||||
|
if right_justify
|
||||||
|
second_side + first_side
|
||||||
|
else
|
||||||
|
first_side + second_side
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Clip the given array of items to the given space, counting downwards.
|
||||||
|
def layout_left(items, selected, space)
|
||||||
|
trimmed = []
|
||||||
|
|
||||||
|
i = selected - 1
|
||||||
|
while i >= 0
|
||||||
|
m = items[i]
|
||||||
|
if space > m.length
|
||||||
|
trimmed << m
|
||||||
|
space -= m.length
|
||||||
|
elsif space > 0
|
||||||
|
trimmed << m[m.length - (space - LeftContinuerItem.length), \
|
||||||
|
space - LeftContinuerItem.length]
|
||||||
|
trimmed << LeftContinuerItem.new
|
||||||
|
space = 0
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
i -= 1
|
||||||
|
end
|
||||||
|
|
||||||
|
return trimmed.reverse, space
|
||||||
|
end
|
||||||
|
|
||||||
|
# Clip the given array of items to the given space, counting upwards.
|
||||||
|
def layout_right(items, selected, space)
|
||||||
|
trimmed = []
|
||||||
|
|
||||||
|
i = selected
|
||||||
|
while i < items.length
|
||||||
|
m = items[i]
|
||||||
|
if space > m.length
|
||||||
|
trimmed << m
|
||||||
|
space -= m.length
|
||||||
|
elsif space > 0
|
||||||
|
trimmed << m[0, space - RightContinuerItem.length]
|
||||||
|
trimmed << RightContinuerItem.new
|
||||||
|
space = 0
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
i += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
return trimmed, space
|
||||||
|
end
|
||||||
|
|
||||||
|
def NameBar.do_pretty_print(items)
|
||||||
|
args = items.inject([]) { |array, item|
|
||||||
|
array = array + item.pretty_print_input
|
||||||
|
}
|
||||||
|
|
||||||
|
VIM::pretty_msg *args
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
153
.vim/bundle/lusty/src/lusty/prompt.rb
Normal file
153
.vim/bundle/lusty/src/lusty/prompt.rb
Normal file
|
|
@ -0,0 +1,153 @@
|
||||||
|
# Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
module LustyM
|
||||||
|
|
||||||
|
# Used in BufferExplorer
|
||||||
|
class Prompt
|
||||||
|
private
|
||||||
|
@@PROMPT = ">> "
|
||||||
|
|
||||||
|
public
|
||||||
|
def initialize
|
||||||
|
clear!
|
||||||
|
end
|
||||||
|
|
||||||
|
def clear!
|
||||||
|
@input = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
def print
|
||||||
|
VIM::pretty_msg("Comment", @@PROMPT,
|
||||||
|
"None", VIM::single_quote_escape(@input),
|
||||||
|
"Underlined", " ")
|
||||||
|
end
|
||||||
|
|
||||||
|
def set!(s)
|
||||||
|
@input = s
|
||||||
|
end
|
||||||
|
|
||||||
|
def input
|
||||||
|
@input
|
||||||
|
end
|
||||||
|
|
||||||
|
def insensitive?
|
||||||
|
@input == @input.downcase
|
||||||
|
end
|
||||||
|
|
||||||
|
def ends_with?(c)
|
||||||
|
LustyM::ends_with?(@input, c)
|
||||||
|
end
|
||||||
|
|
||||||
|
def add!(s)
|
||||||
|
@input << s
|
||||||
|
end
|
||||||
|
|
||||||
|
def backspace!
|
||||||
|
@input.chop!
|
||||||
|
end
|
||||||
|
|
||||||
|
def up_one_dir!
|
||||||
|
@input.chop!
|
||||||
|
while !@input.empty? and @input[-1] != ?/
|
||||||
|
@input.chop!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Used in FilesystemExplorer
|
||||||
|
class FilesystemPrompt < Prompt
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
super
|
||||||
|
@memoized = nil
|
||||||
|
@dirty = true
|
||||||
|
end
|
||||||
|
|
||||||
|
def clear!
|
||||||
|
super
|
||||||
|
@dirty = true
|
||||||
|
end
|
||||||
|
|
||||||
|
def set!(s)
|
||||||
|
# On Windows, Vim will return paths with a '\' separator, but
|
||||||
|
# we want to use '/'.
|
||||||
|
super(s.gsub('\\', '/'))
|
||||||
|
@dirty = true
|
||||||
|
end
|
||||||
|
|
||||||
|
def backspace!
|
||||||
|
super
|
||||||
|
@dirty = true
|
||||||
|
end
|
||||||
|
|
||||||
|
def up_one_dir!
|
||||||
|
super
|
||||||
|
@dirty = true
|
||||||
|
end
|
||||||
|
|
||||||
|
def at_dir?
|
||||||
|
# We have not typed anything yet or have just typed the final '/' on a
|
||||||
|
# directory name in pwd. This check is interspersed throughout
|
||||||
|
# FilesystemExplorer because of the conventions of basename and dirname.
|
||||||
|
input().empty? or input()[-1] == File::SEPARATOR[0]
|
||||||
|
# Don't think the File.directory? call is necessary, but leaving this
|
||||||
|
# here as a reminder.
|
||||||
|
#(File.directory?(input()) and input().ends_with?(File::SEPARATOR))
|
||||||
|
end
|
||||||
|
|
||||||
|
def insensitive?
|
||||||
|
at_dir? or (basename() == basename().downcase)
|
||||||
|
end
|
||||||
|
|
||||||
|
def add!(s)
|
||||||
|
# Assumption: add!() will only receive enough chars at a time to complete
|
||||||
|
# a single directory level, e.g. foo/, not foo/bar/
|
||||||
|
|
||||||
|
@input << s
|
||||||
|
@dirty = true
|
||||||
|
end
|
||||||
|
|
||||||
|
def input
|
||||||
|
if @dirty
|
||||||
|
@memoized = LustyM::simplify_path(variable_expansion(@input))
|
||||||
|
@dirty = false
|
||||||
|
end
|
||||||
|
|
||||||
|
@memoized
|
||||||
|
end
|
||||||
|
|
||||||
|
def basename
|
||||||
|
File.basename input()
|
||||||
|
end
|
||||||
|
|
||||||
|
def dirname
|
||||||
|
File.dirname input()
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def variable_expansion (input_str)
|
||||||
|
strings = input_str.split('$', -1)
|
||||||
|
return "" if strings.nil? or strings.length == 0
|
||||||
|
|
||||||
|
first = strings.shift
|
||||||
|
|
||||||
|
# Try to expand each instance of $<word>.
|
||||||
|
strings.inject(first) { |str, s|
|
||||||
|
if s =~ /^(\w+)/ and ENV[$1]
|
||||||
|
str + s.sub($1, ENV[$1])
|
||||||
|
else
|
||||||
|
str + "$" + s
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
67
.vim/bundle/lusty/src/lusty/saved-settings.rb
Normal file
67
.vim/bundle/lusty/src/lusty/saved-settings.rb
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
# Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
# Save and restore settings when creating the explorer buffer.
|
||||||
|
module LustyM
|
||||||
|
class SavedSettings
|
||||||
|
def initialize
|
||||||
|
save()
|
||||||
|
end
|
||||||
|
|
||||||
|
def save
|
||||||
|
@timeoutlen = VIM::evaluate("&timeoutlen")
|
||||||
|
|
||||||
|
@splitbelow = VIM::evaluate_bool("&splitbelow")
|
||||||
|
@insertmode = VIM::evaluate_bool("&insertmode")
|
||||||
|
@showcmd = VIM::evaluate_bool("&showcmd")
|
||||||
|
@list = VIM::evaluate_bool("&list")
|
||||||
|
|
||||||
|
@report = VIM::evaluate("&report")
|
||||||
|
@sidescroll = VIM::evaluate("&sidescroll")
|
||||||
|
@sidescrolloff = VIM::evaluate("&sidescrolloff")
|
||||||
|
|
||||||
|
VIM::command "let s:win_size_restore = winrestcmd()"
|
||||||
|
end
|
||||||
|
|
||||||
|
def restore
|
||||||
|
VIM::set_option "timeoutlen=#{@timeoutlen}"
|
||||||
|
|
||||||
|
if @splitbelow
|
||||||
|
VIM::set_option "splitbelow"
|
||||||
|
else
|
||||||
|
VIM::set_option "nosplitbelow"
|
||||||
|
end
|
||||||
|
|
||||||
|
if @insertmode
|
||||||
|
VIM::set_option "insertmode"
|
||||||
|
else
|
||||||
|
VIM::set_option "noinsertmode"
|
||||||
|
end
|
||||||
|
|
||||||
|
if @showcmd
|
||||||
|
VIM::set_option "showcmd"
|
||||||
|
else
|
||||||
|
VIM::set_option "noshowcmd"
|
||||||
|
end
|
||||||
|
|
||||||
|
if @list
|
||||||
|
VIM::set_option "list"
|
||||||
|
else
|
||||||
|
VIM::set_option "nolist"
|
||||||
|
end
|
||||||
|
|
||||||
|
VIM::command "set report=#{@report}"
|
||||||
|
VIM::command "set sidescroll=#{@sidescroll}"
|
||||||
|
VIM::command "set sidescrolloff=#{@sidescrolloff}"
|
||||||
|
|
||||||
|
VIM::command "exe s:win_size_restore"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
42
.vim/bundle/lusty/src/lusty/vim-swaps.rb
Normal file
42
.vim/bundle/lusty/src/lusty/vim-swaps.rb
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
# Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
module LustyM
|
||||||
|
class VimSwaps
|
||||||
|
def initialize
|
||||||
|
if VIM::has_syntax?
|
||||||
|
# FIXME: vvv disabled
|
||||||
|
# @vim_r = IO.popen("vim -r --noplugin -i NONE 2>&1")
|
||||||
|
# @files_with_swaps = nil
|
||||||
|
@files_with_swaps = []
|
||||||
|
else
|
||||||
|
@files_with_swaps = []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def file_names
|
||||||
|
if @files_with_swaps.nil?
|
||||||
|
if LustyM::ready_for_read?(@vim_r)
|
||||||
|
@files_with_swaps = []
|
||||||
|
@vim_r.each_line do |line|
|
||||||
|
if line =~ /^ +file name: (.*)$/
|
||||||
|
file = $1.chomp
|
||||||
|
@files_with_swaps << Pathname.new(LustyM::simplify_path(file))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@files_with_swaps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
34
.vim/bundle/lusty/src/lusty/window.rb
Normal file
34
.vim/bundle/lusty/src/lusty/window.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
# Simplify switching between windows.
|
||||||
|
module LustyM
|
||||||
|
class Window
|
||||||
|
def self.select(window)
|
||||||
|
return true if window == $curwin
|
||||||
|
|
||||||
|
start = $curwin
|
||||||
|
|
||||||
|
# Try to select the given window.
|
||||||
|
begin
|
||||||
|
VIM::command "wincmd w"
|
||||||
|
end while ($curwin != window) and ($curwin != start)
|
||||||
|
|
||||||
|
if $curwin == window
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
# Failed -- re-select the starting window.
|
||||||
|
VIM::command("wincmd w") while $curwin != start
|
||||||
|
VIM::pretty_msg("ErrorMsg", "Cannot find the correct window!")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
103
.vim/bundle/lusty/src/mercury.rb
Normal file
103
.vim/bundle/lusty/src/mercury.rb
Normal file
|
|
@ -0,0 +1,103 @@
|
||||||
|
# Copyright (C) 2010 Matt Tolton
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
# Mercury fuzzy matching algorithm, written by Matt Tolton.
|
||||||
|
# based on the Quicksilver and LiquidMetal fuzzy matching algorithms
|
||||||
|
class Mercury
|
||||||
|
public
|
||||||
|
def self.score(string, abbrev)
|
||||||
|
return self.new(string, abbrev).score()
|
||||||
|
end
|
||||||
|
|
||||||
|
def score()
|
||||||
|
return @@SCORE_TRAILING if @abbrev.empty?
|
||||||
|
return @@SCORE_NO_MATCH if @abbrev.length > @string.length
|
||||||
|
|
||||||
|
raw_score = raw_score(0, 0, 0, false)
|
||||||
|
return raw_score / @string.length
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize(string, abbrev)
|
||||||
|
@string = string
|
||||||
|
@lower_string = string.downcase()
|
||||||
|
@abbrev = abbrev.downcase()
|
||||||
|
@level = 0
|
||||||
|
@branches = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
@@SCORE_NO_MATCH = 0.0 # do not change, this is assumed to be 0.0
|
||||||
|
@@SCORE_EXACT_MATCH = 1.0
|
||||||
|
@@SCORE_MATCH = 0.9
|
||||||
|
@@SCORE_TRAILING = 0.7
|
||||||
|
@@SCORE_TRAILING_BUT_STARTED = 0.80
|
||||||
|
@@SCORE_BUFFER = 0.70
|
||||||
|
@@SCORE_BUFFER_BUT_STARTED = 0.80
|
||||||
|
|
||||||
|
@@BRANCH_LIMIT = 100
|
||||||
|
|
||||||
|
#def raw_score(a, b, c, d)
|
||||||
|
# @level += 1
|
||||||
|
# puts "#{' ' * @level}#{a}, #{b}, #{c}, #{d}"
|
||||||
|
# ret = recurse_and_score(a, b, c, d)
|
||||||
|
# puts "#{' ' * @level}#{a}, #{b}, #{c}, #{d} -> #{ret}"
|
||||||
|
# @level -= 1
|
||||||
|
# return ret
|
||||||
|
#end
|
||||||
|
|
||||||
|
def raw_score(abbrev_idx, match_idx, score_idx, first_char_matched)
|
||||||
|
index = @lower_string.index(@abbrev[abbrev_idx], match_idx)
|
||||||
|
return 0.0 if index.nil?
|
||||||
|
|
||||||
|
# TODO Instead of having two scores, should there be a sliding "match"
|
||||||
|
# score based on the distance of the matched character to the beginning
|
||||||
|
# of the string?
|
||||||
|
if abbrev_idx == index
|
||||||
|
score = @@SCORE_EXACT_MATCH
|
||||||
|
else
|
||||||
|
score = @@SCORE_MATCH
|
||||||
|
end
|
||||||
|
|
||||||
|
started = (index == 0 or first_char_matched)
|
||||||
|
|
||||||
|
# If matching on a word boundary, score the characters since the last match
|
||||||
|
if index > score_idx
|
||||||
|
buffer_score = started ? @@SCORE_BUFFER_BUT_STARTED : @@SCORE_BUFFER
|
||||||
|
if " \t/._-".include?(@string[index - 1])
|
||||||
|
score += @@SCORE_MATCH
|
||||||
|
score += buffer_score * ((index - 1) - score_idx)
|
||||||
|
elsif @string[index] >= "A"[0] and @string[index] <= "Z"[0]
|
||||||
|
score += buffer_score * (index - score_idx)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if abbrev_idx + 1 == @abbrev.length
|
||||||
|
trailing_score = started ? @@SCORE_TRAILING_BUT_STARTED : @@SCORE_TRAILING
|
||||||
|
# We just matched the last character in the pattern
|
||||||
|
score += trailing_score * (@string.length - (index + 1))
|
||||||
|
else
|
||||||
|
tail_score = raw_score(abbrev_idx + 1, index + 1, index + 1, started)
|
||||||
|
return 0.0 if tail_score == 0.0
|
||||||
|
score += tail_score
|
||||||
|
end
|
||||||
|
|
||||||
|
if @branches < @@BRANCH_LIMIT
|
||||||
|
@branches += 1
|
||||||
|
alternate = raw_score(abbrev_idx,
|
||||||
|
index + 1,
|
||||||
|
score_idx,
|
||||||
|
first_char_matched)
|
||||||
|
#puts "#{' ' * @level}#{score}, #{alternate}"
|
||||||
|
score = [score, alternate].max
|
||||||
|
end
|
||||||
|
|
||||||
|
return score
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
145
.vim/bundle/lusty/src/mercury_test.rb
Normal file
145
.vim/bundle/lusty/src/mercury_test.rb
Normal file
|
|
@ -0,0 +1,145 @@
|
||||||
|
# Mercury tests, as well the quicksilver and liquidmetal algorithms which we
|
||||||
|
# sometimes use for comparison
|
||||||
|
|
||||||
|
require 'mercury'
|
||||||
|
|
||||||
|
# Fuzzy matching algorithm from Quicksilver, the OS X tool
|
||||||
|
def qs_score(entry, abbrev)
|
||||||
|
return 0.9 if abbrev.length == 0
|
||||||
|
return 0.0 if abbrev.length > entry.length
|
||||||
|
|
||||||
|
abbrev.length.downto(1) do |i|
|
||||||
|
sub_abbrev = abbrev[0...i]
|
||||||
|
index = entry.index(sub_abbrev)
|
||||||
|
|
||||||
|
next if index.nil?
|
||||||
|
next if index + sub_abbrev.length > entry.length
|
||||||
|
|
||||||
|
next_entry = entry[index+sub_abbrev.length..-1]
|
||||||
|
|
||||||
|
next_abbrev = i >= abbrev.length ? "" : abbrev[i..-1]
|
||||||
|
|
||||||
|
remaining_score = qs_score(next_entry, next_abbrev)
|
||||||
|
|
||||||
|
if remaining_score > 0
|
||||||
|
score = entry.length - next_entry.length
|
||||||
|
|
||||||
|
if index != 0
|
||||||
|
c = entry[index - 1]
|
||||||
|
word_boundaries = " \t/._"
|
||||||
|
if word_boundaries.include?(c)
|
||||||
|
for j in 0...(index-1)
|
||||||
|
c = entry[j]
|
||||||
|
score -= word_boundaries.include?(c) ? 1 : 0.15
|
||||||
|
end
|
||||||
|
else
|
||||||
|
score -= index
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
score += remaining_score * next_entry.length
|
||||||
|
score /= entry.length
|
||||||
|
return score
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 0.0
|
||||||
|
end
|
||||||
|
|
||||||
|
# Port of Ryan McGeary's LiquidMetal fuzzy matching algorithm found at:
|
||||||
|
# http://github.com/rmm5t/liquidmetal/tree/master.
|
||||||
|
class LiquidMetal
|
||||||
|
@@SCORE_NO_MATCH = 0.0
|
||||||
|
@@SCORE_MATCH = 1.0
|
||||||
|
@@SCORE_TRAILING = 0.8
|
||||||
|
@@SCORE_TRAILING_BUT_STARTED = 0.90
|
||||||
|
@@SCORE_BUFFER = 0.85
|
||||||
|
|
||||||
|
def self.score(string, abbrev)
|
||||||
|
return @@SCORE_TRAILING if abbrev.empty?
|
||||||
|
return @@SCORE_NO_MATCH if abbrev.length > string.length
|
||||||
|
|
||||||
|
scores = buildScoreArray(string, abbrev)
|
||||||
|
|
||||||
|
sum = scores.inject { |a, b| a + b }
|
||||||
|
|
||||||
|
return sum / scores.length;
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.buildScoreArray(string, abbrev)
|
||||||
|
scores = Array.new(string.length)
|
||||||
|
lower = string.downcase()
|
||||||
|
|
||||||
|
lastIndex = -1
|
||||||
|
started = false
|
||||||
|
|
||||||
|
abbrev.downcase().each_byte do |c|
|
||||||
|
index = lower.index(c, lastIndex + 1)
|
||||||
|
return scores.fill(@@SCORE_NO_MATCH, 0..-1) if index.nil?
|
||||||
|
started = true if index == 0
|
||||||
|
|
||||||
|
if index > 0 and " \t/._-".include?(string[index - 1])
|
||||||
|
scores[index - 1] = @@SCORE_MATCH
|
||||||
|
scores.fill(@@SCORE_BUFFER, (lastIndex + 1)...(index - 1))
|
||||||
|
elsif string[index] >= "A"[0] and string[index] <= "Z"[0]
|
||||||
|
scores.fill(@@SCORE_BUFFER, (lastIndex + 1)...index)
|
||||||
|
else
|
||||||
|
scores.fill(@@SCORE_NO_MATCH, (lastIndex + 1)...index)
|
||||||
|
end
|
||||||
|
|
||||||
|
scores[index] = @@SCORE_MATCH
|
||||||
|
lastIndex = index
|
||||||
|
end
|
||||||
|
|
||||||
|
trailing_score = started ? @@SCORE_TRAILING_BUT_STARTED : @@SCORE_TRAILING
|
||||||
|
scores.fill(trailing_score, lastIndex + 1)
|
||||||
|
return scores
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_score(entry, abbrev)
|
||||||
|
old_score = LiquidMetal.score(entry, abbrev)
|
||||||
|
new_score = Mercury.score(entry, abbrev)
|
||||||
|
|
||||||
|
puts "%-25s %-10s %.4f %.4f" % [entry, abbrev, old_score, new_score]
|
||||||
|
end
|
||||||
|
|
||||||
|
def test(high_entry, low_entry, abbrev)
|
||||||
|
high = Mercury.score(high_entry, abbrev)
|
||||||
|
low = Mercury.score(low_entry, abbrev)
|
||||||
|
puts "%-8s %-10s %-25s %.4f %-25s %.4f" % [high > low ? "PASS" : "FAIL", abbrev,
|
||||||
|
high_entry, high, low_entry, low]
|
||||||
|
end
|
||||||
|
|
||||||
|
print_score("phone numbers.txt", "phnb")
|
||||||
|
print_score("phone numbers.txt", "pht")
|
||||||
|
print_score("poohead.txt", "pht")
|
||||||
|
print_score("poohead.txt", "poo")
|
||||||
|
print_score("poohead.txt", "pood")
|
||||||
|
print_score("foo.lua", "lua")
|
||||||
|
print_score("lua-expression.h", "lua")
|
||||||
|
print_score("query-dispatcher.h", "qudisp")
|
||||||
|
print_score("query-dispatcher.cc", "qudisp")
|
||||||
|
print_score("query-dispatcher.h", "qudisph")
|
||||||
|
print_score("query-dispatcher.cc", "qudisph")
|
||||||
|
print_score("query-dispatczer.h", "qudisph")
|
||||||
|
print_score("query-dispatczer.h", "qudisp")
|
||||||
|
print_score("aaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaa")
|
||||||
|
print_score("query-executor.h", "exec")
|
||||||
|
print_score("query-executor.cc", "exec")
|
||||||
|
print_score("tablet-executor-node.h", "ten")
|
||||||
|
print_score("materialize-executor-node.h", "ten")
|
||||||
|
|
||||||
|
test("protocoltype.go", "serverstatus.proto", "proto")
|
||||||
|
test("protocoltype.go", "test.proto", "proto")
|
||||||
|
test("protocoltype.go", "test.proto", "pr")
|
||||||
|
test("protocoltype.go", "test.proto", "p")
|
||||||
|
test("protocoltype.go", "test.proto", "poto")
|
||||||
|
test("query-dispatcher.h", "query-dispatcher.cc", "qudisph")
|
||||||
|
test("query-plan.h", "query-dispatcher.h", "qup")
|
||||||
|
test("phone numbers.txt", "poohead.txt", "pht")
|
||||||
|
test("tokyo.txt", "abcde.txt", "t")
|
||||||
|
test("tablet-executor-node.h", "materialize-executor-node.h", "ten")
|
||||||
|
test("tent.txt", "tablet-executor-node.h", "ten")
|
||||||
|
test("tent.txt", "tablet-executor-node.h", "te")
|
||||||
|
test("ad", "m-a", "a")
|
||||||
|
test("a", "b", "A")
|
||||||
112
.vim/bundle/lusty/src/vim.rb
Normal file
112
.vim/bundle/lusty/src/vim.rb
Normal file
|
|
@ -0,0 +1,112 @@
|
||||||
|
# Copyright (C) 2007-2010 Stephen Bach
|
||||||
|
#
|
||||||
|
# Permission is hereby granted to use and distribute this code, with or without
|
||||||
|
# modifications, provided that this copyright notice is copied with it. Like
|
||||||
|
# anything else that's free, this file is provided *as is* and comes with no
|
||||||
|
# warranty of any kind, either expressed or implied. In no event will the
|
||||||
|
# copyright holder be liable for any damages resulting from the use of this
|
||||||
|
# software.
|
||||||
|
|
||||||
|
module VIM
|
||||||
|
|
||||||
|
unless const_defined? "MOST_POSITIVE_INTEGER"
|
||||||
|
MOST_POSITIVE_INTEGER = 2**(32 - 1) - 2 # Vim ints are signed 32-bit.
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.zero?(var)
|
||||||
|
# In Vim 7.2 and older, VIM::evaluate returns Strings for boolean
|
||||||
|
# expressions; in later versions, Fixnums.
|
||||||
|
case var
|
||||||
|
when String
|
||||||
|
var == "0"
|
||||||
|
when Fixnum
|
||||||
|
var == 0
|
||||||
|
else
|
||||||
|
LustyM::assert(false, "unexpected type: #{var.class}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.nonzero?(var)
|
||||||
|
not zero?(var)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.evaluate_bool(var)
|
||||||
|
nonzero? evaluate(var)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.exists?(s)
|
||||||
|
nonzero? evaluate("exists('#{s}')")
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.has_syntax?
|
||||||
|
nonzero? evaluate('has("syntax")')
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.columns
|
||||||
|
evaluate("&columns").to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.lines
|
||||||
|
evaluate("&lines").to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.getcwd
|
||||||
|
evaluate("getcwd()")
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.bufname(i)
|
||||||
|
if evaluate_bool("empty(bufname(#{i}))")
|
||||||
|
"<Unknown #{i}>"
|
||||||
|
else
|
||||||
|
evaluate("bufname(#{i})")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.single_quote_escape(s)
|
||||||
|
# Everything in a Vim single-quoted string is literal, except single
|
||||||
|
# quotes. Single quotes are escaped by doubling them.
|
||||||
|
s.gsub("'", "''")
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.filename_escape(s)
|
||||||
|
# Escape slashes, open square braces, spaces, sharps, and double quotes.
|
||||||
|
s.gsub(/\\/, '\\\\\\').gsub(/[\[ #"]/, '\\\\\0')
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.regex_escape(s)
|
||||||
|
s.gsub(/[\]\[.~"^$\\*]/,'\\\\\0')
|
||||||
|
end
|
||||||
|
|
||||||
|
class Buffer
|
||||||
|
def modified?
|
||||||
|
VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&modified')")
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.obj_for_bufnr(n)
|
||||||
|
# There's gotta be a better way to do this...
|
||||||
|
(0..VIM::Buffer.count-1).each do |i|
|
||||||
|
obj = VIM::Buffer[i]
|
||||||
|
return obj if obj.number == n
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Print with colours
|
||||||
|
def self.pretty_msg(*rest)
|
||||||
|
return if rest.length == 0
|
||||||
|
return if rest.length % 2 != 0
|
||||||
|
|
||||||
|
command "redraw" # see :help echo-redraw
|
||||||
|
i = 0
|
||||||
|
while i < rest.length do
|
||||||
|
command "echohl #{rest[i]}"
|
||||||
|
command "echon '#{rest[i+1]}'"
|
||||||
|
i += 2
|
||||||
|
end
|
||||||
|
|
||||||
|
command 'echohl None'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
25
.vim/bundle/lusty/tests/buffer-explorer-view/expect
Normal file
25
.vim/bundle/lusty/tests/buffer-explorer-view/expect
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
spawn $env(VIEW) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":LustyBufferExplorer\r"
|
||||||
|
# Launching should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Changing a readonly file" {exit 1}
|
||||||
|
"Error detected" {exit 1}
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
">>"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
25
.vim/bundle/lusty/tests/buffer-explorer/expect
Normal file
25
.vim/bundle/lusty/tests/buffer-explorer/expect
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":LustyBufferExplorer\r"
|
||||||
|
# Launching should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
">>"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
25
.vim/bundle/lusty/tests/buffer-grep-explorer/expect
Normal file
25
.vim/bundle/lusty/tests/buffer-grep-explorer/expect
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":LustyBufferGrep\r"
|
||||||
|
# Launching should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
">>"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
1
.vim/bundle/lusty/tests/buffer-modified/bar
Normal file
1
.vim/bundle/lusty/tests/buffer-modified/bar
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
bar***
|
||||||
45
.vim/bundle/lusty/tests/buffer-modified/expect
Normal file
45
.vim/bundle/lusty/tests/buffer-modified/expect
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":e foo\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"foo###" # Success
|
||||||
|
}
|
||||||
|
|
||||||
|
send ":e bar\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"bar***" # Success
|
||||||
|
}
|
||||||
|
|
||||||
|
send "otypingblah"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"typingblah" # Success
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
|
||||||
|
send ":LustyBufferExplorer\r"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"\[+]" # Success
|
||||||
|
}
|
||||||
|
|
||||||
|
send \033
|
||||||
|
|
||||||
|
send ":qa!\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
1
.vim/bundle/lusty/tests/buffer-modified/foo
Normal file
1
.vim/bundle/lusty/tests/buffer-modified/foo
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
foo###
|
||||||
25
.vim/bundle/lusty/tests/file-as-dir/expect
Normal file
25
.vim/bundle/lusty/tests/file-as-dir/expect
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":LustyFilesystemExplorer\r"
|
||||||
|
expect ">>"
|
||||||
|
send "random-file/"
|
||||||
|
# Should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"NO MATCHES" # Success
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
0
.vim/bundle/lusty/tests/file-as-dir/random-file
Normal file
0
.vim/bundle/lusty/tests/file-as-dir/random-file
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
spawn $env(VIEW) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":LustyFilesystemExplorerFromHere\r"
|
||||||
|
# Launching should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Changing a readonly file" {exit 1}
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
">>"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
25
.vim/bundle/lusty/tests/filesystem-explorer-from-here/expect
Normal file
25
.vim/bundle/lusty/tests/filesystem-explorer-from-here/expect
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":LustyFilesystemExplorerFromHere\r"
|
||||||
|
# Launching should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
">>"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
26
.vim/bundle/lusty/tests/filesystem-explorer-view/expect
Normal file
26
.vim/bundle/lusty/tests/filesystem-explorer-view/expect
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
spawn $env(VIEW) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":LustyFilesystemExplorer\r"
|
||||||
|
# Launching should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Changing a readonly file" {exit 1}
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
">>"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
25
.vim/bundle/lusty/tests/filesystem-explorer/expect
Normal file
25
.vim/bundle/lusty/tests/filesystem-explorer/expect
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":LustyFilesystemExplorer\r"
|
||||||
|
# Launching should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
">>"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
35
.vim/bundle/lusty/tests/juggler-letters/expect
Normal file
35
.vim/bundle/lusty/tests/juggler-letters/expect
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":e file-name-abc\r"
|
||||||
|
send ":e file-name-def\r"
|
||||||
|
send ":LustyJuggler\r"
|
||||||
|
# Launching should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"file-name-abc"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Choose and open second entry
|
||||||
|
send "ss"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"inside abc"
|
||||||
|
}
|
||||||
|
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
1
.vim/bundle/lusty/tests/juggler-letters/file-name-abc
Normal file
1
.vim/bundle/lusty/tests/juggler-letters/file-name-abc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
inside abc
|
||||||
1
.vim/bundle/lusty/tests/juggler-letters/file-name-def
Normal file
1
.vim/bundle/lusty/tests/juggler-letters/file-name-def
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
inside def
|
||||||
85
.vim/bundle/lusty/tests/juggler-more-than-10/expect
Normal file
85
.vim/bundle/lusty/tests/juggler-more-than-10/expect
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Open >10 files
|
||||||
|
send ":e file-name-abc\r"
|
||||||
|
send ":e file-name-def\r"
|
||||||
|
send ":e file-name-ghi\r"
|
||||||
|
send ":e file-name-jkl\r"
|
||||||
|
send ":e file-name-mno\r"
|
||||||
|
send ":e file-name-pqr\r"
|
||||||
|
send ":e file-name-stu\r"
|
||||||
|
send ":e file-name-vwx\r"
|
||||||
|
send ":e file-name-yza\r"
|
||||||
|
send ":e file-name-bcd\r"
|
||||||
|
send ":e file-name-efg\r"
|
||||||
|
send ":e file-name-hij\r"
|
||||||
|
|
||||||
|
send ":LustyJuggler\r"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"file-name-hij"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Choose and open last entry
|
||||||
|
send ";;"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"\"file-name-ghi\""
|
||||||
|
}
|
||||||
|
|
||||||
|
send ":LustyJuggler\r"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"file-name-hij"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Choose and open last entry
|
||||||
|
send ";;"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"\"file-name-jkl\""
|
||||||
|
}
|
||||||
|
|
||||||
|
send ":LustyJuggler\r"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"file-name-hij"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Choose and open sixth entry
|
||||||
|
send "hh"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"\"file-name-yza\""
|
||||||
|
}
|
||||||
|
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
inside abc
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
inside bcd
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
inside def
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
inside efg
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
inside ghi
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
inside hij
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
inside jkl
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
inside mno
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
inside pqr
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
inside stu
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
inside vwx
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
inside yza
|
||||||
23
.vim/bundle/lusty/tests/juggler-no-other-buffers/expect
Normal file
23
.vim/bundle/lusty/tests/juggler-no-other-buffers/expect
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":LustyJuggler\r"
|
||||||
|
# Launching should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"No other buffers"
|
||||||
|
}
|
||||||
|
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
35
.vim/bundle/lusty/tests/juggler-numbers/expect
Normal file
35
.vim/bundle/lusty/tests/juggler-numbers/expect
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":e file-name-abc\r"
|
||||||
|
send ":e file-name-def\r"
|
||||||
|
send ":LustyJuggler\r"
|
||||||
|
# Launching should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"file-name-abc"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Choose and open second entry
|
||||||
|
send "22"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"inside abc"
|
||||||
|
}
|
||||||
|
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
1
.vim/bundle/lusty/tests/juggler-numbers/file-name-abc
Normal file
1
.vim/bundle/lusty/tests/juggler-numbers/file-name-abc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
inside abc
|
||||||
1
.vim/bundle/lusty/tests/juggler-numbers/file-name-def
Normal file
1
.vim/bundle/lusty/tests/juggler-numbers/file-name-def
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
inside def
|
||||||
35
.vim/bundle/lusty/tests/juggler-out-of-bounds/expect
Normal file
35
.vim/bundle/lusty/tests/juggler-out-of-bounds/expect
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":e file-name-abc\r"
|
||||||
|
send ":e file-name-def\r"
|
||||||
|
send ":LustyJuggler\r"
|
||||||
|
# Launching should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"file-name-abc"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Choose and open 10th entry -- should be second entry.
|
||||||
|
send ";;"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"inside abc"
|
||||||
|
}
|
||||||
|
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
inside abc
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
inside def
|
||||||
0
.vim/bundle/lusty/tests/longest-common-prefix/abc
Normal file
0
.vim/bundle/lusty/tests/longest-common-prefix/abc
Normal file
1
.vim/bundle/lusty/tests/longest-common-prefix/dir/abc
Normal file
1
.vim/bundle/lusty/tests/longest-common-prefix/dir/abc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
switched
|
||||||
1
.vim/bundle/lusty/tests/longest-common-prefix/dir/def
Normal file
1
.vim/bundle/lusty/tests/longest-common-prefix/dir/def
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
content
|
||||||
69
.vim/bundle/lusty/tests/longest-common-prefix/expect
Normal file
69
.vim/bundle/lusty/tests/longest-common-prefix/expect
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":e abc\r"
|
||||||
|
send ":e dir/abc\r"
|
||||||
|
send ":e dir/def\r"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"content" # Success
|
||||||
|
}
|
||||||
|
|
||||||
|
send ":LustyBufferExplorer\r"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
">>"
|
||||||
|
}
|
||||||
|
|
||||||
|
send "dir/def\r"
|
||||||
|
sleep 1
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"NO MATCHES" # Success
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
|
||||||
|
send ":LustyBufferExplorer\r"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
">>"
|
||||||
|
}
|
||||||
|
|
||||||
|
send "dir/abc\r"
|
||||||
|
sleep 1
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
"NO MATCHES" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"switched" # Success
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
|
||||||
|
send ":qa!\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
37
.vim/bundle/lusty/tests/open-all/expect
Normal file
37
.vim/bundle/lusty/tests/open-all/expect
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
|
||||||
|
send ":LustyFilesystemExplorer\r"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
">>" # Success
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
send "file"
|
||||||
|
# Ctrl-A
|
||||||
|
send \001
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"opened" # Success
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
send ":qa!\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
1
.vim/bundle/lusty/tests/open-all/file1
Normal file
1
.vim/bundle/lusty/tests/open-all/file1
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
opened
|
||||||
1
.vim/bundle/lusty/tests/open-all/file2
Normal file
1
.vim/bundle/lusty/tests/open-all/file2
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
opened
|
||||||
1
.vim/bundle/lusty/tests/open-all/file3
Normal file
1
.vim/bundle/lusty/tests/open-all/file3
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
opened
|
||||||
0
.vim/bundle/lusty/tests/recurse-no-selection/abc
Normal file
0
.vim/bundle/lusty/tests/recurse-no-selection/abc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
opened!
|
||||||
44
.vim/bundle/lusty/tests/recurse-no-selection/expect
Normal file
44
.vim/bundle/lusty/tests/recurse-no-selection/expect
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":LustyFilesystemExplorer\r"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
">>"
|
||||||
|
}
|
||||||
|
# Ctrl-N (for next file -- select dir)
|
||||||
|
send \016
|
||||||
|
# ENTER -- recurse into dir
|
||||||
|
send \015
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"file-in-dir"
|
||||||
|
}
|
||||||
|
# Enter -- should select
|
||||||
|
send \015
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
"Error" {exit 1}
|
||||||
|
"Warning" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"opened!"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":LustyFilesystemExplorer\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
">>"
|
||||||
|
}
|
||||||
|
# Ctrl-U
|
||||||
|
send \025
|
||||||
|
send "/"
|
||||||
|
# Should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"/"
|
||||||
|
}
|
||||||
|
send "12hlx"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"12hlx"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
36
.vim/bundle/lusty/tests/root-navigation/expect
Normal file
36
.vim/bundle/lusty/tests/root-navigation/expect
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":LustyFilesystemExplorer\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
">>"
|
||||||
|
}
|
||||||
|
# Ctrl-U
|
||||||
|
send \025
|
||||||
|
send "/"
|
||||||
|
# Should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"/"
|
||||||
|
}
|
||||||
|
send "home"
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"home"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
55
.vim/bundle/lusty/tests/run-tests.bash
Executable file
55
.vim/bundle/lusty/tests/run-tests.bash
Executable file
|
|
@ -0,0 +1,55 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
-h|--help)
|
||||||
|
echo '[VIM=path/to/vim] ./run-tests.bash [test-dir]'
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
?*)
|
||||||
|
if [ -d "$1" ]; then
|
||||||
|
test_dirs="$1"
|
||||||
|
else
|
||||||
|
echo "Error: $1 unknown"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ ! "$VIM" ]; then
|
||||||
|
export VIM=`which vim`
|
||||||
|
fi
|
||||||
|
|
||||||
|
export VIEW=${VIM%/*}/view
|
||||||
|
|
||||||
|
export DISPLAY=
|
||||||
|
|
||||||
|
vim_version=$($VIM --version | head -n1)
|
||||||
|
ruby_version=$($VIM --version | grep -- '-lruby' | \
|
||||||
|
sed 's/.*-lruby\([^ ]*\).*/\1/')
|
||||||
|
|
||||||
|
echo "Testing against:"
|
||||||
|
echo " $vim_version"
|
||||||
|
echo " Ruby: $ruby_version"
|
||||||
|
|
||||||
|
failures=
|
||||||
|
|
||||||
|
if [ ! "$test_dirs" ]; then
|
||||||
|
test_dirs=*/
|
||||||
|
fi
|
||||||
|
|
||||||
|
for dir in $test_dirs; do
|
||||||
|
cd $dir
|
||||||
|
if ! expect -f expect; then
|
||||||
|
echo "fail: $dir"
|
||||||
|
failures="$failures $dir"
|
||||||
|
fi
|
||||||
|
cd ..
|
||||||
|
done >/dev/null
|
||||||
|
|
||||||
|
if [ "$failures" ]; then
|
||||||
|
echo
|
||||||
|
echo "Failing tests: $failures" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo Success
|
||||||
|
|
||||||
55
.vim/bundle/lusty/tests/single-quote/expect
Normal file
55
.vim/bundle/lusty/tests/single-quote/expect
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
spawn $env(VIM) -N --noplugin -u ../vimrc
|
||||||
|
set timeout 3
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
"VIM - Vi IMproved"
|
||||||
|
}
|
||||||
|
send ":LustyFilesystemExplorer\r"
|
||||||
|
expect ">>"
|
||||||
|
send "'"
|
||||||
|
# Should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"foo'" # Success
|
||||||
|
}
|
||||||
|
|
||||||
|
# ESC
|
||||||
|
send \033
|
||||||
|
|
||||||
|
send ":LustyFilesystemExplorer\r"
|
||||||
|
expect ">>"
|
||||||
|
send "foo'\r"
|
||||||
|
# Should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Error detected" {exit 1}
|
||||||
|
"E116" {exit 1}
|
||||||
|
"E15" {exit 1}
|
||||||
|
"E32" {exit 1}
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"opened!" # Success -- contents of file
|
||||||
|
}
|
||||||
|
|
||||||
|
send ":LustyBufferExplorer\r"
|
||||||
|
expect ">>"
|
||||||
|
send "'\r"
|
||||||
|
# Should not have caused a backtrace and "Press ENTER ..." message
|
||||||
|
expect {
|
||||||
|
"Error detected" {exit 1}
|
||||||
|
"E116" {exit 1}
|
||||||
|
"E15" {exit 1}
|
||||||
|
"E32" {exit 1}
|
||||||
|
"Press ENTER" {exit 1}
|
||||||
|
timeout {exit 1}
|
||||||
|
"'" # Success
|
||||||
|
}
|
||||||
|
|
||||||
|
send \033
|
||||||
|
send ":q\r"
|
||||||
|
expect {
|
||||||
|
timeout {exit 1}
|
||||||
|
eof
|
||||||
|
}
|
||||||
|
exit 0
|
||||||
|
|
||||||
1
.vim/bundle/lusty/tests/single-quote/foo'
Normal file
1
.vim/bundle/lusty/tests/single-quote/foo'
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
opened!
|
||||||
17
.vim/bundle/lusty/tests/vimrc
Normal file
17
.vim/bundle/lusty/tests/vimrc
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
set nocompatible
|
||||||
|
set hidden
|
||||||
|
set nobackup
|
||||||
|
set noswapfile
|
||||||
|
|
||||||
|
source ../../plugin/lusty-explorer.vim
|
||||||
|
source ../../plugin/lusty-juggler.vim
|
||||||
|
|
||||||
|
" Not too useful because a bug in Vim causes an E15 error
|
||||||
|
" whenever a Ruby plugin is called. :-(
|
||||||
|
function CheckForError()
|
||||||
|
if empty(v:errmsg)
|
||||||
|
exec writefile([v:errmsg], "success")
|
||||||
|
else
|
||||||
|
exec writefile([v:errmsg], "fail")
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
@ -15,6 +15,10 @@ augroup END
|
||||||
augroup lilypond
|
augroup lilypond
|
||||||
au! BufNewFile,BufRead *.ly,*.ily setf lilypond
|
au! BufNewFile,BufRead *.ly,*.ily setf lilypond
|
||||||
augroup END
|
augroup END
|
||||||
|
augroup java
|
||||||
|
autocmd BufRead *.java set efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#
|
||||||
|
autocmd BufRead *.java set makeprg=ant\ -find\ build.xml
|
||||||
|
augroup END
|
||||||
|
|
||||||
au BufNewFile,BufRead motd.public,/tmp/motd.public.r.* setf motd
|
au BufNewFile,BufRead motd.public,/tmp/motd.public.r.* setf motd
|
||||||
|
|
||||||
|
|
|
||||||
309
.vim/plugin/buftabs.vim
Normal file
309
.vim/plugin/buftabs.vim
Normal file
|
|
@ -0,0 +1,309 @@
|
||||||
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
" buftabs (C) 2006 Ico Doornekamp
|
||||||
|
"
|
||||||
|
" This program is free software; you can redistribute it and/or modify it
|
||||||
|
" under the terms of the GNU General Public License as published by the Free
|
||||||
|
" Software Foundation; either version 2 of the License, or (at your option)
|
||||||
|
" any later version.
|
||||||
|
"
|
||||||
|
" This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
" more details.
|
||||||
|
"
|
||||||
|
" Introduction
|
||||||
|
" ------------
|
||||||
|
"
|
||||||
|
" This is a simple script that shows a tabs-like list of buffers in the bottom
|
||||||
|
" of the window. The biggest advantage of this script over various others is
|
||||||
|
" that it does not take any lines away from your terminal, leaving more space
|
||||||
|
" for the document you're editing. The tabs are only visible when you need
|
||||||
|
" them - when you are switchin between buffers.
|
||||||
|
"
|
||||||
|
" Usage
|
||||||
|
" -----
|
||||||
|
"
|
||||||
|
" This script draws buffer tabs on vim startup, when a new buffer is created
|
||||||
|
" and when switching between buffers.
|
||||||
|
"
|
||||||
|
" It might be handy to create a few maps for easy switching of buffers in your
|
||||||
|
" .vimrc file. For example, using F1 and F2 keys:
|
||||||
|
"
|
||||||
|
" noremap <f1> :bprev<CR>
|
||||||
|
" noremap <f2> :bnext<CR>
|
||||||
|
"
|
||||||
|
" or using control-left and control-right keys:
|
||||||
|
"
|
||||||
|
" :noremap <C-left> :bprev<CR>
|
||||||
|
" :noremap <C-right> :bnext<CR>
|
||||||
|
"
|
||||||
|
"
|
||||||
|
" The following extra configuration variables are availabe:
|
||||||
|
"
|
||||||
|
" * g:buftabs_only_basename
|
||||||
|
"
|
||||||
|
" Define this variable to make buftabs only print the filename of each buffer,
|
||||||
|
" omitting the preceding directory name. Add to your .vimrc:
|
||||||
|
"
|
||||||
|
" :let g:buftabs_only_basename=1
|
||||||
|
"
|
||||||
|
"
|
||||||
|
" * g:buftabs_in_statusline
|
||||||
|
"
|
||||||
|
" Define this variable to make the plugin show the buftabs in the statusline
|
||||||
|
" instead of the command line. It is a good idea to configure vim to show
|
||||||
|
" the statusline as well when only one window is open. Add to your .vimrc:
|
||||||
|
"
|
||||||
|
" set laststatus=2
|
||||||
|
" :let g:buftabs_in_statusline=1
|
||||||
|
"
|
||||||
|
"
|
||||||
|
" * g:buftabs_active_highlight_group
|
||||||
|
" * g:buftabs_inactive_highlight_group
|
||||||
|
"
|
||||||
|
" The name of a highlight group (:help highligh-groups) which is used to
|
||||||
|
" show the name of the current active buffer and of all other inactive
|
||||||
|
" buffers. If these variables are not defined, no highlighting is used.
|
||||||
|
" (Highlighting is only functional when g:buftabs_in_statusline is enabled)
|
||||||
|
"
|
||||||
|
" :let g:buftabs_active_highlight_group="Visual"
|
||||||
|
"
|
||||||
|
"
|
||||||
|
" * g:buftabs_marker_start [
|
||||||
|
" * g:buftabs_marker_end ]
|
||||||
|
" * g:buftabs_separator -
|
||||||
|
"
|
||||||
|
" These strings are drawn around each tab as separators.
|
||||||
|
"
|
||||||
|
" :let g:buftabs_separator = "."
|
||||||
|
" :let g:buftabs_marker_start = "("
|
||||||
|
" :let g:buftabs_marker_end = ")"
|
||||||
|
"
|
||||||
|
"
|
||||||
|
" Changelog
|
||||||
|
" ---------
|
||||||
|
"
|
||||||
|
" 0.1 2006-09-22 Initial version
|
||||||
|
"
|
||||||
|
" 0.2 2006-09-22 Better handling when the list of buffers is longer then the
|
||||||
|
" window width.
|
||||||
|
"
|
||||||
|
" 0.3 2006-09-27 Some cleanups, set 'hidden' mode by default
|
||||||
|
"
|
||||||
|
" 0.4 2007-02-26 Don't draw buftabs until VimEnter event to avoid clutter at
|
||||||
|
" startup in some circumstances
|
||||||
|
"
|
||||||
|
" 0.5 2007-02-26 Added option for showing only filenames without directories
|
||||||
|
" in tabs
|
||||||
|
"
|
||||||
|
" 0.6 2007-03-04 'only_basename' changed to a global variable. Removed
|
||||||
|
" functions and add event handlers instead. 'hidden' mode
|
||||||
|
" broke some things, so is disabled now. Fixed documentation
|
||||||
|
"
|
||||||
|
" 0.7 2007-03-07 Added configuration option to show tabs in statusline
|
||||||
|
" instead of cmdline
|
||||||
|
"
|
||||||
|
" 0.8 2007-04-02 Update buftabs when leaving insertmode
|
||||||
|
"
|
||||||
|
" 0.9 2007-08-22 Now compatible with older Vim versions < 7.0
|
||||||
|
"
|
||||||
|
" 0.10 2008-01-26 Added GPL license
|
||||||
|
"
|
||||||
|
" 0.11 2008-02-29 Added optional syntax highlighting to active buffer name
|
||||||
|
"
|
||||||
|
" 0.12 2009-03-18 Fixed support for split windows
|
||||||
|
"
|
||||||
|
" 0.13 2009-05-07 Store and reuse right-aligned part of original statusline
|
||||||
|
"
|
||||||
|
" 0.14 2010-01-28 Fixed bug that caused buftabs in command line being
|
||||||
|
" overwritten when 'hidden' mode is enabled.
|
||||||
|
"
|
||||||
|
" 0.15 2010-02-16 Fixed window width handling bug which caused strange
|
||||||
|
" behaviour in combination with the bufferlist plugin.
|
||||||
|
" Fixed wrong buffer display when deleting last window.
|
||||||
|
" Added extra options for tabs style and highlighting.
|
||||||
|
"
|
||||||
|
" 0.16 2010-02-28 Fixed bug causing errors when using buftabs in vim
|
||||||
|
" diff mode.
|
||||||
|
"
|
||||||
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
|
||||||
|
let w:buftabs_enabled = 0
|
||||||
|
let w:original_statusline = matchstr(&statusline, "%=.*")
|
||||||
|
|
||||||
|
"
|
||||||
|
" Don't bother when in diff mode
|
||||||
|
"
|
||||||
|
|
||||||
|
if &diff
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
"
|
||||||
|
" Called on VimEnter event
|
||||||
|
"
|
||||||
|
|
||||||
|
function! Buftabs_enable()
|
||||||
|
let w:buftabs_enabled = 1
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
"
|
||||||
|
" Persistent echo to avoid overwriting of status line when 'hidden' is enabled
|
||||||
|
"
|
||||||
|
|
||||||
|
function! Pecho(msg)
|
||||||
|
let s:hold_ut=&ut|let &ut=1
|
||||||
|
let s:Pecho=a:msg
|
||||||
|
aug Pecho
|
||||||
|
au CursorHold * ec s:Pecho
|
||||||
|
\|let &ut=s:hold_ut
|
||||||
|
\|aug Pecho|exe 'au!'|aug END|aug! Pecho
|
||||||
|
aug END
|
||||||
|
endf
|
||||||
|
|
||||||
|
|
||||||
|
"
|
||||||
|
" Draw the buftabs
|
||||||
|
"
|
||||||
|
|
||||||
|
function! Buftabs_show(deleted_buf)
|
||||||
|
|
||||||
|
let l:i = 1
|
||||||
|
let l:list = ''
|
||||||
|
let l:start = 0
|
||||||
|
let l:end = 0
|
||||||
|
if ! exists("w:from")
|
||||||
|
let w:from = 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ! exists("w:buftabs_enabled")
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Walk the list of buffers
|
||||||
|
|
||||||
|
while(l:i <= bufnr('$'))
|
||||||
|
|
||||||
|
" Only show buffers in the list, and omit help screens
|
||||||
|
|
||||||
|
if buflisted(l:i) && getbufvar(l:i, "&modifiable") && a:deleted_buf != l:i
|
||||||
|
|
||||||
|
" Get the name of the current buffer, and escape characters that might
|
||||||
|
" mess up the statusline
|
||||||
|
|
||||||
|
if exists("g:buftabs_only_basename")
|
||||||
|
let l:name = fnamemodify(bufname(l:i), ":t")
|
||||||
|
else
|
||||||
|
let l:name = bufname(l:i)
|
||||||
|
endif
|
||||||
|
let l:name = substitute(l:name, "%", "%%", "g")
|
||||||
|
|
||||||
|
" Append the current buffer number and name to the list. If the buffer
|
||||||
|
" is the active buffer, enclose it in some magick characters which will
|
||||||
|
" be replaced by markers later. If it is modified, it is appended with
|
||||||
|
" an exclaimation mark
|
||||||
|
|
||||||
|
if winbufnr(winnr()) == l:i
|
||||||
|
let l:start = strlen(l:list)
|
||||||
|
let l:list = l:list . "\x01"
|
||||||
|
else
|
||||||
|
let l:list = l:list . ' '
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:buftabs_separator = "-"
|
||||||
|
if exists("g:buftabs_separator")
|
||||||
|
let l:buftabs_separator = g:buftabs_separator
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:list = l:list . l:i . l:buftabs_separator
|
||||||
|
let l:list = l:list . l:name
|
||||||
|
|
||||||
|
if getbufvar(l:i, "&modified") == 1
|
||||||
|
let l:list = l:list . "!"
|
||||||
|
endif
|
||||||
|
|
||||||
|
if winbufnr(winnr()) == l:i
|
||||||
|
let l:list = l:list . "\x02"
|
||||||
|
let l:end = strlen(l:list)
|
||||||
|
else
|
||||||
|
let l:list = l:list . ' '
|
||||||
|
endif
|
||||||
|
end
|
||||||
|
|
||||||
|
let l:i = l:i + 1
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
" If the resulting list is too long to fit on the screen, chop
|
||||||
|
" out the appropriate part
|
||||||
|
|
||||||
|
let l:width = winwidth(0) - 12
|
||||||
|
|
||||||
|
if(l:start < w:from)
|
||||||
|
let w:from = l:start - 1
|
||||||
|
endif
|
||||||
|
if l:end > w:from + l:width
|
||||||
|
let w:from = l:end - l:width
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:list = strpart(l:list, w:from, l:width)
|
||||||
|
|
||||||
|
" Replace the magic characters by visible markers for highlighting the
|
||||||
|
" current buffer. The markers can be simple characters like square brackets,
|
||||||
|
" but can also be special codes with highlight groups
|
||||||
|
|
||||||
|
let l:buftabs_marker_start = "["
|
||||||
|
if exists("g:buftabs_marker_start")
|
||||||
|
let l:buftabs_marker_start = g:buftabs_marker_start
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:buftabs_marker_end = "]"
|
||||||
|
if exists("g:buftabs_marker_end")
|
||||||
|
let l:buftabs_marker_end = g:buftabs_marker_end
|
||||||
|
endif
|
||||||
|
|
||||||
|
if exists("g:buftabs_active_highlight_group")
|
||||||
|
if exists("g:buftabs_in_statusline")
|
||||||
|
let l:buftabs_marker_start = "%#" . g:buftabs_active_highlight_group . "#" . l:buftabs_marker_start
|
||||||
|
let l:buftabs_marker_end = l:buftabs_marker_end . "%##"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if exists("g:buftabs_inactive_highlight_group")
|
||||||
|
if exists("g:buftabs_in_statusline")
|
||||||
|
let l:list = '%#' . g:buftabs_inactive_highlight_group . '#' . l:list
|
||||||
|
let l:list .= '%##'
|
||||||
|
let l:buftabs_marker_end = l:buftabs_marker_end . '%#' . g:buftabs_inactive_highlight_group . '#'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
let l:list = substitute(l:list, "\x01", l:buftabs_marker_start, 'g')
|
||||||
|
let l:list = substitute(l:list, "\x02", l:buftabs_marker_end, 'g')
|
||||||
|
|
||||||
|
" Show the list. The buftabs_in_statusline variable determines of the list
|
||||||
|
" is displayed in the command line (volatile) or in the statusline
|
||||||
|
" (persistent)
|
||||||
|
|
||||||
|
if exists("g:buftabs_in_statusline")
|
||||||
|
let &l:statusline = l:list . w:original_statusline
|
||||||
|
else
|
||||||
|
redraw
|
||||||
|
call Pecho(l:list)
|
||||||
|
end
|
||||||
|
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
" Hook to events to show buftabs at startup, when creating and when switching
|
||||||
|
" buffers
|
||||||
|
|
||||||
|
autocmd VimEnter * call Buftabs_enable()
|
||||||
|
autocmd VimEnter,BufNew,BufEnter,BufWritePost * call Buftabs_show(-1)
|
||||||
|
autocmd BufDelete * call Buftabs_show(expand('<abuf>'))
|
||||||
|
if version >= 700
|
||||||
|
autocmd InsertLeave,VimResized * call Buftabs_show(-1)
|
||||||
|
end
|
||||||
|
|
||||||
|
" vi: ts=2 sw=2
|
||||||
|
|
||||||
27
.vimrc
27
.vimrc
|
|
@ -12,6 +12,7 @@ set ts=8
|
||||||
set softtabstop=2
|
set softtabstop=2
|
||||||
set shiftwidth=2
|
set shiftwidth=2
|
||||||
set expandtab
|
set expandtab
|
||||||
|
let mapleader = ","
|
||||||
|
|
||||||
filetype off
|
filetype off
|
||||||
call pathogen#runtime_append_all_bundles()
|
call pathogen#runtime_append_all_bundles()
|
||||||
|
|
@ -55,6 +56,8 @@ autocmd FileType python set tags+=$HOME/.vim/tags/python.ctags
|
||||||
let python_highlight_all = 1
|
let python_highlight_all = 1
|
||||||
let g:Tb_MaxSize=0
|
let g:Tb_MaxSize=0
|
||||||
let g:Tb_MapCTabSwitchBufs = 1
|
let g:Tb_MapCTabSwitchBufs = 1
|
||||||
|
let g:buftabs_only_basename = 1
|
||||||
|
"let g:buftabs_in_statusline=1
|
||||||
|
|
||||||
|
|
||||||
"MiniBufExplore Options
|
"MiniBufExplore Options
|
||||||
|
|
@ -185,6 +188,28 @@ function! Find(name)
|
||||||
endfunction
|
endfunction
|
||||||
command! -nargs=1 Find :call Find("<args>")
|
command! -nargs=1 Find :call Find("<args>")
|
||||||
|
|
||||||
|
" toggles the quickfix window.
|
||||||
|
command -bang -nargs=? QFix call QFixToggle(<bang>0)
|
||||||
|
function! QFixToggle(forced)
|
||||||
|
if exists("g:qfix_win") && a:forced == 0
|
||||||
|
cclose
|
||||||
|
else
|
||||||
|
execute "copen " . 15
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" used to track the quickfix window
|
||||||
|
augroup QFixToggle
|
||||||
|
autocmd!
|
||||||
|
autocmd BufWinEnter quickfix let g:qfix_win = bufnr("$")
|
||||||
|
autocmd BufWinEnter quickfix exec "nnoremap <silent> <buffer> q :QFix<CR>"
|
||||||
|
autocmd BufWinLeave * if exists("g:qfix_win") && expand("<abuf>") == g:qfix_win | unlet! g:qfix_win | endif
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
nnoremap <Leader>qf :QFix<CR>
|
||||||
|
nnoremap <Leader>aw :AckWord<CR>
|
||||||
|
nnoremap <Leader>ac :Ack
|
||||||
|
|
||||||
" Googley things....
|
" Googley things....
|
||||||
|
|
||||||
function! HighlightTooLongLines()
|
function! HighlightTooLongLines()
|
||||||
|
|
@ -224,3 +249,5 @@ endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ Darwin)
|
||||||
MACPORTS_PATH=/opt/local/bin:/opt/local/sbin:/opt/local/usr/bin:/opt/local/usr/local/bin; export MACPORTS_PATH
|
MACPORTS_PATH=/opt/local/bin:/opt/local/sbin:/opt/local/usr/bin:/opt/local/usr/local/bin; export MACPORTS_PATH
|
||||||
PATH=$HOME/bin:$MACPORTS_PATH:$PATH; export PATH
|
PATH=$HOME/bin:$MACPORTS_PATH:$PATH; export PATH
|
||||||
export DISPLAY=:0.0
|
export DISPLAY=:0.0
|
||||||
set completion-ignore-case on
|
# set completion-ignore-case on
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue