Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/denops_std/option/vim/mod.ts>balloonexpr

📚 Standard module for denops.vim
Latest
variable balloonexpr
import { balloonexpr } from "https://deno.land/x/denops_std@v6.5.0/option/vim/mod.ts";

Expression for text to show in evaluation balloon. It is only used when 'ballooneval' or 'balloonevalterm' is on. These variables can be used:

v:beval_bufnr number of the buffer in which balloon is going to show v:beval_winnr number of the window v:beval_winid ID of the window v:beval_lnum line number v:beval_col column number (byte index) v:beval_text word under or after the mouse pointer

Instead of showing a balloon, which is limited to plain text, consider using a popup window, see popup_beval_example. A popup window can use highlighting and show a border.

The evaluation of the expression must not have side effects! Example:

function MyBalloonExpr()
    return 'Cursor is at line ' .. v:beval_lnum ..
            \ ', column ' .. v:beval_col ..
            \ ' of file ' ..  bufname(v:beval_bufnr) ..
            \ ' on word "' .. v:beval_text .. '"'
endfunction
set bexpr=MyBalloonExpr()
set ballooneval balloonevalterm

Also see balloon_show(), it can be used if the content of the balloon is to be fetched asynchronously. In that case evaluating 'balloonexpr' should result in an empty string. If you get a balloon with only "0" you probably didn't return anything from your function.

NOTE: The balloon is displayed only if the cursor is on a text character. If the result of evaluating 'balloonexpr' is not empty, Vim does not try to send a message to an external debugger (Netbeans or Sun Workshop).

If the expression starts with s: or <SID>, then it is replaced with the script ID (local-function). Example:

set bexpr=s:MyBalloonExpr()
set bexpr=<SID>SomeBalloonExpr()

Otherwise, the expression is evaluated in the context of the script where the option was set, thus script-local items are available.

The expression will be evaluated in the sandbox when set from a modeline, see sandbox-option. This option cannot be set in a modeline when 'modelineexpr' is off.

It is not allowed to change text or jump to another window while evaluating 'balloonexpr', see textlock.

To check whether line breaks in the balloon text work use this check:

if has("balloon_multiline")

When they are supported "\n" characters will start a new line. If the expression evaluates to a List this is equal to using each List item as a string and putting "\n" in between them. NOTE: This option is set to "" when 'compatible' is set.

(default "")

only available when compiled with the +balloon_eval feature