Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ddc_vim/deps.ts>fn.libcall

Dark deno-powered completion framework for neovim/Vim
Go to Latest
function fn.libcall
import { fn } from "https://deno.land/x/ddc_vim@v4.0.2/deps.ts";
const { libcall } = fn;

Call function {funcname} in the run-time library {libname} with single argument {argument}. This is useful to call functions in a library that you especially made to be used with Vim. Since only one argument is possible, calling standard library functions is rather limited. The result is the String returned by the function. If the function returns NULL, this will appear as an empty string "" to Vim. If the function returns a number, use libcallnr()! If {argument} is a number, it is passed to the function as an int; if {argument} is a string, it is passed as a null-terminated string. This function will fail in restricted-mode.

libcall() allows you to write your own 'plug-in' extensions to Vim without having to recompile the program. It is NOT a means to call system functions! If you try to do so Vim will very probably crash.

For Win32, the functions you write must be placed in a DLL and use the normal C calling convention (NOT Pascal which is used in Windows System DLLs). The function must take exactly one parameter, either a character pointer or a long integer, and must return a character pointer or NULL. The character pointer returned must point to memory that will remain valid after the function has returned (e.g. in static data in the DLL). If it points to allocated memory, that memory will leak away. Using a static buffer in the function should work, it's then freed when the DLL is unloaded.

WARNING: If the function returns a non-valid pointer, Vim may crash! This also happens if the function returns a number, because Vim thinks it's a pointer. For Win32 systems, {libname} should be the filename of the DLL without the ".DLL" suffix. A full path is only required if the DLL is not in the usual places. For Unix: When compiling your own plugins, remember that the object code must be compiled as position-independent ('PIC'). only in Win32 and some Unix versions, when the +libcall feature is present Examples:

:echo libcall("libc.so", "getenv", "HOME")

Can also be used as a method, the base is passed as the third argument:

GetValue()->libcall("libc.so", "getenv")

Parameters

denops: Denops
libname: unknown
funcname: unknown
argument: unknown

Returns

Promise<string>