To create a .emmyrc.json
file in the root directory of your workspace, which is used to configure some parameters of EmmyLuaAnalyzer.
The main configuration format is:
{
"completion": {
"autoRequire": true,
"autoRequireFunction": "require",
"autoRequireNamingConvention": "camelCase",
"callSnippet": false,
"postfix": "@"
},
"signature": {
"detailSignatureHelper": false
},
"diagnostics": {
"disable": [
],
"globals": [],
"globalsRegex": [],
"severity": {
},
"enables": [
]
},
"hint": {
"paramHint": true,
"indexHint": true,
"localHint": true,
"overrideHint": true
},
"runtime": {
"version": "Lua5.4",
"requireLikeFunction": [],
"frameworkVersions": [],
"extensions": [],
"requirePattern": []
},
"workspace": {
"ignoreDir": [
],
"ignoreGlobs": [
],
"library": [],
"workspaceRoots": [],
"preloadFileSize": 1048576,
"encoding": ""
},
"resource": {
"paths": [
]
},
"codeLens": {
"enable": true
},
"strict": {
"requirePath": false,
"typeCall": true
}
}
autoRequire
: Whether to automatically complete the require statement, default istrue
.autoRequireFunction
: The function name used for automatically completing the require statement, default isrequire
.autoRequireNamingConvention
: The naming convention used for automatically completing the require statement, default iscamelCase
, optional values arecamelCase
,snakeCase
,pascalCase
.callSnippet
: Whether to use code snippets for function call completion, default isfalse
.postfix
: The postfix used for completion, default is@
. However, setting this option is currently ineffective.
detailSignatureHelper
: Whether to display detailed function signature help, default isfalse
.
disable
: List of disabled diagnostic messages. If you need to disable some diagnostic messages in the workspace, you need to fill in the corresponding diagnostic IDs, for example:"undefined-global"
.globals
: List of global variables. Global variables in this list will not be diagnosed as undefined.globalsRegex
: List of regular expressions for global variables. Global variables that match the regular expressions will not be diagnosed as undefined.severity
: Severity of diagnostic messages, for example:"undefined-global": "warning"
, optional values are"error"
,"warning"
,"information"
,"hint"
.enables
: List of enabled diagnostic messages. Not all diagnostic messages of the language service are enabled by default. You can use this option to enable some diagnostic messages, for example:"undefined-field"
.
paramHint
: Whether to display parameter hints, default istrue
.indexHint
: Whether to display hints when indexing expressions span multiple lines, default istrue
.localHint
: Whether to display hints for local variables, default istrue
.overrideHint
: Whether to display hints for overrides, default istrue
.
version
: Runtime version, default isLua5.4
, optional values areLua5.1
,Lua5.2
,Lua5.3
,Lua5.4
,LuaJIT
.requireLikeFunction
: List of functions similar to require, used to identify functions similar to require, for example:["import"]
.frameworkVersions
: List of framework versions, used to identify framework versions, for example:["love2d"]
. Can be used in conjunction with the version tag in emmylua doc.extensions
: List of file extensions, used to identify file extensions, for example:[".lua", ".lua.txt"]
.requirePattern
: List of require patterns, this parameter is related to package.path and package.cpath in Lua, for example:["?.lua", "?.lua.txt"]
. It is not necessary to fill in by default, it will be automatically included,["?.lua", "?/init.lua"]
.
Workspace configuration, most workspace configurations support both relative paths and absolute paths.
ignoreDir
: List of ignored directories, used to ignore some directories, for example:["build", "dist"]
.ignoreGlobs
: List of ignored files, used to ignore some files based on regular expressions, for example:["*.log", "*.tmp"]
.library
: List of library directories, used to specify some library files, for example:["/usr/local/lib"]
.workspaceRoots
: List of workspace root directories, used to specify the root directories of the workspace, for example:["Assets/script/Lua"]
. This feature is mainly used to make require work properly. If you need to open the parent directory of the lua main directory, you need to add the relative path of the currently opened directory to the lua main directory here.preloadFileSize
: Preloaded file size, default is1048576
bytes, used to control the size of preloaded files.encoding
: File encoding, default isutf-8
, used for reading files.
paths
: List of resource paths, used to specify the root directories of the resources that need to be loaded, for example:["Assets/settings"]
. Its default value is the currently opened workspace directory. EmmyLua supports file path completion in any string and file path jumping in any string. By configuring this directory, EmmyLua can know which directories are resource directories and provide completion and jumping correctly.
enable
: Whether to enable the CodeLens feature, default istrue
.
requirePath
: Whether to enable strict mode for require, default istrue
. In strict mode, require must start from the specified root directory, otherwise it cannot jump.typeCall
: Whether to enable strict mode for type calls, default istrue
. In strict mode, type calls must have manually written overloads, otherwise it will return unknown. In non-strict mode, type calls will return themselves.