diff --git a/.vim/bundle/lusty/doc/explorer-vim.changes b/.vim/bundle/lusty/doc/explorer-vim.changes index 10244b2..a9d9d00 100644 --- a/.vim/bundle/lusty/doc/explorer-vim.changes +++ b/.vim/bundle/lusty/doc/explorer-vim.changes @@ -1,2 +1,5 @@ -Don't throw an error when looking up special non-file buffers. -New and improved fuzzy matching algorithm. +- New and improved fuzzy matching algorithm: Mercury. (Matt Tolton) +- 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) diff --git a/.vim/bundle/lusty/doc/juggler-vim.changes b/.vim/bundle/lusty/doc/juggler-vim.changes index 99caa01..1b812d6 100644 --- a/.vim/bundle/lusty/doc/juggler-vim.changes +++ b/.vim/bundle/lusty/doc/juggler-vim.changes @@ -1,3 +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) +- Don't show unlisted buffers. (Thanks to Johannes Holzfuß) +- New Alt-Tab mode to emulate window manager switching. See g:LustyJugglerAltTabMode in documentation. (Thanks to Martin Wache) +- Save and restore keymappings. (Thanks to Vincent Driessen) diff --git a/.vim/bundle/lusty/doc/juggler-vim.writeup b/.vim/bundle/lusty/doc/juggler-vim.writeup index 2f3ace1..9256879 100644 --- a/.vim/bundle/lusty/doc/juggler-vim.writeup +++ b/.vim/bundle/lusty/doc/juggler-vim.writeup @@ -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. -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 - -Annotated snapshot progression: - http://viewglob.sourceforge.net/lusty-juggler-annotated.png Launch the juggler with this key combo: @@ -34,9 +34,12 @@ If you want to switch to that buffer, press "f" or "4" again or press "". If you changed your mind, cancel the juggler with any of "q", "", "", "", or "". If you like LustyJuggler, you may also like LustyExplorer: vimscript #1890 - + +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 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 "". These include YankRing and SuperTab. diff --git a/.vim/bundle/lusty/plugin/lusty-explorer.vim b/.vim/bundle/lusty/plugin/lusty-explorer.vim index 794079e..ec83555 100644 --- a/.vim/bundle/lusty/plugin/lusty-explorer.vim +++ b/.vim/bundle/lusty/plugin/lusty-explorer.vim @@ -15,10 +15,10 @@ " 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 +" robquant, lilydjwg, Martin Wache, Johannes Holzfuß " -" Release Date: July 21, 2010 -" Version: 3.1.1 +" Release Date: December 16, 2010 +" Version: 4.0 " " Usage: " lf - Opens the filesystem explorer. @@ -59,6 +59,8 @@ " " select [n]ext match " select [p]revious match +" select [f]orward one column +" select [b]ack one column " " clear prompt " @@ -242,8 +244,8 @@ let g:loaded_lustyexplorer = "yep" " Commands. command LustyBufferExplorer :call LustyBufferExplorerStart() -command LustyFilesystemExplorer :call LustyFilesystemExplorerStart() -command LustyFilesystemExplorerFromHere :call LustyFilesystemExplorerFromHereStart() +command -nargs=? LustyFilesystemExplorer :call LustyFilesystemExplorerStart("") +command LustyFilesystemExplorerFromHere :call LustyFilesystemExplorerStart(expand("%:p:h")) command LustyBufferGrep :call LustyBufferGrepStart() " Deprecated command names. @@ -269,12 +271,8 @@ nmap lb :LustyBufferExplorer nmap lg :LustyBufferGrep " 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 } +function! s:LustyFilesystemExplorerStart(path) + exec "ruby LustyE::profile() { $lusty_filesystem_explorer.run_from_path('".a:path."') }" endfunction function! s:LustyBufferExplorerStart() @@ -410,6 +408,10 @@ module VIM VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&modified')") end + def listed? + VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&buflisted')") + 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| @@ -438,6 +440,22 @@ module VIM 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. module LustyE @@ -659,12 +677,13 @@ class Entry @label = label end + # NOTE: very similar to BufferStack::shorten_paths() 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? + next if (o.nil? or not o.listed?) buffer_entries << self.new(o, n) end @@ -804,6 +823,26 @@ class Explorer @selected_index = \ (@selected_index - 1) % @current_sorted_matches.size 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 choose(:new_split) when 20 # C-t choose in new tab @@ -846,8 +885,8 @@ class Explorer on_refresh() highlight_selected_index() if VIM::has_syntax? - @display.print @current_sorted_matches.map { |x| x.label } - @prompt.print + @row_count = @display.print @current_sorted_matches.map { |x| x.label } + @prompt.print Display.max_width end def create_explorer_window @@ -1032,21 +1071,12 @@ class FilesystemExplorer < Explorer super end - def run_from_here + def run_from_path(path) 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) + if path.empty? + path = VIM::getcwd() + end + @prompt.set!(path + File::SEPARATOR) run() end @@ -1469,9 +1499,16 @@ class Prompt @input = "" 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, - "None", VIM::single_quote_escape(@input), + "None", VIM::single_quote_escape(text), "Underlined", " ") end @@ -1782,6 +1819,10 @@ class Display VIM::command 'highlight link LustyFileWithSwap WarningMsg' VIM::command 'highlight link LustyNoEntries ErrorMsg' VIM::command 'highlight link LustyTruncated Visual' + + if VIM::exists? '*clearmatches' + VIM::evaluate 'clearmatches()' + end end # @@ -1820,6 +1861,8 @@ class Display VIM::command "#{map} :call #{prefix}KeyPressed(23)" VIM::command "#{map} :call #{prefix}KeyPressed(14)" VIM::command "#{map} :call #{prefix}KeyPressed(16)" + VIM::command "#{map} :call #{prefix}KeyPressed(6)" + VIM::command "#{map} :call #{prefix}KeyPressed(2)" VIM::command "#{map} :call #{prefix}KeyPressed(15)" VIM::command "#{map} :call #{prefix}KeyPressed(20)" VIM::command "#{map} :call #{prefix}KeyPressed(22)" @@ -1851,7 +1894,7 @@ class Display if col_index < col_count - 1 # 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 end end @@ -1861,6 +1904,7 @@ class Display end print_rows(rows, truncated) + row_count end def close @@ -1928,7 +1972,8 @@ class Display column_widths = [] total_width = 0 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 break if total_width > max_width @@ -2241,8 +2286,11 @@ class BufferStack private def cull! - # Remove empty buffers. - @stack.delete_if { |x| not VIM::evaluate_bool("bufexists(#{x})") } + # Remove empty and unlisted buffers. + @stack.delete_if { |x| + not (VIM::evaluate_bool("bufexists(#{x})") and + VIM::evaluate_bool("getbufvar(#{x}, '&buflisted')")) + } end # NOTE: very similar to Entry::compute_buffer_entries() diff --git a/.vim/bundle/lusty/plugin/lusty-juggler.vim b/.vim/bundle/lusty/plugin/lusty-juggler.vim index 0bbde8e..907be38 100644 --- a/.vim/bundle/lusty/plugin/lusty-juggler.vim +++ b/.vim/bundle/lusty/plugin/lusty-juggler.vim @@ -10,10 +10,11 @@ " Name Of File: lusty-juggler.vim " Description: Dynamic Buffer Switcher Vim Plugin " Maintainer: Stephen Bach -" 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 -" Version: 1.1.4 +" Release Date: December 16, 2010 +" Version: 1.2 " " Usage: " lj - Opens the buffer juggler. @@ -52,18 +53,34 @@ " To cancel the juggler, press any of "q", "", "", "", or "". " +" LustyJuggler can act very much like window switching. +" To enable this mode, add the following line to your .vimrc: +" +" let g:LustyJugglerAltTabMode = 1 +" +" Then, given the following mapping: +" +" noremap :LustyJuggler +" +" Pressing "" will launch the LustyJuggler with the +" previous buffer highlighted. Typing "" again will cycle +" to the next buffer (in most-recently used order), and +" "" will open the highlighted buffer. For example, the +" sequence "" will open the previous buffer, and +" "" will open the buffer used just before the +" previous buffer, and so on. " " 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: " @@ -138,7 +155,7 @@ if !has("ruby") if !exists("g:LustyExplorerSuppressRubyWarning") || \ g:LustyExplorerSuppressRubyWarning == "0" if !exists("g:LustyJugglerSuppressRubyWarning") || - \ g:LustyJugglerSuppressRubyWarning == "0" + \ g:LustyJugglerSuppressRubyWarning == "0" echohl ErrorMsg echon "Sorry, LustyJuggler requires ruby. " echon "Here are some tips for adding it:\n" @@ -312,6 +329,10 @@ module VIM VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&modified')") end + def listed? + VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&buflisted')") + 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| @@ -340,6 +361,22 @@ module VIM 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. module LustyJ @@ -487,13 +524,19 @@ class LustyJuggler end def run - return if @running - if $lj_buffer_stack.length <= 1 VIM::pretty_msg("PreProc", "No other buffers") return 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 # Need to zero the timeout length or pressing 'g' will hang. @@ -517,6 +560,7 @@ class LustyJuggler map_key("", ":call LustyJugglerKeyPressed('TAB')") # Cancel keys. + map_key("i", ":call LustyJugglerCancel()") map_key("q", ":call LustyJugglerCancel()") map_key("", ":call LustyJugglerCancel()") map_key("", ":call LustyJugglerCancel()") @@ -524,7 +568,8 @@ class LustyJuggler map_key("", ":call LustyJugglerCancel()") map_key("", ":call LustyJugglerCancel()") - print_buffer_list() + @last_pressed = 2 if LustyJuggler::alt_tab_mode_active? + print_buffer_list(@last_pressed) end def key_pressed() @@ -532,12 +577,12 @@ class LustyJuggler if @last_pressed.nil? and c == 'ENTER' cleanup() - elsif @last_pressed and (c == @last_pressed or c == 'ENTER') - choose(@@KEYS[@last_pressed]) + elsif @last_pressed and (@@KEYS[c] == @last_pressed or c == 'ENTER') + choose(@last_pressed) cleanup() else - print_buffer_list(@@KEYS[c]) - @last_pressed = c + @last_pressed = @@KEYS[c] + print_buffer_list(@last_pressed) end end @@ -556,6 +601,7 @@ class LustyJuggler unmap_key("") unmap_key("") + unmap_key("i") unmap_key("q") unmap_key("") unmap_key("") @@ -569,6 +615,11 @@ class LustyJuggler end 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) # If the user pressed a key higher than the number of open buffers, # highlight the highest (see also BufferStack.num_at_pos()). @@ -690,7 +741,7 @@ class BufferItem < BarItem slash_color = @@SLASH_COLOR end - pieces = @str.split(File::SEPARATOR, -1) + pieces = @str.split(File::SEPARATOR, -1) @array = [] @array << dir_color @@ -993,8 +1044,11 @@ class BufferStack private def cull! - # Remove empty buffers. - @stack.delete_if { |x| not VIM::evaluate_bool("bufexists(#{x})") } + # Remove empty and unlisted buffers. + @stack.delete_if { |x| + not (VIM::evaluate_bool("bufexists(#{x})") and + VIM::evaluate_bool("getbufvar(#{x}, '&buflisted')")) + } end # NOTE: very similar to Entry::compute_buffer_entries() diff --git a/.vim/bundle/lusty/src/explorer.vim b/.vim/bundle/lusty/src/explorer.vim index 13f7756..8c6a041 100644 --- a/.vim/bundle/lusty/src/explorer.vim +++ b/.vim/bundle/lusty/src/explorer.vim @@ -15,10 +15,10 @@ " 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 +" robquant, lilydjwg, Martin Wache, Johannes Holzfuß " -" Release Date: July 21, 2010 -" Version: 3.1.1 +" Release Date: December 16, 2010 +" Version: 4.0 " " Usage: " lf - Opens the filesystem explorer. @@ -59,6 +59,8 @@ " " select [n]ext match " select [p]revious match +" select [f]orward one column +" select [b]ack one column " " clear prompt " @@ -242,8 +244,8 @@ let g:loaded_lustyexplorer = "yep" " Commands. command LustyBufferExplorer :call LustyBufferExplorerStart() -command LustyFilesystemExplorer :call LustyFilesystemExplorerStart() -command LustyFilesystemExplorerFromHere :call LustyFilesystemExplorerFromHereStart() +command -nargs=? LustyFilesystemExplorer :call LustyFilesystemExplorerStart("") +command LustyFilesystemExplorerFromHere :call LustyFilesystemExplorerStart(expand("%:p:h")) command LustyBufferGrep :call LustyBufferGrepStart() " Deprecated command names. @@ -269,12 +271,8 @@ nmap lb :LustyBufferExplorer nmap lg :LustyBufferGrep " 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 } +function! s:LustyFilesystemExplorerStart(path) + exec "ruby LustyE::profile() { $lusty_filesystem_explorer.run_from_path('".a:path."') }" endfunction function! s:LustyBufferExplorerStart() diff --git a/.vim/bundle/lusty/src/juggler.vim b/.vim/bundle/lusty/src/juggler.vim index 620fc7d..801660e 100644 --- a/.vim/bundle/lusty/src/juggler.vim +++ b/.vim/bundle/lusty/src/juggler.vim @@ -10,10 +10,11 @@ " Name Of File: lusty-juggler.vim " Description: Dynamic Buffer Switcher Vim Plugin " Maintainer: Stephen Bach -" 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 -" Version: 1.1.4 +" Release Date: December 16, 2010 +" Version: 1.2 " " Usage: " lj - Opens the buffer juggler. @@ -52,18 +53,34 @@ " To cancel the juggler, press any of "q", "", "", "", or "". " +" LustyJuggler can act very much like window switching. +" To enable this mode, add the following line to your .vimrc: +" +" let g:LustyJugglerAltTabMode = 1 +" +" Then, given the following mapping: +" +" noremap :LustyJuggler +" +" Pressing "" will launch the LustyJuggler with the +" previous buffer highlighted. Typing "" again will cycle +" to the next buffer (in most-recently used order), and +" "" will open the highlighted buffer. For example, the +" sequence "" will open the previous buffer, and +" "" will open the buffer used just before the +" previous buffer, and so on. " " 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: " @@ -138,7 +155,7 @@ if !has("ruby") if !exists("g:LustyExplorerSuppressRubyWarning") || \ g:LustyExplorerSuppressRubyWarning == "0" if !exists("g:LustyJugglerSuppressRubyWarning") || - \ g:LustyJugglerSuppressRubyWarning == "0" + \ g:LustyJugglerSuppressRubyWarning == "0" echohl ErrorMsg echon "Sorry, LustyJuggler requires ruby. " echon "Here are some tips for adding it:\n" diff --git a/.vim/bundle/lusty/src/lusty/bar-item.rb b/.vim/bundle/lusty/src/lusty/bar-item.rb index 9121f16..dfdc7ae 100644 --- a/.vim/bundle/lusty/src/lusty/bar-item.rb +++ b/.vim/bundle/lusty/src/lusty/bar-item.rb @@ -70,7 +70,7 @@ class BufferItem < BarItem slash_color = @@SLASH_COLOR end - pieces = @str.split(File::SEPARATOR, -1) + pieces = @str.split(File::SEPARATOR, -1) @array = [] @array << dir_color diff --git a/.vim/bundle/lusty/src/lusty/buffer-stack.rb b/.vim/bundle/lusty/src/lusty/buffer-stack.rb index dbf3f53..4cff280 100644 --- a/.vim/bundle/lusty/src/lusty/buffer-stack.rb +++ b/.vim/bundle/lusty/src/lusty/buffer-stack.rb @@ -73,8 +73,11 @@ class BufferStack private def cull! - # Remove empty buffers. - @stack.delete_if { |x| not VIM::evaluate_bool("bufexists(#{x})") } + # Remove empty and unlisted buffers. + @stack.delete_if { |x| + not (VIM::evaluate_bool("bufexists(#{x})") and + VIM::evaluate_bool("getbufvar(#{x}, '&buflisted')")) + } end # NOTE: very similar to Entry::compute_buffer_entries() diff --git a/.vim/bundle/lusty/src/lusty/display.rb b/.vim/bundle/lusty/src/lusty/display.rb index e90af6f..85ab75c 100644 --- a/.vim/bundle/lusty/src/lusty/display.rb +++ b/.vim/bundle/lusty/src/lusty/display.rb @@ -106,6 +106,10 @@ class Display VIM::command 'highlight link LustyFileWithSwap WarningMsg' VIM::command 'highlight link LustyNoEntries ErrorMsg' VIM::command 'highlight link LustyTruncated Visual' + + if VIM::exists? '*clearmatches' + VIM::evaluate 'clearmatches()' + end end # @@ -144,6 +148,8 @@ class Display VIM::command "#{map} :call #{prefix}KeyPressed(23)" VIM::command "#{map} :call #{prefix}KeyPressed(14)" VIM::command "#{map} :call #{prefix}KeyPressed(16)" + VIM::command "#{map} :call #{prefix}KeyPressed(6)" + VIM::command "#{map} :call #{prefix}KeyPressed(2)" VIM::command "#{map} :call #{prefix}KeyPressed(15)" VIM::command "#{map} :call #{prefix}KeyPressed(20)" VIM::command "#{map} :call #{prefix}KeyPressed(22)" @@ -175,7 +181,7 @@ class Display if col_index < col_count - 1 # 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 end end @@ -185,6 +191,7 @@ class Display end print_rows(rows, truncated) + row_count end def close @@ -252,7 +259,8 @@ class Display column_widths = [] total_width = 0 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 break if total_width > max_width diff --git a/.vim/bundle/lusty/src/lusty/entry.rb b/.vim/bundle/lusty/src/lusty/entry.rb index 658f16e..e0c43b1 100644 --- a/.vim/bundle/lusty/src/lusty/entry.rb +++ b/.vim/bundle/lusty/src/lusty/entry.rb @@ -18,12 +18,13 @@ class Entry @label = label end + # NOTE: very similar to BufferStack::shorten_paths() 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? + next if (o.nil? or not o.listed?) buffer_entries << self.new(o, n) end diff --git a/.vim/bundle/lusty/src/lusty/explorer.rb b/.vim/bundle/lusty/src/lusty/explorer.rb index d8cd66c..4c7e7c0 100644 --- a/.vim/bundle/lusty/src/lusty/explorer.rb +++ b/.vim/bundle/lusty/src/lusty/explorer.rb @@ -60,6 +60,26 @@ class Explorer @selected_index = \ (@selected_index - 1) % @current_sorted_matches.size 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 choose(:new_split) when 20 # C-t choose in new tab @@ -102,8 +122,8 @@ class Explorer on_refresh() highlight_selected_index() if VIM::has_syntax? - @display.print @current_sorted_matches.map { |x| x.label } - @prompt.print + @row_count = @display.print @current_sorted_matches.map { |x| x.label } + @prompt.print Display.max_width end def create_explorer_window diff --git a/.vim/bundle/lusty/src/lusty/filesystem-explorer.rb b/.vim/bundle/lusty/src/lusty/filesystem-explorer.rb index 60f23d0..a4ac119 100644 --- a/.vim/bundle/lusty/src/lusty/filesystem-explorer.rb +++ b/.vim/bundle/lusty/src/lusty/filesystem-explorer.rb @@ -25,21 +25,12 @@ class FilesystemExplorer < Explorer super end - def run_from_here + def run_from_path(path) 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) + if path.empty? + path = VIM::getcwd() + end + @prompt.set!(path + File::SEPARATOR) run() end diff --git a/.vim/bundle/lusty/src/lusty/juggler.rb b/.vim/bundle/lusty/src/lusty/juggler.rb index 2effee6..b6624a2 100644 --- a/.vim/bundle/lusty/src/lusty/juggler.rb +++ b/.vim/bundle/lusty/src/lusty/juggler.rb @@ -39,13 +39,19 @@ class LustyJuggler end def run - return if @running - if $lj_buffer_stack.length <= 1 VIM::pretty_msg("PreProc", "No other buffers") return 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 # Need to zero the timeout length or pressing 'g' will hang. @@ -69,6 +75,7 @@ class LustyJuggler map_key("", ":call LustyJugglerKeyPressed('TAB')") # Cancel keys. + map_key("i", ":call LustyJugglerCancel()") map_key("q", ":call LustyJugglerCancel()") map_key("", ":call LustyJugglerCancel()") map_key("", ":call LustyJugglerCancel()") @@ -76,7 +83,8 @@ class LustyJuggler map_key("", ":call LustyJugglerCancel()") map_key("", ":call LustyJugglerCancel()") - print_buffer_list() + @last_pressed = 2 if LustyJuggler::alt_tab_mode_active? + print_buffer_list(@last_pressed) end def key_pressed() @@ -84,12 +92,12 @@ class LustyJuggler if @last_pressed.nil? and c == 'ENTER' cleanup() - elsif @last_pressed and (c == @last_pressed or c == 'ENTER') - choose(@@KEYS[@last_pressed]) + elsif @last_pressed and (@@KEYS[c] == @last_pressed or c == 'ENTER') + choose(@last_pressed) cleanup() else - print_buffer_list(@@KEYS[c]) - @last_pressed = c + @last_pressed = @@KEYS[c] + print_buffer_list(@last_pressed) end end @@ -108,6 +116,7 @@ class LustyJuggler unmap_key("") unmap_key("") + unmap_key("i") unmap_key("q") unmap_key("") unmap_key("") @@ -121,6 +130,11 @@ class LustyJuggler end 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) # If the user pressed a key higher than the number of open buffers, # highlight the highest (see also BufferStack.num_at_pos()). diff --git a/.vim/bundle/lusty/src/lusty/prompt.rb b/.vim/bundle/lusty/src/lusty/prompt.rb index 36927b6..29b84d8 100644 --- a/.vim/bundle/lusty/src/lusty/prompt.rb +++ b/.vim/bundle/lusty/src/lusty/prompt.rb @@ -23,9 +23,16 @@ class Prompt @input = "" 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, - "None", VIM::single_quote_escape(@input), + "None", VIM::single_quote_escape(text), "Underlined", " ") end diff --git a/.vim/bundle/lusty/src/vim.rb b/.vim/bundle/lusty/src/vim.rb index a8ddeb9..d93d227 100644 --- a/.vim/bundle/lusty/src/vim.rb +++ b/.vim/bundle/lusty/src/vim.rb @@ -82,6 +82,10 @@ module VIM VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&modified')") end + def listed? + VIM::nonzero? VIM::evaluate("getbufvar(#{number()}, '&buflisted')") + 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| @@ -110,3 +114,19 @@ module VIM 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 + diff --git a/.vim/bundle/yankring/plugin/yankring.vim b/.vim/bundle/yankring/disabled/yankring.vim similarity index 100% rename from .vim/bundle/yankring/plugin/yankring.vim rename to .vim/bundle/yankring/disabled/yankring.vim diff --git a/.vim/colors/baraknew.vim b/.vim/colors/baraknew.vim index 31c4f7b..905eb39 100644 --- a/.vim/colors/baraknew.vim +++ b/.vim/colors/baraknew.vim @@ -37,7 +37,7 @@ hi Normal ctermfg=253 ctermbg=NONE " Comment Group " ------------- " any comment -hi Comment guifg=#238e23 gui=none +hi Comment guifg=#238e23 gui=italic hi Comment ctermfg=34 cterm=none