WebOS development in vim

After getting frustrated with Aptana + Eclipse I decided to start using vim for my WebOS development needs. One of the more interesting features of the WebOS Eclipse plugin is the ability to generate a new scene without having to manually call palm-generate.

So I made a vim command (put this in your ~/.vimrc):

let basedir = "/DATA/projects"

function GenerateScene(basedir, project, name)
    exe '!palm-generate -t new_scene -p "name=' . a:name . '" ' . basedir . '/' . a:project
endfunction

command -nargs=+ Newscene call GenerateScene(basedir, <f-args>)

Now whenever I call :Newscene <project> <scene-name> a new scene called scene-name will be created in /DATA/projects/project

Switching projects?

:let basedir="/path/to/new/project"

Of course, after doing some development I want to do a testrun as well. You'll need to make sure both novacomd and the emulator are running.

The command for packaging, installing and launching the app on the emulator:

:Testrun <project>

And for cleaning up (uninstall and remove the ipk file):

:Cleanup <project>

Here's the code for your ~/.vimrc file:

let domain = "be.venefyxatu.palm."
let appversion = "1.0.0"

function GenerateScene(basedir, project, name)
    exe '!palm-generate -t new_scene -p "name=' . a:name . '" ' . a:basedir . '/' . a:project
endfunction

command -nargs=+ Newscene call GenerateScene(basedir, <f-args>)

function Testrun(basedir, domain, appversion, project)
    call PackageApp(a:basedir, a:project)
    call InstallApp(a:domain, a:project, a:appversion)
    call LaunchApp(a:domain, a:project)
endfunction

function PackageApp(basedir, project)
    silent exe '!palm-package ' . a:basedir . '/' . a:project
endfunction

function InstallApp(domain, project, appversion)
    silent exe '!palm-install ' . a:domain . a:project . '_' . a:appversion . '_all.ipk'
endfunction

function LaunchApp(domain, project)
    silent exe '!palm-launch ' . a:domain . a:project
endfunction

function RemoveApp(basedir, domain, appversion, project)
    silent exe '!palm-install -r ' . a:domain . a:project
    silent exe '!rm -f ' . a:basedir . '/' . a:project . '/' . a:domain . a:project . '_' . a:appversion . '_all.ipk'
endfunction

command -nargs=1 Testrun call Testrun(basedir, domain, appversion, <f-args>)
command -nargs=1 Cleanup call RemoveApp(basedir, domain, appversion, <f-args>)

Yes, there is probably a way to get the domain and version from the appinfo.json file, but I can't really be bothered :-)

This might be interesting as a vim extension as well ... but once again I can't really be bothered :-)

 Permalink

Comments

No new comments allowed (anymore) on this post.