Created
July 6, 2015 07:21
-
-
Save marcotrosi/c41b08945a162642c6ee to your computer and use it in GitHub Desktop.
Vim/Lua - exporting balloon info as Lua data and running external script to create the balloon text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set balloonexpr=Balloon() | |
let g:BalloonScript="<scriptname>" | |
set ballooneval | |
function! Balloon() | |
let balloondata = ['return', '{'] | |
call add(balloondata, " ['cwd'] = [[" . getcwd() . "]],") | |
call add(balloondata, " ['fileabspath'] = [[" . expand('%:p') . "]],") | |
call add(balloondata, " ['filerelpath'] = [[" . expand('%:.') . "]],") | |
call add(balloondata, " ['fileabsdir'] = [[" . expand('%:p:h') . "]],") | |
call add(balloondata, " ['filereldir'] = [[" . expand('%:.:h') . "]],") | |
call add(balloondata, " ['file'] = [[" . expand('%:t') . "]],") | |
call add(balloondata, " ['filename'] = [[" . expand('%:t:r') . "]],") | |
call add(balloondata, " ['fileext'] = [[" . expand('%:e') . "]],") | |
call add(balloondata, " ['line'] = [[" . v:beval_lnum . "]],") | |
call add(balloondata, " ['column'] = [[" . v:beval_col . "]],") | |
call add(balloondata, " ['text'] = [[" . v:beval_text . "]],") | |
call add(balloondata, "}") | |
call writefile(balloondata, "/path/to/.vimballooninfo") | |
call system(g:BalloonScript) | |
return join(readfile("/path/to/.vimballoontext"), "\n") | |
endfunction | |
" to load the data into a Lua script run | |
" t = dofile("/path/to/.vimballooninfo") | |
" the Lua script shall write the balloon text into the file "/path/to/.vimballoontext". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment