aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2023-08-03 08:35:10 -0700
committerGitHub <noreply@github.com>2023-08-03 08:35:10 -0700
commitb034378cf58bea18ea1bdb4d63692a1336b5752b (patch)
treeb5e2d1a9015c29fd505b8cab53201ff8857792ce
parent4d859d00d13893815b6072a7bf2022dd89d5e3f8 (diff)
downloadrneovim-b034378cf58bea18ea1bdb4d63692a1336b5752b.tar.gz
rneovim-b034378cf58bea18ea1bdb4d63692a1336b5752b.tar.bz2
rneovim-b034378cf58bea18ea1bdb4d63692a1336b5752b.zip
docs: luaref cleanup #24541
- drop "luaref-" prefix in favor of "lua-" or nothing, where possible. - remove redundant "luaref--lang…" and "luaref-api…" tags.
-rw-r--r--runtime/doc/lsp.txt2
-rw-r--r--runtime/doc/lua-guide.txt6
-rw-r--r--runtime/doc/lua.txt53
-rw-r--r--runtime/doc/luaref.txt469
-rw-r--r--runtime/doc/treesitter.txt8
-rw-r--r--runtime/doc/vim_diff.txt2
-rw-r--r--runtime/lua/vim/_meta/regex.lua6
-rw-r--r--runtime/lua/vim/shared.lua4
8 files changed, 270 insertions, 280 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index f85150adb6..1b35219bb8 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -67,7 +67,7 @@ To override the above defaults, set or unset the options on |LspAttach|: >lua
callback = function(ev)
vim.bo[ev.buf].formatexpr = nil
vim.bo[ev.buf].omnifunc = nil
- vim.keymap.del("n", "K", { bufnr = ev.buf })
+ vim.keymap.del("n", "K", { buffer = ev.buf })
end,
})
diff --git a/runtime/doc/lua-guide.txt b/runtime/doc/lua-guide.txt
index 61c3925a07..e2fece916c 100644
--- a/runtime/doc/lua-guide.txt
+++ b/runtime/doc/lua-guide.txt
@@ -167,8 +167,8 @@ the cache manually first:
<
------------------------------------------------------------------------------
See also:
-• |lua-require|
-• |luaref-pcall()|
+• |lua-module-load|
+• |pcall()|
==============================================================================
Using Vim commands and functions from Lua *lua-guide-vimscript*
@@ -186,7 +186,7 @@ Note that special characters will need to be escaped with backslashes:
>lua
vim.cmd("%s/\\Vfoo/bar/g")
<
-An alternative is to use a literal string (see |luaref-literal|) delimited by
+An alternative is to use a literal string (see |lua-literal|) delimited by
double brackets `[[ ]]` as in
>lua
vim.cmd([[%s/\Vfoo/bar/g]])
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 94a2c0d45e..bee3a761f3 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -62,10 +62,10 @@ programming": tables, closures, and coroutines.
https://www.lua.org/doc/cacm2018.pdf
- Tables are the "object" or container datastructure: they represent both
lists and maps, you can extend them to represent your own datatypes and
- change their behavior using |luaref-metatable| (like Python's "datamodel").
+ change their behavior using |metatable|s (like Python's "datamodel").
- EVERY scope in Lua is a closure: a function is a closure, a module is
- a closure, a `do` block (|luaref-do|) is a closure--and they all work the
- same. A Lua module is literally just a big closure discovered on the "path"
+ a closure, a `do` block (|lua-do|) is a closure--and they all work the same.
+ A Lua module is literally just a big closure discovered on the "path"
(where your modules are found: |package.cpath|).
- Stackful coroutines enable cooperative multithreading, generators, and
versatile control for both Lua and its host (Nvim).
@@ -81,7 +81,7 @@ An "iterable" is anything that |vim.iter()| can consume: tables, dicts, lists,
iterator functions, tables implementing the |__call()| metamethod, and
|vim.iter()| objects.
- *lua-call-function*
+ *lua-function-call*
Lua functions can be called in multiple ways. Consider the function: >lua
local foo = function(a, b)
print("A: ", a)
@@ -94,21 +94,19 @@ The first way to call this function is: >lua
-- A: 1
-- B: 2
-This way of calling a function is familiar from most scripting languages.
-In Lua, any missing arguments are passed as `nil`. Example: >lua
+This way of calling a function is familiar from most scripting languages. In
+Lua, any missing arguments are passed as `nil`, and extra parameters are
+silently discarded. Example: >lua
foo(1)
-- ==== Result ====
-- A: 1
-- B: nil
-
-Furthermore it is not an error if extra parameters are passed, they are just
-discarded.
-
+<
*kwargs*
When calling a function, you can omit the parentheses if the function takes
exactly one string literal (`"foo"`) or table literal (`{1,2,3}`). The latter
-is often used to approximate "named parameters" ("kwargs" or "keyword args")
-as in languages like Python and C#. Example: >lua
+is often used to mimic "named parameters" ("kwargs" or "keyword args") as in
+languages like Python and C#. Example: >lua
local func_with_opts = function(opts)
local will_do_foo = opts.foo
local filename = opts.filename
@@ -119,21 +117,16 @@ as in languages like Python and C#. Example: >lua
<
There's nothing special going on here except that parentheses are treated as
whitespace. But visually, this small bit of sugar gets reasonably close to
-a "keyword args" interface.
-
-It is of course also valid to call the function with parentheses: >lua
- func_with_opts({ foo = true, filename = "hello.world" })
-<
-Nvim tends to prefer the keyword args style.
+a "keyword args" interface. Nvim code tends to prefer this style.
------------------------------------------------------------------------------
LUA PATTERNS *lua-patterns*
Lua intentionally does not support regular expressions, instead it has limited
-"patterns" |luaref-patterns| which avoid the performance pitfalls of extended
+"patterns" |lua-pattern| which avoid the performance pitfalls of extended
regex. Lua scripts can also use Vim regex via |vim.regex()|.
-These examples use |string.match()| to demonstrate Lua patterns: >lua
+Examples: >lua
print(string.match("foo123bar123", "%d+"))
-- 123
@@ -145,7 +138,7 @@ These examples use |string.match()| to demonstrate Lua patterns: >lua
-- .bar
==============================================================================
-IMPORTING LUA MODULES *require()* *lua-require*
+IMPORTING LUA MODULES *lua-module-load*
Modules are searched for under the directories specified in 'runtimepath', in
the order they appear. Any "." in the module name is treated as a directory
@@ -159,7 +152,7 @@ back to Lua's default search mechanism. The first script found is run and
The return value is cached after the first call to `require()` for each module,
with subsequent calls returning the cached value without searching for, or
-executing any script. For further details on `require()`, see |luaref-require()|.
+executing any script. For further details see |require()|.
For example, if 'runtimepath' is `foo,bar` and |package.cpath| was
`./?.so;./?.dll` at startup, `require('mod')` searches these paths in order
@@ -332,22 +325,22 @@ Example: >vim
:echo luaeval('string.match(_A, "[a-z]+")', 'XYXfoo123')
" foo
<
- *lua-table*
+ *lua-table-ambiguous*
Lua tables are used as both dictionaries and lists, so it is impossible to
determine whether empty table is meant to be empty list or empty dictionary.
Additionally Lua does not have integer numbers. To distinguish between these
cases there is the following agreement:
- *lua-list*
+ *lua-list*
0. Empty table is empty list.
1. Table with N incrementally growing integral numbers, starting from 1 and
ending with N is considered to be a list.
- *lua-dict*
+ *lua-dict*
2. Table with string keys, none of which contains NUL byte, is considered to
be a dictionary.
3. Table with string keys, at least one of which contains NUL byte, is also
considered to be a dictionary, but this time it is converted to
a |msgpack-special-map|.
- *lua-special-tbl*
+ *lua-special-tbl*
4. Table with `vim.type_idx` key may be a dictionary, a list or floating-point
value:
- `{[vim.type_idx]=vim.types.float, [vim.val_idx]=1}` is converted to
@@ -680,8 +673,8 @@ vim.regex:match_line({bufnr}, {line_idx}, {start}, {end_})
vim.regex:match_str({str}) *regex:match_str()*
Match the string against the regex. If the string should match the regex
- precisely, surround the regex with `^` and `$` . If the was a match, the byte indices for the beginning and end of the
- match is returned. When there is no match, `nil` is returned. As any integer is truth-y, `regex:match()` can be directly used as a condition in an if-statement.
+ precisely, surround the regex with `^` and `$` . If there was a match, the byte indices for the beginning and end of the
+ match are returned. When there is no match, `nil` is returned. Because any integer is "truthy", `regex:match()` can be directly used as a condition in an if-statement.
Parameters: ~
• {str} (string)
@@ -1952,7 +1945,7 @@ vim.gsplit({s}, {sep}, {opts}) *vim.gsplit()*
See also: ~
• |string.gmatch()|
• |vim.split()|
- • |luaref-patterns|
+ • |lua-patterns|
• https://www.lua.org/pil/20.2.html
• http://lua-users.org/wiki/StringLibraryTutorial
@@ -2333,7 +2326,7 @@ vim.trim({s}) *vim.trim()*
(string) String with whitespace removed from its beginning and end
See also: ~
- • |luaref-patterns|
+ • |lua-patterns|
• https://www.lua.org/pil/20.2.html
vim.validate({opt}) *vim.validate()*
diff --git a/runtime/doc/luaref.txt b/runtime/doc/luaref.txt
index 1096759ad8..341f620a8d 100644
--- a/runtime/doc/luaref.txt
+++ b/runtime/doc/luaref.txt
@@ -1,5 +1,5 @@
*luaref.txt* Nvim
- *luaref* *Lua-Reference*
+ *luaref*
LUA REFERENCE MANUAL
@@ -16,14 +16,14 @@
Copyright (c) 2006 Lua.org, PUC-Rio.
- See |luaref-doc| for information on this manual.
- See |luaref-copyright| for copyright and licenses.
+ See |lua-ref-doc| for information on this manual.
+ See |lua-ref-copyright| for copyright and licenses.
Type |gO| to see the table of contents.
==============================================================================
-1 INTRODUCTION *luaref-intro*
+1 INTRODUCTION *luaref-intro*
Lua is an extension programming language designed to support general
procedural programming with data description facilities. It also offers good
@@ -47,13 +47,13 @@ Lua's official web site, www.lua.org.
Like any other reference manual, this document is dry in places. For a
discussion of the decisions behind the design of Lua, see references at
-|luaref-bibliography|. For a detailed introduction to programming in Lua, see
+|lua-ref-bibliography|. For a detailed introduction to programming in Lua, see
Roberto's book, Programming in Lua.
Lua means "moon" in Portuguese and is pronounced LOO-ah.
==============================================================================
-2 THE LANGUAGE *luaref-language*
+2 THE LANGUAGE *lua-language*
This section describes the lexis, the syntax, and the semantics of Lua. In
other words, this section describes which tokens are valid, how they can be
@@ -63,9 +63,9 @@ The language constructs will be explained using the usual extended BNF
notation, in which `{ a }` means 0 or more `a`'s, and `[ a ]` means an optional `a`.
==============================================================================
-2.1 Lexical Conventions *luaref-langLexConv*
+2.1 Lexical Conventions *lua-lexical*
- *luaref-names* *luaref-identifiers*
+ *lua-names* *lua-identifiers*
Names (also called identifiers) in Lua can be any string of letters, digits,
and underscores, not beginning with a digit. This coincides with the
definition of identifiers in most languages. (The definition of letter depends
@@ -92,7 +92,7 @@ The following strings denote other tokens:
( ) { } [ ]
; : , . .. ...
<
- *luaref-literal*
+ *lua-literal*
Literal strings can be delimited by matching single or double quotes, and can
contain the following C-like escape sequences:
@@ -146,14 +146,14 @@ coded as 49), the five literals below denote the same string:
alo
123"]==]
<
- *luaref-numconstant*
+ *lua-numconstant*
A numerical constant may be written with an optional decimal part and an
optional decimal exponent. Lua also accepts integer hexadecimal constants, by
prefixing them with `0x`. Examples of valid numerical constants are
>
3 3.0 3.1416 314.16e-2 0.31416E1 0xff 0x56
<
- *luaref-comment*
+ *lua-comment*
A comment starts with a double hyphen (`--`) anywhere outside a string. If the
text immediately after `--` is not an opening long bracket, the comment is a
short comment, which runs until the end of the line. Otherwise, it is a long
@@ -161,7 +161,7 @@ comment, which runs until the corresponding closing long bracket. Long
comments are frequently used to disable code temporarily.
==============================================================================
-2.2 Values and Types *luaref-langValTypes*
+2.2 Values and Types *lua-values*
Lua is a dynamically typed language. This means that variables do not have
types; only values do. There are no type definitions in the language. All
@@ -171,9 +171,9 @@ All values in Lua are first-class values. This means that all values can be
stored in variables, passed as arguments to other functions, and returned as
results.
- *luaref-types* *luaref-nil*
- *luaref-true* *luaref-false*
- *luaref-number* *luaref-string*
+ *lua-types* *lua-nil*
+ *lua-true* *lua-false*
+ *lua-number* *lua-string*
There are eight basic types in Lua: `nil`, `boolean`, `number`, `string`,
`function`, `userdata`, `thread`, and `table`. Nil is the type of the value
`nil`, whose main property is to be different from any other value; it usually
@@ -184,27 +184,27 @@ numbers. (It is easy to build Lua interpreters that use other internal
representations for numbers, such as single-precision float or long integers;
see file `luaconf.h`.) String represents arrays of characters. Lua is 8-bit
clean: strings may contain any 8-bit character, including embedded zeros
-(`\0`) (see |luaref-literal|).
+(`\0`) (see |lua-literal|).
Lua can call (and manipulate) functions written in Lua and functions written
-in C (see |luaref-langFuncCalls|).
+in C (see |lua-function|).
- *luaref-userdatatype*
+ *lua-userdatatype*
The type userdata is provided to allow arbitrary C data to be stored in Lua
variables. This type corresponds to a block of raw memory and has no
pre-defined operations in Lua, except assignment and identity test. However,
by using metatables, the programmer can define operations for userdata values
-(see |luaref-langMetatables|). Userdata values cannot be created or modified
-in Lua, only through the C API. This guarantees the integrity of data owned by
-the host program.
+(see |lua-metatable|). Userdata values cannot be created or modified in Lua,
+only through the C API. This guarantees the integrity of data owned by the
+host program.
- *luaref-thread*
+ *lua-thread*
The type `thread` represents independent threads of execution and it is used to
-implement coroutines (see |luaref-langCoro|). Do not confuse Lua threads with
+implement coroutines (see |lua-coroutine|). Do not confuse Lua threads with
operating-system threads. Lua supports coroutines on all systems, even those
that do not support threads.
- *luaref-table*
+ *lua-table*
The type `table` implements associative arrays, that is, arrays that can be
indexed not only with numbers, but with any value (except `nil`). Tables can
be heterogeneous; that is, they can contain values of all types (except
@@ -213,11 +213,11 @@ used to represent ordinary arrays, symbol tables, sets, records, graphs,
trees, etc. To represent records, Lua uses the field name as an index. The
language supports this representation by providing `a.name` as syntactic sugar
for `a["name"]`. There are several convenient ways to create tables in Lua
-(see |luaref-langTableConst|).
+(see |lua-tableconstructor|).
Like indices, the value of a table field can be of any type (except `nil`). In
particular, because functions are first-class values, table fields may contain
-functions. Thus tables may also carry methods (see |luaref-langFuncDefs|).
+functions. Thus tables may also carry methods (see |lua-function-define|).
Tables, functions, threads and (full) userdata values are objects: variables
do not actually contain these values, only references to them. Assignment,
@@ -225,10 +225,10 @@ parameter passing, and function returns always manipulate references to such
values; these operations do not imply any kind of copy.
The library function `type` returns a string describing the type of a given
-value (see |luaref-type()|).
+value (see |lua-type()|).
------------------------------------------------------------------------------
-2.2.1 Coercion *luaref-langCoercion*
+2.2.1 Coercion *lua-coercion*
Lua provides automatic conversion between string and number values at run
time. Any arithmetic operation applied to a string tries to convert that
@@ -239,7 +239,7 @@ converted to strings, use the `format` function from the string library (see
|string.format()|).
==============================================================================
-2.3 Variables *luaref-langVariables*
+2.3 Variables *lua-variables*
Variables are places that store values. There are three kinds of variables in
Lua: global variables, local variables, and table fields.
@@ -249,12 +249,12 @@ function's formal parameter, which is a particular form of local variable):
>
var ::= Name
<
-Name denotes identifiers, as defined in |luaref-langLexConv|.
+Name denotes identifiers, as defined in |lua-lexical|.
Any variable is assumed to be global unless explicitly declared as a local
-(see |luaref-langLocalDec|). Local variables are lexically scoped: local
+(see |lua-local|). Local variables are lexically scoped: local
variables can be freely accessed by functions defined inside their scope (see
-|luaref-langVisibRules|).
+|lua-visibility|).
Before the first assignment to a variable, its value is `nil`.
@@ -265,21 +265,21 @@ Square brackets are used to index a table:
The first expression (`prefixexp`) should result in a table value; the second
expression (`exp`) identifies a specific entry inside that table. The
expression denoting the table to be indexed has a restricted syntax; see
-|luaref-langExpressions| for details.
+|lua-expressions| for details.
The syntax `var.NAME` is just syntactic sugar for `var["NAME"]` :
>
var ::= prefixexp . Name
<
All global variables live as fields in ordinary Lua tables, called environment
-tables or simply environments (see |luaref-langEnvironments|). Each function
+tables or simply environments (see |lua-environments|). Each function
has its own reference to an environment, so that all global variables in this
function will refer to this environment table. When a function is created, it
inherits the environment from the function that created it. To get the
environment table of a Lua function, you call `getfenv` (see
-|lua_getfenv()|). To replace it, you call `setfenv` (see |luaref-setfenv()|).
+|lua_getfenv()|). To replace it, you call `setfenv` (see |setfenv()|).
(You can only manipulate the environment of C functions through the debug
-library; see |luaref-libDebug|.)
+library; see |lua-lib-debug|.)
An access to a global variable `x` is equivalent to `_env.x`, which in turn is
equivalent to
@@ -291,19 +291,19 @@ not defined in Lua. We use it here only for explanatory purposes.)
The meaning of accesses to global variables and table fields can be changed
via metatables. An access to an indexed variable `t[i]` is equivalent to a
-call `gettable_event(t,i)`. (See |luaref-langMetatables| for a complete
-description of the `gettable_event` function. This function is not defined or
-callable in Lua. We use it here only for explanatory purposes.)
+call `gettable_event(t,i)`. (See |lua-metatable| for a complete description of
+the `gettable_event` function. This function is not defined or callable in
+Lua. We use it here only for explanatory purposes.)
==============================================================================
-2.4 Statements *luaref-langStats*
+2.4 Statements *lua-statement*
Lua supports an almost conventional set of statements, similar to those in
Pascal or C. This set includes assignment, control structures, function
calls, and variable declarations.
------------------------------------------------------------------------------
-2.4.1 Chunks *luaref-chunk* *luaref-langChunks*
+2.4.1 Chunks *lua-chunk*
The unit of execution of Lua is called a chunk. A chunk is simply a sequence
of statements, which are executed sequentially. Each statement can be
@@ -314,7 +314,7 @@ optionally followed by a semicolon:
There are no empty statements and thus `;;` is not legal.
Lua handles a chunk as the body of an anonymous function with a variable
-number of arguments (see |luaref-langFuncDefs|). As such, chunks can define
+number of arguments (see |lua-function-define|). As such, chunks can define
local variables, receive arguments, and return values.
A chunk may be stored in a file or in a string inside the host program. When a
@@ -327,24 +327,24 @@ details. Programs in source and compiled forms are interchangeable; Lua
automatically detects the file type and acts accordingly.
------------------------------------------------------------------------------
-2.4.2 Blocks *luaref-block* *luaref-langBlocks*
+2.4.2 Blocks *lua-block*
A block is a list of statements; syntactically, a block is the same as a
chunk:
>
block ::= chunk
<
- *luaref-do* *luaref-end*
+ *lua-do* *lua-end*
A block may be explicitly delimited to produce a single statement:
>
stat ::= do block end
<
Explicit blocks are useful to control the scope of variable declarations.
Explicit blocks are also sometimes used to add a `return` or `break` statement
-in the middle of another block (see |luaref-langContStructs|).
+in the middle of another block (see |lua-control|).
------------------------------------------------------------------------------
-2.4.3 Assignment *luaref-langAssign*
+2.4.3 Assignment *lua-assign*
Lua allows multiple assignment. Therefore, the syntax for assignment defines a
list of variables on the left side and a list of expressions on the right
@@ -354,7 +354,7 @@ side. The elements in both lists are separated by commas:
varlist1 ::= var { , var }
explist1 ::= exp { , exp }
<
-Expressions are discussed in |luaref-langExpressions|.
+Expressions are discussed in |lua-expressions|.
Before the assignment, the list of values is adjusted to the length of the
list of variables. If there are more values than needed, the excess values are
@@ -362,7 +362,7 @@ thrown away. If there are fewer values than needed, the list is extended with
as many `nil`s as needed. If the list of expressions ends with a function
call, then all values returned by this call enter in the list of values,
before the adjustment (except when the call is enclosed in parentheses; see
-|luaref-langExpressions|).
+|lua-expressions|).
The assignment statement first evaluates all its expressions and only then are
the assignments performed. Thus the code
@@ -379,9 +379,9 @@ exchanges the values of `x` and `y`.
The meaning of assignments to global variables and table fields can be changed
via metatables. An assignment to an indexed variable `t[i] = val` is
-equivalent to `settable_event(t,i,val)`. (See |luaref-langMetatables| for a
-complete description of the `settable_event` function. This function is not
-defined or callable in Lua. We use it here only for explanatory purposes.)
+equivalent to `settable_event(t,i,val)`. (See |lua-metatable| for a complete
+description of the `settable_event` function. This function is not defined or
+callable in Lua. We use it here only for explanatory purposes.)
An assignment to a global variable `x = val` is equivalent to the
assignment `_env.x = val`, which in turn is equivalent to
@@ -392,10 +392,10 @@ where `_env` is the environment of the running function. (The `_env` variable is
not defined in Lua. We use it here only for explanatory purposes.)
------------------------------------------------------------------------------
-2.4.4 Control Structures *luaref-langContStructs*
+2.4.4 Control Structures *lua-control*
- *luaref-if* *luaref-then* *luaref-else* *luaref-elseif*
- *luaref-while* *luaref-repeat* *luaref-until*
+ *lua-if* *lua-then* *lua-else* *lua-elseif*
+ *lua-while* *lua-repeat* *lua-until*
The control structures `if`, `while`, and `repeat` have the usual meaning and
familiar syntax:
>
@@ -404,7 +404,7 @@ familiar syntax:
stat ::= if exp then block { elseif exp then block }
[ else block ] end
<
-Lua also has a `for` statement, in two flavors (see |luaref-langForStat|).
+Lua also has a `for` statement, in two flavors (see |lua-for|).
The condition expression of a control structure may return any value.
Both `false` and `nil` are considered false. All values different
@@ -415,14 +415,14 @@ In the `repeat-until` loop, the inner block does not end at the `until` keyword,
but only after the condition. So, the condition can refer to local variables
declared inside the loop block.
- *luaref-return*
+ *lua-return*
The `return` statement is used to return values from a function or a chunk
(which is just a function). Functions and chunks may return more than one
value, so the syntax for the `return` statement is
`stat ::=` `return` `[explist1]`
- *luaref-break*
+ *lua-break*
The `break` statement is used to terminate the execution of a `while`, `repeat`,
or `for` loop, skipping to the next statement after the loop:
@@ -437,7 +437,7 @@ middle of a block, then an explicit inner block can be used, as in the idioms
the last statements in their (inner) blocks.
------------------------------------------------------------------------------
-2.4.5 For Statement *for* *luaref-langForStat*
+2.4.5 For Statement *for* *lua-for*
The `for` statement has two forms: one numeric and one generic.
@@ -513,17 +513,17 @@ Note the following:
them to other variables before breaking or exiting the loop.
------------------------------------------------------------------------------
-2.4.6 Function Calls as Statements *luaref-langFuncStat*
+2.4.6 Function Calls as Statements *lua-funcstatement*
To allow possible side-effects, function calls can be executed as statements:
>
stat ::= functioncall
<
In this case, all returned values are thrown away. Function calls are
-explained in |luaref-langFuncCalls|.
+explained in |lua-function|.
------------------------------------------------------------------------------
-2.4.7 Local Declarations *luaref-local* *luaref-langLocalDec*
+2.4.7 Local Declarations *lua-local*
Local variables may be declared anywhere inside a block. The declaration may
include an initial assignment:
@@ -532,18 +532,17 @@ include an initial assignment:
namelist ::= Name { , Name }
<
If present, an initial assignment has the same semantics of a multiple
-assignment (see |luaref-langAssign|). Otherwise, all variables are initialized
+assignment (see |lua-assign|). Otherwise, all variables are initialized
with `nil`.
-A chunk is also a block (see |luaref-langChunks|), and so local variables can be
+A chunk is also a block (see |lua-chunk|), and so local variables can be
declared in a chunk outside any explicit block. The scope of such local
variables extends until the end of the chunk.
-The visibility rules for local variables are explained in
-|luaref-langVisibRules|.
+The visibility rules for local variables are explained in |lua-visibility|.
==============================================================================
-2.5 Expressions *luaref-langExpressions*
+2.5 Expressions *lua-expressions*
The basic expressions in Lua are the following:
>
@@ -558,22 +557,22 @@ The basic expressions in Lua are the following:
exp ::= unop exp
prefixexp ::= var | functioncall | ( exp )
<
-Numbers and literal strings are explained in |luaref-langLexConv|; variables are
-explained in |luaref-langVariables|; function definitions are explained in
-|luaref-langFuncDefs|; function calls are explained in |luaref-langFuncCalls|;
-table constructors are explained in |luaref-langTableConst|. Vararg expressions,
+Numbers and literal strings are explained in |lua-lexical|; variables are
+explained in |lua-variables|; function definitions are explained in
+|lua-function-define|; function calls are explained in |lua-function|;
+table constructors are explained in |lua-tableconstructor|. Vararg expressions,
denoted by three dots (`...`), can only be used inside vararg functions;
-they are explained in |luaref-langFuncDefs|.
+they are explained in |lua-function-define|.
-Binary operators comprise arithmetic operators (see |luaref-langArithOp|),
-relational operators (see |luaref-langRelOp|), logical operators (see
-|luaref-langLogOp|), and the concatenation operator (see |luaref-langConcat|).
-Unary operators comprise the unary minus (see |luaref-langArithOp|), the unary
-`not` (see |luaref-langLogOp|), and the unary length operator (see
-|luaref-langLength|).
+Binary operators comprise arithmetic operators (see |lua-arithmetic|),
+relational operators (see |lua-relational|), logical operators (see
+|lua-logicalop|), and the concatenation operator (see |lua-concat|).
+Unary operators comprise the unary minus (see |lua-arithmetic|), the unary
+`not` (see |lua-logicalop|), and the unary length operator (see
+|lua-length|).
Both function calls and vararg expressions may result in multiple values. If
-the expression is used as a statement (see |luaref-langFuncStat|)
+the expression is used as a statement (see |lua-funcstatement|)
(only possible for function calls), then its return list is adjusted to zero
elements, thus discarding all returned values. If the expression is used as
the last (or the only) element of a list of expressions, then no adjustment is
@@ -606,12 +605,12 @@ An expression enclosed in parentheses always results in only one value. Thus,
return any values.)
------------------------------------------------------------------------------
-2.5.1 Arithmetic Operators *luaref-langArithOp*
+2.5.1 Arithmetic Operators *lua-arithmetic*
Lua supports the usual arithmetic operators: the binary `+` (addition),
`-` (subtraction), `*` (multiplication), `/` (division), `%` (modulo)
and `^` (exponentiation); and unary `-` (negation). If the operands are numbers,
-or strings that can be converted to numbers (see |luaref-langCoercion|), then all
+or strings that can be converted to numbers (see |lua-coercion|), then all
operations have the usual meaning. Exponentiation works for any exponent. For
instance, `x^(-0.5)` computes the inverse of the square root of `x`. Modulo is
defined as
@@ -622,7 +621,7 @@ That is, it is the remainder of a division that rounds the quotient towards
minus infinity.
------------------------------------------------------------------------------
-2.5.2 Relational Operators *luaref-langRelOp*
+2.5.2 Relational Operators *lua-relational*
The relational operators in Lua are
>
@@ -639,9 +638,9 @@ create a new object (a table, userdata, or function), this new object is
different from any previously existing object.
You can change the way that Lua compares tables and userdata using the "eq"
-metamethod (see |luaref-langMetatables|).
+metamethod (see |lua-metatable|).
-The conversion rules of coercion |luaref-langCoercion| do not apply to
+The conversion rules of coercion |lua-coercion| do not apply to
equality comparisons. Thus, `"0"==0` evaluates to `false`, and `t[0]` and
`t["0"]` denote different entries in a table.
@@ -650,19 +649,19 @@ The operator `~=` is exactly the negation of equality (`==`).
The order operators work as follows. If both arguments are numbers, then they
are compared as such. Otherwise, if both arguments are strings, then their
values are compared according to the current locale. Otherwise, Lua tries to
-call the "lt" or the "le" metamethod (see |luaref-langMetatables|).
+call the "lt" or the "le" metamethod (see |lua-metatable|).
------------------------------------------------------------------------------
-2.5.3 Logical Operators *luaref-langLogOp*
+2.5.3 Logical Operators *lua-logicalop*
The logical operators in Lua are
>
and or not
<
-Like the control structures (see |luaref-langContStructs|), all logical operators
+Like the control structures (see |lua-control|), all logical operators
consider both `false` and `nil` as false and anything else as true.
- *luaref-not* *luaref-and* *luaref-or*
+ *lua-not* *lua-and* *lua-or*
The negation operator `not` always returns `false` or `true`. The conjunction
operator `and` returns its first argument if this value is `false` or `nil`;
otherwise, `and` returns its second argument. The disjunction
@@ -683,15 +682,15 @@ evaluated only if necessary. Here are some examples:
(In this manual, `-->` indicates the result of the preceding expression.)
------------------------------------------------------------------------------
-2.5.4 Concatenation *luaref-langConcat*
+2.5.4 Concatenation *lua-concat*
The string concatenation operator in Lua is denoted by two dots (`..`).
If both operands are strings or numbers, then they are converted to strings
-according to the rules mentioned in |luaref-langCoercion|. Otherwise, the
-"concat" metamethod is called (see |luaref-langMetatables|).
+according to the rules mentioned in |lua-coercion|. Otherwise, the
+"concat" metamethod is called (see |lua-metatable|).
------------------------------------------------------------------------------
-2.5.5 The Length Operator *luaref-langLength*
+2.5.5 The Length Operator *lua-length*
The length operator is denoted by the unary operator `#`. The length of a
string is its number of bytes (that is, the usual meaning of string length
@@ -706,7 +705,7 @@ indices that directly precedes a `nil` value (that is, it may consider any
such `nil` value as the end of the array).
------------------------------------------------------------------------------
-2.5.6 Precedence *luaref-langPrec*
+2.5.6 Precedence *lua-precedence*
Operator precedence in Lua follows the table below, from lower to higher
priority:
@@ -725,7 +724,7 @@ The concatenation (`..`) and exponentiation (`^`) operators are right
associative. All other binary operators are left associative.
------------------------------------------------------------------------------
-2.5.7 Table Constructors *luaref-langTableConst*
+2.5.7 Table Constructors