This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
⚠️ Warning
This wiki has been replaced by the wiki on our website. This wiki will be removed in the future.
Project File Structure
Below is an explanation of the project file structure. Hovering an item will show a description, clicking a linked item will jump to more detailed info, if available.
Files marked with ⛔ are ignored by git.
📦 lua-language-server/
├── 📁 .github/
├── 📁 .vscode/
├── 📁 3rd/
├── 📁 bin/ ⛔
├── 📁 doc/
├── 📁 locale/
├── 📁 log/ ⛔
├── 📁 make/
├── 📂 meta/
│ ├── 📁 3rd/
│ ├── 📁 template/
│ └── 📂 Lua ${LUA_VERSION} ${LANGUAGE_ID} ${ENCODING}/ ⛔
├── 📂 script/
│ ├── 📁 brave/
│ ├── 📁 cli/
│ ├── 📁 config/
│ ├── 📁 core/
│ ├── 📁 encoder/
│ ├── 📁 glob/
│ ├── 📂 parser/
│ │ ├── 📜 guide.lua
│ │ ├── 📜 luadoc.lua
│ │ ├── 📜 newparser.lua
│ │ └── 📜 tokens.lua
│ ├── 📂 proto/
│ │ ├── 📜 converter.lua
│ │ ├── 📜 define.lua
│ │ └── 📜 proto.lua
│ ├── 📂 provider/
│ │ ├── 📜 diagnostic.lua
│ │ └── 📜 provider.lua
│ ├── 📁 pub/
│ ├── 📁 service/
│ ├── 📁 test
│ ├── 📁 tools
│ ├── 📂 vm/
│ │ ├── 📜 compiler.lua
│ │ ├── 📜 def.lua
│ │ ├── 📜 doc.lua
│ │ ├── 📜 field.lua
│ │ ├── 📜 generic.lua
│ │ ├── 📜 global.lua
│ │ ├── 📜 infer.lua
│ │ ├── 📜 local-id.lua
│ │ ├── 📜 node.lua
│ │ ├── 📜 ref.lua
│ │ ├── 📜 runner.lua
│ │ └── 📜 sign.lua
│ ├── 📂 workspace/
│ │ ├── 📜 loading.lua
│ │ ├── 📜 require-path.lua
│ │ ├── 📜 scope.lua
│ │ └── 📜 workspace.lua
│ ├── 📜 await.lua
│ ├── 📜 client.lua
│ ├── 📜 files.lua
│ ├── 📜 language.lua
│ ├── 📜 lclient.lua
│ ├── 📜 library.lua
│ ├── 📜 plugin.lua
├── 📜 debugger.lua
├── 📜 test.lua
└── 📜 main.lua
.github/
Github-specific files for metadata, issue templates, etc.
.vscode/
Visual Studio Code specific files for development.
3rd/
Contains Lua defintion files for various included libraries like love2d and OpenResty.
script/parser/
Parses Lua code into an abstract syntax tree (AST).
Turns:
x = 10
y = 20
into:
{
type = 'main',
start = 0,
finish = 20000,
[1] = {
type = 'setglobal',
start = 0,
finish = 1,
range = 5,
[1] = 'x',
value = {
type = 'integer',
start = 4,
finish = 6,
[1] = 10
},
},
[2] = {
type = 'setglobal',
start = 10000,
finish = 10001,
range = 10005,
[1] = 'y',
value = {
type = 'integer',
start = 10004,
finish = 10006,
[1] = 20
},
},
}
ℹ️ Note: first line is
0, start is cursor position on the left and finish is cursor position on the right.
ℹ️ Note:
position = row * 10000 + col, therefore, only codes with fewer than 10000 bytes in a single line are supported. These nodes are generally named source.
ℹ️ Note: Most of the children files are obsolete, only the ones still in use are documented.
script/parser/newparser.lua
Parses Lua code into an AST then wraps it into state.
local state = {
version = 'Lua 5.4',
lua = [[local x = 1]],
ast = { ... },
errs = { ... }, -- syntax errors
comms = { ... }, -- comments
lines = { ... }, -- map of offset and position
}
script/vm/
Semantic analysis of the AST and binding status according to the workspace.
Turns:
---@class myClass
local mt
into:
vm.compileNode('mt')
-->
node: {
[1] = {
type = 'local',
[1] = 'mt',
},
[2] = {
type = 'global',
cate = 'type',
name = 'myClass',
},
}
script/vm/runner.lua
Process analysis and tracking of local variables
---@type number|nil
local x
if x then
print(x) --> `x` is number here
end