This repository scrapes the Garry's Mod Lua API and generates annotated code snippets that will help provide autocompletion for Lua in editors like VSCode, Neovim and more.
To get autocompletion for the Garry's Mod Lua API in your Garry's Mod projects, you need to install the Lua Language Server and our GLua API Definitions.
First install Lua Language Server (LuaLS): for your editor of choice:
Then download/install our GLua API Definitions for the Lua Language Server. This process varies depending on your editor:
Installing our GLua API Definitions for the Lua Language Server in Visual Studio Code is easy thanks to the Lua Language Server Addon Manager built into the VSCode extension.
-
In Visual Studio Code open the Command Palette with the key combination
Ctrl+Shift+P
(orCmd+Shift+P
on macOS) -
Search for Addon, then select
Lua: Open Addon Manager ...
:
- Search for the Garry's Mod addon and
Enable
it:
- Setup a folder for storing Lua Language Server addons (e.g.
~/.cache/luals/
) and createaddonManager/addons/garrysmod/module
folders inside it
Note
If you switch between Neovim and VSCode regularly, you probably want to use VSCode's directory, which is ~/AppData/Roaming/Code/User/globalStorage/sumneko.lua
on Windows and ~/.config/Code/User/globalStorage/sumneko.lua
on Linux
-
Clone (or download and unzip) our
lua-language-server-addon
branch into thegarrysmod/module
folder -
In your Neovim config where you call
lspconfig.lua_ls.setup
, add the following to the table
before_init = function(init_params, config)
init_params.initializationOptions = init_params.initializationOptions or {}
init_params.initializationOptions.storagePath = "~/.cache/luals"
end
{
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"runtime.version": "LuaJIT",
"runtime.special": {
"IncludeCS": "dofile",
"include": "dofile"
},
"runtime.nonstandardSymbol": ["!", "!=", "&&", "||", "//", "/**/", "continue"],
"workspace.library": ["${addons}/garrysmod/module/library"],
"workspace.checkThirdParty": false
}
Warning
The VSCode extension currently does not automatically install addons. If a user that does not have this addon installed already opens a project that has this .luarc.json
present, they will have to open the Addon Manager and click Disable and Enable on this addon for it to install the addon properly.
Using GitHub Actions, this repository is automatically updated on the first day of every month at approximately 00:00 UTC.
A workflow will automatically scrape the latest Garry's Mod Lua API from the Garry's Mod Wiki and package them into 🔗 a release.
Note
The Lua Language Server addon might not be immediately updated to align with the definitions in this repository. This delay occurs because we must submit a pull request (PR) to the Lua Language Server Addons repository (LuaLS/LLS-Addons
) to update the addon. Subsequently, a maintainer of the LuaLS/LLS-Addons
repository needs to find time to review and merge the PR.
Our schedule for updating our addon with LuaLS/LLS-Addons
is set for the first day of February, April, June, August, October, and December.
This schedule is subject to change based on the availability of maintainers and the urgency of the update.
If you urgently require the most current definitions from the addon, you can expedite the process by submitting a PR to update it yourself. Instructions for doing so can be found in the CONTRIBUTING.md
file.
You can clone this repository and run the scraper yourself. This is useful if you want to use the latest version of the API, or if you want to make changes to the scraper.
-
Clone this repository
-
Install the dependencies with
npm install
-
Run the scraper with
npm run scrape-wiki
This project uses Jest to automate testing. You can run the tests with npm test
.
The API is also available as JSON. You can find it with the Lua API package on 🔗 the releases page. It is named something like YYYY-MM-DD_HH-MM-SS.json.zip
.
If you cannot or do not want to use Lua Language Server:
-
Download and unzip the latest release from 🔗 the releases page, it's named something like
YYYY-MM-DD_HH-MM-SS.lua.zip
-
Include or symlink the unzipped directory into your workspace
luttje 💻 |
Aske 💻 |
Vurv 💻 |
jason 🤔 |
_AMD_ 🐛 |
[aka]bomb 🐛 💻 |
Rubat 💻 |
Techbot121 🐛 |
TIMON_Z1535 🤔 🐛 |
Cynthia Foxwell 📖 |