Disable yankring, update lusty, add italics
git-svn-id: http://photonzero.com/dotfiles/trunk@93 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
parent
505e3205d2
commit
b5f5d230a3
19 changed files with 2795 additions and 2608 deletions
|
|
@ -1,2 +1,5 @@
|
||||||
Don't throw an error when looking up special non-file buffers.
|
- New and improved fuzzy matching algorithm: Mercury. (Matt Tolton)
|
||||||
New and improved fuzzy matching algorithm.
|
- Buffer Explorer: don't show unlisted buffers. (Thanks to Johannes Holzfuß)
|
||||||
|
- Align multi-byte CJK characters correctly in filenames. (Thanks to lilydjwg)
|
||||||
|
- Truncate prompt if longer than window width to avoid "press any key" message. (Thanks to Martin Wache)
|
||||||
|
- Save/restore window config better. (Thanks to robquant)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
- don't error if ENTER is pressed before selection
|
- Don't show unlisted buffers. (Thanks to Johannes Holzfuß)
|
||||||
- avoid a "Press ENTER to continue" message. (Thanks to Bartosz Leper)
|
- New Alt-Tab mode to emulate window manager switching. See g:LustyJugglerAltTabMode in documentation. (Thanks to Martin Wache)
|
||||||
- don't error when the QuickFix buffer is open. (Thanks to Marco Barberis)
|
- Save and restore keymappings. (Thanks to Vincent Driessen)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
LustyJuggler is a high speed buffer juggler. Having to consciously think about which buffer you need to switch to sucks, so use this instead.
|
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:
|
Someone made a screen cast showing it in action (jump to 6:20):
|
||||||
|
|
||||||
|
http://lococast.net/archives/185
|
||||||
|
|
||||||
|
Some older stuff:
|
||||||
http://viewglob.sourceforge.net/lusty-juggler-animated.gif
|
http://viewglob.sourceforge.net/lusty-juggler-animated.gif
|
||||||
|
|
||||||
Annotated snapshot progression:
|
|
||||||
|
|
||||||
http://viewglob.sourceforge.net/lusty-juggler-annotated.png
|
http://viewglob.sourceforge.net/lusty-juggler-annotated.png
|
||||||
|
|
||||||
Launch the juggler with this key combo:
|
Launch the juggler with this key combo:
|
||||||
|
|
@ -35,8 +35,11 @@ If you changed your mind, cancel the juggler with any of "q", "<ESC>", "<C-c", "
|
||||||
|
|
||||||
If you like LustyJuggler, you may also like LustyExplorer: vimscript #1890
|
If you like LustyJuggler, you may also like LustyExplorer: vimscript #1890
|
||||||
|
|
||||||
|
Development repository: http://github.com/sjbach/lusty
|
||||||
|
|
||||||
install details
|
install details
|
||||||
Copy the script into your $HOME/.vim/plugin directory so that it will be sourced on startup.
|
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.
|
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.
|
||||||
|
|
||||||
|
Also: because of a bug in Vim's maparg() call, this plugin can interact poorly with plugins that remap common normal mode keys such as "d" (for dd, dw, etc.) and "<ENTER>". These include YankRing and SuperTab.
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@
|
||||||
" Rajendra Badapanda, cho45, Simo Salminen, Sami Samhuri,
|
" Rajendra Badapanda, cho45, Simo Salminen, Sami Samhuri,
|
||||||
" Matt Tolton, Björn Winckler, sowill, David Brown
|
" Matt Tolton, Björn Winckler, sowill, David Brown
|
||||||
" Brett DiFrischia, Ali Asad Lotia, Kenneth Love, Ben Boeckel,
|
" Brett DiFrischia, Ali Asad Lotia, Kenneth Love, Ben Boeckel,
|
||||||
" robquant
|
" robquant, lilydjwg, Martin Wache, Johannes Holzfuß
|
||||||
"
|
"
|
||||||
" Release Date: July 21, 2010
|
" Release Date: December 16, 2010
|
||||||
" Version: 3.1.1
|
" Version: 4.0
|
||||||
"
|
"
|
||||||
" Usage:
|
" Usage:
|
||||||
" <Leader>lf - Opens the filesystem explorer.
|
" <Leader>lf - Opens the filesystem explorer.
|
||||||
|
|
@ -59,6 +59,8 @@
|
||||||
"
|
"
|
||||||
" <C-n> select [n]ext match
|
" <C-n> select [n]ext match
|
||||||
" <C-p> select [p]revious match
|
" <C-p> select [p]revious match
|
||||||
|
" <C-f> select [f]orward one column
|
||||||
|
" <C-b> select [b]ack one column
|
||||||
"
|
"
|
||||||
" <C-u> clear prompt
|
" <C-u> clear prompt
|
||||||
"
|
"
|
||||||
|
|
@ -242,8 +244,8 @@ let g:loaded_lustyexplorer = "yep"
|
||||||
|
|
||||||
" Commands.
|
" Commands.
|
||||||
command LustyBufferExplorer :call <SID>LustyBufferExplorerStart()
|
command LustyBufferExplorer :call <SID>LustyBufferExplorerStart()
|
||||||
command LustyFilesystemExplorer :call <SID>LustyFilesystemExplorerStart()
|
command -nargs=? LustyFilesystemExplorer :call <SID>LustyFilesystemExplorerStart("<args>")
|
||||||
command LustyFilesystemExplorerFromHere :call <SID>LustyFilesystemExplorerFromHereStart()
|
command LustyFilesystemExplorerFromHere :call <SID>LustyFilesystemExplorerStart(expand("%:p:h"))
|
||||||
command LustyBufferGrep :call <SID>LustyBufferGrepStart()
|
command LustyBufferGrep :call <SID>LustyBufferGrepStart()
|
||||||
|
|
||||||
" Deprecated command names.
|
" Deprecated command names.
|
||||||
|
|
@ -269,12 +271,8 @@ nmap <silent> <Leader>lb :LustyBufferExplorer<CR>
|
||||||
nmap <silent> <Leader>lg :LustyBufferGrep<CR>
|
nmap <silent> <Leader>lg :LustyBufferGrep<CR>
|
||||||
|
|
||||||
" Vim-to-ruby function calls.
|
" Vim-to-ruby function calls.
|
||||||
function! s:LustyFilesystemExplorerStart()
|
function! s:LustyFilesystemExplorerStart(path)
|
||||||
ruby LustyE::profile() { $lusty_filesystem_explorer.run_from_wd }
|
exec "ruby LustyE::profile() { $lusty_filesystem_explorer.run_from_path('".a:path."') }"
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:LustyFilesystemExplorerFromHereStart()
|
|
||||||
ruby LustyE::profile() { $lusty_filesystem_explorer.run_from_here }
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:LustyBufferExplorerStart()
|
function! s:LustyBufferExplorerStart()
|
||||||
|
|
@ -410,6 +408,10 @@ module VIM
|
||||||
VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&modified')")
|
VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&modified')")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def listed?
|
||||||
|
VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&buflisted')")
|
||||||
|
end
|
||||||
|
|
||||||
def self.obj_for_bufnr(n)
|
def self.obj_for_bufnr(n)
|
||||||
# There's gotta be a better way to do this...
|
# There's gotta be a better way to do this...
|
||||||
(0..VIM::Buffer.count-1).each do |i|
|
(0..VIM::Buffer.count-1).each do |i|
|
||||||
|
|
@ -438,6 +440,22 @@ module VIM
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Hack for wide CJK characters.
|
||||||
|
if VIM::exists?("*strwidth")
|
||||||
|
module VIM
|
||||||
|
def self.strwidth(s)
|
||||||
|
# strwidth() is defined in Vim 7.3.
|
||||||
|
evaluate("strwidth('#{single_quote_escape(s)}')").to_i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
module VIM
|
||||||
|
def self.strwidth(s)
|
||||||
|
s.length
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# Utility functions.
|
# Utility functions.
|
||||||
module LustyE
|
module LustyE
|
||||||
|
|
@ -659,12 +677,13 @@ class Entry
|
||||||
@label = label
|
@label = label
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# NOTE: very similar to BufferStack::shorten_paths()
|
||||||
def self.compute_buffer_entries()
|
def self.compute_buffer_entries()
|
||||||
buffer_entries = []
|
buffer_entries = []
|
||||||
|
|
||||||
$le_buffer_stack.numbers.each do |n|
|
$le_buffer_stack.numbers.each do |n|
|
||||||
o = VIM::Buffer.obj_for_bufnr(n)
|
o = VIM::Buffer.obj_for_bufnr(n)
|
||||||
next if o.nil?
|
next if (o.nil? or not o.listed?)
|
||||||
buffer_entries << self.new(o, n)
|
buffer_entries << self.new(o, n)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -804,6 +823,26 @@ class Explorer
|
||||||
@selected_index = \
|
@selected_index = \
|
||||||
(@selected_index - 1) % @current_sorted_matches.size
|
(@selected_index - 1) % @current_sorted_matches.size
|
||||||
refresh_mode = :no_recompute
|
refresh_mode = :no_recompute
|
||||||
|
when 6 # C-f (select right)
|
||||||
|
columns = (@current_sorted_matches.size.to_f / @row_count.to_f).ceil
|
||||||
|
cur_column = @selected_index / @row_count
|
||||||
|
cur_row = @selected_index % @row_count
|
||||||
|
new_column = (cur_column + 1) % columns
|
||||||
|
if (new_column + 1) * (cur_row + 1) > @current_sorted_matches.size
|
||||||
|
new_column = 0
|
||||||
|
end
|
||||||
|
@selected_index = new_column * @row_count + cur_row
|
||||||
|
refresh_mode = :no_recompute
|
||||||
|
when 2 # C-b (select left)
|
||||||
|
columns = (@current_sorted_matches.size.to_f / @row_count.to_f).ceil
|
||||||
|
cur_column = @selected_index / @row_count
|
||||||
|
cur_row = @selected_index % @row_count
|
||||||
|
new_column = (cur_column - 1) % columns
|
||||||
|
if (new_column + 1) * (cur_row + 1) > @current_sorted_matches.size
|
||||||
|
new_column = columns - 2
|
||||||
|
end
|
||||||
|
@selected_index = new_column * @row_count + cur_row
|
||||||
|
refresh_mode = :no_recompute
|
||||||
when 15 # C-o choose in new horizontal split
|
when 15 # C-o choose in new horizontal split
|
||||||
choose(:new_split)
|
choose(:new_split)
|
||||||
when 20 # C-t choose in new tab
|
when 20 # C-t choose in new tab
|
||||||
|
|
@ -846,8 +885,8 @@ class Explorer
|
||||||
|
|
||||||
on_refresh()
|
on_refresh()
|
||||||
highlight_selected_index() if VIM::has_syntax?
|
highlight_selected_index() if VIM::has_syntax?
|
||||||
@display.print @current_sorted_matches.map { |x| x.label }
|
@row_count = @display.print @current_sorted_matches.map { |x| x.label }
|
||||||
@prompt.print
|
@prompt.print Display.max_width
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_explorer_window
|
def create_explorer_window
|
||||||
|
|
@ -1032,21 +1071,12 @@ class FilesystemExplorer < Explorer
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_from_here
|
def run_from_path(path)
|
||||||
return if @running
|
return if @running
|
||||||
start_path = if $curbuf.name.nil?
|
if path.empty?
|
||||||
VIM::getcwd()
|
path = VIM::getcwd()
|
||||||
else
|
|
||||||
VIM::evaluate("expand('%:p:h')")
|
|
||||||
end
|
end
|
||||||
|
@prompt.set!(path + File::SEPARATOR)
|
||||||
@prompt.set!(start_path + File::SEPARATOR)
|
|
||||||
run()
|
|
||||||
end
|
|
||||||
|
|
||||||
def run_from_wd
|
|
||||||
return if @running
|
|
||||||
@prompt.set!(VIM::getcwd() + File::SEPARATOR)
|
|
||||||
run()
|
run()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -1469,9 +1499,16 @@ class Prompt
|
||||||
@input = ""
|
@input = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def print
|
def print(max_width = 0)
|
||||||
|
text = @input
|
||||||
|
# may need some extra characters for "..." and spacing
|
||||||
|
max_width -= 5
|
||||||
|
if max_width > 0 && text.length > max_width
|
||||||
|
text = "..." + text[(text.length - max_width + 3 ) .. -1]
|
||||||
|
end
|
||||||
|
|
||||||
VIM::pretty_msg("Comment", @@PROMPT,
|
VIM::pretty_msg("Comment", @@PROMPT,
|
||||||
"None", VIM::single_quote_escape(@input),
|
"None", VIM::single_quote_escape(text),
|
||||||
"Underlined", " ")
|
"Underlined", " ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -1782,6 +1819,10 @@ class Display
|
||||||
VIM::command 'highlight link LustyFileWithSwap WarningMsg'
|
VIM::command 'highlight link LustyFileWithSwap WarningMsg'
|
||||||
VIM::command 'highlight link LustyNoEntries ErrorMsg'
|
VIM::command 'highlight link LustyNoEntries ErrorMsg'
|
||||||
VIM::command 'highlight link LustyTruncated Visual'
|
VIM::command 'highlight link LustyTruncated Visual'
|
||||||
|
|
||||||
|
if VIM::exists? '*clearmatches'
|
||||||
|
VIM::evaluate 'clearmatches()'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -1820,6 +1861,8 @@ class Display
|
||||||
VIM::command "#{map} <C-w> :call <SID>#{prefix}KeyPressed(23)<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-n> :call <SID>#{prefix}KeyPressed(14)<CR>"
|
||||||
VIM::command "#{map} <C-p> :call <SID>#{prefix}KeyPressed(16)<CR>"
|
VIM::command "#{map} <C-p> :call <SID>#{prefix}KeyPressed(16)<CR>"
|
||||||
|
VIM::command "#{map} <C-f> :call <SID>#{prefix}KeyPressed(6)<CR>"
|
||||||
|
VIM::command "#{map} <C-b> :call <SID>#{prefix}KeyPressed(2)<CR>"
|
||||||
VIM::command "#{map} <C-o> :call <SID>#{prefix}KeyPressed(15)<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-t> :call <SID>#{prefix}KeyPressed(20)<CR>"
|
||||||
VIM::command "#{map} <C-v> :call <SID>#{prefix}KeyPressed(22)<CR>"
|
VIM::command "#{map} <C-v> :call <SID>#{prefix}KeyPressed(22)<CR>"
|
||||||
|
|
@ -1851,7 +1894,7 @@ class Display
|
||||||
|
|
||||||
if col_index < col_count - 1
|
if col_index < col_count - 1
|
||||||
# Add spacer to the width of the column
|
# Add spacer to the width of the column
|
||||||
rows[i] << (" " * (column_width - string.length))
|
rows[i] << (" " * (column_width - VIM::strwidth(string)))
|
||||||
rows[i] << @@COLUMN_SEPARATOR
|
rows[i] << @@COLUMN_SEPARATOR
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1861,6 +1904,7 @@ class Display
|
||||||
end
|
end
|
||||||
|
|
||||||
print_rows(rows, truncated)
|
print_rows(rows, truncated)
|
||||||
|
row_count
|
||||||
end
|
end
|
||||||
|
|
||||||
def close
|
def close
|
||||||
|
|
@ -1928,7 +1972,8 @@ class Display
|
||||||
column_widths = []
|
column_widths = []
|
||||||
total_width = 0
|
total_width = 0
|
||||||
strings.each_slice(optimal_row_count) do |column|
|
strings.each_slice(optimal_row_count) do |column|
|
||||||
column_width = column.max { |a, b| a.length <=> b.length }.length
|
longest = column.max { |a, b| VIM::strwidth(a) <=> VIM::strwidth(b) }
|
||||||
|
column_width = VIM::strwidth(longest)
|
||||||
total_width += column_width
|
total_width += column_width
|
||||||
|
|
||||||
break if total_width > max_width
|
break if total_width > max_width
|
||||||
|
|
@ -2241,8 +2286,11 @@ class BufferStack
|
||||||
|
|
||||||
private
|
private
|
||||||
def cull!
|
def cull!
|
||||||
# Remove empty buffers.
|
# Remove empty and unlisted buffers.
|
||||||
@stack.delete_if { |x| not VIM::evaluate_bool("bufexists(#{x})") }
|
@stack.delete_if { |x|
|
||||||
|
not (VIM::evaluate_bool("bufexists(#{x})") and
|
||||||
|
VIM::evaluate_bool("getbufvar(#{x}, '&buflisted')"))
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
# NOTE: very similar to Entry::compute_buffer_entries()
|
# NOTE: very similar to Entry::compute_buffer_entries()
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,11 @@
|
||||||
" Name Of File: lusty-juggler.vim
|
" Name Of File: lusty-juggler.vim
|
||||||
" Description: Dynamic Buffer Switcher Vim Plugin
|
" Description: Dynamic Buffer Switcher Vim Plugin
|
||||||
" Maintainer: Stephen Bach <this-file@sjbach.com>
|
" Maintainer: Stephen Bach <this-file@sjbach.com>
|
||||||
" Contributors: Juan Frias, Bartosz Leper, Marco Barberis
|
" Contributors: Juan Frias, Bartosz Leper, Marco Barberis, Vincent Driessen,
|
||||||
|
" Martin Wache, Johannes Holzfuß, Adam Rutkowski
|
||||||
"
|
"
|
||||||
" Release Date: June 2, 2010
|
" Release Date: December 16, 2010
|
||||||
" Version: 1.1.4
|
" Version: 1.2
|
||||||
"
|
"
|
||||||
" Usage:
|
" Usage:
|
||||||
" <Leader>lj - Opens the buffer juggler.
|
" <Leader>lj - Opens the buffer juggler.
|
||||||
|
|
@ -52,6 +53,22 @@
|
||||||
" To cancel the juggler, press any of "q", "<ESC>", "<C-c",
|
" To cancel the juggler, press any of "q", "<ESC>", "<C-c",
|
||||||
" "<BS>", "<Del>", or "<C-h>".
|
" "<BS>", "<Del>", or "<C-h>".
|
||||||
"
|
"
|
||||||
|
" LustyJuggler can act very much like <A-Tab> window switching.
|
||||||
|
" To enable this mode, add the following line to your .vimrc:
|
||||||
|
"
|
||||||
|
" let g:LustyJugglerAltTabMode = 1
|
||||||
|
"
|
||||||
|
" Then, given the following mapping:
|
||||||
|
"
|
||||||
|
" noremap <silent> <A-s> :LustyJuggler<CR>
|
||||||
|
"
|
||||||
|
" Pressing "<A-s>" will launch the LustyJuggler with the
|
||||||
|
" previous buffer highlighted. Typing "<A-s>" again will cycle
|
||||||
|
" to the next buffer (in most-recently used order), and
|
||||||
|
" "<ENTER>" will open the highlighted buffer. For example, the
|
||||||
|
" sequence "<A-s><Enter>" will open the previous buffer, and
|
||||||
|
" "<A-s><A-s><Enter>" will open the buffer used just before the
|
||||||
|
" previous buffer, and so on.
|
||||||
"
|
"
|
||||||
" Bonus: This plugin also includes the following command, which will
|
" Bonus: This plugin also includes the following command, which will
|
||||||
" immediately switch to your previously used buffer:
|
" immediately switch to your previously used buffer:
|
||||||
|
|
@ -312,6 +329,10 @@ module VIM
|
||||||
VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&modified')")
|
VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&modified')")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def listed?
|
||||||
|
VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&buflisted')")
|
||||||
|
end
|
||||||
|
|
||||||
def self.obj_for_bufnr(n)
|
def self.obj_for_bufnr(n)
|
||||||
# There's gotta be a better way to do this...
|
# There's gotta be a better way to do this...
|
||||||
(0..VIM::Buffer.count-1).each do |i|
|
(0..VIM::Buffer.count-1).each do |i|
|
||||||
|
|
@ -340,6 +361,22 @@ module VIM
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Hack for wide CJK characters.
|
||||||
|
if VIM::exists?("*strwidth")
|
||||||
|
module VIM
|
||||||
|
def self.strwidth(s)
|
||||||
|
# strwidth() is defined in Vim 7.3.
|
||||||
|
evaluate("strwidth('#{single_quote_escape(s)}')").to_i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
module VIM
|
||||||
|
def self.strwidth(s)
|
||||||
|
s.length
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# Utility functions.
|
# Utility functions.
|
||||||
module LustyJ
|
module LustyJ
|
||||||
|
|
@ -487,13 +524,19 @@ class LustyJuggler
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
return if @running
|
|
||||||
|
|
||||||
if $lj_buffer_stack.length <= 1
|
if $lj_buffer_stack.length <= 1
|
||||||
VIM::pretty_msg("PreProc", "No other buffers")
|
VIM::pretty_msg("PreProc", "No other buffers")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# If already running, highlight next buffer
|
||||||
|
if @running and LustyJuggler::alt_tab_mode_active?
|
||||||
|
@last_pressed = (@last_pressed % $lj_buffer_stack.length) + 1;
|
||||||
|
print_buffer_list(@last_pressed)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
return if @running
|
||||||
@running = true
|
@running = true
|
||||||
|
|
||||||
# Need to zero the timeout length or pressing 'g' will hang.
|
# Need to zero the timeout length or pressing 'g' will hang.
|
||||||
|
|
@ -517,6 +560,7 @@ class LustyJuggler
|
||||||
map_key("<Tab>", ":call <SID>LustyJugglerKeyPressed('TAB')<CR>")
|
map_key("<Tab>", ":call <SID>LustyJugglerKeyPressed('TAB')<CR>")
|
||||||
|
|
||||||
# Cancel keys.
|
# Cancel keys.
|
||||||
|
map_key("i", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
map_key("q", ":call <SID>LustyJugglerCancel()<CR>")
|
map_key("q", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
map_key("<Esc>", ":call <SID>LustyJugglerCancel()<CR>")
|
map_key("<Esc>", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
map_key("<C-c>", ":call <SID>LustyJugglerCancel()<CR>")
|
map_key("<C-c>", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
|
|
@ -524,7 +568,8 @@ class LustyJuggler
|
||||||
map_key("<Del>", ":call <SID>LustyJugglerCancel()<CR>")
|
map_key("<Del>", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
map_key("<C-h>", ":call <SID>LustyJugglerCancel()<CR>")
|
map_key("<C-h>", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
|
|
||||||
print_buffer_list()
|
@last_pressed = 2 if LustyJuggler::alt_tab_mode_active?
|
||||||
|
print_buffer_list(@last_pressed)
|
||||||
end
|
end
|
||||||
|
|
||||||
def key_pressed()
|
def key_pressed()
|
||||||
|
|
@ -532,12 +577,12 @@ class LustyJuggler
|
||||||
|
|
||||||
if @last_pressed.nil? and c == 'ENTER'
|
if @last_pressed.nil? and c == 'ENTER'
|
||||||
cleanup()
|
cleanup()
|
||||||
elsif @last_pressed and (c == @last_pressed or c == 'ENTER')
|
elsif @last_pressed and (@@KEYS[c] == @last_pressed or c == 'ENTER')
|
||||||
choose(@@KEYS[@last_pressed])
|
choose(@last_pressed)
|
||||||
cleanup()
|
cleanup()
|
||||||
else
|
else
|
||||||
print_buffer_list(@@KEYS[c])
|
@last_pressed = @@KEYS[c]
|
||||||
@last_pressed = c
|
print_buffer_list(@last_pressed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -556,6 +601,7 @@ class LustyJuggler
|
||||||
unmap_key("<CR>")
|
unmap_key("<CR>")
|
||||||
unmap_key("<Tab>")
|
unmap_key("<Tab>")
|
||||||
|
|
||||||
|
unmap_key("i")
|
||||||
unmap_key("q")
|
unmap_key("q")
|
||||||
unmap_key("<Esc>")
|
unmap_key("<Esc>")
|
||||||
unmap_key("<C-c>")
|
unmap_key("<C-c>")
|
||||||
|
|
@ -569,6 +615,11 @@ class LustyJuggler
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
def self.alt_tab_mode_active?
|
||||||
|
return (VIM::exists?("g:LustyJugglerAltTabMode") and
|
||||||
|
VIM::evaluate("g:LustyJugglerAltTabMode").to_i != 0)
|
||||||
|
end
|
||||||
|
|
||||||
def print_buffer_list(highlighted_entry = nil)
|
def print_buffer_list(highlighted_entry = nil)
|
||||||
# If the user pressed a key higher than the number of open buffers,
|
# If the user pressed a key higher than the number of open buffers,
|
||||||
# highlight the highest (see also BufferStack.num_at_pos()).
|
# highlight the highest (see also BufferStack.num_at_pos()).
|
||||||
|
|
@ -993,8 +1044,11 @@ class BufferStack
|
||||||
|
|
||||||
private
|
private
|
||||||
def cull!
|
def cull!
|
||||||
# Remove empty buffers.
|
# Remove empty and unlisted buffers.
|
||||||
@stack.delete_if { |x| not VIM::evaluate_bool("bufexists(#{x})") }
|
@stack.delete_if { |x|
|
||||||
|
not (VIM::evaluate_bool("bufexists(#{x})") and
|
||||||
|
VIM::evaluate_bool("getbufvar(#{x}, '&buflisted')"))
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
# NOTE: very similar to Entry::compute_buffer_entries()
|
# NOTE: very similar to Entry::compute_buffer_entries()
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@
|
||||||
" Rajendra Badapanda, cho45, Simo Salminen, Sami Samhuri,
|
" Rajendra Badapanda, cho45, Simo Salminen, Sami Samhuri,
|
||||||
" Matt Tolton, Björn Winckler, sowill, David Brown
|
" Matt Tolton, Björn Winckler, sowill, David Brown
|
||||||
" Brett DiFrischia, Ali Asad Lotia, Kenneth Love, Ben Boeckel,
|
" Brett DiFrischia, Ali Asad Lotia, Kenneth Love, Ben Boeckel,
|
||||||
" robquant
|
" robquant, lilydjwg, Martin Wache, Johannes Holzfuß
|
||||||
"
|
"
|
||||||
" Release Date: July 21, 2010
|
" Release Date: December 16, 2010
|
||||||
" Version: 3.1.1
|
" Version: 4.0
|
||||||
"
|
"
|
||||||
" Usage:
|
" Usage:
|
||||||
" <Leader>lf - Opens the filesystem explorer.
|
" <Leader>lf - Opens the filesystem explorer.
|
||||||
|
|
@ -59,6 +59,8 @@
|
||||||
"
|
"
|
||||||
" <C-n> select [n]ext match
|
" <C-n> select [n]ext match
|
||||||
" <C-p> select [p]revious match
|
" <C-p> select [p]revious match
|
||||||
|
" <C-f> select [f]orward one column
|
||||||
|
" <C-b> select [b]ack one column
|
||||||
"
|
"
|
||||||
" <C-u> clear prompt
|
" <C-u> clear prompt
|
||||||
"
|
"
|
||||||
|
|
@ -242,8 +244,8 @@ let g:loaded_lustyexplorer = "yep"
|
||||||
|
|
||||||
" Commands.
|
" Commands.
|
||||||
command LustyBufferExplorer :call <SID>LustyBufferExplorerStart()
|
command LustyBufferExplorer :call <SID>LustyBufferExplorerStart()
|
||||||
command LustyFilesystemExplorer :call <SID>LustyFilesystemExplorerStart()
|
command -nargs=? LustyFilesystemExplorer :call <SID>LustyFilesystemExplorerStart("<args>")
|
||||||
command LustyFilesystemExplorerFromHere :call <SID>LustyFilesystemExplorerFromHereStart()
|
command LustyFilesystemExplorerFromHere :call <SID>LustyFilesystemExplorerStart(expand("%:p:h"))
|
||||||
command LustyBufferGrep :call <SID>LustyBufferGrepStart()
|
command LustyBufferGrep :call <SID>LustyBufferGrepStart()
|
||||||
|
|
||||||
" Deprecated command names.
|
" Deprecated command names.
|
||||||
|
|
@ -269,12 +271,8 @@ nmap <silent> <Leader>lb :LustyBufferExplorer<CR>
|
||||||
nmap <silent> <Leader>lg :LustyBufferGrep<CR>
|
nmap <silent> <Leader>lg :LustyBufferGrep<CR>
|
||||||
|
|
||||||
" Vim-to-ruby function calls.
|
" Vim-to-ruby function calls.
|
||||||
function! s:LustyFilesystemExplorerStart()
|
function! s:LustyFilesystemExplorerStart(path)
|
||||||
ruby LustyE::profile() { $lusty_filesystem_explorer.run_from_wd }
|
exec "ruby LustyE::profile() { $lusty_filesystem_explorer.run_from_path('".a:path."') }"
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:LustyFilesystemExplorerFromHereStart()
|
|
||||||
ruby LustyE::profile() { $lusty_filesystem_explorer.run_from_here }
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:LustyBufferExplorerStart()
|
function! s:LustyBufferExplorerStart()
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,11 @@
|
||||||
" Name Of File: lusty-juggler.vim
|
" Name Of File: lusty-juggler.vim
|
||||||
" Description: Dynamic Buffer Switcher Vim Plugin
|
" Description: Dynamic Buffer Switcher Vim Plugin
|
||||||
" Maintainer: Stephen Bach <this-file@sjbach.com>
|
" Maintainer: Stephen Bach <this-file@sjbach.com>
|
||||||
" Contributors: Juan Frias, Bartosz Leper, Marco Barberis
|
" Contributors: Juan Frias, Bartosz Leper, Marco Barberis, Vincent Driessen,
|
||||||
|
" Martin Wache, Johannes Holzfuß, Adam Rutkowski
|
||||||
"
|
"
|
||||||
" Release Date: June 2, 2010
|
" Release Date: December 16, 2010
|
||||||
" Version: 1.1.4
|
" Version: 1.2
|
||||||
"
|
"
|
||||||
" Usage:
|
" Usage:
|
||||||
" <Leader>lj - Opens the buffer juggler.
|
" <Leader>lj - Opens the buffer juggler.
|
||||||
|
|
@ -52,6 +53,22 @@
|
||||||
" To cancel the juggler, press any of "q", "<ESC>", "<C-c",
|
" To cancel the juggler, press any of "q", "<ESC>", "<C-c",
|
||||||
" "<BS>", "<Del>", or "<C-h>".
|
" "<BS>", "<Del>", or "<C-h>".
|
||||||
"
|
"
|
||||||
|
" LustyJuggler can act very much like <A-Tab> window switching.
|
||||||
|
" To enable this mode, add the following line to your .vimrc:
|
||||||
|
"
|
||||||
|
" let g:LustyJugglerAltTabMode = 1
|
||||||
|
"
|
||||||
|
" Then, given the following mapping:
|
||||||
|
"
|
||||||
|
" noremap <silent> <A-s> :LustyJuggler<CR>
|
||||||
|
"
|
||||||
|
" Pressing "<A-s>" will launch the LustyJuggler with the
|
||||||
|
" previous buffer highlighted. Typing "<A-s>" again will cycle
|
||||||
|
" to the next buffer (in most-recently used order), and
|
||||||
|
" "<ENTER>" will open the highlighted buffer. For example, the
|
||||||
|
" sequence "<A-s><Enter>" will open the previous buffer, and
|
||||||
|
" "<A-s><A-s><Enter>" will open the buffer used just before the
|
||||||
|
" previous buffer, and so on.
|
||||||
"
|
"
|
||||||
" Bonus: This plugin also includes the following command, which will
|
" Bonus: This plugin also includes the following command, which will
|
||||||
" immediately switch to your previously used buffer:
|
" immediately switch to your previously used buffer:
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,11 @@ class BufferStack
|
||||||
|
|
||||||
private
|
private
|
||||||
def cull!
|
def cull!
|
||||||
# Remove empty buffers.
|
# Remove empty and unlisted buffers.
|
||||||
@stack.delete_if { |x| not VIM::evaluate_bool("bufexists(#{x})") }
|
@stack.delete_if { |x|
|
||||||
|
not (VIM::evaluate_bool("bufexists(#{x})") and
|
||||||
|
VIM::evaluate_bool("getbufvar(#{x}, '&buflisted')"))
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
# NOTE: very similar to Entry::compute_buffer_entries()
|
# NOTE: very similar to Entry::compute_buffer_entries()
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,10 @@ class Display
|
||||||
VIM::command 'highlight link LustyFileWithSwap WarningMsg'
|
VIM::command 'highlight link LustyFileWithSwap WarningMsg'
|
||||||
VIM::command 'highlight link LustyNoEntries ErrorMsg'
|
VIM::command 'highlight link LustyNoEntries ErrorMsg'
|
||||||
VIM::command 'highlight link LustyTruncated Visual'
|
VIM::command 'highlight link LustyTruncated Visual'
|
||||||
|
|
||||||
|
if VIM::exists? '*clearmatches'
|
||||||
|
VIM::evaluate 'clearmatches()'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -144,6 +148,8 @@ class Display
|
||||||
VIM::command "#{map} <C-w> :call <SID>#{prefix}KeyPressed(23)<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-n> :call <SID>#{prefix}KeyPressed(14)<CR>"
|
||||||
VIM::command "#{map} <C-p> :call <SID>#{prefix}KeyPressed(16)<CR>"
|
VIM::command "#{map} <C-p> :call <SID>#{prefix}KeyPressed(16)<CR>"
|
||||||
|
VIM::command "#{map} <C-f> :call <SID>#{prefix}KeyPressed(6)<CR>"
|
||||||
|
VIM::command "#{map} <C-b> :call <SID>#{prefix}KeyPressed(2)<CR>"
|
||||||
VIM::command "#{map} <C-o> :call <SID>#{prefix}KeyPressed(15)<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-t> :call <SID>#{prefix}KeyPressed(20)<CR>"
|
||||||
VIM::command "#{map} <C-v> :call <SID>#{prefix}KeyPressed(22)<CR>"
|
VIM::command "#{map} <C-v> :call <SID>#{prefix}KeyPressed(22)<CR>"
|
||||||
|
|
@ -175,7 +181,7 @@ class Display
|
||||||
|
|
||||||
if col_index < col_count - 1
|
if col_index < col_count - 1
|
||||||
# Add spacer to the width of the column
|
# Add spacer to the width of the column
|
||||||
rows[i] << (" " * (column_width - string.length))
|
rows[i] << (" " * (column_width - VIM::strwidth(string)))
|
||||||
rows[i] << @@COLUMN_SEPARATOR
|
rows[i] << @@COLUMN_SEPARATOR
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -185,6 +191,7 @@ class Display
|
||||||
end
|
end
|
||||||
|
|
||||||
print_rows(rows, truncated)
|
print_rows(rows, truncated)
|
||||||
|
row_count
|
||||||
end
|
end
|
||||||
|
|
||||||
def close
|
def close
|
||||||
|
|
@ -252,7 +259,8 @@ class Display
|
||||||
column_widths = []
|
column_widths = []
|
||||||
total_width = 0
|
total_width = 0
|
||||||
strings.each_slice(optimal_row_count) do |column|
|
strings.each_slice(optimal_row_count) do |column|
|
||||||
column_width = column.max { |a, b| a.length <=> b.length }.length
|
longest = column.max { |a, b| VIM::strwidth(a) <=> VIM::strwidth(b) }
|
||||||
|
column_width = VIM::strwidth(longest)
|
||||||
total_width += column_width
|
total_width += column_width
|
||||||
|
|
||||||
break if total_width > max_width
|
break if total_width > max_width
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,13 @@ class Entry
|
||||||
@label = label
|
@label = label
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# NOTE: very similar to BufferStack::shorten_paths()
|
||||||
def self.compute_buffer_entries()
|
def self.compute_buffer_entries()
|
||||||
buffer_entries = []
|
buffer_entries = []
|
||||||
|
|
||||||
$le_buffer_stack.numbers.each do |n|
|
$le_buffer_stack.numbers.each do |n|
|
||||||
o = VIM::Buffer.obj_for_bufnr(n)
|
o = VIM::Buffer.obj_for_bufnr(n)
|
||||||
next if o.nil?
|
next if (o.nil? or not o.listed?)
|
||||||
buffer_entries << self.new(o, n)
|
buffer_entries << self.new(o, n)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,26 @@ class Explorer
|
||||||
@selected_index = \
|
@selected_index = \
|
||||||
(@selected_index - 1) % @current_sorted_matches.size
|
(@selected_index - 1) % @current_sorted_matches.size
|
||||||
refresh_mode = :no_recompute
|
refresh_mode = :no_recompute
|
||||||
|
when 6 # C-f (select right)
|
||||||
|
columns = (@current_sorted_matches.size.to_f / @row_count.to_f).ceil
|
||||||
|
cur_column = @selected_index / @row_count
|
||||||
|
cur_row = @selected_index % @row_count
|
||||||
|
new_column = (cur_column + 1) % columns
|
||||||
|
if (new_column + 1) * (cur_row + 1) > @current_sorted_matches.size
|
||||||
|
new_column = 0
|
||||||
|
end
|
||||||
|
@selected_index = new_column * @row_count + cur_row
|
||||||
|
refresh_mode = :no_recompute
|
||||||
|
when 2 # C-b (select left)
|
||||||
|
columns = (@current_sorted_matches.size.to_f / @row_count.to_f).ceil
|
||||||
|
cur_column = @selected_index / @row_count
|
||||||
|
cur_row = @selected_index % @row_count
|
||||||
|
new_column = (cur_column - 1) % columns
|
||||||
|
if (new_column + 1) * (cur_row + 1) > @current_sorted_matches.size
|
||||||
|
new_column = columns - 2
|
||||||
|
end
|
||||||
|
@selected_index = new_column * @row_count + cur_row
|
||||||
|
refresh_mode = :no_recompute
|
||||||
when 15 # C-o choose in new horizontal split
|
when 15 # C-o choose in new horizontal split
|
||||||
choose(:new_split)
|
choose(:new_split)
|
||||||
when 20 # C-t choose in new tab
|
when 20 # C-t choose in new tab
|
||||||
|
|
@ -102,8 +122,8 @@ class Explorer
|
||||||
|
|
||||||
on_refresh()
|
on_refresh()
|
||||||
highlight_selected_index() if VIM::has_syntax?
|
highlight_selected_index() if VIM::has_syntax?
|
||||||
@display.print @current_sorted_matches.map { |x| x.label }
|
@row_count = @display.print @current_sorted_matches.map { |x| x.label }
|
||||||
@prompt.print
|
@prompt.print Display.max_width
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_explorer_window
|
def create_explorer_window
|
||||||
|
|
|
||||||
|
|
@ -25,21 +25,12 @@ class FilesystemExplorer < Explorer
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_from_here
|
def run_from_path(path)
|
||||||
return if @running
|
return if @running
|
||||||
start_path = if $curbuf.name.nil?
|
if path.empty?
|
||||||
VIM::getcwd()
|
path = VIM::getcwd()
|
||||||
else
|
|
||||||
VIM::evaluate("expand('%:p:h')")
|
|
||||||
end
|
end
|
||||||
|
@prompt.set!(path + File::SEPARATOR)
|
||||||
@prompt.set!(start_path + File::SEPARATOR)
|
|
||||||
run()
|
|
||||||
end
|
|
||||||
|
|
||||||
def run_from_wd
|
|
||||||
return if @running
|
|
||||||
@prompt.set!(VIM::getcwd() + File::SEPARATOR)
|
|
||||||
run()
|
run()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,19 @@ class LustyJuggler
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
return if @running
|
|
||||||
|
|
||||||
if $lj_buffer_stack.length <= 1
|
if $lj_buffer_stack.length <= 1
|
||||||
VIM::pretty_msg("PreProc", "No other buffers")
|
VIM::pretty_msg("PreProc", "No other buffers")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# If already running, highlight next buffer
|
||||||
|
if @running and LustyJuggler::alt_tab_mode_active?
|
||||||
|
@last_pressed = (@last_pressed % $lj_buffer_stack.length) + 1;
|
||||||
|
print_buffer_list(@last_pressed)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
return if @running
|
||||||
@running = true
|
@running = true
|
||||||
|
|
||||||
# Need to zero the timeout length or pressing 'g' will hang.
|
# Need to zero the timeout length or pressing 'g' will hang.
|
||||||
|
|
@ -69,6 +75,7 @@ class LustyJuggler
|
||||||
map_key("<Tab>", ":call <SID>LustyJugglerKeyPressed('TAB')<CR>")
|
map_key("<Tab>", ":call <SID>LustyJugglerKeyPressed('TAB')<CR>")
|
||||||
|
|
||||||
# Cancel keys.
|
# Cancel keys.
|
||||||
|
map_key("i", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
map_key("q", ":call <SID>LustyJugglerCancel()<CR>")
|
map_key("q", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
map_key("<Esc>", ":call <SID>LustyJugglerCancel()<CR>")
|
map_key("<Esc>", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
map_key("<C-c>", ":call <SID>LustyJugglerCancel()<CR>")
|
map_key("<C-c>", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
|
|
@ -76,7 +83,8 @@ class LustyJuggler
|
||||||
map_key("<Del>", ":call <SID>LustyJugglerCancel()<CR>")
|
map_key("<Del>", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
map_key("<C-h>", ":call <SID>LustyJugglerCancel()<CR>")
|
map_key("<C-h>", ":call <SID>LustyJugglerCancel()<CR>")
|
||||||
|
|
||||||
print_buffer_list()
|
@last_pressed = 2 if LustyJuggler::alt_tab_mode_active?
|
||||||
|
print_buffer_list(@last_pressed)
|
||||||
end
|
end
|
||||||
|
|
||||||
def key_pressed()
|
def key_pressed()
|
||||||
|
|
@ -84,12 +92,12 @@ class LustyJuggler
|
||||||
|
|
||||||
if @last_pressed.nil? and c == 'ENTER'
|
if @last_pressed.nil? and c == 'ENTER'
|
||||||
cleanup()
|
cleanup()
|
||||||
elsif @last_pressed and (c == @last_pressed or c == 'ENTER')
|
elsif @last_pressed and (@@KEYS[c] == @last_pressed or c == 'ENTER')
|
||||||
choose(@@KEYS[@last_pressed])
|
choose(@last_pressed)
|
||||||
cleanup()
|
cleanup()
|
||||||
else
|
else
|
||||||
print_buffer_list(@@KEYS[c])
|
@last_pressed = @@KEYS[c]
|
||||||
@last_pressed = c
|
print_buffer_list(@last_pressed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -108,6 +116,7 @@ class LustyJuggler
|
||||||
unmap_key("<CR>")
|
unmap_key("<CR>")
|
||||||
unmap_key("<Tab>")
|
unmap_key("<Tab>")
|
||||||
|
|
||||||
|
unmap_key("i")
|
||||||
unmap_key("q")
|
unmap_key("q")
|
||||||
unmap_key("<Esc>")
|
unmap_key("<Esc>")
|
||||||
unmap_key("<C-c>")
|
unmap_key("<C-c>")
|
||||||
|
|
@ -121,6 +130,11 @@ class LustyJuggler
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
def self.alt_tab_mode_active?
|
||||||
|
return (VIM::exists?("g:LustyJugglerAltTabMode") and
|
||||||
|
VIM::evaluate("g:LustyJugglerAltTabMode").to_i != 0)
|
||||||
|
end
|
||||||
|
|
||||||
def print_buffer_list(highlighted_entry = nil)
|
def print_buffer_list(highlighted_entry = nil)
|
||||||
# If the user pressed a key higher than the number of open buffers,
|
# If the user pressed a key higher than the number of open buffers,
|
||||||
# highlight the highest (see also BufferStack.num_at_pos()).
|
# highlight the highest (see also BufferStack.num_at_pos()).
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,16 @@ class Prompt
|
||||||
@input = ""
|
@input = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def print
|
def print(max_width = 0)
|
||||||
|
text = @input
|
||||||
|
# may need some extra characters for "..." and spacing
|
||||||
|
max_width -= 5
|
||||||
|
if max_width > 0 && text.length > max_width
|
||||||
|
text = "..." + text[(text.length - max_width + 3 ) .. -1]
|
||||||
|
end
|
||||||
|
|
||||||
VIM::pretty_msg("Comment", @@PROMPT,
|
VIM::pretty_msg("Comment", @@PROMPT,
|
||||||
"None", VIM::single_quote_escape(@input),
|
"None", VIM::single_quote_escape(text),
|
||||||
"Underlined", " ")
|
"Underlined", " ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,10 @@ module VIM
|
||||||
VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&modified')")
|
VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&modified')")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def listed?
|
||||||
|
VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&buflisted')")
|
||||||
|
end
|
||||||
|
|
||||||
def self.obj_for_bufnr(n)
|
def self.obj_for_bufnr(n)
|
||||||
# There's gotta be a better way to do this...
|
# There's gotta be a better way to do this...
|
||||||
(0..VIM::Buffer.count-1).each do |i|
|
(0..VIM::Buffer.count-1).each do |i|
|
||||||
|
|
@ -110,3 +114,19 @@ module VIM
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Hack for wide CJK characters.
|
||||||
|
if VIM::exists?("*strwidth")
|
||||||
|
module VIM
|
||||||
|
def self.strwidth(s)
|
||||||
|
# strwidth() is defined in Vim 7.3.
|
||||||
|
evaluate("strwidth('#{single_quote_escape(s)}')").to_i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
module VIM
|
||||||
|
def self.strwidth(s)
|
||||||
|
s.length
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ hi Normal ctermfg=253 ctermbg=NONE
|
||||||
" Comment Group
|
" Comment Group
|
||||||
" -------------
|
" -------------
|
||||||
" any comment
|
" any comment
|
||||||
hi Comment guifg=#238e23 gui=none
|
hi Comment guifg=#238e23 gui=italic
|
||||||
hi Comment ctermfg=34 cterm=none
|
hi Comment ctermfg=34 cterm=none
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue