Skip to main content
Version: 1.2.1

Auto-completion (IDE)

OrvexORM includes complete LuaLS annotations throughout the source code. This means your IDE can provide auto-completion, type-checking, and inline documentation while you code.


Configure VS Code

1. Install the Lua extension

Install the Lua Language Server (sumneko) extension:

  • Search for "Lua" in VS Code extensions
  • Install the one by sumneko (the most popular)
tip

The extension is officially called "Lua" by sumneko. Its ID is sumneko.lua.

2. Configure .luarc.json

Create a .luarc.json file at the root of your resource:

your-resource/.luarc.json
{
"runtime": {
"version": "Lua 5.4"
},
"workspace": {
"library": [
"../orvexorm"
],
"checkThirdParty": false
},
"diagnostics": {
"globals": ["MySQL", "Citizen", "promise", "json", "OrvexORM"]
},
"completion": {
"callSnippet": "Replace",
"keywordSnippet": "Replace"
}
}

:::caution Adjust the path The path "../orvexorm" depends on where your resource is relative to OrvexORM inside the resources/ folder. If your structure is:

resources/
├── orvexorm/
└── my-resource/

Then "../orvexorm" is correct. Adjust according to your structure. :::

3. Enjoy auto-completion

After configuring the file, you'll have access to:

Auto-completion on OrvexORM — all methods appear automatically:

OrvexORM.model() -- Create a model
OrvexORM.transaction() -- Create a transaction
OrvexORM.enableCache() -- Enable cache
OrvexORM.migrate() -- Run migrations
OrvexORM.introspect() -- Introspect a table
OrvexORM.fromTable() -- Generate a model from a table
OrvexORM.raw() -- Raw SQL query
-- etc.

Auto-completion on modelsUser., Vehicle., etc.:

User.create() -- Create
User.find() -- Find one
User.findAll() -- Find many
User.update() -- Update
User.delete() -- Delete
User.query() -- Query Builder
User.count() -- Count
User.sync() -- Create table
User.hook() -- Add a hook
User.beforeCreate() -- Shorthand hook
-- etc.

Auto-completion on instancesplayer:, vehicle:, etc.:

player:update() -- Update this instance
player:delete() -- Delete
player:increment() -- Increment a field
player:decrement() -- Decrement a field
player:get() -- Load a relation
player:attach() -- Attach (many-to-many)
player:detach() -- Detach
player:restore() -- Restore (soft delete)
-- etc.

Inline documentation — hover over any method to see its description, parameters, and types:

---@param tableName string The MySQL table name
---@param fields table The fields and their types
---@param opts? OrvexModelOpts Options (primaryKey, softDelete, timestamps...)
---@return OrvexModel

Available types

OrvexORM defines the following types for LuaLS:

TypeDescription
OrvexORMThe main module
OrvexModelA model (User, Vehicle, etc.)
OrvexInstanceAn instance (a found player, a vehicle, etc.)
OrvexBuilderThe Query Builder
OrvexTransactionA transaction
OrvexSchemaBuilderThe schema builder for migrations
OrvexTableBuilderThe column builder in migrations
OrvexCacheThe cache system
OrvexAdapterThe database adapter
OrvexFieldType"string" | "number" | "boolean" | "json" | "auto"
OrvexModelOptsModel options (primaryKey, softDelete, timestamps)
OrvexMigrationMigration definition (name, up, down)
OrvexRelationDefRelation definition

Other IDEs

IntelliJ / Rider

Install the EmmyLua plugin and configure the workspace the same way.

Neovim

If you use nvim-lspconfig with lua_ls:

require('lspconfig').lua_ls.setup({
settings = {
Lua = {
runtime = { version = "Lua 5.4" },
workspace = {
library = { "/path/to/resources/orvexorm" },
checkThirdParty = false,
},
diagnostics = {
globals = { "MySQL", "Citizen", "promise", "json", "OrvexORM" },
},
},
},
})

Source distribution

OrvexORM is distributed as source .lua files with complete LuaLS annotations. Auto-completion works natively — just add the OrvexORM folder to workspace.library in your .luarc.json.