Type definitions for the LPeg library.
Functions and operators in LPeg can be split into two main groups. One that
creates patterns and one that creates captures. The corresponding types are
called Pattern
and Capture
. For example lpeg.P('a')
returns a Pattern
while lpeg.Cc('a')
returns a Capture
. Technically however, each capture is
also a pattern. In other words Capture
is an alias of Pattern
.
Whether the tooltips of your editor display a capture type as Capture
or
Pattern
depends on the
hover.expandAlias
setting in the configuration file of
lua-language-server.
Here are two screenshots showing the different behavior. If hover.expandAlias
is false
,
the tooltip for a function like lpeg.Cc()
displays the return type as Capture
:
If hover.expandAlias
is true
, the tooltip displays the return type as Pattern
:
Lua-language-server provides several
configuration file for defining settings like hover.expandAlias
, and they are all
explained in the documentation of lua-language-server.
One way to configure it is the following: Create a JSON file
.luarc.json
in the top-level directory of your workspace with the following content. If this
configuration file already exists, just add the expandAlias
key.
{
"Lua" : {
"hover" : {
"expandAlias" : false,
},
},
}