|
| 1 | +# 配置说明 |
| 2 | +To create a `.emmyrc.json` file in the root directory of your workspace, which is used to configure some parameters of EmmyLuaAnalyzer. |
| 3 | + |
| 4 | +The main configuration format is: |
| 5 | +```json |
| 6 | +{ |
| 7 | + "completion": { |
| 8 | + "autoRequire": true, |
| 9 | + "autoRequireFunction": "require", |
| 10 | + "autoRequireNamingConvention": "camelCase", |
| 11 | + "callSnippet": false, |
| 12 | + "postfix": "@" |
| 13 | + }, |
| 14 | + "signature": { |
| 15 | + "detailSignatureHelper": false |
| 16 | + }, |
| 17 | + "diagnostics": { |
| 18 | + "disable": [ |
| 19 | + ], |
| 20 | + "globals": [], |
| 21 | + "globalsRegex": [], |
| 22 | + "severity": { |
| 23 | + }, |
| 24 | + "enables": [ |
| 25 | + ] |
| 26 | + }, |
| 27 | + "hint": { |
| 28 | + "paramHint": true, |
| 29 | + "indexHint": true, |
| 30 | + "localHint": true, |
| 31 | + "overrideHint": true |
| 32 | + }, |
| 33 | + "runtime": { |
| 34 | + "version": "Lua5.4", |
| 35 | + "requireLikeFunction": [], |
| 36 | + "frameworkVersions": [], |
| 37 | + "extensions": [], |
| 38 | + "requirePattern": [] |
| 39 | + }, |
| 40 | + "workspace": { |
| 41 | + "ignoreDir": [ |
| 42 | + |
| 43 | + ], |
| 44 | + "ignoreGlobs": [ |
| 45 | + ], |
| 46 | + "library": [], |
| 47 | + "workspaceRoots": [], |
| 48 | + "preloadFileSize": 1048576, |
| 49 | + "encoding": "" |
| 50 | + }, |
| 51 | + "resource": { |
| 52 | + "paths": [ |
| 53 | + ] |
| 54 | + }, |
| 55 | + "codeLens": { |
| 56 | + "enable": true |
| 57 | + }, |
| 58 | + "strict": { |
| 59 | + "requirePath": false, |
| 60 | + "typeCall": true |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +``` |
| 65 | + |
| 66 | + |
| 67 | +## completion |
| 68 | + |
| 69 | +- `autoRequire`: Whether to automatically complete the require statement, default is `true`. |
| 70 | +- `autoRequireFunction`: The function name used for automatically completing the require statement, default is `require`. |
| 71 | +- `autoRequireNamingConvention`: The naming convention used for automatically completing the require statement, default is `camelCase`, optional values are `camelCase`, `snakeCase`, `pascalCase`. |
| 72 | +- `callSnippet`: Whether to use code snippets for function call completion, default is `false`. |
| 73 | +- `postfix`: The postfix used for completion, default is `@`. However, setting this option is currently ineffective. |
| 74 | + |
| 75 | +## signature |
| 76 | + |
| 77 | +- `detailSignatureHelper`: Whether to display detailed function signature help, default is `false`. |
| 78 | + |
| 79 | +## diagnostics |
| 80 | + |
| 81 | +- `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"`. |
| 82 | +- `globals`: List of global variables. Global variables in this list will not be diagnosed as undefined. |
| 83 | +- `globalsRegex`: List of regular expressions for global variables. Global variables that match the regular expressions will not be diagnosed as undefined. |
| 84 | +- `severity`: Severity of diagnostic messages, for example: `"undefined-global": "warning"`, optional values are `"error"`, `"warning"`, `"information"`, `"hint"`. |
| 85 | +- `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"`. |
| 86 | + |
| 87 | +## hint |
| 88 | + |
| 89 | +- `paramHint`: Whether to display parameter hints, default is `true`. |
| 90 | +- `indexHint`: Whether to display hints when indexing expressions span multiple lines, default is `true`. |
| 91 | +- `localHint`: Whether to display hints for local variables, default is `true`. |
| 92 | +- `overrideHint`: Whether to display hints for overrides, default is `true`. |
| 93 | + |
| 94 | +## runtime |
| 95 | + |
| 96 | +- `version`: Runtime version, default is `Lua5.4`, optional values are `Lua5.1`, `Lua5.2`, `Lua5.3`, `Lua5.4`, `LuaJIT`. |
| 97 | +- `requireLikeFunction`: List of functions similar to require, used to identify functions similar to require, for example: `["import"]`. |
| 98 | +- `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. |
| 99 | +- `extensions`: List of file extensions, used to identify file extensions, for example: `[".lua", ".lua.txt"]`. |
| 100 | +- `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"]`. |
| 101 | + |
| 102 | +## workspace |
| 103 | + |
| 104 | +Workspace configuration, most workspace configurations support both relative paths and absolute paths. |
| 105 | + |
| 106 | +- `ignoreDir`: List of ignored directories, used to ignore some directories, for example: `["build", "dist"]`. |
| 107 | +- `ignoreGlobs`: List of ignored files, used to ignore some files based on regular expressions, for example: `["*.log", "*.tmp"]`. |
| 108 | +- `library`: List of library directories, used to specify some library files, for example: `["/usr/local/lib"]`. |
| 109 | +- `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. |
| 110 | +- `preloadFileSize`: Preloaded file size, default is `1048576` bytes, used to control the size of preloaded files. |
| 111 | +- `encoding`: File encoding, default is `utf-8`, used for reading files. |
| 112 | + |
| 113 | +## resource |
| 114 | + |
| 115 | +- `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. |
| 116 | + |
| 117 | +## codeLens |
| 118 | + |
| 119 | +- `enable`: Whether to enable the CodeLens feature, default is `true`. |
| 120 | + |
| 121 | +## strict |
| 122 | + |
| 123 | +- `requirePath`: Whether to enable strict mode for require, default is `true`. In strict mode, require must start from the specified root directory, otherwise it cannot jump. |
| 124 | +- `typeCall`: Whether to enable strict mode for type calls, default is `true`. In strict mode, type calls must have manually written overloads, otherwise it will return unknown. In non-strict mode, type calls will return themselves. |
0 commit comments