Skip to content

Instantly share code, notes, and snippets.

@humus
Created September 15, 2016 18:37
Show Gist options
  • Save humus/b7492f82ef76c1450130e7a3ea2348fc to your computer and use it in GitHub Desktop.
Save humus/b7492f82ef76c1450130e7a3ea2348fc to your computer and use it in GitHub Desktop.
Script for working with java functions
fun! Fqcn() "{{{
let s:lnum = search('\v^package[^;]+;\s*$', 'n')
let s:strline = getline(s:lnum)
let s:packagename=matchstr(s:strline, '\v^package\s+\zs[^;]+\ze;')
return s:packagename . '.' . expand('%:t:r')
endfunction "}}}
fun! Compile() "{{{
execute 'silent! !tmux send-keys "cpjar_javac ' . expand('%:t:r') . '" c-m'
redraw!
endfunction "}}}
fun! Execute() "{{{
execute 'silent! !tmux send-keys "cpjar_javax ' . Fqcn() . '" c-m'
redraw!
endfunction "}}}
fun! Execute_test() "{{{
execute 'silent! !tmux send-keys "cpjar_junit ' . Fqcn() . '" c-m'
redraw!
endfunction "}}}
noremap! <buffer> ,,c <C-r>=Fqcn()<cr>
noremap <buffer> ,,c :call Compile()<cr>
noremap <buffer> ,,x :call Execute()<cr>
noremap <buffer> ,,t :call Execute_test()<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment