From f157976b3fa4974afbeb0caa3135fbf41bc23638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Sterle?= Date: Mon, 15 Feb 2021 00:04:21 +0100 Subject: [PATCH] run docgen.sh --- README.md | 3 +-- doc/nvim-lua-guide.txt | 39 +++++++-------------------------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 1bbb1fd..d8f46d9 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,6 @@ * [Using meta-accessors](#using-meta-accessors-1) * [Caveats](#caveats-4) * [Calling Vimscript functions](#calling-vimscript-functions) - * [vim.call()](#vimcall) * [vim.fn.{function}()](#vimfnfunction) * [Tips](#tips-4) * [Caveats](#caveats-5) @@ -774,7 +773,7 @@ vim.fn.jobstart('ls', { on_stdout = print_stdout }) ``` Strings with invalid Lua names can be used with `vim.fn[variable]`. -For example, hashes (`#`) are no valid characters for indentifiers in Lua, so autoload functions have to be called with this syntax: +For example, hashes (`#`) are not valid characters for indentifiers in Lua, so autoload functions have to be called with this syntax: ```lua vim.fn['my#autoload#function']() diff --git a/doc/nvim-lua-guide.txt b/doc/nvim-lua-guide.txt index b00e263..2a854d2 100644 --- a/doc/nvim-lua-guide.txt +++ b/doc/nvim-lua-guide.txt @@ -39,7 +39,7 @@ is easy to learn, especially if you have experience with similar scripting languages like JavaScript. You may already know more Lua than you realise! Note: the version of Lua that Neovim embeds is LuaJIT 2.1.0, which -maintains compatibility with Lua 5.1 (with a few 5.2 extensions) +maintains compatibility with Lua 5.1 (with a few 5.2 extensions). Existing tutorials for writing Lua in Neovim~ @@ -844,37 +844,11 @@ This is a known issue: CALLING VIMSCRIPT FUNCTIONS *luaguide-calling-vimscript-functions* -vim.call()~ - -`vim.call()` calls a Vimscript function. This can either be a built-in -Vim function or a user function. Again, data types are converted back -and forth from Lua to Vimscript. - -It takes in the name of the function followed by the arguments you want -to pass to that function: - - > - print(vim.call('printf', 'Hello from %s', 'Lua')) - - local reversed_list = vim.call('reverse', { 'a', 'b', 'c' }) - print(vim.inspect(reversed_list)) -- { "c", "b", "a" } - - local function print_stdout(chan_id, data, name) - print(data[1]) - end - - vim.call('jobstart', 'ls', { on_stdout = print_stdout }) - - vim.call('my#autoload#function') -< - -See also: -- |vim.call()| - vim.fn.{function}()~ -`vim.fn` does the exact same thing as `vim.call()`, but looks more like -a native Lua function call: +`vim.fn` is for calling a Vimscript function. +The Vimscript function can either be a built-in Vim function or a user +function. Data types are converted back and forth from Lua to Vimscript. > print(vim.fn.printf('Hello from %s', 'Lua')) @@ -889,8 +863,9 @@ a native Lua function call: vim.fn.jobstart('ls', { on_stdout = print_stdout }) < -Hashes `#` aren't valid characters for indentifiers in Lua, so autoload -functions have to be called with this syntax: +Strings with invalid Lua names can be used with `vim.fn[variable]`. +For example, hashes (`#`) are not valid characters for indentifiers in +Lua, so autoload functions have to be called with this syntax: > vim.fn['my#autoload#function']()