Thursday, June 19, 2014

Custom Vorax Status Line

Vorax does a pretty well job when it comes to display the status line of the output window. It shows a lot of stuff like: the current output funnel (PAGEZIP, VERTICAL or TABLEZIP), the APPEND or STICKY flag and, of course, the current Oracle connection.

However, it looks a bit too minimalist, especially with all these nice statusline management plugins around:
I've played a little with all the above plugins and in the end I decided on Airline. Even Lighline is more KISS oriented, I didn't want to spend too much time on configuring everything: NERDTree, quickfix window etc. Unlike Lighline, Airline is designed to be extensible and plugins like NERDTree, vim-fugitive etc. may contribute with their own airline extensions in order to configure the look of the status line.

So, below is Vorax with airline:

It'a nice improvement, and the information from the status line is better highlighted. In addition, I configured the current Oracle connection to be also displayed in a Vorax buffer (sql or plsql), just to be sure we know where we're connected to, especially if the output window is not shown (it can be toggled, I'm sure you know this).

So, let's see how we can achieve this. I put the following in my .vimrc file:

" Let me choose the statusbar
let g:vorax_output_force_overwrite_status_line = 0

function! VoraxOutputFlags()
  let funnel = ["", "VERTICAL", "PAGEZIP", "TABLEZIP"][vorax#output#GetFunnel()]
  let append = g:vorax_output_window_append ? "APPEND" : ""
  let sticky = g:vorax_output_window_sticky_cursor ? "STICKY" : ""
  let heading = g:vorax_output_full_heading ? "HEADING" : ""
  let top = g:vorax_output_cursor_on_top ? "TOP" : ""
  return join(filter([funnel, append, sticky, heading, top], 'v:val != ""'), ' ')

function! VoraxAirPlugin(...)
  let session = '%{vorax#sqlplus#SessionOwner()}'
  let txn = '%{vorax#utils#IsOpenTxn() ? "!" . g:vorax_output_txn_marker : ""}'
  if vorax#utils#IsVoraxBuffer()
    let w:airline_section_b = get(w:, 'airline_section_b', g:airline_section_b) . session
    let w:airline_section_warning = get(w:, 'airline_section_warning', g:airline_section_warning) . txn
  if &ft == 'outputvorax'
    let lrows = '%{exists("g:vorax_limit_rows") ? " [LIMIT ROWS <=" . g:vorax_limit_rows . "] " : ""}'
    let w:airline_section_a = '%{vorax#utils#Throbber()}'
    let w:airline_section_b = airline#section#create_left([session])
    let w:airline_section_c = 'Output window'
    let w:airline_section_x = ''
    let w:airline_section_y = g:airline_section_z
    let w:airline_section_z = airline#section#create(["%{VoraxOutputFlags()}"])
    let w:airline_section_warning = get(w:, 'airline_section_warning', g:airline_section_warning)
    let w:airline_section_warning .= airline#section#create([lrows, txn])
  elseif (&ft == 'connvorax') || (&ft == 'explorervorax') || (&ft == 'oradocvorax')
    let w:airline_section_a = ''
    let w:airline_section_b = ''
    let w:airline_section_c = (&ft == 'connvorax' ? 'Connection Profiles' : &ft == 'explorervorax' ? 'DB Explorer' : 'Oracle Documentation')
    let w:airline_section_x = ''
    let w:airline_section_y = ''
    let w:airline_section_z = ''
call airline#add_statusline_func('VoraxAirPlugin')

" Let the statusbar as it is for inactive windows
let g:airline_inactive_collapse=0
That's all! The next logical step would be to defeat my lazyness and submit a real Airline extension for Vorax. I'm going to add this to my procrastination list.

Monday, December 2, 2013

Bye-bye Vorax3, Welcome Vorax4

It's official! Starting from today, Vorax3 is no longer supported. It wasn't very active anyway since my focus was on the new Vorax4 brother.

In this post I want to underline some of the big differences between the old and the new version.

First of all, the new Vorax was rewritten from scratch, taking into consideration the learnt lessons from implementing the previous version. Being a major version change, the API/commands are not the same anymore but, don't worry, because Vorax4 is supposed to have a more straightforward interface, and everything is covered into the Wiki or right into the Vim documentation bundled into the Vorax plugin.

The installation should be simpler. The ruby dependencies of Vorax can be now installed in one step using:
gem install vorax
In addition, Vorax4 supports Ruby 1.9 and Ruby 2.0. That's really a step forward since it's harder and harder to get Vorax running with the old Ruby 1.8 runtime on the new OS distributions.

As far as the Oracle documentation is concerned, Vorax4 doesn't depend anymore on external tools which must be installed on your computer, like it was the case with Vorax3 and Swish-e. Vorax4 relies now on the ferret gem which is automatically installed when you install the vorax gem.

Vorax4 is coming also with a better omni-completion system which should be smart enough to understand PL/SQL code too. This means that it'll also complete local variable names, types etc.

Another nice addition which wasn't in the old Vorax3 is the plsql code folding feature. Both these new features may prove to be a life saver for any PL/SQL Developer which is fool enough to code using the console only.

There's also a new output format called "pagezip", which compresses the output on a page basis, having the big advantage of spitting that page as soon as it gets compressed. This means that, unlike the "tablezip" format you'll have immediate feedback during the fetch phase. In addition, Vorax4 is smart enough to incrementally parse the output and to ask for any substitution variables or prompts, even in these custom output formats. This wasn't the case with the old Vorax3.

There are also some missing features, which were implemented in Vorax3 and get rid of them in Vorax4 for various reasons which I'm not going to cover here:
  • no logging for the output window. You may decide, however, to save the output buffer as a regular file if you want to.
  • no omni-completion for words within the output window. This can be achieved using the standard omni mechanism, but you have to configure it yourself if you need this kind of behavior.
  • Cygwin support was dropped in Vorax4. It was a PITA to maintain it in Vorax3 with little benefit.
So, without further ado, I hope you'll like the new Vorax. It's still an Oracle IDE for geeks and you're welcome to contribute or to send your feedback.

Tuesday, October 22, 2013

Vorax 4.0 Preview

Well, it's been awhile since I posted my last Vorax article here. Funny enough, it was about Vorax 3.0 improvements ideas. Meanwhile Vorax 3.0 was released into the wild, but at that time I didn't want to make such a big fuss because I wasn't sure it had the right implementation.

Now Vorax4 is in beta-testing and I'm quite pleased by the results: it's much faster, it has a smarter code completion and it's more KISS compliant.

So, please check it on:
Your feedback is highly appreciated!

Tuesday, May 3, 2011

Ideas for a completely rewritten VoraX 3.0

One year ago the first version of VoraX was released. It initially started as a proof of concept tool but, step by step, evolved into a more complex application. Unfortunately, at that time, my experience in writing Vim plugins was a bit poor. Now, when I'm looking to the code I wrote for implementing several functionalities I don't feel very proud: it's rude, not DRY and hard to maintain/understand. That's one of the reasons I think VoraX 3.0 should be a completely rewritten version. There are also some new features/improvements that I have in mind, the most important ones being:
  • a better DbExplorer tree. The main improvement I see here is the possibility to register custom plugins to provide additional functionality. For example, an user may write a very simple plugin to display DBMS_SPACE statistics for various objects within the tree. The same functionality provided by NERDTree via plugins may be also implemented for DbExplorer.
  • a tree based connection profile window with a XML file behind to store all profiles. I think this would be better than the actual implementation where these profiles are spread out in several files which, of course, is not very intuitive.
  • all VoraX config files should reside in $HOME/.vorax instead of directly in $HOME, messing up the user's home folder.
  • the possibility to configure one output window per tab. Sometimes is useful to open another tab and querying the database from there while preserving the old tab, including the output window.
  • text HTML output. The idea is to display the output of a query in a more friendly format without a lot of "column format" trickery. The main benefit would be that all columns will have the right size. The drawback is that the user must wait for the query to finish and only after that the output will be displayed. That's different than the way it is now when you have immediate feedback and the result is spit out as soon as it is available into the sqlplus out buffer. However, the user should have an easy option to switch from one type of output to another.
  • support for ruby 1.9? I don't know if both versions, 1.8.7 and 1.9 should be supported or not. The problem is that the PTY mechanism used by VoraX for Unix systems has changed in ruby 1.9. As far as Windows platforms are concerned, I must check if win32-api.gem can be used on ruby 1.9. However, being prepared for ruby 1.9 doesn't sound like a bad idea, does it?
  • move to GitHub. I already created a repository for VoraX 3.0. Despite I have little experience with this versioning system I'm eager to learn it because it seems more open to collaboration.
  • completion for various VoraX commands. For example, the :VoraxConnect command may provide completion based on registered connection profiles.
  • new commands. It would be nice to have the possibility to open packages or triggers directly using VoraX commands instead of navigating through the DbExplorer. This may be really handy, especially combined with a smart completion.
  • testing. It would be really nice to have a regression test suite or something in order to validate that the changes made to the code doesn't hurt the current functionality. There are some VIM plugins which may be used to test VimL code but I don't have any experience with any of them. Nevertheless, investing effort in this area would be really helpful.
If you have other ideas (or useful hints) please let me know. VoraX is an open source project therefore everybody is welcome to contribute.

Friday, April 1, 2011

VoraX on MAC OS

A few weeks ago I received an issue about the fact that VoraX doesn't work on MAC OS. For me it wasn't such a big surprise as I never tested VoraX on MAC OS, simply because I didn't have this platform available.

"It's time for action!" I said to myself having in mind the possibility to install this OS as a virtual machine and test VoraX on it. So, I grabbed a vmware MAC OS image and I tried to run it using vmware player. It's not a big deal, isn't it? Well, apparently this can't be done on my old PC because a CPU with VM-x stuff is needed. Damn it! Yeap, it's time for a CPU upgrade. I ordered an Intel Dual Core Duo 8400 and I patiently waited to arrive. Yesterday the new CPU was on my desk, ready to be installed. The installation was a piece of cake, the new CPU being recognised by my old motherboard except for the virtualization feature, that VT-x I was looking for. Buying a new motherboard didn't sound very appealing so I decided to look for a BIOS update. My MB is a Gygabyte and it already had the last stable BIOS installed. There was also a beta firmware available but that "beta" seemed a little bit scary. However, I had nothing to loose therefore I decided to go with the beta version. Aaand, after the upgrade, what a surprise! A brand new option called "Virtualization" was available in BIOS. Yesss! With this VT-x feature available I was able to run the vmware MAC OS image.

Hmmm... my very first time on MAC OS. It looks nice, kind of glossy but nothing to complain of. Well, maybe my lack of knowledge about this OS. However, having previous experience with a *NIX system is a big advantage. As soon as you get a terminal window it's like an usual *NIX box. I was able to check for ruby version and to install antlr3 gem. Mac OS 1.6.X is quite ready for VoraX. Then I downloaded macvim which has ruby support enabled. Then I installed the oracle instant client. I was a little bit surprised about the fact that the last available version for MAC is and not In the end I installed VoraX (the linux way into the ~/.vim dir) and I created a very basic .vimrc file:

set nocompatible
filetype plugin on

Below is the final result.

Yeap, VoraX on MAC. It's time to update the site/documentation to let people know that VoraX is also supported on MAC. Have fun guys!

Monday, January 24, 2011

Knock, Knock... Who's there?... VoraX 2.8

Hey folks! I feel bad for VoraX 2.7. It really had a short life, just a week... If you're the kind-hearted type then you may choose to keep VoraX 2.7 and make it happy. But, would you be also happy without these new VoraX 2.8 goodies? Well, let's see...

First of all, VoraX 2.8 is faster because it has a redesigned OS interface. This becomes obvious especially on Cygwin. Till now, there was an annoying delay immediately after a statement was finished executing. That was because another call was made in order to get connection information, which was further used to update the VoraX title. In VoraX 2.8 this is no longer true, the connection info is gathered in one step, as part of the statement execution itself.

Another useful feature is the monitoring capability of the results window. If you have a long running statement and you want to be notified when it's done then this is perfectly doable in VoraX 2.8. And because a picture worths one thousands words, below is a screen-shot showing this feature on my Ubuntu box:

Just put the following snippet into your .vimrc:
" Nice notification for my monitored long runinng queries
function VoraxNotification()
  let cmd = "notify-send -i 'terminal' 'VoraX' 'Execution of your monitored statement on ". 
            \ &titlestring . " has just finished.'" 
  exe 'silent! !' . cmd
let g:vorax_notify_command = "call VoraxNotification()"

On Windows I have no idea how to configure this but I guess there are some "cool" command line programs to display those annoying balloons in your tray.

And that's not all. Did you noticed the re-polished status line for the results window? Much better, isn't it?

As far as bug fixes are concerned I recommend you to upgrade because this version has a fix for a quite critical bug reported by Shaun Batterton. The bug description goes like this: if your statement has an "end" somewhere in between then a "/" will be appended. For example, if you execute something like:

alter tablespace muci_tbs add datafile size 100m autotextend on;

behind VoraX will rewrite (in a wrong way because of the bug) as:

alter tablespace muci_tbs add datafile size 100m autoextend on;

I know it's stupid but because the statement has an "end" (in autoextend) we end up adding two datafiles which, of course, is not what we've meant. Thanks Shaun for this bug report.

There's also another bug fix in connection with virtualedit setting but that's not something to pay too much attention in this post.

Okey, that's all. You may find additional details about these new features within the VoraX updated documentation.

Monday, January 17, 2011

VoraX 2.7 Released

By this post I want to let you know that VoraX 2.7 is available for download. The most important improvement this version brings out to light is a better way to define your key mappings for VoraX commands. No more VoraX event handler bullshit! Starting with this version you may define these mappings using a few g:vorax_key_for_* global variables. For example, my vimrc file contains now the following:

let g:vorax_key_for_exec_buffer = "<F8>"
let g:vorax_key_for_exec_sql = "<Leader>e"
let g:vorax_key_for_exec_one = "<Leader>1"
let g:vorax_key_for_describe = "<Leader>d"
let g:vorax_key_for_describe_verbose = "<Leader>D"
let g:vorax_key_for_explain_plan = "<F5>"
let g:vorax_key_for_explain_only = "<S-F5>"
let g:vorax_key_for_fuzzy_search = "??"
let g:vorax_key_for_goto_def = "gd"
let g:vorax_key_for_toggle_logging = "<Leader>l"

Of course, you're free to choose whatever you want. You are no longer bound to the default VoraX key mappings.

There are also a couple of bug fixes. They are detailed into the changelog.