├── .github └── dependabot.yml ├── .gitignore ├── .npmignore ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── coc-sumneko-lua.json ├── esbuild.mjs ├── eslint.config.js ├── examples-for-distributions.md ├── package-lock.json ├── package.json ├── settings.md ├── src ├── commands.ts ├── config.ts ├── ctx.ts ├── downloader.ts ├── index.ts └── neodev.ts ├── tsconfig.json └── update-config.js /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: npm # See documentation for possible values 9 | directory: / # Location of package manifests 10 | schedule: 11 | interval: weekly 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lib 2 | node_modules/ 3 | .vim 4 | *.mpack 5 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | nvim_lua_data 2 | .github 3 | src 4 | scripts 5 | coc-sumneko-lua.json 6 | esbuild.json 7 | .eslintrc.js 8 | esbuild.json 9 | tsconfig.json 10 | yarn.lock 11 | update-config.js 12 | esbuild.json 13 | .vim 14 | eslint.config.js 15 | package-lock.json 16 | esbuild.mjs -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | // Enable the ESlint flat config support 3 | "eslint.experimental.useFlatConfig": true, 4 | 5 | // Disable the default formatter, use eslint instead 6 | "prettier.enable": false, 7 | "editor.formatOnSave": false, 8 | 9 | // Auto fix 10 | "editor.codeActionsOnSave": { 11 | "source.fixAll.eslint": "explicit", 12 | "source.organizeImports": "never" 13 | }, 14 | 15 | // Silent the stylistic rules in you IDE, but still auto fix them 16 | "eslint.rules.customizations": [ 17 | { "rule": "style/*", "severity": "off" }, 18 | { "rule": "format/*", "severity": "off" }, 19 | { "rule": "*-indent", "severity": "off" }, 20 | { "rule": "*-spacing", "severity": "off" }, 21 | { "rule": "*-spaces", "severity": "off" }, 22 | { "rule": "*-order", "severity": "off" }, 23 | { "rule": "*-dangle", "severity": "off" }, 24 | { "rule": "*-newline", "severity": "off" }, 25 | { "rule": "*quotes", "severity": "off" }, 26 | { "rule": "*semi", "severity": "off" } 27 | ], 28 | 29 | // Enable eslint for all supported languages 30 | "eslint.validate": [ 31 | "javascript", 32 | "javascriptreact", 33 | "typescript", 34 | "typescriptreact", 35 | "vue", 36 | "html", 37 | "markdown", 38 | "json", 39 | "jsonc", 40 | "yaml", 41 | "toml" 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 wongxy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # coc-sumneko-lua 2 | 3 | Lua extension using sumneko lua-language-server for coc.nvim 4 | 5 | This extension uses server binaries extracted from [`sumneko/vscode-lua`](https://github.com/sumneko/vscode-lua). 6 | You can also custom the server path([`sumneko-lua.serverDir`](https://github.com/xiyaowong/coc-sumneko-lua/blob/main/settings.md#sumneko-luaserverdir)). 7 | 8 | ## Features 9 | 10 | - Supported features by the server 11 | 12 | ![base](https://user-images.githubusercontent.com/47070852/133086083-a5357ca3-ada6-46d9-953f-f86026c137e4.png) 13 | 14 | - Nvim lua development(check setting `sumneko-lua.enableNvimLuaDev`). Credit: [folke/neodev.nvim](https://github.com/folke/neodev.nvim) 15 | 16 | ![nvim-lua-dev](https://user-images.githubusercontent.com/47070852/133085674-2310670d-6129-4aac-86ea-0e475bf09b25.gif) 17 | 18 | - Inlay-hints provided by coc.nvim. 19 | 20 | ## Install 21 | 22 | `:CocInstall coc-sumneko-lua` 23 | 24 | ## [Settings (Click me)](settings.md) 25 | 26 | ## [Config Examples for Distributions (Currently only NixOS)](examples-for-distributions.md) 27 | 28 | ## Commands 29 | 30 | | Command | Description | 31 | | ---------------------------------------- | ------------------------------------------------------------------------------ | 32 | | `sumneko-lua.install` | Install or update sumneko lua-language-server | 33 | | `sumneko-lua.restart` | Restart server | 34 | | `sumneko-lua.version` | Echo server version | 35 | | `sumneko-lua.checkUpdate` | Check update | 36 | | `sumneko-lua.showTooltip` | Show tooltips | 37 | | `sumneko-lua.insertNvimLuaPluginLibrary` | Insert nvim lua plugin to current workspace library | 38 | | `sumneko-lua.downloadNvimLuaTypes` | **Download/Update** nvim lua types(Clone https://github.com/folke/neodev.nvim) | 39 | 40 | ## Credit 41 | 42 | - [`fannheyward/coc-rust-analyzer`](https://github.com/fannheyward/coc-rust-analyzer) 43 | - [`sumneko/vscode-lua`](https://github.com/sumneko/vscode-lua) 44 | - [`josa42/coc-lua`](https://github.com/josa42/coc-lua) 45 | 46 | ## License 47 | 48 | MIT 49 | 50 | --- 51 | 52 | > This extension is built with [create-coc-extension](https://github.com/fannheyward/create-coc-extension) 53 | -------------------------------------------------------------------------------- /coc-sumneko-lua.json: -------------------------------------------------------------------------------- 1 | { 2 | "sumneko-lua.enable": { 3 | "type": "boolean", 4 | "default": true, 5 | "description": "Enable coc-sumneko-lua extension" 6 | }, 7 | "sumneko-lua.prompt": { 8 | "type": "boolean", 9 | "default": true, 10 | "description": "Prompt when server is not found or when server can be updated" 11 | }, 12 | "sumneko-lua.locale": { 13 | "type": "string", 14 | "default": "en-us", 15 | "enum": ["en-us", "zh-cn", "zh-tw", "pt-br"], 16 | "description": "The localized language used", 17 | "enumDescriptions": ["`\"en-us\"` English", "`\"zh-cn\"` 简体中文", "`\"zh-tw\"` 繁體中文", "`\"pt-br\"` Português"] 18 | }, 19 | "sumneko-lua.logPath": { 20 | "type": "string", 21 | "default": "", 22 | "description": "The log path" 23 | }, 24 | "sumneko-lua.enableNvimLuaDev": { 25 | "type": "boolean", 26 | "default": false, 27 | "description": "Enable the nvim lua development" 28 | }, 29 | "sumneko-lua.checkUpdate": { 30 | "type": "boolean", 31 | "default": true, 32 | "description": "Automatically check for updates after startup(Only one check within 4 hours)" 33 | }, 34 | "sumneko-lua.serverDir": { 35 | "type": "string", 36 | "default": null, 37 | "description": "The server directory which contains: bin/, changelog.md, debugger.lua, locale/, main.lua, meta/, script/. Download and set by default" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /esbuild.mjs: -------------------------------------------------------------------------------- 1 | import * as esbuild from 'esbuild' 2 | 3 | const options = { 4 | entryPoints: ['src/index.ts'], 5 | bundle: true, 6 | minify: true, 7 | sourcemap: process.env.NODE_ENV === 'development', 8 | mainFields: ['module', 'main'], 9 | external: ['coc.nvim'], 10 | platform: 'node', 11 | target: 'node16', 12 | outfile: 'lib/index.js', 13 | } 14 | 15 | if (process.argv.length > 2 && process.argv[2] === '--watch') { 16 | const ctx = await esbuild.context(options) 17 | await ctx.watch() 18 | console.log('watching...') 19 | } 20 | else { 21 | const result = await esbuild.build(options) 22 | if (result.errors.length) 23 | console.error(result.errors) 24 | } 25 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | const wongxy = require('@wongxy/eslint-config').default 2 | 3 | module.exports = wongxy({ 4 | rules: { 5 | 'node/prefer-global/process': 'off', 6 | }, 7 | }) 8 | -------------------------------------------------------------------------------- /examples-for-distributions.md: -------------------------------------------------------------------------------- 1 | # Config Examples for Distributions 2 | 3 | ## NixOS 4 | 5 | `coc-sumneko-lua` (or `lua-language-server`) use `sumneko-lua.serverDir` to store generated metafiles and log. However, `lua-language-server` installed by nix is read-only in NixOS. Therefore just setting `sumneko-lua.serverDir` is not enough in NixOS, some cmd args are also needed to be set. 6 | 7 | Here's an minimal working example: 8 | 9 | `coc-settings.json`: 10 | 11 | ```json 12 | { 13 | "Lua.misc.parameters": [ 14 | "--metapath", 15 | "~/.cache/sumneko_lua/meta", 16 | "--logpath", 17 | "~/.cache/sumneko_lua/log" 18 | ], 19 | "sumneko-lua.serverDir": "${pkgs.lua-language-server}/share/lua-language-server" 20 | } 21 | ``` 22 | 23 | `${pkgs.lua-language-server}` needs to be replaced by real path of `lua-language-server`. And `lua-language-server` used to be called `sumneko-lua-language-server` in `nixpkgs`, maybe you need to use old name. 24 | 25 | If you don't want to generate your coc configuration by nix and don't want to change the absolute path of `lua-language-server` every time updating your `nixpkgs`, you can link `lua-language-server` to somewhere fixed and change last line of configuration to the link target. 26 | 27 | For example, add it to `environment.systemPackages` and change 28 | 29 | - `configuration.nix` 30 | 31 | ``` 32 | { pkgs, ... }: { 33 | environment.systemPackages = [ pkgs.lua-language-server ]; 34 | } 35 | ``` 36 | 37 | - `coc-settings.json` 38 | 39 | ```json 40 | { 41 | "Lua.misc.parameters": [ 42 | "--metapath", 43 | "~/.cache/sumneko_lua/meta", 44 | "--logpath", 45 | "~/.cache/sumneko_lua/log" 46 | ], 47 | "sumneko-lua.serverDir": "/run/current-system/sw/share/lua-language-server" 48 | } 49 | ``` 50 | 51 | ## Others 52 | 53 | Default config should work. 54 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "coc-sumneko-lua", 3 | "version": "0.0.42", 4 | "description": "Lua extension using sumneko lua-language-server for coc.nvim", 5 | "author": "wongxy ", 6 | "license": "MIT", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/xiyaowong/coc-sumneko-lua.git" 10 | }, 11 | "keywords": [ 12 | "coc.nvim" 13 | ], 14 | "main": "lib/index.js", 15 | "engines": { 16 | "coc": "^0.0.80" 17 | }, 18 | "activationEvents": [ 19 | "onLanguage:lua" 20 | ], 21 | "contributes": { 22 | "configuration": { 23 | "type": "object", 24 | "title": "coc-sumneko-lua configuration", 25 | "properties": { 26 | "sumneko-lua.enable": { 27 | "type": "boolean", 28 | "default": true, 29 | "description": "Enable coc-sumneko-lua extension" 30 | }, 31 | "sumneko-lua.prompt": { 32 | "type": "boolean", 33 | "default": true, 34 | "description": "Prompt when server is not found or when server can be updated" 35 | }, 36 | "sumneko-lua.locale": { 37 | "type": "string", 38 | "default": "en-us", 39 | "enum": [ 40 | "en-us", 41 | "zh-cn", 42 | "zh-tw", 43 | "pt-br" 44 | ], 45 | "description": "The localized language used", 46 | "enumDescriptions": [ 47 | "`\"en-us\"` English", 48 | "`\"zh-cn\"` 简体中文", 49 | "`\"zh-tw\"` 繁體中文", 50 | "`\"pt-br\"` Português" 51 | ] 52 | }, 53 | "sumneko-lua.logPath": { 54 | "type": "string", 55 | "default": "", 56 | "description": "The log path" 57 | }, 58 | "sumneko-lua.enableNvimLuaDev": { 59 | "type": "boolean", 60 | "default": false, 61 | "description": "Enable the nvim lua development" 62 | }, 63 | "sumneko-lua.checkUpdate": { 64 | "type": "boolean", 65 | "default": true, 66 | "description": "Automatically check for updates after startup(Only one check within 4 hours)" 67 | }, 68 | "sumneko-lua.serverDir": { 69 | "type": "string", 70 | "default": null, 71 | "description": "The server directory which contains: bin/, changelog.md, debugger.lua, locale/, main.lua, meta/, script/. Download and set by default" 72 | }, 73 | "Lua.addonManager.enable": { 74 | "default": true, 75 | "markdownDescription": "Whether the addon manager is enabled or not.", 76 | "scope": "resource", 77 | "type": "boolean" 78 | }, 79 | "Lua.codeLens.enable": { 80 | "default": false, 81 | "markdownDescription": "Enable code lens.", 82 | "scope": "resource", 83 | "type": "boolean" 84 | }, 85 | "Lua.completion.autoRequire": { 86 | "default": true, 87 | "markdownDescription": "When the input looks like a file name, automatically `require` this file.", 88 | "scope": "resource", 89 | "type": "boolean" 90 | }, 91 | "Lua.completion.callSnippet": { 92 | "default": "Disable", 93 | "enum": [ 94 | "Disable", 95 | "Both", 96 | "Replace" 97 | ], 98 | "markdownDescription": "Shows function call snippets.", 99 | "markdownEnumDescriptions": [ 100 | "Only shows `function name`.", 101 | "Shows `function name` and `call snippet`.", 102 | "Only shows `call snippet.`" 103 | ], 104 | "scope": "resource", 105 | "type": "string" 106 | }, 107 | "Lua.completion.displayContext": { 108 | "default": 0, 109 | "markdownDescription": "Previewing the relevant code snippet of the suggestion may help you understand the usage of the suggestion. The number set indicates the number of intercepted lines in the code fragment. If it is set to `0`, this feature can be disabled.", 110 | "scope": "resource", 111 | "type": "integer" 112 | }, 113 | "Lua.completion.enable": { 114 | "default": true, 115 | "markdownDescription": "Enable completion.", 116 | "scope": "resource", 117 | "type": "boolean" 118 | }, 119 | "Lua.completion.keywordSnippet": { 120 | "default": "Replace", 121 | "enum": [ 122 | "Disable", 123 | "Both", 124 | "Replace" 125 | ], 126 | "markdownDescription": "Shows keyword syntax snippets.", 127 | "markdownEnumDescriptions": [ 128 | "Only shows `keyword`.", 129 | "Shows `keyword` and `syntax snippet`.", 130 | "Only shows `syntax snippet`." 131 | ], 132 | "scope": "resource", 133 | "type": "string" 134 | }, 135 | "Lua.completion.postfix": { 136 | "default": "@", 137 | "markdownDescription": "The symbol used to trigger the postfix suggestion.", 138 | "scope": "resource", 139 | "type": "string" 140 | }, 141 | "Lua.completion.requireSeparator": { 142 | "default": ".", 143 | "markdownDescription": "The separator used when `require`.", 144 | "scope": "resource", 145 | "type": "string" 146 | }, 147 | "Lua.completion.showParams": { 148 | "default": true, 149 | "markdownDescription": "Display parameters in completion list. When the function has multiple definitions, they will be displayed separately.", 150 | "scope": "resource", 151 | "type": "boolean" 152 | }, 153 | "Lua.completion.showWord": { 154 | "default": "Fallback", 155 | "enum": [ 156 | "Enable", 157 | "Fallback", 158 | "Disable" 159 | ], 160 | "markdownDescription": "Show contextual words in suggestions.", 161 | "markdownEnumDescriptions": [ 162 | "Always show context words in suggestions.", 163 | "Contextual words are only displayed when suggestions based on semantics cannot be provided.", 164 | "Do not display context words." 165 | ], 166 | "scope": "resource", 167 | "type": "string" 168 | }, 169 | "Lua.completion.workspaceWord": { 170 | "default": true, 171 | "markdownDescription": "Whether the displayed context word contains the content of other files in the workspace.", 172 | "scope": "resource", 173 | "type": "boolean" 174 | }, 175 | "Lua.diagnostics.disable": { 176 | "default": [], 177 | "items": { 178 | "enum": [ 179 | "action-after-return", 180 | "ambiguity-1", 181 | "ambiguous-syntax", 182 | "args-after-dots", 183 | "assign-type-mismatch", 184 | "await-in-sync", 185 | "block-after-else", 186 | "break-outside", 187 | "cast-local-type", 188 | "cast-type-mismatch", 189 | "circle-doc-class", 190 | "close-non-object", 191 | "code-after-break", 192 | "codestyle-check", 193 | "count-down-loop", 194 | "deprecated", 195 | "different-requires", 196 | "discard-returns", 197 | "doc-field-no-class", 198 | "duplicate-doc-alias", 199 | "duplicate-doc-field", 200 | "duplicate-doc-param", 201 | "duplicate-index", 202 | "duplicate-set-field", 203 | "empty-block", 204 | "err-assign-as-eq", 205 | "err-c-long-comment", 206 | "err-comment-prefix", 207 | "err-do-as-then", 208 | "err-eq-as-assign", 209 | "err-esc", 210 | "err-nonstandard-symbol", 211 | "err-then-as-do", 212 | "exp-in-action", 213 | "global-element", 214 | "global-in-nil-env", 215 | "incomplete-signature-doc", 216 | "index-in-func-name", 217 | "inject-field", 218 | "invisible", 219 | "jump-local-scope", 220 | "keyword", 221 | "local-limit", 222 | "lowercase-global", 223 | "lua-doc-miss-sign", 224 | "luadoc-error-diag-mode", 225 | "luadoc-miss-alias-extends", 226 | "luadoc-miss-alias-name", 227 | "luadoc-miss-arg-name", 228 | "luadoc-miss-cate-name", 229 | "luadoc-miss-class-extends-name", 230 | "luadoc-miss-class-name", 231 | "luadoc-miss-diag-mode", 232 | "luadoc-miss-diag-name", 233 | "luadoc-miss-field-extends", 234 | "luadoc-miss-field-name", 235 | "luadoc-miss-fun-after-overload", 236 | "luadoc-miss-generic-name", 237 | "luadoc-miss-local-name", 238 | "luadoc-miss-module-name", 239 | "luadoc-miss-operator-name", 240 | "luadoc-miss-param-extends", 241 | "luadoc-miss-param-name", 242 | "luadoc-miss-see-name", 243 | "luadoc-miss-sign-name", 244 | "luadoc-miss-symbol", 245 | "luadoc-miss-type-name", 246 | "luadoc-miss-vararg-type", 247 | "luadoc-miss-version", 248 | "malformed-number", 249 | "miss-end", 250 | "miss-esc-x", 251 | "miss-exp", 252 | "miss-exponent", 253 | "miss-field", 254 | "miss-loop-max", 255 | "miss-loop-min", 256 | "miss-method", 257 | "miss-name", 258 | "miss-sep-in-table", 259 | "miss-space-between", 260 | "miss-symbol", 261 | "missing-fields", 262 | "missing-global-doc", 263 | "missing-local-export-doc", 264 | "missing-parameter", 265 | "missing-return", 266 | "missing-return-value", 267 | "name-style-check", 268 | "need-check-nil", 269 | "need-paren", 270 | "nesting-long-mark", 271 | "newfield-call", 272 | "newline-call", 273 | "no-unknown", 274 | "no-visible-label", 275 | "not-yieldable", 276 | "param-type-mismatch", 277 | "redefined-label", 278 | "redefined-local", 279 | "redundant-parameter", 280 | "redundant-return", 281 | "redundant-return-value", 282 | "redundant-value", 283 | "return-type-mismatch", 284 | "set-const", 285 | "spell-check", 286 | "trailing-space", 287 | "unbalanced-assignments", 288 | "undefined-doc-class", 289 | "undefined-doc-name", 290 | "undefined-doc-param", 291 | "undefined-env-child", 292 | "undefined-field", 293 | "undefined-global", 294 | "unexpect-dots", 295 | "unexpect-efunc-name", 296 | "unexpect-lfunc-name", 297 | "unexpect-symbol", 298 | "unicode-name", 299 | "unknown-attribute", 300 | "unknown-cast-variable", 301 | "unknown-diag-code", 302 | "unknown-operator", 303 | "unknown-symbol", 304 | "unreachable-code", 305 | "unsupport-symbol", 306 | "unused-function", 307 | "unused-label", 308 | "unused-local", 309 | "unused-vararg" 310 | ], 311 | "type": "string" 312 | }, 313 | "markdownDescription": "Disabled diagnostic (Use code in hover brackets).", 314 | "scope": "resource", 315 | "type": "array" 316 | }, 317 | "Lua.diagnostics.disableScheme": { 318 | "default": [ 319 | "git" 320 | ], 321 | "items": { 322 | "type": "string" 323 | }, 324 | "markdownDescription": "Do not diagnose Lua files that use the following scheme.", 325 | "scope": "resource", 326 | "type": "array" 327 | }, 328 | "Lua.diagnostics.enable": { 329 | "default": true, 330 | "markdownDescription": "Enable diagnostics.", 331 | "scope": "resource", 332 | "type": "boolean" 333 | }, 334 | "Lua.diagnostics.globals": { 335 | "default": [], 336 | "items": { 337 | "type": "string" 338 | }, 339 | "markdownDescription": "Defined global variables.", 340 | "scope": "resource", 341 | "type": "array" 342 | }, 343 | "Lua.diagnostics.groupFileStatus": { 344 | "additionalProperties": false, 345 | "markdownDescription": "Modify the diagnostic needed file status in a group.\n\n* Opened: only diagnose opened files\n* Any: diagnose all files\n* None: disable this diagnostic\n\n`Fallback` means that diagnostics in this group are controlled by `diagnostics.neededFileStatus` separately.\nOther settings will override individual settings without end of `!`.\n", 346 | "properties": { 347 | "ambiguity": { 348 | "default": "Fallback", 349 | "description": "* ambiguity-1\n* count-down-loop\n* different-requires\n* newfield-call\n* newline-call", 350 | "enum": [ 351 | "Any", 352 | "Opened", 353 | "None", 354 | "Fallback" 355 | ], 356 | "type": "string" 357 | }, 358 | "await": { 359 | "default": "Fallback", 360 | "description": "* await-in-sync\n* not-yieldable", 361 | "enum": [ 362 | "Any", 363 | "Opened", 364 | "None", 365 | "Fallback" 366 | ], 367 | "type": "string" 368 | }, 369 | "codestyle": { 370 | "default": "Fallback", 371 | "description": "* codestyle-check\n* name-style-check\n* spell-check", 372 | "enum": [ 373 | "Any", 374 | "Opened", 375 | "None", 376 | "Fallback" 377 | ], 378 | "type": "string" 379 | }, 380 | "conventions": { 381 | "default": "Fallback", 382 | "description": "* global-element", 383 | "enum": [ 384 | "Any", 385 | "Opened", 386 | "None", 387 | "Fallback" 388 | ], 389 | "type": "string" 390 | }, 391 | "duplicate": { 392 | "default": "Fallback", 393 | "description": "* duplicate-index\n* duplicate-set-field", 394 | "enum": [ 395 | "Any", 396 | "Opened", 397 | "None", 398 | "Fallback" 399 | ], 400 | "type": "string" 401 | }, 402 | "global": { 403 | "default": "Fallback", 404 | "description": "* global-in-nil-env\n* lowercase-global\n* undefined-env-child\n* undefined-global", 405 | "enum": [ 406 | "Any", 407 | "Opened", 408 | "None", 409 | "Fallback" 410 | ], 411 | "type": "string" 412 | }, 413 | "luadoc": { 414 | "default": "Fallback", 415 | "description": "* circle-doc-class\n* doc-field-no-class\n* duplicate-doc-alias\n* duplicate-doc-field\n* duplicate-doc-param\n* incomplete-signature-doc\n* missing-global-doc\n* missing-local-export-doc\n* undefined-doc-class\n* undefined-doc-name\n* undefined-doc-param\n* unknown-cast-variable\n* unknown-diag-code\n* unknown-operator", 416 | "enum": [ 417 | "Any", 418 | "Opened", 419 | "None", 420 | "Fallback" 421 | ], 422 | "type": "string" 423 | }, 424 | "redefined": { 425 | "default": "Fallback", 426 | "description": "* redefined-local", 427 | "enum": [ 428 | "Any", 429 | "Opened", 430 | "None", 431 | "Fallback" 432 | ], 433 | "type": "string" 434 | }, 435 | "strict": { 436 | "default": "Fallback", 437 | "description": "* close-non-object\n* deprecated\n* discard-returns\n* invisible", 438 | "enum": [ 439 | "Any", 440 | "Opened", 441 | "None", 442 | "Fallback" 443 | ], 444 | "type": "string" 445 | }, 446 | "strong": { 447 | "default": "Fallback", 448 | "description": "* no-unknown", 449 | "enum": [ 450 | "Any", 451 | "Opened", 452 | "None", 453 | "Fallback" 454 | ], 455 | "type": "string" 456 | }, 457 | "type-check": { 458 | "default": "Fallback", 459 | "description": "* assign-type-mismatch\n* cast-local-type\n* cast-type-mismatch\n* inject-field\n* need-check-nil\n* param-type-mismatch\n* return-type-mismatch\n* undefined-field", 460 | "enum": [ 461 | "Any", 462 | "Opened", 463 | "None", 464 | "Fallback" 465 | ], 466 | "type": "string" 467 | }, 468 | "unbalanced": { 469 | "default": "Fallback", 470 | "description": "* missing-fields\n* missing-parameter\n* missing-return\n* missing-return-value\n* redundant-parameter\n* redundant-return-value\n* redundant-value\n* unbalanced-assignments", 471 | "enum": [ 472 | "Any", 473 | "Opened", 474 | "None", 475 | "Fallback" 476 | ], 477 | "type": "string" 478 | }, 479 | "unused": { 480 | "default": "Fallback", 481 | "description": "* code-after-break\n* empty-block\n* redundant-return\n* trailing-space\n* unreachable-code\n* unused-function\n* unused-label\n* unused-local\n* unused-vararg", 482 | "enum": [ 483 | "Any", 484 | "Opened", 485 | "None", 486 | "Fallback" 487 | ], 488 | "type": "string" 489 | } 490 | }, 491 | "scope": "resource", 492 | "title": "groupFileStatus", 493 | "type": "object" 494 | }, 495 | "Lua.diagnostics.groupSeverity": { 496 | "additionalProperties": false, 497 | "markdownDescription": "Modify the diagnostic severity in a group.\n`Fallback` means that diagnostics in this group are controlled by `diagnostics.severity` separately.\nOther settings will override individual settings without end of `!`.\n", 498 | "properties": { 499 | "ambiguity": { 500 | "default": "Fallback", 501 | "description": "* ambiguity-1\n* count-down-loop\n* different-requires\n* newfield-call\n* newline-call", 502 | "enum": [ 503 | "Error", 504 | "Warning", 505 | "Information", 506 | "Hint", 507 | "Fallback" 508 | ], 509 | "type": "string" 510 | }, 511 | "await": { 512 | "default": "Fallback", 513 | "description": "* await-in-sync\n* not-yieldable", 514 | "enum": [ 515 | "Error", 516 | "Warning", 517 | "Information", 518 | "Hint", 519 | "Fallback" 520 | ], 521 | "type": "string" 522 | }, 523 | "codestyle": { 524 | "default": "Fallback", 525 | "description": "* codestyle-check\n* name-style-check\n* spell-check", 526 | "enum": [ 527 | "Error", 528 | "Warning", 529 | "Information", 530 | "Hint", 531 | "Fallback" 532 | ], 533 | "type": "string" 534 | }, 535 | "conventions": { 536 | "default": "Fallback", 537 | "description": "* global-element", 538 | "enum": [ 539 | "Error", 540 | "Warning", 541 | "Information", 542 | "Hint", 543 | "Fallback" 544 | ], 545 | "type": "string" 546 | }, 547 | "duplicate": { 548 | "default": "Fallback", 549 | "description": "* duplicate-index\n* duplicate-set-field", 550 | "enum": [ 551 | "Error", 552 | "Warning", 553 | "Information", 554 | "Hint", 555 | "Fallback" 556 | ], 557 | "type": "string" 558 | }, 559 | "global": { 560 | "default": "Fallback", 561 | "description": "* global-in-nil-env\n* lowercase-global\n* undefined-env-child\n* undefined-global", 562 | "enum": [ 563 | "Error", 564 | "Warning", 565 | "Information", 566 | "Hint", 567 | "Fallback" 568 | ], 569 | "type": "string" 570 | }, 571 | "luadoc": { 572 | "default": "Fallback", 573 | "description": "* circle-doc-class\n* doc-field-no-class\n* duplicate-doc-alias\n* duplicate-doc-field\n* duplicate-doc-param\n* incomplete-signature-doc\n* missing-global-doc\n* missing-local-export-doc\n* undefined-doc-class\n* undefined-doc-name\n* undefined-doc-param\n* unknown-cast-variable\n* unknown-diag-code\n* unknown-operator", 574 | "enum": [ 575 | "Error", 576 | "Warning", 577 | "Information", 578 | "Hint", 579 | "Fallback" 580 | ], 581 | "type": "string" 582 | }, 583 | "redefined": { 584 | "default": "Fallback", 585 | "description": "* redefined-local", 586 | "enum": [ 587 | "Error", 588 | "Warning", 589 | "Information", 590 | "Hint", 591 | "Fallback" 592 | ], 593 | "type": "string" 594 | }, 595 | "strict": { 596 | "default": "Fallback", 597 | "description": "* close-non-object\n* deprecated\n* discard-returns\n* invisible", 598 | "enum": [ 599 | "Error", 600 | "Warning", 601 | "Information", 602 | "Hint", 603 | "Fallback" 604 | ], 605 | "type": "string" 606 | }, 607 | "strong": { 608 | "default": "Fallback", 609 | "description": "* no-unknown", 610 | "enum": [ 611 | "Error", 612 | "Warning", 613 | "Information", 614 | "Hint", 615 | "Fallback" 616 | ], 617 | "type": "string" 618 | }, 619 | "type-check": { 620 | "default": "Fallback", 621 | "description": "* assign-type-mismatch\n* cast-local-type\n* cast-type-mismatch\n* inject-field\n* need-check-nil\n* param-type-mismatch\n* return-type-mismatch\n* undefined-field", 622 | "enum": [ 623 | "Error", 624 | "Warning", 625 | "Information", 626 | "Hint", 627 | "Fallback" 628 | ], 629 | "type": "string" 630 | }, 631 | "unbalanced": { 632 | "default": "Fallback", 633 | "description": "* missing-fields\n* missing-parameter\n* missing-return\n* missing-return-value\n* redundant-parameter\n* redundant-return-value\n* redundant-value\n* unbalanced-assignments", 634 | "enum": [ 635 | "Error", 636 | "Warning", 637 | "Information", 638 | "Hint", 639 | "Fallback" 640 | ], 641 | "type": "string" 642 | }, 643 | "unused": { 644 | "default": "Fallback", 645 | "description": "* code-after-break\n* empty-block\n* redundant-return\n* trailing-space\n* unreachable-code\n* unused-function\n* unused-label\n* unused-local\n* unused-vararg", 646 | "enum": [ 647 | "Error", 648 | "Warning", 649 | "Information", 650 | "Hint", 651 | "Fallback" 652 | ], 653 | "type": "string" 654 | } 655 | }, 656 | "scope": "resource", 657 | "title": "groupSeverity", 658 | "type": "object" 659 | }, 660 | "Lua.diagnostics.ignoredFiles": { 661 | "default": "Opened", 662 | "enum": [ 663 | "Enable", 664 | "Opened", 665 | "Disable" 666 | ], 667 | "markdownDescription": "How to diagnose ignored files.", 668 | "markdownEnumDescriptions": [ 669 | "Always diagnose these files.", 670 | "Only when these files are opened will it be diagnosed.", 671 | "These files are not diagnosed." 672 | ], 673 | "scope": "resource", 674 | "type": "string" 675 | }, 676 | "Lua.diagnostics.libraryFiles": { 677 | "default": "Opened", 678 | "enum": [ 679 | "Enable", 680 | "Opened", 681 | "Disable" 682 | ], 683 | "markdownDescription": "How to diagnose files loaded via `Lua.workspace.library`.", 684 | "markdownEnumDescriptions": [ 685 | "Always diagnose these files.", 686 | "Only when these files are opened will it be diagnosed.", 687 | "These files are not diagnosed." 688 | ], 689 | "scope": "resource", 690 | "type": "string" 691 | }, 692 | "Lua.diagnostics.neededFileStatus": { 693 | "additionalProperties": false, 694 | "markdownDescription": "* Opened: only diagnose opened files\n* Any: diagnose all files\n* None: disable this diagnostic\n\nEnd with `!` means override the group setting `diagnostics.groupFileStatus`.\n", 695 | "properties": { 696 | "ambiguity-1": { 697 | "default": "Any", 698 | "description": "Enable ambiguous operator precedence diagnostics. For example, the `num or 0 + 1` expression will be suggested `(num or 0) + 1` instead.", 699 | "enum": [ 700 | "Any", 701 | "Opened", 702 | "None", 703 | "Any!", 704 | "Opened!", 705 | "None!" 706 | ], 707 | "type": "string" 708 | }, 709 | "assign-type-mismatch": { 710 | "default": "Opened", 711 | "description": "Enable diagnostics for assignments in which the value's type does not match the type of the assigned variable.", 712 | "enum": [ 713 | "Any", 714 | "Opened", 715 | "None", 716 | "Any!", 717 | "Opened!", 718 | "None!" 719 | ], 720 | "type": "string" 721 | }, 722 | "await-in-sync": { 723 | "default": "None", 724 | "description": "Enable diagnostics for calls of asynchronous functions within a synchronous function.", 725 | "enum": [ 726 | "Any", 727 | "Opened", 728 | "None", 729 | "Any!", 730 | "Opened!", 731 | "None!" 732 | ], 733 | "type": "string" 734 | }, 735 | "cast-local-type": { 736 | "default": "Opened", 737 | "description": "Enable diagnostics for casts of local variables where the target type does not match the defined type.", 738 | "enum": [ 739 | "Any", 740 | "Opened", 741 | "None", 742 | "Any!", 743 | "Opened!", 744 | "None!" 745 | ], 746 | "type": "string" 747 | }, 748 | "cast-type-mismatch": { 749 | "default": "Opened", 750 | "description": "Enable diagnostics for casts where the target type does not match the initial type.", 751 | "enum": [ 752 | "Any", 753 | "Opened", 754 | "None", 755 | "Any!", 756 | "Opened!", 757 | "None!" 758 | ], 759 | "type": "string" 760 | }, 761 | "circle-doc-class": { 762 | "default": "Any", 763 | "description": "TODO: Needs documentation", 764 | "enum": [ 765 | "Any", 766 | "Opened", 767 | "None", 768 | "Any!", 769 | "Opened!", 770 | "None!" 771 | ], 772 | "type": "string" 773 | }, 774 | "close-non-object": { 775 | "default": "Any", 776 | "description": "Enable diagnostics for attempts to close a variable with a non-object.", 777 | "enum": [ 778 | "Any", 779 | "Opened", 780 | "None", 781 | "Any!", 782 | "Opened!", 783 | "None!" 784 | ], 785 | "type": "string" 786 | }, 787 | "code-after-break": { 788 | "default": "Opened", 789 | "description": "Enable diagnostics for code placed after a break statement in a loop.", 790 | "enum": [ 791 | "Any", 792 | "Opened", 793 | "None", 794 | "Any!", 795 | "Opened!", 796 | "None!" 797 | ], 798 | "type": "string" 799 | }, 800 | "codestyle-check": { 801 | "default": "None", 802 | "description": "Enable diagnostics for incorrectly styled lines.", 803 | "enum": [ 804 | "Any", 805 | "Opened", 806 | "None", 807 | "Any!", 808 | "Opened!", 809 | "None!" 810 | ], 811 | "type": "string" 812 | }, 813 | "count-down-loop": { 814 | "default": "Any", 815 | "description": "Enable diagnostics for `for` loops which will never reach their max/limit because the loop is incrementing instead of decrementing.", 816 | "enum": [ 817 | "Any", 818 | "Opened", 819 | "None", 820 | "Any!", 821 | "Opened!", 822 | "None!" 823 | ], 824 | "type": "string" 825 | }, 826 | "deprecated": { 827 | "default": "Any", 828 | "description": "Enable diagnostics to highlight deprecated API.", 829 | "enum": [ 830 | "Any", 831 | "Opened", 832 | "None", 833 | "Any!", 834 | "Opened!", 835 | "None!" 836 | ], 837 | "type": "string" 838 | }, 839 | "different-requires": { 840 | "default": "Any", 841 | "description": "Enable diagnostics for files which are required by two different paths.", 842 | "enum": [ 843 | "Any", 844 | "Opened", 845 | "None", 846 | "Any!", 847 | "Opened!", 848 | "None!" 849 | ], 850 | "type": "string" 851 | }, 852 | "discard-returns": { 853 | "default": "Any", 854 | "description": "Enable diagnostics for calls of functions annotated with `---@nodiscard` where the return values are ignored.", 855 | "enum": [ 856 | "Any", 857 | "Opened", 858 | "None", 859 | "Any!", 860 | "Opened!", 861 | "None!" 862 | ], 863 | "type": "string" 864 | }, 865 | "doc-field-no-class": { 866 | "default": "Any", 867 | "description": "Enable diagnostics to highlight a field annotation without a defining class annotation.", 868 | "enum": [ 869 | "Any", 870 | "Opened", 871 | "None", 872 | "Any!", 873 | "Opened!", 874 | "None!" 875 | ], 876 | "type": "string" 877 | }, 878 | "duplicate-doc-alias": { 879 | "default": "Any", 880 | "description": "Enable diagnostics for a duplicated alias annotation name.", 881 | "enum": [ 882 | "Any", 883 | "Opened", 884 | "None", 885 | "Any!", 886 | "Opened!", 887 | "None!" 888 | ], 889 | "type": "string" 890 | }, 891 | "duplicate-doc-field": { 892 | "default": "Any", 893 | "description": "Enable diagnostics for a duplicated field annotation name.", 894 | "enum": [ 895 | "Any", 896 | "Opened", 897 | "None", 898 | "Any!", 899 | "Opened!", 900 | "None!" 901 | ], 902 | "type": "string" 903 | }, 904 | "duplicate-doc-param": { 905 | "default": "Any", 906 | "description": "Enable diagnostics for a duplicated param annotation name.", 907 | "enum": [ 908 | "Any", 909 | "Opened", 910 | "None", 911 | "Any!", 912 | "Opened!", 913 | "None!" 914 | ], 915 | "type": "string" 916 | }, 917 | "duplicate-index": { 918 | "default": "Any", 919 | "description": "Enable duplicate table index diagnostics.", 920 | "enum": [ 921 | "Any", 922 | "Opened", 923 | "None", 924 | "Any!", 925 | "Opened!", 926 | "None!" 927 | ], 928 | "type": "string" 929 | }, 930 | "duplicate-set-field": { 931 | "default": "Opened", 932 | "description": "Enable diagnostics for setting the same field in a class more than once.", 933 | "enum": [ 934 | "Any", 935 | "Opened", 936 | "None", 937 | "Any!", 938 | "Opened!", 939 | "None!" 940 | ], 941 | "type": "string" 942 | }, 943 | "empty-block": { 944 | "default": "Opened", 945 | "description": "Enable empty code block diagnostics.", 946 | "enum": [ 947 | "Any", 948 | "Opened", 949 | "None", 950 | "Any!", 951 | "Opened!", 952 | "None!" 953 | ], 954 | "type": "string" 955 | }, 956 | "global-element": { 957 | "default": "None", 958 | "description": "Enable diagnostics to warn about global elements.", 959 | "enum": [ 960 | "Any", 961 | "Opened", 962 | "None", 963 | "Any!", 964 | "Opened!", 965 | "None!" 966 | ], 967 | "type": "string" 968 | }, 969 | "global-in-nil-env": { 970 | "default": "Any", 971 | "description": "Enable cannot use global variables ( `_ENV` is set to `nil`) diagnostics.", 972 | "enum": [ 973 | "Any", 974 | "Opened", 975 | "None", 976 | "Any!", 977 | "Opened!", 978 | "None!" 979 | ], 980 | "type": "string" 981 | }, 982 | "incomplete-signature-doc": { 983 | "default": "None", 984 | "description": "Incomplete @param or @return annotations for functions.", 985 | "enum": [ 986 | "Any", 987 | "Opened", 988 | "None", 989 | "Any!", 990 | "Opened!", 991 | "None!" 992 | ], 993 | "type": "string" 994 | }, 995 | "inject-field": { 996 | "default": "Opened", 997 | "description": "TODO: Needs documentation", 998 | "enum": [ 999 | "Any", 1000 | "Opened", 1001 | "None", 1002 | "Any!", 1003 | "Opened!", 1004 | "None!" 1005 | ], 1006 | "type": "string" 1007 | }, 1008 | "invisible": { 1009 | "default": "Any", 1010 | "description": "Enable diagnostics for accesses to fields which are invisible.", 1011 | "enum": [ 1012 | "Any", 1013 | "Opened", 1014 | "None", 1015 | "Any!", 1016 | "Opened!", 1017 | "None!" 1018 | ], 1019 | "type": "string" 1020 | }, 1021 | "lowercase-global": { 1022 | "default": "Any", 1023 | "description": "Enable lowercase global variable definition diagnostics.", 1024 | "enum": [ 1025 | "Any", 1026 | "Opened", 1027 | "None", 1028 | "Any!", 1029 | "Opened!", 1030 | "None!" 1031 | ], 1032 | "type": "string" 1033 | }, 1034 | "missing-fields": { 1035 | "default": "Any", 1036 | "description": "TODO: Needs documentation", 1037 | "enum": [ 1038 | "Any", 1039 | "Opened", 1040 | "None", 1041 | "Any!", 1042 | "Opened!", 1043 | "None!" 1044 | ], 1045 | "type": "string" 1046 | }, 1047 | "missing-global-doc": { 1048 | "default": "None", 1049 | "description": "Missing annotations for globals! Global functions must have a comment and annotations for all parameters and return values.", 1050 | "enum": [ 1051 | "Any", 1052 | "Opened", 1053 | "None", 1054 | "Any!", 1055 | "Opened!", 1056 | "None!" 1057 | ], 1058 | "type": "string" 1059 | }, 1060 | "missing-local-export-doc": { 1061 | "default": "None", 1062 | "description": "Missing annotations for exported locals! Exported local functions must have a comment and annotations for all parameters and return values.", 1063 | "enum": [ 1064 | "Any", 1065 | "Opened", 1066 | "None", 1067 | "Any!", 1068 | "Opened!", 1069 | "None!" 1070 | ], 1071 | "type": "string" 1072 | }, 1073 | "missing-parameter": { 1074 | "default": "Any", 1075 | "description": "Enable diagnostics for function calls where the number of arguments is less than the number of annotated function parameters.", 1076 | "enum": [ 1077 | "Any", 1078 | "Opened", 1079 | "None", 1080 | "Any!", 1081 | "Opened!", 1082 | "None!" 1083 | ], 1084 | "type": "string" 1085 | }, 1086 | "missing-return": { 1087 | "default": "Any", 1088 | "description": "Enable diagnostics for functions with return annotations which have no return statement.", 1089 | "enum": [ 1090 | "Any", 1091 | "Opened", 1092 | "None", 1093 | "Any!", 1094 | "Opened!", 1095 | "None!" 1096 | ], 1097 | "type": "string" 1098 | }, 1099 | "missing-return-value": { 1100 | "default": "Any", 1101 | "description": "Enable diagnostics for return statements without values although the containing function declares returns.", 1102 | "enum": [ 1103 | "Any", 1104 | "Opened", 1105 | "None", 1106 | "Any!", 1107 | "Opened!", 1108 | "None!" 1109 | ], 1110 | "type": "string" 1111 | }, 1112 | "name-style-check": { 1113 | "default": "None", 1114 | "description": "Enable diagnostics for name style.", 1115 | "enum": [ 1116 | "Any", 1117 | "Opened", 1118 | "None", 1119 | "Any!", 1120 | "Opened!", 1121 | "None!" 1122 | ], 1123 | "type": "string" 1124 | }, 1125 | "need-check-nil": { 1126 | "default": "Opened", 1127 | "description": "Enable diagnostics for variable usages if `nil` or an optional (potentially `nil`) value was assigned to the variable before.", 1128 | "enum": [ 1129 | "Any", 1130 | "Opened", 1131 | "None", 1132 | "Any!", 1133 | "Opened!", 1134 | "None!" 1135 | ], 1136 | "type": "string" 1137 | }, 1138 | "newfield-call": { 1139 | "default": "Any", 1140 | "description": "Enable newfield call diagnostics. It is raised when the parenthesis of a function call appear on the following line when defining a field in a table.", 1141 | "enum": [ 1142 | "Any", 1143 | "Opened", 1144 | "None", 1145 | "Any!", 1146 | "Opened!", 1147 | "None!" 1148 | ], 1149 | "type": "string" 1150 | }, 1151 | "newline-call": { 1152 | "default": "Any", 1153 | "description": "Enable newline call diagnostics. Is's raised when a line starting with `(` is encountered, which is syntactically parsed as a function call on the previous line.", 1154 | "enum": [ 1155 | "Any", 1156 | "Opened", 1157 | "None", 1158 | "Any!", 1159 | "Opened!", 1160 | "None!" 1161 | ], 1162 | "type": "string" 1163 | }, 1164 | "no-unknown": { 1165 | "default": "None", 1166 | "description": "Enable diagnostics for cases in which the type cannot be inferred.", 1167 | "enum": [ 1168 | "Any", 1169 | "Opened", 1170 | "None", 1171 | "Any!", 1172 | "Opened!", 1173 | "None!" 1174 | ], 1175 | "type": "string" 1176 | }, 1177 | "not-yieldable": { 1178 | "default": "None", 1179 | "description": "Enable diagnostics for calls to `coroutine.yield()` when it is not permitted.", 1180 | "enum": [ 1181 | "Any", 1182 | "Opened", 1183 | "None", 1184 | "Any!", 1185 | "Opened!", 1186 | "None!" 1187 | ], 1188 | "type": "string" 1189 | }, 1190 | "param-type-mismatch": { 1191 | "default": "Opened", 1192 | "description": "Enable diagnostics for function calls where the type of a provided parameter does not match the type of the annotated function definition.", 1193 | "enum": [ 1194 | "Any", 1195 | "Opened", 1196 | "None", 1197 | "Any!", 1198 | "Opened!", 1199 | "None!" 1200 | ], 1201 | "type": "string" 1202 | }, 1203 | "redefined-local": { 1204 | "default": "Opened", 1205 | "description": "Enable redefined local variable diagnostics.", 1206 | "enum": [ 1207 | "Any", 1208 | "Opened", 1209 | "None", 1210 | "Any!", 1211 | "Opened!", 1212 | "None!" 1213 | ], 1214 | "type": "string" 1215 | }, 1216 | "redundant-parameter": { 1217 | "default": "Any", 1218 | "description": "Enable redundant function parameter diagnostics.", 1219 | "enum": [ 1220 | "Any", 1221 | "Opened", 1222 | "None", 1223 | "Any!", 1224 | "Opened!", 1225 | "None!" 1226 | ], 1227 | "type": "string" 1228 | }, 1229 | "redundant-return": { 1230 | "default": "Opened", 1231 | "description": "Enable diagnostics for return statements which are not needed because the function would exit on its own.", 1232 | "enum": [ 1233 | "Any", 1234 | "Opened", 1235 | "None", 1236 | "Any!", 1237 | "Opened!", 1238 | "None!" 1239 | ], 1240 | "type": "string" 1241 | }, 1242 | "redundant-return-value": { 1243 | "default": "Any", 1244 | "description": "Enable diagnostics for return statements which return an extra value which is not specified by a return annotation.", 1245 | "enum": [ 1246 | "Any", 1247 | "Opened", 1248 | "None", 1249 | "Any!", 1250 | "Opened!", 1251 | "None!" 1252 | ], 1253 | "type": "string" 1254 | }, 1255 | "redundant-value": { 1256 | "default": "Any", 1257 | "description": "Enable the redundant values assigned diagnostics. It's raised during assignment operation, when the number of values is higher than the number of objects being assigned.", 1258 | "enum": [ 1259 | "Any", 1260 | "Opened", 1261 | "None", 1262 | "Any!", 1263 | "Opened!", 1264 | "None!" 1265 | ], 1266 | "type": "string" 1267 | }, 1268 | "return-type-mismatch": { 1269 | "default": "Opened", 1270 | "description": "Enable diagnostics for return values whose type does not match the type declared in the corresponding return annotation.", 1271 | "enum": [ 1272 | "Any", 1273 | "Opened", 1274 | "None", 1275 | "Any!", 1276 | "Opened!", 1277 | "None!" 1278 | ], 1279 | "type": "string" 1280 | }, 1281 | "spell-check": { 1282 | "default": "None", 1283 | "description": "Enable diagnostics for typos in strings.", 1284 | "enum": [ 1285 | "Any", 1286 | "Opened", 1287 | "None", 1288 | "Any!", 1289 | "Opened!", 1290 | "None!" 1291 | ], 1292 | "type": "string" 1293 | }, 1294 | "trailing-space": { 1295 | "default": "Opened", 1296 | "description": "Enable trailing space diagnostics.", 1297 | "enum": [ 1298 | "Any", 1299 | "Opened", 1300 | "None", 1301 | "Any!", 1302 | "Opened!", 1303 | "None!" 1304 | ], 1305 | "type": "string" 1306 | }, 1307 | "unbalanced-assignments": { 1308 | "default": "Any", 1309 | "description": "Enable diagnostics on multiple assignments if not all variables obtain a value (e.g., `local x,y = 1`).", 1310 | "enum": [ 1311 | "Any", 1312 | "Opened", 1313 | "None", 1314 | "Any!", 1315 | "Opened!", 1316 | "None!" 1317 | ], 1318 | "type": "string" 1319 | }, 1320 | "undefined-doc-class": { 1321 | "default": "Any", 1322 | "description": "Enable diagnostics for class annotations in which an undefined class is referenced.", 1323 | "enum": [ 1324 | "Any", 1325 | "Opened", 1326 | "None", 1327 | "Any!", 1328 | "Opened!", 1329 | "None!" 1330 | ], 1331 | "type": "string" 1332 | }, 1333 | "undefined-doc-name": { 1334 | "default": "Any", 1335 | "description": "Enable diagnostics for type annotations referencing an undefined type or alias.", 1336 | "enum": [ 1337 | "Any", 1338 | "Opened", 1339 | "None", 1340 | "Any!", 1341 | "Opened!", 1342 | "None!" 1343 | ], 1344 | "type": "string" 1345 | }, 1346 | "undefined-doc-param": { 1347 | "default": "Any", 1348 | "description": "Enable diagnostics for cases in which a parameter annotation is given without declaring the parameter in the function definition.", 1349 | "enum": [ 1350 | "Any", 1351 | "Opened", 1352 | "None", 1353 | "Any!", 1354 | "Opened!", 1355 | "None!" 1356 | ], 1357 | "type": "string" 1358 | }, 1359 | "undefined-env-child": { 1360 | "default": "Any", 1361 | "description": "Enable undefined environment variable diagnostics. It's raised when `_ENV` table is set to a new literal table, but the used global variable is no longer present in the global environment.", 1362 | "enum": [ 1363 | "Any", 1364 | "Opened", 1365 | "None", 1366 | "Any!", 1367 | "Opened!", 1368 | "None!" 1369 | ], 1370 | "type": "string" 1371 | }, 1372 | "undefined-field": { 1373 | "default": "Opened", 1374 | "description": "Enable diagnostics for cases in which an undefined field of a variable is read.", 1375 | "enum": [ 1376 | "Any", 1377 | "Opened", 1378 | "None", 1379 | "Any!", 1380 | "Opened!", 1381 | "None!" 1382 | ], 1383 | "type": "string" 1384 | }, 1385 | "undefined-global": { 1386 | "default": "Any", 1387 | "description": "Enable undefined global variable diagnostics.", 1388 | "enum": [ 1389 | "Any", 1390 | "Opened", 1391 | "None", 1392 | "Any!", 1393 | "Opened!", 1394 | "None!" 1395 | ], 1396 | "type": "string" 1397 | }, 1398 | "unknown-cast-variable": { 1399 | "default": "Any", 1400 | "description": "Enable diagnostics for casts of undefined variables.", 1401 | "enum": [ 1402 | "Any", 1403 | "Opened", 1404 | "None", 1405 | "Any!", 1406 | "Opened!", 1407 | "None!" 1408 | ], 1409 | "type": "string" 1410 | }, 1411 | "unknown-diag-code": { 1412 | "default": "Any", 1413 | "description": "Enable diagnostics in cases in which an unknown diagnostics code is entered.", 1414 | "enum": [ 1415 | "Any", 1416 | "Opened", 1417 | "None", 1418 | "Any!", 1419 | "Opened!", 1420 | "None!" 1421 | ], 1422 | "type": "string" 1423 | }, 1424 | "unknown-operator": { 1425 | "default": "Any", 1426 | "description": "Enable diagnostics for unknown operators.", 1427 | "enum": [ 1428 | "Any", 1429 | "Opened", 1430 | "None", 1431 | "Any!", 1432 | "Opened!", 1433 | "None!" 1434 | ], 1435 | "type": "string" 1436 | }, 1437 | "unreachable-code": { 1438 | "default": "Opened", 1439 | "description": "Enable diagnostics for unreachable code.", 1440 | "enum": [ 1441 | "Any", 1442 | "Opened", 1443 | "None", 1444 | "Any!", 1445 | "Opened!", 1446 | "None!" 1447 | ], 1448 | "type": "string" 1449 | }, 1450 | "unused-function": { 1451 | "default": "Opened", 1452 | "description": "Enable unused function diagnostics.", 1453 | "enum": [ 1454 | "Any", 1455 | "Opened", 1456 | "None", 1457 | "Any!", 1458 | "Opened!", 1459 | "None!" 1460 | ], 1461 | "type": "string" 1462 | }, 1463 | "unused-label": { 1464 | "default": "Opened", 1465 | "description": "Enable unused label diagnostics.", 1466 | "enum": [ 1467 | "Any", 1468 | "Opened", 1469 | "None", 1470 | "Any!", 1471 | "Opened!", 1472 | "None!" 1473 | ], 1474 | "type": "string" 1475 | }, 1476 | "unused-local": { 1477 | "default": "Opened", 1478 | "description": "Enable unused local variable diagnostics.", 1479 | "enum": [ 1480 | "Any", 1481 | "Opened", 1482 | "None", 1483 | "Any!", 1484 | "Opened!", 1485 | "None!" 1486 | ], 1487 | "type": "string" 1488 | }, 1489 | "unused-vararg": { 1490 | "default": "Opened", 1491 | "description": "Enable unused vararg diagnostics.", 1492 | "enum": [ 1493 | "Any", 1494 | "Opened", 1495 | "None", 1496 | "Any!", 1497 | "Opened!", 1498 | "None!" 1499 | ], 1500 | "type": "string" 1501 | } 1502 | }, 1503 | "scope": "resource", 1504 | "title": "neededFileStatus", 1505 | "type": "object" 1506 | }, 1507 | "Lua.diagnostics.severity": { 1508 | "additionalProperties": false, 1509 | "markdownDescription": "Modify the diagnostic severity.\n\nEnd with `!` means override the group setting `diagnostics.groupSeverity`.\n", 1510 | "properties": { 1511 | "ambiguity-1": { 1512 | "default": "Warning", 1513 | "description": "Enable ambiguous operator precedence diagnostics. For example, the `num or 0 + 1` expression will be suggested `(num or 0) + 1` instead.", 1514 | "enum": [ 1515 | "Error", 1516 | "Warning", 1517 | "Information", 1518 | "Hint", 1519 | "Error!", 1520 | "Warning!", 1521 | "Information!", 1522 | "Hint!" 1523 | ], 1524 | "type": "string" 1525 | }, 1526 | "assign-type-mismatch": { 1527 | "default": "Warning", 1528 | "description": "Enable diagnostics for assignments in which the value's type does not match the type of the assigned variable.", 1529 | "enum": [ 1530 | "Error", 1531 | "Warning", 1532 | "Information", 1533 | "Hint", 1534 | "Error!", 1535 | "Warning!", 1536 | "Information!", 1537 | "Hint!" 1538 | ], 1539 | "type": "string" 1540 | }, 1541 | "await-in-sync": { 1542 | "default": "Warning", 1543 | "description": "Enable diagnostics for calls of asynchronous functions within a synchronous function.", 1544 | "enum": [ 1545 | "Error", 1546 | "Warning", 1547 | "Information", 1548 | "Hint", 1549 | "Error!", 1550 | "Warning!", 1551 | "Information!", 1552 | "Hint!" 1553 | ], 1554 | "type": "string" 1555 | }, 1556 | "cast-local-type": { 1557 | "default": "Warning", 1558 | "description": "Enable diagnostics for casts of local variables where the target type does not match the defined type.", 1559 | "enum": [ 1560 | "Error", 1561 | "Warning", 1562 | "Information", 1563 | "Hint", 1564 | "Error!", 1565 | "Warning!", 1566 | "Information!", 1567 | "Hint!" 1568 | ], 1569 | "type": "string" 1570 | }, 1571 | "cast-type-mismatch": { 1572 | "default": "Warning", 1573 | "description": "Enable diagnostics for casts where the target type does not match the initial type.", 1574 | "enum": [ 1575 | "Error", 1576 | "Warning", 1577 | "Information", 1578 | "Hint", 1579 | "Error!", 1580 | "Warning!", 1581 | "Information!", 1582 | "Hint!" 1583 | ], 1584 | "type": "string" 1585 | }, 1586 | "circle-doc-class": { 1587 | "default": "Warning", 1588 | "description": "TODO: Needs documentation", 1589 | "enum": [ 1590 | "Error", 1591 | "Warning", 1592 | "Information", 1593 | "Hint", 1594 | "Error!", 1595 | "Warning!", 1596 | "Information!", 1597 | "Hint!" 1598 | ], 1599 | "type": "string" 1600 | }, 1601 | "close-non-object": { 1602 | "default": "Warning", 1603 | "description": "Enable diagnostics for attempts to close a variable with a non-object.", 1604 | "enum": [ 1605 | "Error", 1606 | "Warning", 1607 | "Information", 1608 | "Hint", 1609 | "Error!", 1610 | "Warning!", 1611 | "Information!", 1612 | "Hint!" 1613 | ], 1614 | "type": "string" 1615 | }, 1616 | "code-after-break": { 1617 | "default": "Hint", 1618 | "description": "Enable diagnostics for code placed after a break statement in a loop.", 1619 | "enum": [ 1620 | "Error", 1621 | "Warning", 1622 | "Information", 1623 | "Hint", 1624 | "Error!", 1625 | "Warning!", 1626 | "Information!", 1627 | "Hint!" 1628 | ], 1629 | "type": "string" 1630 | }, 1631 | "codestyle-check": { 1632 | "default": "Warning", 1633 | "description": "Enable diagnostics for incorrectly styled lines.", 1634 | "enum": [ 1635 | "Error", 1636 | "Warning", 1637 | "Information", 1638 | "Hint", 1639 | "Error!", 1640 | "Warning!", 1641 | "Information!", 1642 | "Hint!" 1643 | ], 1644 | "type": "string" 1645 | }, 1646 | "count-down-loop": { 1647 | "default": "Warning", 1648 | "description": "Enable diagnostics for `for` loops which will never reach their max/limit because the loop is incrementing instead of decrementing.", 1649 | "enum": [ 1650 | "Error", 1651 | "Warning", 1652 | "Information", 1653 | "Hint", 1654 | "Error!", 1655 | "Warning!", 1656 | "Information!", 1657 | "Hint!" 1658 | ], 1659 | "type": "string" 1660 | }, 1661 | "deprecated": { 1662 | "default": "Warning", 1663 | "description": "Enable diagnostics to highlight deprecated API.", 1664 | "enum": [ 1665 | "Error", 1666 | "Warning", 1667 | "Information", 1668 | "Hint", 1669 | "Error!", 1670 | "Warning!", 1671 | "Information!", 1672 | "Hint!" 1673 | ], 1674 | "type": "string" 1675 | }, 1676 | "different-requires": { 1677 | "default": "Warning", 1678 | "description": "Enable diagnostics for files which are required by two different paths.", 1679 | "enum": [ 1680 | "Error", 1681 | "Warning", 1682 | "Information", 1683 | "Hint", 1684 | "Error!", 1685 | "Warning!", 1686 | "Information!", 1687 | "Hint!" 1688 | ], 1689 | "type": "string" 1690 | }, 1691 | "discard-returns": { 1692 | "default": "Warning", 1693 | "description": "Enable diagnostics for calls of functions annotated with `---@nodiscard` where the return values are ignored.", 1694 | "enum": [ 1695 | "Error", 1696 | "Warning", 1697 | "Information", 1698 | "Hint", 1699 | "Error!", 1700 | "Warning!", 1701 | "Information!", 1702 | "Hint!" 1703 | ], 1704 | "type": "string" 1705 | }, 1706 | "doc-field-no-class": { 1707 | "default": "Warning", 1708 | "description": "Enable diagnostics to highlight a field annotation without a defining class annotation.", 1709 | "enum": [ 1710 | "Error", 1711 | "Warning", 1712 | "Information", 1713 | "Hint", 1714 | "Error!", 1715 | "Warning!", 1716 | "Information!", 1717 | "Hint!" 1718 | ], 1719 | "type": "string" 1720 | }, 1721 | "duplicate-doc-alias": { 1722 | "default": "Warning", 1723 | "description": "Enable diagnostics for a duplicated alias annotation name.", 1724 | "enum": [ 1725 | "Error", 1726 | "Warning", 1727 | "Information", 1728 | "Hint", 1729 | "Error!", 1730 | "Warning!", 1731 | "Information!", 1732 | "Hint!" 1733 | ], 1734 | "type": "string" 1735 | }, 1736 | "duplicate-doc-field": { 1737 | "default": "Warning", 1738 | "description": "Enable diagnostics for a duplicated field annotation name.", 1739 | "enum": [ 1740 | "Error", 1741 | "Warning", 1742 | "Information", 1743 | "Hint", 1744 | "Error!", 1745 | "Warning!", 1746 | "Information!", 1747 | "Hint!" 1748 | ], 1749 | "type": "string" 1750 | }, 1751 | "duplicate-doc-param": { 1752 | "default": "Warning", 1753 | "description": "Enable diagnostics for a duplicated param annotation name.", 1754 | "enum": [ 1755 | "Error", 1756 | "Warning", 1757 | "Information", 1758 | "Hint", 1759 | "Error!", 1760 | "Warning!", 1761 | "Information!", 1762 | "Hint!" 1763 | ], 1764 | "type": "string" 1765 | }, 1766 | "duplicate-index": { 1767 | "default": "Warning", 1768 | "description": "Enable duplicate table index diagnostics.", 1769 | "enum": [ 1770 | "Error", 1771 | "Warning", 1772 | "Information", 1773 | "Hint", 1774 | "Error!", 1775 | "Warning!", 1776 | "Information!", 1777 | "Hint!" 1778 | ], 1779 | "type": "string" 1780 | }, 1781 | "duplicate-set-field": { 1782 | "default": "Warning", 1783 | "description": "Enable diagnostics for setting the same field in a class more than once.", 1784 | "enum": [ 1785 | "Error", 1786 | "Warning", 1787 | "Information", 1788 | "Hint", 1789 | "Error!", 1790 | "Warning!", 1791 | "Information!", 1792 | "Hint!" 1793 | ], 1794 | "type": "string" 1795 | }, 1796 | "empty-block": { 1797 | "default": "Hint", 1798 | "description": "Enable empty code block diagnostics.", 1799 | "enum": [ 1800 | "Error", 1801 | "Warning", 1802 | "Information", 1803 | "Hint", 1804 | "Error!", 1805 | "Warning!", 1806 | "Information!", 1807 | "Hint!" 1808 | ], 1809 | "type": "string" 1810 | }, 1811 | "global-element": { 1812 | "default": "Warning", 1813 | "description": "Enable diagnostics to warn about global elements.", 1814 | "enum": [ 1815 | "Error", 1816 | "Warning", 1817 | "Information", 1818 | "Hint", 1819 | "Error!", 1820 | "Warning!", 1821 | "Information!", 1822 | "Hint!" 1823 | ], 1824 | "type": "string" 1825 | }, 1826 | "global-in-nil-env": { 1827 | "default": "Warning", 1828 | "description": "Enable cannot use global variables ( `_ENV` is set to `nil`) diagnostics.", 1829 | "enum": [ 1830 | "Error", 1831 | "Warning", 1832 | "Information", 1833 | "Hint", 1834 | "Error!", 1835 | "Warning!", 1836 | "Information!", 1837 | "Hint!" 1838 | ], 1839 | "type": "string" 1840 | }, 1841 | "incomplete-signature-doc": { 1842 | "default": "Warning", 1843 | "description": "Incomplete @param or @return annotations for functions.", 1844 | "enum": [ 1845 | "Error", 1846 | "Warning", 1847 | "Information", 1848 | "Hint", 1849 | "Error!", 1850 | "Warning!", 1851 | "Information!", 1852 | "Hint!" 1853 | ], 1854 | "type": "string" 1855 | }, 1856 | "inject-field": { 1857 | "default": "Warning", 1858 | "description": "TODO: Needs documentation", 1859 | "enum": [ 1860 | "Error", 1861 | "Warning", 1862 | "Information", 1863 | "Hint", 1864 | "Error!", 1865 | "Warning!", 1866 | "Information!", 1867 | "Hint!" 1868 | ], 1869 | "type": "string" 1870 | }, 1871 | "invisible": { 1872 | "default": "Warning", 1873 | "description": "Enable diagnostics for accesses to fields which are invisible.", 1874 | "enum": [ 1875 | "Error", 1876 | "Warning", 1877 | "Information", 1878 | "Hint", 1879 | "Error!", 1880 | "Warning!", 1881 | "Information!", 1882 | "Hint!" 1883 | ], 1884 | "type": "string" 1885 | }, 1886 | "lowercase-global": { 1887 | "default": "Information", 1888 | "description": "Enable lowercase global variable definition diagnostics.", 1889 | "enum": [ 1890 | "Error", 1891 | "Warning", 1892 | "Information", 1893 | "Hint", 1894 | "Error!", 1895 | "Warning!", 1896 | "Information!", 1897 | "Hint!" 1898 | ], 1899 | "type": "string" 1900 | }, 1901 | "missing-fields": { 1902 | "default": "Warning", 1903 | "description": "TODO: Needs documentation", 1904 | "enum": [ 1905 | "Error", 1906 | "Warning", 1907 | "Information", 1908 | "Hint", 1909 | "Error!", 1910 | "Warning!", 1911 | "Information!", 1912 | "Hint!" 1913 | ], 1914 | "type": "string" 1915 | }, 1916 | "missing-global-doc": { 1917 | "default": "Warning", 1918 | "description": "Missing annotations for globals! Global functions must have a comment and annotations for all parameters and return values.", 1919 | "enum": [ 1920 | "Error", 1921 | "Warning", 1922 | "Information", 1923 | "Hint", 1924 | "Error!", 1925 | "Warning!", 1926 | "Information!", 1927 | "Hint!" 1928 | ], 1929 | "type": "string" 1930 | }, 1931 | "missing-local-export-doc": { 1932 | "default": "Warning", 1933 | "description": "Missing annotations for exported locals! Exported local functions must have a comment and annotations for all parameters and return values.", 1934 | "enum": [ 1935 | "Error", 1936 | "Warning", 1937 | "Information", 1938 | "Hint", 1939 | "Error!", 1940 | "Warning!", 1941 | "Information!", 1942 | "Hint!" 1943 | ], 1944 | "type": "string" 1945 | }, 1946 | "missing-parameter": { 1947 | "default": "Warning", 1948 | "description": "Enable diagnostics for function calls where the number of arguments is less than the number of annotated function parameters.", 1949 | "enum": [ 1950 | "Error", 1951 | "Warning", 1952 | "Information", 1953 | "Hint", 1954 | "Error!", 1955 | "Warning!", 1956 | "Information!", 1957 | "Hint!" 1958 | ], 1959 | "type": "string" 1960 | }, 1961 | "missing-return": { 1962 | "default": "Warning", 1963 | "description": "Enable diagnostics for functions with return annotations which have no return statement.", 1964 | "enum": [ 1965 | "Error", 1966 | "Warning", 1967 | "Information", 1968 | "Hint", 1969 | "Error!", 1970 | "Warning!", 1971 | "Information!", 1972 | "Hint!" 1973 | ], 1974 | "type": "string" 1975 | }, 1976 | "missing-return-value": { 1977 | "default": "Warning", 1978 | "description": "Enable diagnostics for return statements without values although the containing function declares returns.", 1979 | "enum": [ 1980 | "Error", 1981 | "Warning", 1982 | "Information", 1983 | "Hint", 1984 | "Error!", 1985 | "Warning!", 1986 | "Information!", 1987 | "Hint!" 1988 | ], 1989 | "type": "string" 1990 | }, 1991 | "name-style-check": { 1992 | "default": "Warning", 1993 | "description": "Enable diagnostics for name style.", 1994 | "enum": [ 1995 | "Error", 1996 | "Warning", 1997 | "Information", 1998 | "Hint", 1999 | "Error!", 2000 | "Warning!", 2001 | "Information!", 2002 | "Hint!" 2003 | ], 2004 | "type": "string" 2005 | }, 2006 | "need-check-nil": { 2007 | "default": "Warning", 2008 | "description": "Enable diagnostics for variable usages if `nil` or an optional (potentially `nil`) value was assigned to the variable before.", 2009 | "enum": [ 2010 | "Error", 2011 | "Warning", 2012 | "Information", 2013 | "Hint", 2014 | "Error!", 2015 | "Warning!", 2016 | "Information!", 2017 | "Hint!" 2018 | ], 2019 | "type": "string" 2020 | }, 2021 | "newfield-call": { 2022 | "default": "Warning", 2023 | "description": "Enable newfield call diagnostics. It is raised when the parenthesis of a function call appear on the following line when defining a field in a table.", 2024 | "enum": [ 2025 | "Error", 2026 | "Warning", 2027 | "Information", 2028 | "Hint", 2029 | "Error!", 2030 | "Warning!", 2031 | "Information!", 2032 | "Hint!" 2033 | ], 2034 | "type": "string" 2035 | }, 2036 | "newline-call": { 2037 | "default": "Warning", 2038 | "description": "Enable newline call diagnostics. Is's raised when a line starting with `(` is encountered, which is syntactically parsed as a function call on the previous line.", 2039 | "enum": [ 2040 | "Error", 2041 | "Warning", 2042 | "Information", 2043 | "Hint", 2044 | "Error!", 2045 | "Warning!", 2046 | "Information!", 2047 | "Hint!" 2048 | ], 2049 | "type": "string" 2050 | }, 2051 | "no-unknown": { 2052 | "default": "Warning", 2053 | "description": "Enable diagnostics for cases in which the type cannot be inferred.", 2054 | "enum": [ 2055 | "Error", 2056 | "Warning", 2057 | "Information", 2058 | "Hint", 2059 | "Error!", 2060 | "Warning!", 2061 | "Information!", 2062 | "Hint!" 2063 | ], 2064 | "type": "string" 2065 | }, 2066 | "not-yieldable": { 2067 | "default": "Warning", 2068 | "description": "Enable diagnostics for calls to `coroutine.yield()` when it is not permitted.", 2069 | "enum": [ 2070 | "Error", 2071 | "Warning", 2072 | "Information", 2073 | "Hint", 2074 | "Error!", 2075 | "Warning!", 2076 | "Information!", 2077 | "Hint!" 2078 | ], 2079 | "type": "string" 2080 | }, 2081 | "param-type-mismatch": { 2082 | "default": "Warning", 2083 | "description": "Enable diagnostics for function calls where the type of a provided parameter does not match the type of the annotated function definition.", 2084 | "enum": [ 2085 | "Error", 2086 | "Warning", 2087 | "Information", 2088 | "Hint", 2089 | "Error!", 2090 | "Warning!", 2091 | "Information!", 2092 | "Hint!" 2093 | ], 2094 | "type": "string" 2095 | }, 2096 | "redefined-local": { 2097 | "default": "Hint", 2098 | "description": "Enable redefined local variable diagnostics.", 2099 | "enum": [ 2100 | "Error", 2101 | "Warning", 2102 | "Information", 2103 | "Hint", 2104 | "Error!", 2105 | "Warning!", 2106 | "Information!", 2107 | "Hint!" 2108 | ], 2109 | "type": "string" 2110 | }, 2111 | "redundant-parameter": { 2112 | "default": "Warning", 2113 | "description": "Enable redundant function parameter diagnostics.", 2114 | "enum": [ 2115 | "Error", 2116 | "Warning", 2117 | "Information", 2118 | "Hint", 2119 | "Error!", 2120 | "Warning!", 2121 | "Information!", 2122 | "Hint!" 2123 | ], 2124 | "type": "string" 2125 | }, 2126 | "redundant-return": { 2127 | "default": "Hint", 2128 | "description": "Enable diagnostics for return statements which are not needed because the function would exit on its own.", 2129 | "enum": [ 2130 | "Error", 2131 | "Warning", 2132 | "Information", 2133 | "Hint", 2134 | "Error!", 2135 | "Warning!", 2136 | "Information!", 2137 | "Hint!" 2138 | ], 2139 | "type": "string" 2140 | }, 2141 | "redundant-return-value": { 2142 | "default": "Warning", 2143 | "description": "Enable diagnostics for return statements which return an extra value which is not specified by a return annotation.", 2144 | "enum": [ 2145 | "Error", 2146 | "Warning", 2147 | "Information", 2148 | "Hint", 2149 | "Error!", 2150 | "Warning!", 2151 | "Information!", 2152 | "Hint!" 2153 | ], 2154 | "type": "string" 2155 | }, 2156 | "redundant-value": { 2157 | "default": "Warning", 2158 | "description": "Enable the redundant values assigned diagnostics. It's raised during assignment operation, when the number of values is higher than the number of objects being assigned.", 2159 | "enum": [ 2160 | "Error", 2161 | "Warning", 2162 | "Information", 2163 | "Hint", 2164 | "Error!", 2165 | "Warning!", 2166 | "Information!", 2167 | "Hint!" 2168 | ], 2169 | "type": "string" 2170 | }, 2171 | "return-type-mismatch": { 2172 | "default": "Warning", 2173 | "description": "Enable diagnostics for return values whose type does not match the type declared in the corresponding return annotation.", 2174 | "enum": [ 2175 | "Error", 2176 | "Warning", 2177 | "Information", 2178 | "Hint", 2179 | "Error!", 2180 | "Warning!", 2181 | "Information!", 2182 | "Hint!" 2183 | ], 2184 | "type": "string" 2185 | }, 2186 | "spell-check": { 2187 | "default": "Information", 2188 | "description": "Enable diagnostics for typos in strings.", 2189 | "enum": [ 2190 | "Error", 2191 | "Warning", 2192 | "Information", 2193 | "Hint", 2194 | "Error!", 2195 | "Warning!", 2196 | "Information!", 2197 | "Hint!" 2198 | ], 2199 | "type": "string" 2200 | }, 2201 | "trailing-space": { 2202 | "default": "Hint", 2203 | "description": "Enable trailing space diagnostics.", 2204 | "enum": [ 2205 | "Error", 2206 | "Warning", 2207 | "Information", 2208 | "Hint", 2209 | "Error!", 2210 | "Warning!", 2211 | "Information!", 2212 | "Hint!" 2213 | ], 2214 | "type": "string" 2215 | }, 2216 | "unbalanced-assignments": { 2217 | "default": "Warning", 2218 | "description": "Enable diagnostics on multiple assignments if not all variables obtain a value (e.g., `local x,y = 1`).", 2219 | "enum": [ 2220 | "Error", 2221 | "Warning", 2222 | "Information", 2223 | "Hint", 2224 | "Error!", 2225 | "Warning!", 2226 | "Information!", 2227 | "Hint!" 2228 | ], 2229 | "type": "string" 2230 | }, 2231 | "undefined-doc-class": { 2232 | "default": "Warning", 2233 | "description": "Enable diagnostics for class annotations in which an undefined class is referenced.", 2234 | "enum": [ 2235 | "Error", 2236 | "Warning", 2237 | "Information", 2238 | "Hint", 2239 | "Error!", 2240 | "Warning!", 2241 | "Information!", 2242 | "Hint!" 2243 | ], 2244 | "type": "string" 2245 | }, 2246 | "undefined-doc-name": { 2247 | "default": "Warning", 2248 | "description": "Enable diagnostics for type annotations referencing an undefined type or alias.", 2249 | "enum": [ 2250 | "Error", 2251 | "Warning", 2252 | "Information", 2253 | "Hint", 2254 | "Error!", 2255 | "Warning!", 2256 | "Information!", 2257 | "Hint!" 2258 | ], 2259 | "type": "string" 2260 | }, 2261 | "undefined-doc-param": { 2262 | "default": "Warning", 2263 | "description": "Enable diagnostics for cases in which a parameter annotation is given without declaring the parameter in the function definition.", 2264 | "enum": [ 2265 | "Error", 2266 | "Warning", 2267 | "Information", 2268 | "Hint", 2269 | "Error!", 2270 | "Warning!", 2271 | "Information!", 2272 | "Hint!" 2273 | ], 2274 | "type": "string" 2275 | }, 2276 | "undefined-env-child": { 2277 | "default": "Information", 2278 | "description": "Enable undefined environment variable diagnostics. It's raised when `_ENV` table is set to a new literal table, but the used global variable is no longer present in the global environment.", 2279 | "enum": [ 2280 | "Error", 2281 | "Warning", 2282 | "Information", 2283 | "Hint", 2284 | "Error!", 2285 | "Warning!", 2286 | "Information!", 2287 | "Hint!" 2288 | ], 2289 | "type": "string" 2290 | }, 2291 | "undefined-field": { 2292 | "default": "Warning", 2293 | "description": "Enable diagnostics for cases in which an undefined field of a variable is read.", 2294 | "enum": [ 2295 | "Error", 2296 | "Warning", 2297 | "Information", 2298 | "Hint", 2299 | "Error!", 2300 | "Warning!", 2301 | "Information!", 2302 | "Hint!" 2303 | ], 2304 | "type": "string" 2305 | }, 2306 | "undefined-global": { 2307 | "default": "Warning", 2308 | "description": "Enable undefined global variable diagnostics.", 2309 | "enum": [ 2310 | "Error", 2311 | "Warning", 2312 | "Information", 2313 | "Hint", 2314 | "Error!", 2315 | "Warning!", 2316 | "Information!", 2317 | "Hint!" 2318 | ], 2319 | "type": "string" 2320 | }, 2321 | "unknown-cast-variable": { 2322 | "default": "Warning", 2323 | "description": "Enable diagnostics for casts of undefined variables.", 2324 | "enum": [ 2325 | "Error", 2326 | "Warning", 2327 | "Information", 2328 | "Hint", 2329 | "Error!", 2330 | "Warning!", 2331 | "Information!", 2332 | "Hint!" 2333 | ], 2334 | "type": "string" 2335 | }, 2336 | "unknown-diag-code": { 2337 | "default": "Warning", 2338 | "description": "Enable diagnostics in cases in which an unknown diagnostics code is entered.", 2339 | "enum": [ 2340 | "Error", 2341 | "Warning", 2342 | "Information", 2343 | "Hint", 2344 | "Error!", 2345 | "Warning!", 2346 | "Information!", 2347 | "Hint!" 2348 | ], 2349 | "type": "string" 2350 | }, 2351 | "unknown-operator": { 2352 | "default": "Warning", 2353 | "description": "Enable diagnostics for unknown operators.", 2354 | "enum": [ 2355 | "Error", 2356 | "Warning", 2357 | "Information", 2358 | "Hint", 2359 | "Error!", 2360 | "Warning!", 2361 | "Information!", 2362 | "Hint!" 2363 | ], 2364 | "type": "string" 2365 | }, 2366 | "unreachable-code": { 2367 | "default": "Hint", 2368 | "description": "Enable diagnostics for unreachable code.", 2369 | "enum": [ 2370 | "Error", 2371 | "Warning", 2372 | "Information", 2373 | "Hint", 2374 | "Error!", 2375 | "Warning!", 2376 | "Information!", 2377 | "Hint!" 2378 | ], 2379 | "type": "string" 2380 | }, 2381 | "unused-function": { 2382 | "default": "Hint", 2383 | "description": "Enable unused function diagnostics.", 2384 | "enum": [ 2385 | "Error", 2386 | "Warning", 2387 | "Information", 2388 | "Hint", 2389 | "Error!", 2390 | "Warning!", 2391 | "Information!", 2392 | "Hint!" 2393 | ], 2394 | "type": "string" 2395 | }, 2396 | "unused-label": { 2397 | "default": "Hint", 2398 | "description": "Enable unused label diagnostics.", 2399 | "enum": [ 2400 | "Error", 2401 | "Warning", 2402 | "Information", 2403 | "Hint", 2404 | "Error!", 2405 | "Warning!", 2406 | "Information!", 2407 | "Hint!" 2408 | ], 2409 | "type": "string" 2410 | }, 2411 | "unused-local": { 2412 | "default": "Hint", 2413 | "description": "Enable unused local variable diagnostics.", 2414 | "enum": [ 2415 | "Error", 2416 | "Warning", 2417 | "Information", 2418 | "Hint", 2419 | "Error!", 2420 | "Warning!", 2421 | "Information!", 2422 | "Hint!" 2423 | ], 2424 | "type": "string" 2425 | }, 2426 | "unused-vararg": { 2427 | "default": "Hint", 2428 | "description": "Enable unused vararg diagnostics.", 2429 | "enum": [ 2430 | "Error", 2431 | "Warning", 2432 | "Information", 2433 | "Hint", 2434 | "Error!", 2435 | "Warning!", 2436 | "Information!", 2437 | "Hint!" 2438 | ], 2439 | "type": "string" 2440 | } 2441 | }, 2442 | "scope": "resource", 2443 | "title": "severity", 2444 | "type": "object" 2445 | }, 2446 | "Lua.diagnostics.unusedLocalExclude": { 2447 | "default": [], 2448 | "items": { 2449 | "type": "string" 2450 | }, 2451 | "markdownDescription": "Do not diagnose `unused-local` when the variable name matches the following pattern.", 2452 | "scope": "resource", 2453 | "type": "array" 2454 | }, 2455 | "Lua.diagnostics.workspaceDelay": { 2456 | "default": 3000, 2457 | "markdownDescription": "Latency (milliseconds) for workspace diagnostics.", 2458 | "scope": "resource", 2459 | "type": "integer" 2460 | }, 2461 | "Lua.diagnostics.workspaceEvent": { 2462 | "default": "OnSave", 2463 | "enum": [ 2464 | "OnChange", 2465 | "OnSave", 2466 | "None" 2467 | ], 2468 | "markdownDescription": "Set the time to trigger workspace diagnostics.", 2469 | "markdownEnumDescriptions": [ 2470 | "Trigger workspace diagnostics when the file is changed.", 2471 | "Trigger workspace diagnostics when the file is saved.", 2472 | "Disable workspace diagnostics." 2473 | ], 2474 | "scope": "resource", 2475 | "type": "string" 2476 | }, 2477 | "Lua.diagnostics.workspaceRate": { 2478 | "default": 100, 2479 | "markdownDescription": "Workspace diagnostics run rate (%). Decreasing this value reduces CPU usage, but also reduces the speed of workspace diagnostics. The diagnosis of the file you are currently editing is always done at full speed and is not affected by this setting.", 2480 | "scope": "resource", 2481 | "type": "integer" 2482 | }, 2483 | "Lua.doc.packageName": { 2484 | "default": [], 2485 | "items": { 2486 | "type": "string" 2487 | }, 2488 | "markdownDescription": "Treat specific field names as package, e.g. `m_*` means `XXX.m_id` and `XXX.m_type` are package, witch can only be accessed in the file where the definition is located.", 2489 | "scope": "resource", 2490 | "type": "array" 2491 | }, 2492 | "Lua.doc.privateName": { 2493 | "default": [], 2494 | "items": { 2495 | "type": "string" 2496 | }, 2497 | "markdownDescription": "Treat specific field names as private, e.g. `m_*` means `XXX.m_id` and `XXX.m_type` are private, witch can only be accessed in the class where the definition is located.", 2498 | "scope": "resource", 2499 | "type": "array" 2500 | }, 2501 | "Lua.doc.protectedName": { 2502 | "default": [], 2503 | "items": { 2504 | "type": "string" 2505 | }, 2506 | "markdownDescription": "Treat specific field names as protected, e.g. `m_*` means `XXX.m_id` and `XXX.m_type` are protected, witch can only be accessed in the class where the definition is located and its subclasses.", 2507 | "scope": "resource", 2508 | "type": "array" 2509 | }, 2510 | "Lua.format.defaultConfig": { 2511 | "additionalProperties": false, 2512 | "default": {}, 2513 | "markdownDescription": "The default format configuration. Has a lower priority than `.editorconfig` file in the workspace.\nRead [formatter docs](https://github.com/CppCXY/EmmyLuaCodeStyle/tree/master/docs) to learn usage.\n", 2514 | "patternProperties": { 2515 | ".*": { 2516 | "default": "", 2517 | "type": "string" 2518 | } 2519 | }, 2520 | "scope": "resource", 2521 | "title": "defaultConfig", 2522 | "type": "object" 2523 | }, 2524 | "Lua.format.enable": { 2525 | "default": true, 2526 | "markdownDescription": "Enable code formatter.", 2527 | "scope": "resource", 2528 | "type": "boolean" 2529 | }, 2530 | "Lua.hint.arrayIndex": { 2531 | "default": "Auto", 2532 | "enum": [ 2533 | "Enable", 2534 | "Auto", 2535 | "Disable" 2536 | ], 2537 | "markdownDescription": "Show hints of array index when constructing a table.", 2538 | "markdownEnumDescriptions": [ 2539 | "Show hints in all tables.", 2540 | "Show hints only when the table is greater than 3 items, or the table is a mixed table.", 2541 | "Disable hints of array index." 2542 | ], 2543 | "scope": "resource", 2544 | "type": "string" 2545 | }, 2546 | "Lua.hint.await": { 2547 | "default": true, 2548 | "markdownDescription": "If the called function is marked `---@async`, prompt `await` at the call.", 2549 | "scope": "resource", 2550 | "type": "boolean" 2551 | }, 2552 | "Lua.hint.enable": { 2553 | "default": true, 2554 | "markdownDescription": "Enable inlay hint.", 2555 | "scope": "resource", 2556 | "type": "boolean" 2557 | }, 2558 | "Lua.hint.paramName": { 2559 | "default": "All", 2560 | "enum": [ 2561 | "All", 2562 | "Literal", 2563 | "Disable" 2564 | ], 2565 | "markdownDescription": "Show hints of parameter name at the function call.", 2566 | "markdownEnumDescriptions": [ 2567 | "All types of parameters are shown.", 2568 | "Only literal type parameters are shown.", 2569 | "Disable parameter hints." 2570 | ], 2571 | "scope": "resource", 2572 | "type": "string" 2573 | }, 2574 | "Lua.hint.paramType": { 2575 | "default": true, 2576 | "markdownDescription": "Show type hints at the parameter of the function.", 2577 | "scope": "resource", 2578 | "type": "boolean" 2579 | }, 2580 | "Lua.hint.semicolon": { 2581 | "default": "SameLine", 2582 | "enum": [ 2583 | "All", 2584 | "SameLine", 2585 | "Disable" 2586 | ], 2587 | "markdownDescription": "If there is no semicolon at the end of the statement, display a virtual semicolon.", 2588 | "markdownEnumDescriptions": [ 2589 | "All statements display virtual semicolons.", 2590 | "When two statements are on the same line, display a semicolon between them.", 2591 | "Disable virtual semicolons." 2592 | ], 2593 | "scope": "resource", 2594 | "type": "string" 2595 | }, 2596 | "Lua.hint.setType": { 2597 | "default": false, 2598 | "markdownDescription": "Show hints of type at assignment operation.", 2599 | "scope": "resource", 2600 | "type": "boolean" 2601 | }, 2602 | "Lua.hover.enable": { 2603 | "default": true, 2604 | "markdownDescription": "Enable hover.", 2605 | "scope": "resource", 2606 | "type": "boolean" 2607 | }, 2608 | "Lua.hover.enumsLimit": { 2609 | "default": 5, 2610 | "markdownDescription": "When the value corresponds to multiple types, limit the number of types displaying.", 2611 | "scope": "resource", 2612 | "type": "integer" 2613 | }, 2614 | "Lua.hover.expandAlias": { 2615 | "default": true, 2616 | "markdownDescription": "Whether to expand the alias. For example, expands `---@alias myType boolean|number` appears as `boolean|number`, otherwise it appears as `myType'.\n", 2617 | "scope": "resource", 2618 | "type": "boolean" 2619 | }, 2620 | "Lua.hover.previewFields": { 2621 | "default": 50, 2622 | "markdownDescription": "When hovering to view a table, limits the maximum number of previews for fields.", 2623 | "scope": "resource", 2624 | "type": "integer" 2625 | }, 2626 | "Lua.hover.viewNumber": { 2627 | "default": true, 2628 | "markdownDescription": "Hover to view numeric content (only if literal is not decimal).", 2629 | "scope": "resource", 2630 | "type": "boolean" 2631 | }, 2632 | "Lua.hover.viewString": { 2633 | "default": true, 2634 | "markdownDescription": "Hover to view the contents of a string (only if the literal contains an escape character).", 2635 | "scope": "resource", 2636 | "type": "boolean" 2637 | }, 2638 | "Lua.hover.viewStringMax": { 2639 | "default": 1000, 2640 | "markdownDescription": "The maximum length of a hover to view the contents of a string.", 2641 | "scope": "resource", 2642 | "type": "integer" 2643 | }, 2644 | "Lua.misc.executablePath": { 2645 | "default": "", 2646 | "markdownDescription": "Specify the executable path.", 2647 | "scope": "resource", 2648 | "type": "string" 2649 | }, 2650 | "Lua.misc.parameters": { 2651 | "default": [], 2652 | "items": { 2653 | "type": "string" 2654 | }, 2655 | "markdownDescription": "Additional command line parameters when starting the language service.", 2656 | "scope": "resource", 2657 | "type": "array" 2658 | }, 2659 | "Lua.nameStyle.config": { 2660 | "additionalProperties": false, 2661 | "default": {}, 2662 | "markdownDescription": "Set name style config", 2663 | "patternProperties": { 2664 | ".*": { 2665 | "type": [ 2666 | "string", 2667 | "array" 2668 | ] 2669 | } 2670 | }, 2671 | "scope": "resource", 2672 | "title": "config", 2673 | "type": "object" 2674 | }, 2675 | "Lua.runtime.builtin": { 2676 | "additionalProperties": false, 2677 | "markdownDescription": "Adjust the enabled state of the built-in library. You can disable (or redefine) the non-existent library according to the actual runtime environment.\n\n* `default`: Indicates that the library will be enabled or disabled according to the runtime version\n* `enable`: always enable\n* `disable`: always disable\n", 2678 | "properties": { 2679 | "basic": { 2680 | "default": "default", 2681 | "description": "TODO: Needs documentation", 2682 | "enum": [ 2683 | "default", 2684 | "enable", 2685 | "disable" 2686 | ], 2687 | "type": "string" 2688 | }, 2689 | "bit": { 2690 | "default": "default", 2691 | "description": "TODO: Needs documentation", 2692 | "enum": [ 2693 | "default", 2694 | "enable", 2695 | "disable" 2696 | ], 2697 | "type": "string" 2698 | }, 2699 | "bit32": { 2700 | "default": "default", 2701 | "description": "TODO: Needs documentation", 2702 | "enum": [ 2703 | "default", 2704 | "enable", 2705 | "disable" 2706 | ], 2707 | "type": "string" 2708 | }, 2709 | "builtin": { 2710 | "default": "default", 2711 | "description": "TODO: Needs documentation", 2712 | "enum": [ 2713 | "default", 2714 | "enable", 2715 | "disable" 2716 | ], 2717 | "type": "string" 2718 | }, 2719 | "coroutine": { 2720 | "default": "default", 2721 | "description": "TODO: Needs documentation", 2722 | "enum": [ 2723 | "default", 2724 | "enable", 2725 | "disable" 2726 | ], 2727 | "type": "string" 2728 | }, 2729 | "debug": { 2730 | "default": "default", 2731 | "description": "TODO: Needs documentation", 2732 | "enum": [ 2733 | "default", 2734 | "enable", 2735 | "disable" 2736 | ], 2737 | "type": "string" 2738 | }, 2739 | "ffi": { 2740 | "default": "default", 2741 | "description": "TODO: Needs documentation", 2742 | "enum": [ 2743 | "default", 2744 | "enable", 2745 | "disable" 2746 | ], 2747 | "type": "string" 2748 | }, 2749 | "io": { 2750 | "default": "default", 2751 | "description": "TODO: Needs documentation", 2752 | "enum": [ 2753 | "default", 2754 | "enable", 2755 | "disable" 2756 | ], 2757 | "type": "string" 2758 | }, 2759 | "jit": { 2760 | "default": "default", 2761 | "description": "TODO: Needs documentation", 2762 | "enum": [ 2763 | "default", 2764 | "enable", 2765 | "disable" 2766 | ], 2767 | "type": "string" 2768 | }, 2769 | "jit.profile": { 2770 | "default": "default", 2771 | "description": "TODO: Needs documentation", 2772 | "enum": [ 2773 | "default", 2774 | "enable", 2775 | "disable" 2776 | ], 2777 | "type": "string" 2778 | }, 2779 | "jit.util": { 2780 | "default": "default", 2781 | "description": "TODO: Needs documentation", 2782 | "enum": [ 2783 | "default", 2784 | "enable", 2785 | "disable" 2786 | ], 2787 | "type": "string" 2788 | }, 2789 | "math": { 2790 | "default": "default", 2791 | "description": "TODO: Needs documentation", 2792 | "enum": [ 2793 | "default", 2794 | "enable", 2795 | "disable" 2796 | ], 2797 | "type": "string" 2798 | }, 2799 | "os": { 2800 | "default": "default", 2801 | "description": "TODO: Needs documentation", 2802 | "enum": [ 2803 | "default", 2804 | "enable", 2805 | "disable" 2806 | ], 2807 | "type": "string" 2808 | }, 2809 | "package": { 2810 | "default": "default", 2811 | "description": "TODO: Needs documentation", 2812 | "enum": [ 2813 | "default", 2814 | "enable", 2815 | "disable" 2816 | ], 2817 | "type": "string" 2818 | }, 2819 | "string": { 2820 | "default": "default", 2821 | "description": "TODO: Needs documentation", 2822 | "enum": [ 2823 | "default", 2824 | "enable", 2825 | "disable" 2826 | ], 2827 | "type": "string" 2828 | }, 2829 | "string.buffer": { 2830 | "default": "default", 2831 | "description": "TODO: Needs documentation", 2832 | "enum": [ 2833 | "default", 2834 | "enable", 2835 | "disable" 2836 | ], 2837 | "type": "string" 2838 | }, 2839 | "table": { 2840 | "default": "default", 2841 | "description": "TODO: Needs documentation", 2842 | "enum": [ 2843 | "default", 2844 | "enable", 2845 | "disable" 2846 | ], 2847 | "type": "string" 2848 | }, 2849 | "table.clear": { 2850 | "default": "default", 2851 | "description": "TODO: Needs documentation", 2852 | "enum": [ 2853 | "default", 2854 | "enable", 2855 | "disable" 2856 | ], 2857 | "type": "string" 2858 | }, 2859 | "table.new": { 2860 | "default": "default", 2861 | "description": "TODO: Needs documentation", 2862 | "enum": [ 2863 | "default", 2864 | "enable", 2865 | "disable" 2866 | ], 2867 | "type": "string" 2868 | }, 2869 | "utf8": { 2870 | "default": "default", 2871 | "description": "TODO: Needs documentation", 2872 | "enum": [ 2873 | "default", 2874 | "enable", 2875 | "disable" 2876 | ], 2877 | "type": "string" 2878 | } 2879 | }, 2880 | "scope": "resource", 2881 | "title": "builtin", 2882 | "type": "object" 2883 | }, 2884 | "Lua.runtime.fileEncoding": { 2885 | "default": "utf8", 2886 | "enum": [ 2887 | "utf8", 2888 | "ansi", 2889 | "utf16le", 2890 | "utf16be" 2891 | ], 2892 | "markdownDescription": "File encoding. The `ansi` option is only available under the `Windows` platform.", 2893 | "markdownEnumDescriptions": [ 2894 | "TODO: Needs documentation", 2895 | "TODO: Needs documentation", 2896 | "TODO: Needs documentation", 2897 | "TODO: Needs documentation" 2898 | ], 2899 | "scope": "resource", 2900 | "type": "string" 2901 | }, 2902 | "Lua.runtime.meta": { 2903 | "default": "${version} ${language} ${encoding}", 2904 | "markdownDescription": "Format of the directory name of the meta files.", 2905 | "scope": "resource", 2906 | "type": "string" 2907 | }, 2908 | "Lua.runtime.nonstandardSymbol": { 2909 | "default": [], 2910 | "items": { 2911 | "enum": [ 2912 | "//", 2913 | "/**/", 2914 | "`", 2915 | "+=", 2916 | "-=", 2917 | "*=", 2918 | "/=", 2919 | "%=", 2920 | "^=", 2921 | "//=", 2922 | "|=", 2923 | "&=", 2924 | "<<=", 2925 | ">>=", 2926 | "||", 2927 | "&&", 2928 | "!", 2929 | "!=", 2930 | "continue" 2931 | ], 2932 | "type": "string" 2933 | }, 2934 | "markdownDescription": "Supports non-standard symbols. Make sure that your runtime environment supports these symbols.", 2935 | "scope": "resource", 2936 | "type": "array" 2937 | }, 2938 | "Lua.runtime.path": { 2939 | "default": [ 2940 | "?.lua", 2941 | "?/init.lua" 2942 | ], 2943 | "items": { 2944 | "type": "string" 2945 | }, 2946 | "markdownDescription": "When using `require`, how to find the file based on the input name.\nSetting this config to `?/init.lua` means that when you enter `require 'myfile'`, `${workspace}/myfile/init.lua` will be searched from the loaded files.\nif `runtime.pathStrict` is `false`, `${workspace}/**/myfile/init.lua` will also be searched.\nIf you want to load files outside the workspace, you need to set `Lua.workspace.library` first.\n", 2947 | "scope": "resource", 2948 | "type": "array" 2949 | }, 2950 | "Lua.runtime.pathStrict": { 2951 | "default": false, 2952 | "markdownDescription": "When enabled, `runtime.path` will only search the first level of directories, see the description of `runtime.path`.", 2953 | "scope": "resource", 2954 | "type": "boolean" 2955 | }, 2956 | "Lua.runtime.plugin": { 2957 | "default": "", 2958 | "markdownDescription": "Plugin path. Please read [wiki](https://luals.github.io/wiki/plugins) to learn more.", 2959 | "scope": "resource", 2960 | "type": "string" 2961 | }, 2962 | "Lua.runtime.pluginArgs": { 2963 | "default": [], 2964 | "items": { 2965 | "type": "string" 2966 | }, 2967 | "markdownDescription": "Additional arguments for the plugin.", 2968 | "scope": "resource", 2969 | "type": "array" 2970 | }, 2971 | "Lua.runtime.special": { 2972 | "additionalProperties": false, 2973 | "default": {}, 2974 | "markdownDescription": "The custom global variables are regarded as some special built-in variables, and the language server will provide special support\nThe following example shows that 'include' is treated as' require '.\n```json\n\"Lua.runtime.special\" : {\n \"include\" : \"require\"\n}\n```\n", 2975 | "patternProperties": { 2976 | ".*": { 2977 | "default": "require", 2978 | "enum": [ 2979 | "_G", 2980 | "rawset", 2981 | "rawget", 2982 | "setmetatable", 2983 | "require", 2984 | "dofile", 2985 | "loadfile", 2986 | "pcall", 2987 | "xpcall", 2988 | "assert", 2989 | "error", 2990 | "type", 2991 | "os.exit" 2992 | ], 2993 | "type": "string" 2994 | } 2995 | }, 2996 | "scope": "resource", 2997 | "title": "special", 2998 | "type": "object" 2999 | }, 3000 | "Lua.runtime.unicodeName": { 3001 | "default": false, 3002 | "markdownDescription": "Allows Unicode characters in name.", 3003 | "scope": "resource", 3004 | "type": "boolean" 3005 | }, 3006 | "Lua.runtime.version": { 3007 | "default": "Lua 5.4", 3008 | "enum": [ 3009 | "Lua 5.1", 3010 | "Lua 5.2", 3011 | "Lua 5.3", 3012 | "Lua 5.4", 3013 | "LuaJIT" 3014 | ], 3015 | "markdownDescription": "Lua runtime version.", 3016 | "markdownEnumDescriptions": [ 3017 | "TODO: Needs documentation", 3018 | "TODO: Needs documentation", 3019 | "TODO: Needs documentation", 3020 | "TODO: Needs documentation", 3021 | "TODO: Needs documentation" 3022 | ], 3023 | "scope": "resource", 3024 | "type": "string" 3025 | }, 3026 | "Lua.semantic.annotation": { 3027 | "default": true, 3028 | "markdownDescription": "Semantic coloring of type annotations.", 3029 | "scope": "resource", 3030 | "type": "boolean" 3031 | }, 3032 | "Lua.semantic.enable": { 3033 | "default": true, 3034 | "markdownDescription": "Enable semantic color. You may need to set `editor.semanticHighlighting.enabled` to `true` to take effect.", 3035 | "scope": "resource", 3036 | "type": "boolean" 3037 | }, 3038 | "Lua.semantic.keyword": { 3039 | "default": false, 3040 | "markdownDescription": "Semantic coloring of keywords/literals/operators. You only need to enable this feature if your editor cannot do syntax coloring.", 3041 | "scope": "resource", 3042 | "type": "boolean" 3043 | }, 3044 | "Lua.semantic.variable": { 3045 | "default": true, 3046 | "markdownDescription": "Semantic coloring of variables/fields/parameters.", 3047 | "scope": "resource", 3048 | "type": "boolean" 3049 | }, 3050 | "Lua.signatureHelp.enable": { 3051 | "default": true, 3052 | "markdownDescription": "Enable signature help.", 3053 | "scope": "resource", 3054 | "type": "boolean" 3055 | }, 3056 | "Lua.spell.dict": { 3057 | "default": [], 3058 | "items": { 3059 | "type": "string" 3060 | }, 3061 | "markdownDescription": "Custom words for spell checking.", 3062 | "scope": "resource", 3063 | "type": "array" 3064 | }, 3065 | "Lua.type.castNumberToInteger": { 3066 | "default": true, 3067 | "markdownDescription": "Allowed to assign the `number` type to the `integer` type.", 3068 | "scope": "resource", 3069 | "type": "boolean" 3070 | }, 3071 | "Lua.type.weakNilCheck": { 3072 | "default": false, 3073 | "markdownDescription": "When checking the type of union type, ignore the `nil` in it.\n\nWhen this setting is `false`, the `number|nil` type cannot be assigned to the `number` type. It can be with `true`.\n", 3074 | "scope": "resource", 3075 | "type": "boolean" 3076 | }, 3077 | "Lua.type.weakUnionCheck": { 3078 | "default": false, 3079 | "markdownDescription": "Once one subtype of a union type meets the condition, the union type also meets the condition.\n\nWhen this setting is `false`, the `number|boolean` type cannot be assigned to the `number` type. It can be with `true`.\n", 3080 | "scope": "resource", 3081 | "type": "boolean" 3082 | }, 3083 | "Lua.typeFormat.config": { 3084 | "additionalProperties": false, 3085 | "markdownDescription": "Configures the formatting behavior while typing Lua code.", 3086 | "properties": { 3087 | "auto_complete_end": { 3088 | "default": "true", 3089 | "description": "Controls if `end` is automatically completed at suitable positions.", 3090 | "type": "string" 3091 | }, 3092 | "auto_complete_table_sep": { 3093 | "default": "true", 3094 | "description": "Controls if a separator is automatically appended at the end of a table declaration.", 3095 | "type": "string" 3096 | }, 3097 | "format_line": { 3098 | "default": "true", 3099 | "description": "Controls if a line is formatted at all.", 3100 | "type": "string" 3101 | } 3102 | }, 3103 | "scope": "resource", 3104 | "title": "config", 3105 | "type": "object" 3106 | }, 3107 | "Lua.window.progressBar": { 3108 | "default": true, 3109 | "markdownDescription": "Show progress bar in status bar.", 3110 | "scope": "resource", 3111 | "type": "boolean" 3112 | }, 3113 | "Lua.window.statusBar": { 3114 | "default": true, 3115 | "markdownDescription": "Show extension status in status bar.", 3116 | "scope": "resource", 3117 | "type": "boolean" 3118 | }, 3119 | "Lua.workspace.checkThirdParty": { 3120 | "markdownDescription": "Automatic detection and adaptation of third-party libraries, currently supported libraries are:\n\n* OpenResty\n* Cocos4.0\n* LÖVE\n* LÖVR\n* skynet\n* Jass\n", 3121 | "scope": "resource", 3122 | "type": [ 3123 | "string", 3124 | "boolean" 3125 | ] 3126 | }, 3127 | "Lua.workspace.ignoreDir": { 3128 | "default": [ 3129 | ".vscode" 3130 | ], 3131 | "items": { 3132 | "type": "string" 3133 | }, 3134 | "markdownDescription": "Ignored files and directories (Use `.gitignore` grammar).", 3135 | "scope": "resource", 3136 | "type": "array" 3137 | }, 3138 | "Lua.workspace.ignoreSubmodules": { 3139 | "default": true, 3140 | "markdownDescription": "Ignore submodules.", 3141 | "scope": "resource", 3142 | "type": "boolean" 3143 | }, 3144 | "Lua.workspace.library": { 3145 | "default": [], 3146 | "items": { 3147 | "type": "string" 3148 | }, 3149 | "markdownDescription": "In addition to the current workspace, which directories will load files from. The files in these directories will be treated as externally provided code libraries, and some features (such as renaming fields) will not modify these files.", 3150 | "scope": "resource", 3151 | "type": "array" 3152 | }, 3153 | "Lua.workspace.maxPreload": { 3154 | "default": 5000, 3155 | "markdownDescription": "Max preloaded files.", 3156 | "scope": "resource", 3157 | "type": "integer" 3158 | }, 3159 | "Lua.workspace.preloadFileSize": { 3160 | "default": 500, 3161 | "markdownDescription": "Skip files larger than this value (KB) when preloading.", 3162 | "scope": "resource", 3163 | "type": "integer" 3164 | }, 3165 | "Lua.workspace.useGitIgnore": { 3166 | "default": true, 3167 | "markdownDescription": "Ignore files list in `.gitignore` .", 3168 | "scope": "resource", 3169 | "type": "boolean" 3170 | }, 3171 | "Lua.workspace.userThirdParty": { 3172 | "default": [], 3173 | "items": { 3174 | "type": "string" 3175 | }, 3176 | "markdownDescription": "Add private third-party library configuration file paths here, please refer to the built-in [configuration file path](https://github.com/LuaLS/lua-language-server/tree/master/meta/3rd)", 3177 | "scope": "resource", 3178 | "type": "array" 3179 | } 3180 | } 3181 | }, 3182 | "commands": [ 3183 | { 3184 | "command": "sumneko-lua.install", 3185 | "title": "Install or update sumneko lua-language-server", 3186 | "category": "Sumneko lua-language-server" 3187 | }, 3188 | { 3189 | "command": "sumneko-lua.restart", 3190 | "title": "Restart server", 3191 | "category": "Sumneko lua-language-server" 3192 | }, 3193 | { 3194 | "command": "sumneko-lua.version", 3195 | "title": "Echo server version", 3196 | "category": "Sumneko lua-language-server" 3197 | }, 3198 | { 3199 | "command": "sumneko-lua.checkUpdate", 3200 | "title": "Check update", 3201 | "category": "Sumneko lua-language-server" 3202 | }, 3203 | { 3204 | "command": "sumneko-lua.showTooltip", 3205 | "title": "Show tooltips", 3206 | "category": "Sumneko lua-language-server" 3207 | }, 3208 | { 3209 | "command": "sumneko-lua.insertNvimLuaPluginLibrary", 3210 | "title": "Insert nvim lua plugin to current workspace library", 3211 | "category": "Sumneko lua-language-server" 3212 | }, 3213 | { 3214 | "command": "sumneko-lua.downloadNvimLuaTypes", 3215 | "title": "Download/Update nvim lua types(Clone https://github.com/folke/neodev.nvim)", 3216 | "category": "Sumneko lua-language-server" 3217 | } 3218 | ] 3219 | }, 3220 | "scripts": { 3221 | "lint": "eslint src", 3222 | "lint:fix": "eslint src --fix", 3223 | "clean": "rimraf lib", 3224 | "watch": "node esbuild.mjs --watch", 3225 | "build": "node esbuild.mjs", 3226 | "prepare": "node esbuild.mjs", 3227 | "schema": "node ./update-config.js", 3228 | "release": "bumpp && npm publish" 3229 | }, 3230 | "dependencies": { 3231 | "tslib": "^2.6.2" 3232 | }, 3233 | "devDependencies": { 3234 | "@types/fs-extra": "^11.0.4", 3235 | "@types/node": "^16.0.0", 3236 | "@types/node-fetch": "2.6.11", 3237 | "@wongxy/eslint-config": "^0.0.17", 3238 | "bumpp": "^9.4.0", 3239 | "coc.nvim": "^0.0.83-next.18", 3240 | "esbuild": "0.20.2", 3241 | "eslint": "^8.57.0", 3242 | "executable": "^4.1.1", 3243 | "extract-zip": "^2.0.1", 3244 | "fs-extra": "^11.2.0", 3245 | "node-fetch": "2.7.0", 3246 | "node-version-compare": "^1.0.3", 3247 | "rimraf": "^5.0.5", 3248 | "typescript": "4.9.5" 3249 | } 3250 | } 3251 | -------------------------------------------------------------------------------- /settings.md: -------------------------------------------------------------------------------- 1 | # Get more information 2 | 3 | - [schema.json](https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json) 4 | - trigger completion in coc-settings 5 | ## `sumneko-lua.enable` 6 | - type: `boolean` 7 | - default: `true` 8 | - description: Enable coc-sumneko-lua extension 9 | ## `sumneko-lua.prompt` 10 | - type: `boolean` 11 | - default: `true` 12 | - description: Prompt when server is not found or when server can be updated 13 | ## `sumneko-lua.locale` 14 | - type: `string` 15 | - default: `"en-us"` 16 | - description: The localized language used 17 | ## `sumneko-lua.logPath` 18 | - type: `string` 19 | - default: `""` 20 | - description: The log path 21 | ## `sumneko-lua.enableNvimLuaDev` 22 | - type: `boolean` 23 | - default: `false` 24 | - description: Enable the nvim lua development 25 | ## `sumneko-lua.checkUpdate` 26 | - type: `boolean` 27 | - default: `true` 28 | - description: Automatically check for updates after startup(Only one check within 4 hours) 29 | ## `sumneko-lua.serverDir` 30 | - type: `string` 31 | - default: `null` 32 | - description: The server directory which contains: bin/, changelog.md, debugger.lua, locale/, main.lua, meta/, script/. Download and set by default 33 | ## `Lua.addonManager.enable` 34 | - type: `boolean` 35 | - default: `true` 36 | - description: Whether the addon manager is enabled or not. 37 | ## `Lua.codeLens.enable` 38 | - type: `boolean` 39 | - default: `false` 40 | - description: Enable code lens. 41 | ## `Lua.completion.autoRequire` 42 | - type: `boolean` 43 | - default: `true` 44 | - description: When the input looks like a file name, automatically `require` this file. 45 | ## `Lua.completion.callSnippet` 46 | - type: `string` 47 | - default: `"Disable"` 48 | - description: Shows function call snippets. 49 | ## `Lua.completion.displayContext` 50 | - type: `integer` 51 | - default: `0` 52 | - description: Previewing the relevant code snippet of the suggestion may help you understand the usage of the suggestion. The number set indicates the number of intercepted lines in the code fragment. If it is set to `0`, this feature can be disabled. 53 | ## `Lua.completion.enable` 54 | - type: `boolean` 55 | - default: `true` 56 | - description: Enable completion. 57 | ## `Lua.completion.keywordSnippet` 58 | - type: `string` 59 | - default: `"Replace"` 60 | - description: Shows keyword syntax snippets. 61 | ## `Lua.completion.postfix` 62 | - type: `string` 63 | - default: `"@"` 64 | - description: The symbol used to trigger the postfix suggestion. 65 | ## `Lua.completion.requireSeparator` 66 | - type: `string` 67 | - default: `"."` 68 | - description: The separator used when `require`. 69 | ## `Lua.completion.showParams` 70 | - type: `boolean` 71 | - default: `true` 72 | - description: Display parameters in completion list. When the function has multiple definitions, they will be displayed separately. 73 | ## `Lua.completion.showWord` 74 | - type: `string` 75 | - default: `"Fallback"` 76 | - description: Show contextual words in suggestions. 77 | ## `Lua.completion.workspaceWord` 78 | - type: `boolean` 79 | - default: `true` 80 | - description: Whether the displayed context word contains the content of other files in the workspace. 81 | ## `Lua.diagnostics.disable` 82 | - type: `array` 83 | - default: `[]` 84 | - description: Disabled diagnostic (Use code in hover brackets). 85 | ## `Lua.diagnostics.disableScheme` 86 | - type: `array` 87 | - default: `["git"]` 88 | - description: Do not diagnose Lua files that use the following scheme. 89 | ## `Lua.diagnostics.enable` 90 | - type: `boolean` 91 | - default: `true` 92 | - description: Enable diagnostics. 93 | ## `Lua.diagnostics.globals` 94 | - type: `array` 95 | - default: `[]` 96 | - description: Defined global variables. 97 | ## `Lua.diagnostics.groupFileStatus` 98 | - type: `object` 99 | - default: `undefined` 100 | - description: Modify the diagnostic needed file status in a group. 101 | 102 | * Opened: only diagnose opened files 103 | * Any: diagnose all files 104 | * None: disable this diagnostic 105 | 106 | `Fallback` means that diagnostics in this group are controlled by `diagnostics.neededFileStatus` separately. 107 | Other settings will override individual settings without end of `!`. 108 | 109 | ## `Lua.diagnostics.groupSeverity` 110 | - type: `object` 111 | - default: `undefined` 112 | - description: Modify the diagnostic severity in a group. 113 | `Fallback` means that diagnostics in this group are controlled by `diagnostics.severity` separately. 114 | Other settings will override individual settings without end of `!`. 115 | 116 | ## `Lua.diagnostics.ignoredFiles` 117 | - type: `string` 118 | - default: `"Opened"` 119 | - description: How to diagnose ignored files. 120 | ## `Lua.diagnostics.libraryFiles` 121 | - type: `string` 122 | - default: `"Opened"` 123 | - description: How to diagnose files loaded via `Lua.workspace.library`. 124 | ## `Lua.diagnostics.neededFileStatus` 125 | - type: `object` 126 | - default: `undefined` 127 | - description: * Opened: only diagnose opened files 128 | * Any: diagnose all files 129 | * None: disable this diagnostic 130 | 131 | End with `!` means override the group setting `diagnostics.groupFileStatus`. 132 | 133 | ## `Lua.diagnostics.severity` 134 | - type: `object` 135 | - default: `undefined` 136 | - description: Modify the diagnostic severity. 137 | 138 | End with `!` means override the group setting `diagnostics.groupSeverity`. 139 | 140 | ## `Lua.diagnostics.unusedLocalExclude` 141 | - type: `array` 142 | - default: `[]` 143 | - description: Do not diagnose `unused-local` when the variable name matches the following pattern. 144 | ## `Lua.diagnostics.workspaceDelay` 145 | - type: `integer` 146 | - default: `3000` 147 | - description: Latency (milliseconds) for workspace diagnostics. 148 | ## `Lua.diagnostics.workspaceEvent` 149 | - type: `string` 150 | - default: `"OnSave"` 151 | - description: Set the time to trigger workspace diagnostics. 152 | ## `Lua.diagnostics.workspaceRate` 153 | - type: `integer` 154 | - default: `100` 155 | - description: Workspace diagnostics run rate (%). Decreasing this value reduces CPU usage, but also reduces the speed of workspace diagnostics. The diagnosis of the file you are currently editing is always done at full speed and is not affected by this setting. 156 | ## `Lua.doc.packageName` 157 | - type: `array` 158 | - default: `[]` 159 | - description: Treat specific field names as package, e.g. `m_*` means `XXX.m_id` and `XXX.m_type` are package, witch can only be accessed in the file where the definition is located. 160 | ## `Lua.doc.privateName` 161 | - type: `array` 162 | - default: `[]` 163 | - description: Treat specific field names as private, e.g. `m_*` means `XXX.m_id` and `XXX.m_type` are private, witch can only be accessed in the class where the definition is located. 164 | ## `Lua.doc.protectedName` 165 | - type: `array` 166 | - default: `[]` 167 | - description: Treat specific field names as protected, e.g. `m_*` means `XXX.m_id` and `XXX.m_type` are protected, witch can only be accessed in the class where the definition is located and its subclasses. 168 | ## `Lua.format.defaultConfig` 169 | - type: `object` 170 | - default: `{}` 171 | - description: The default format configuration. Has a lower priority than `.editorconfig` file in the workspace. 172 | Read [formatter docs](https://github.com/CppCXY/EmmyLuaCodeStyle/tree/master/docs) to learn usage. 173 | 174 | ## `Lua.format.enable` 175 | - type: `boolean` 176 | - default: `true` 177 | - description: Enable code formatter. 178 | ## `Lua.hint.arrayIndex` 179 | - type: `string` 180 | - default: `"Auto"` 181 | - description: Show hints of array index when constructing a table. 182 | ## `Lua.hint.await` 183 | - type: `boolean` 184 | - default: `true` 185 | - description: If the called function is marked `---@async`, prompt `await` at the call. 186 | ## `Lua.hint.enable` 187 | - type: `boolean` 188 | - default: `true` 189 | - description: Enable inlay hint. 190 | ## `Lua.hint.paramName` 191 | - type: `string` 192 | - default: `"All"` 193 | - description: Show hints of parameter name at the function call. 194 | ## `Lua.hint.paramType` 195 | - type: `boolean` 196 | - default: `true` 197 | - description: Show type hints at the parameter of the function. 198 | ## `Lua.hint.semicolon` 199 | - type: `string` 200 | - default: `"SameLine"` 201 | - description: If there is no semicolon at the end of the statement, display a virtual semicolon. 202 | ## `Lua.hint.setType` 203 | - type: `boolean` 204 | - default: `false` 205 | - description: Show hints of type at assignment operation. 206 | ## `Lua.hover.enable` 207 | - type: `boolean` 208 | - default: `true` 209 | - description: Enable hover. 210 | ## `Lua.hover.enumsLimit` 211 | - type: `integer` 212 | - default: `5` 213 | - description: When the value corresponds to multiple types, limit the number of types displaying. 214 | ## `Lua.hover.expandAlias` 215 | - type: `boolean` 216 | - default: `true` 217 | - description: Whether to expand the alias. For example, expands `---@alias myType boolean|number` appears as `boolean|number`, otherwise it appears as `myType'. 218 | 219 | ## `Lua.hover.previewFields` 220 | - type: `integer` 221 | - default: `50` 222 | - description: When hovering to view a table, limits the maximum number of previews for fields. 223 | ## `Lua.hover.viewNumber` 224 | - type: `boolean` 225 | - default: `true` 226 | - description: Hover to view numeric content (only if literal is not decimal). 227 | ## `Lua.hover.viewString` 228 | - type: `boolean` 229 | - default: `true` 230 | - description: Hover to view the contents of a string (only if the literal contains an escape character). 231 | ## `Lua.hover.viewStringMax` 232 | - type: `integer` 233 | - default: `1000` 234 | - description: The maximum length of a hover to view the contents of a string. 235 | ## `Lua.misc.executablePath` 236 | - type: `string` 237 | - default: `""` 238 | - description: Specify the executable path. 239 | ## `Lua.misc.parameters` 240 | - type: `array` 241 | - default: `[]` 242 | - description: Additional command line parameters when starting the language service. 243 | ## `Lua.nameStyle.config` 244 | - type: `object` 245 | - default: `{}` 246 | - description: Set name style config 247 | ## `Lua.runtime.builtin` 248 | - type: `object` 249 | - default: `undefined` 250 | - description: Adjust the enabled state of the built-in library. You can disable (or redefine) the non-existent library according to the actual runtime environment. 251 | 252 | * `default`: Indicates that the library will be enabled or disabled according to the runtime version 253 | * `enable`: always enable 254 | * `disable`: always disable 255 | 256 | ## `Lua.runtime.fileEncoding` 257 | - type: `string` 258 | - default: `"utf8"` 259 | - description: File encoding. The `ansi` option is only available under the `Windows` platform. 260 | ## `Lua.runtime.meta` 261 | - type: `string` 262 | - default: `"${version} ${language} ${encoding}"` 263 | - description: Format of the directory name of the meta files. 264 | ## `Lua.runtime.nonstandardSymbol` 265 | - type: `array` 266 | - default: `[]` 267 | - description: Supports non-standard symbols. Make sure that your runtime environment supports these symbols. 268 | ## `Lua.runtime.path` 269 | - type: `array` 270 | - default: `["?.lua","?/init.lua"]` 271 | - description: When using `require`, how to find the file based on the input name. 272 | Setting this config to `?/init.lua` means that when you enter `require 'myfile'`, `${workspace}/myfile/init.lua` will be searched from the loaded files. 273 | if `runtime.pathStrict` is `false`, `${workspace}/**/myfile/init.lua` will also be searched. 274 | If you want to load files outside the workspace, you need to set `Lua.workspace.library` first. 275 | 276 | ## `Lua.runtime.pathStrict` 277 | - type: `boolean` 278 | - default: `false` 279 | - description: When enabled, `runtime.path` will only search the first level of directories, see the description of `runtime.path`. 280 | ## `Lua.runtime.plugin` 281 | - type: `string` 282 | - default: `""` 283 | - description: Plugin path. Please read [wiki](https://luals.github.io/wiki/plugins) to learn more. 284 | ## `Lua.runtime.pluginArgs` 285 | - type: `array` 286 | - default: `[]` 287 | - description: Additional arguments for the plugin. 288 | ## `Lua.runtime.special` 289 | - type: `object` 290 | - default: `{}` 291 | - description: The custom global variables are regarded as some special built-in variables, and the language server will provide special support 292 | The following example shows that 'include' is treated as' require '. 293 | ```json 294 | "Lua.runtime.special" : { 295 | "include" : "require" 296 | } 297 | ``` 298 | 299 | ## `Lua.runtime.unicodeName` 300 | - type: `boolean` 301 | - default: `false` 302 | - description: Allows Unicode characters in name. 303 | ## `Lua.runtime.version` 304 | - type: `string` 305 | - default: `"Lua 5.4"` 306 | - description: Lua runtime version. 307 | ## `Lua.semantic.annotation` 308 | - type: `boolean` 309 | - default: `true` 310 | - description: Semantic coloring of type annotations. 311 | ## `Lua.semantic.enable` 312 | - type: `boolean` 313 | - default: `true` 314 | - description: Enable semantic color. You may need to set `editor.semanticHighlighting.enabled` to `true` to take effect. 315 | ## `Lua.semantic.keyword` 316 | - type: `boolean` 317 | - default: `false` 318 | - description: Semantic coloring of keywords/literals/operators. You only need to enable this feature if your editor cannot do syntax coloring. 319 | ## `Lua.semantic.variable` 320 | - type: `boolean` 321 | - default: `true` 322 | - description: Semantic coloring of variables/fields/parameters. 323 | ## `Lua.signatureHelp.enable` 324 | - type: `boolean` 325 | - default: `true` 326 | - description: Enable signature help. 327 | ## `Lua.spell.dict` 328 | - type: `array` 329 | - default: `[]` 330 | - description: Custom words for spell checking. 331 | ## `Lua.type.castNumberToInteger` 332 | - type: `boolean` 333 | - default: `true` 334 | - description: Allowed to assign the `number` type to the `integer` type. 335 | ## `Lua.type.weakNilCheck` 336 | - type: `boolean` 337 | - default: `false` 338 | - description: When checking the type of union type, ignore the `nil` in it. 339 | 340 | When this setting is `false`, the `number|nil` type cannot be assigned to the `number` type. It can be with `true`. 341 | 342 | ## `Lua.type.weakUnionCheck` 343 | - type: `boolean` 344 | - default: `false` 345 | - description: Once one subtype of a union type meets the condition, the union type also meets the condition. 346 | 347 | When this setting is `false`, the `number|boolean` type cannot be assigned to the `number` type. It can be with `true`. 348 | 349 | ## `Lua.typeFormat.config` 350 | - type: `object` 351 | - default: `undefined` 352 | - description: Configures the formatting behavior while typing Lua code. 353 | ## `Lua.window.progressBar` 354 | - type: `boolean` 355 | - default: `true` 356 | - description: Show progress bar in status bar. 357 | ## `Lua.window.statusBar` 358 | - type: `boolean` 359 | - default: `true` 360 | - description: Show extension status in status bar. 361 | ## `Lua.workspace.checkThirdParty` 362 | - type: `string,boolean` 363 | - default: `undefined` 364 | - description: Automatic detection and adaptation of third-party libraries, currently supported libraries are: 365 | 366 | * OpenResty 367 | * Cocos4.0 368 | * LÖVE 369 | * LÖVR 370 | * skynet 371 | * Jass 372 | 373 | ## `Lua.workspace.ignoreDir` 374 | - type: `array` 375 | - default: `[".vscode"]` 376 | - description: Ignored files and directories (Use `.gitignore` grammar). 377 | ## `Lua.workspace.ignoreSubmodules` 378 | - type: `boolean` 379 | - default: `true` 380 | - description: Ignore submodules. 381 | ## `Lua.workspace.library` 382 | - type: `array` 383 | - default: `[]` 384 | - description: In addition to the current workspace, which directories will load files from. The files in these directories will be treated as externally provided code libraries, and some features (such as renaming fields) will not modify these files. 385 | ## `Lua.workspace.maxPreload` 386 | - type: `integer` 387 | - default: `5000` 388 | - description: Max preloaded files. 389 | ## `Lua.workspace.preloadFileSize` 390 | - type: `integer` 391 | - default: `500` 392 | - description: Skip files larger than this value (KB) when preloading. 393 | ## `Lua.workspace.useGitIgnore` 394 | - type: `boolean` 395 | - default: `true` 396 | - description: Ignore files list in `.gitignore` . 397 | ## `Lua.workspace.userThirdParty` 398 | - type: `array` 399 | - default: `[]` 400 | - description: Add private third-party library configuration file paths here, please refer to the built-in [configuration file path](https://github.com/LuaLS/lua-language-server/tree/master/meta/3rd) 401 | -------------------------------------------------------------------------------- /src/commands.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path' 2 | import { window, workspace } from 'coc.nvim' 3 | import { existsSync } from 'fs-extra' 4 | import type { Cmd, Ctx } from './ctx' 5 | import { downloadServer } from './downloader' 6 | 7 | export function install(ctx: Ctx): Cmd { 8 | return async () => { 9 | await downloadServer(ctx.extCtx) 10 | if (ctx.client && ctx.client.needsStop()) { 11 | await ctx.client.stop() 12 | ctx.client.start() 13 | } 14 | else { 15 | window.showInformationMessage('May be you should restart the server') 16 | } 17 | } 18 | } 19 | 20 | export function version(ctx: Ctx): Cmd { 21 | return async () => { 22 | const v = (await ctx.getCurrentVersion()) || 'unknown version' 23 | window.showInformationMessage(v) 24 | } 25 | } 26 | 27 | export function showTooltip(ctx: Ctx): Cmd { 28 | return async () => { 29 | window.showNotification({ content: ctx.barTooltip }) 30 | } 31 | } 32 | 33 | export function insertNvimLuaPluginLibrary(_: Ctx): Cmd { 34 | return async () => { 35 | const config = workspace.getConfiguration('Lua.workspace') 36 | const library = Array.from(config.get('library') || []) 37 | 38 | const runtimepath = (await workspace.nvim.getOption('runtimepath')) as string 39 | const paths = runtimepath 40 | .split(',') 41 | .map((v) => { 42 | return path.join(v, 'lua') 43 | }) 44 | .filter(v => !library.includes(v) && existsSync(v)) 45 | 46 | if (!paths.length) 47 | return 48 | 49 | const vimruntime = (await workspace.nvim.call('expand', ['$VIMRUNTIME/lua'])) as string 50 | const myvimrc = path.join(path.dirname(await workspace.nvim.call('expand', ['$MYVIMRC'])), 'lua') 51 | 52 | const idx = await window.showQuickpick( 53 | paths.map((v, i) => { 54 | let name = '' 55 | 56 | if (v === vimruntime) 57 | name = `${vimruntime} (auto added if sumneko-lua.enableNvimLuaDev is true )` 58 | else if (v === myvimrc) 59 | name = `${myvimrc} (not recommended)` 60 | else 61 | name = path.basename(path.dirname(v)) 62 | 63 | return i < 9 ? ` ${name}` : name 64 | }), 65 | ) 66 | if (idx !== -1) { 67 | library.push(paths[idx]) 68 | config.update('library', library) 69 | } 70 | } 71 | } 72 | 73 | export function downloadNvimLuaTypes(ctx: Ctx): Cmd { 74 | return async () => { 75 | await ctx.neodev.downloadTypes() 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/config.ts: -------------------------------------------------------------------------------- 1 | import { workspace } from 'coc.nvim' 2 | 3 | export type Locale = 'en-us' | 'pt-br' | 'zh-cn' | 'zh-tw' 4 | 5 | export class Config { 6 | private readonly rootSection = 'sumneko-lua' 7 | 8 | get cfg() { 9 | return workspace.getConfiguration(this.rootSection) 10 | } 11 | 12 | get enabled() { 13 | return this.cfg.get('enable') 14 | } 15 | 16 | get prompt() { 17 | return this.cfg.get('prompt') 18 | } 19 | 20 | get locale() { 21 | return this.cfg.get('locale') 22 | } 23 | 24 | get logPath() { 25 | return this.cfg.get('logPath')! 26 | } 27 | 28 | get nvimLuaDev() { 29 | return this.cfg.get('enableNvimLuaDev') 30 | } 31 | 32 | get checkUpdate() { 33 | return this.cfg.get('checkUpdate') 34 | } 35 | 36 | get serverDir() { 37 | return this.cfg.get('serverDir') 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/ctx.ts: -------------------------------------------------------------------------------- 1 | import { execSync } from 'node:child_process' 2 | import path from 'node:path' 3 | import type { 4 | Disposable, 5 | ExtensionContext, 6 | LanguageClientOptions, 7 | ServerOptions, 8 | TextDocument, 9 | } from 'coc.nvim' 10 | import { 11 | LanguageClient, 12 | commands, 13 | events, 14 | services, 15 | window, 16 | workspace, 17 | } from 'coc.nvim' 18 | import executable from 'executable' 19 | import * as fs from 'fs-extra' 20 | import versionCompare from 'node-version-compare' 21 | import { Config } from './config' 22 | import { downloadServer, getLatestRelease } from './downloader' 23 | import { Neodev } from './neodev' 24 | 25 | export type LuaDocument = TextDocument & { languageId: 'lua' } 26 | export function isLuaDocument(document: TextDocument): document is LuaDocument { 27 | const ret = document.languageId === 'lua' 28 | return ret 29 | } 30 | 31 | export type Cmd = (...args: any[]) => unknown 32 | 33 | export class Ctx { 34 | client!: LanguageClient 35 | public readonly config = new Config() 36 | barTooltip = '' 37 | neodev!: Neodev 38 | 39 | constructor(public readonly extCtx: ExtensionContext) { 40 | this.neodev = new Neodev(extCtx) 41 | } 42 | 43 | registerCommand(name: string, factory: (ctx: Ctx) => Cmd, internal = false) { 44 | const fullName = `sumneko-lua.${name}` 45 | const cmd = factory(this) 46 | const d = commands.registerCommand(fullName, cmd, null, internal) 47 | this.extCtx.subscriptions.push(d) 48 | } 49 | 50 | get subscriptions(): Disposable[] { 51 | return this.extCtx.subscriptions 52 | } 53 | 54 | resolveBin(): [string, string[]] | undefined { 55 | // TODO: handle Lua.misc.executablePath 56 | const serverDir = this.config.serverDir 57 | ? this.config.serverDir 58 | : path.join(this.extCtx.storagePath, 'sumneko-lua-ls', 'extension', 'server') 59 | 60 | const platform = process.platform 61 | const bin = path.join(serverDir, 'bin', platform === 'win32' ? 'lua-language-server.exe' : 'lua-language-server') 62 | if (!fs.existsSync(bin)) 63 | return 64 | 65 | if (!executable.sync(bin)) { 66 | window.showInformationMessage(`${bin} is not executable`, 'error') 67 | return 68 | } 69 | 70 | const args: string[] = ['-E', path.join(serverDir, 'bin', 'main.lua'), `--locale=${this.config.locale}`].concat( 71 | workspace.getConfiguration('Lua').get('misc.parameters')!, 72 | ) 73 | if (this.config.logPath.length > 0) 74 | args.push(`--logpath=${this.config.logPath}`) 75 | 76 | return [bin, args] 77 | } 78 | 79 | async getCurrentVersion(): Promise { 80 | if (this.config.serverDir) { 81 | const bin = this.resolveBin() 82 | if (!bin) 83 | return 84 | const [cmd, args] = bin 85 | args.push('--version') 86 | try { 87 | return String(execSync(`${cmd} ${args.join(' ')}`)).trim() 88 | } 89 | catch (err) { 90 | console.log(err) 91 | } 92 | } 93 | else { 94 | // must be based on the version of vscode extension 95 | try { 96 | const packageJson = path.join(this.extCtx.storagePath, 'sumneko-lua-ls', 'extension', 'package.json') 97 | const packageData = await fs.readJson(packageJson) 98 | return packageData.version 99 | } 100 | catch (err) { 101 | console.error(err) 102 | } 103 | } 104 | } 105 | 106 | async checkUpdate() { 107 | // no need 108 | if (this.config.serverDir) 109 | return 110 | 111 | const currentVersion = await this.getCurrentVersion() 112 | if (!currentVersion) 113 | return 114 | 115 | const latest = await getLatestRelease() 116 | if (!latest) 117 | return 118 | 119 | const latestVersion = latest.version.match(/\d.*/) 120 | if (!latestVersion) 121 | return 122 | 123 | if (versionCompare(latestVersion[0], currentVersion) <= 0) 124 | return 125 | 126 | const msg = `Sumneko lua-language-server has a new release: ${latest.version}, you're using v${currentVersion}.` 127 | if (this.config.prompt) { 128 | const ret = await window.showQuickpick(['Download the latest server', 'Cancel'], msg) 129 | if (ret === 0) { 130 | await this.client.stop() 131 | try { 132 | await downloadServer(this.extCtx, latest) 133 | } 134 | catch (e) { 135 | console.error(e) 136 | window.showInformationMessage('Upgrade server failed', 'error') 137 | return 138 | } 139 | this.client.start() 140 | } 141 | else { 142 | window.showInformationMessage(`You can run ':CocCommand sumneko-lua.install' to upgrade server manually`) 143 | } 144 | } 145 | else { 146 | window.showInformationMessage(`${msg} Run :CocCommand sumneko-lua.install to upgrade`) 147 | } 148 | } 149 | 150 | createClient(): undefined | LanguageClient { 151 | const bin = this.resolveBin() 152 | if (!bin) 153 | return 154 | 155 | const [command, args] = bin 156 | 157 | const serverOptions: ServerOptions = { command, args } 158 | 159 | const clientOptions: LanguageClientOptions = { 160 | documentSelector: [{ language: 'lua' }], 161 | progressOnInitialization: true, 162 | initializationOptions: { 163 | changeConfiguration: true, 164 | }, 165 | middleware: { 166 | workspace: { 167 | configuration: async (params, token, next) => { 168 | const result = await next(params, token) 169 | 170 | if (!this.config.nvimLuaDev || !Array.isArray(result)) 171 | return result 172 | 173 | const sectionIndex = params.items.findIndex(item => item.section === 'Lua') 174 | 175 | if (sectionIndex === -1) 176 | return result 177 | 178 | const configuration = result[sectionIndex] 179 | 180 | const library = configuration.workspace.library || [] 181 | 182 | const runtime = await workspace.nvim.call('expand', ['$VIMRUNTIME/lua']) 183 | if (!library.includes(runtime)) 184 | library.push(runtime) 185 | 186 | const types = await this.neodev.getTypesPath() 187 | if (types && !library.includes(types)) 188 | library.push(types) 189 | 190 | configuration.workspace.library = library 191 | 192 | result[sectionIndex] = configuration 193 | 194 | return result 195 | }, 196 | }, 197 | }, 198 | } 199 | return new LanguageClient('sumneko-lua', 'Sumneko Lua Language Server', serverOptions, clientOptions) 200 | } 201 | 202 | async startServer() { 203 | const client = this.createClient() 204 | if (!client) 205 | return 206 | this.extCtx.subscriptions.push(services.registLanguageClient(client)) 207 | await client.onReady() 208 | this.client = client 209 | // activate components 210 | this.activateCommand() 211 | this.activateStatusBar() 212 | } 213 | 214 | activateStatusBar() { 215 | // window status bar 216 | const bar = window.createStatusBarItem() 217 | this.extCtx.subscriptions.push(bar) 218 | 219 | let keepHide = false 220 | 221 | this.client.onNotification('$/status/show', () => { 222 | keepHide = false 223 | bar.show() 224 | }) 225 | this.client.onNotification('$/status/hide', () => { 226 | keepHide = true 227 | bar.hide() 228 | }) 229 | this.client.onNotification('$/status/report', (params) => { 230 | const text: string = params.text 231 | bar.isProgress = text.includes('$(loading~spin)') 232 | bar.text = text.replace('$(loading~spin)', '') 233 | this.barTooltip = params.tooltip 234 | }) 235 | 236 | events.on( 237 | 'BufEnter', 238 | async () => { 239 | const doc = await workspace.document 240 | if (isLuaDocument(doc.textDocument)) { 241 | if (!keepHide) 242 | bar.show() 243 | } 244 | else { 245 | bar.hide() 246 | } 247 | }, 248 | null, 249 | this.extCtx.subscriptions, 250 | ) 251 | } 252 | 253 | activateCommand() { 254 | this.client.onNotification('$/command', (params) => { 255 | if (params.command !== 'lua.config') 256 | return 257 | 258 | const propMap: Map> = new Map() 259 | for (const data of params.data) { 260 | const folder = workspace.getWorkspaceFolder(data.uri) 261 | const config = workspace.getConfiguration(undefined, folder ? data.uri : undefined) 262 | if (data.action === 'add') { 263 | let value = config.get(data.key, []) 264 | // weird... 265 | value = Array.from(value) 266 | value.push(data.value) 267 | config.update(data.key, value, data.global) 268 | continue 269 | } 270 | if (data.action === 'set') { 271 | config.update(data.key, data.value, data.global) 272 | continue 273 | } 274 | if (data.action === 'prop') { 275 | if (!propMap[data.key]) 276 | propMap[data.key] = config.get(data.key) 277 | 278 | propMap[data.key][data.prop] = data.value 279 | config.update(data.key, propMap[data.key], data.global) 280 | continue 281 | } 282 | } 283 | }) 284 | } 285 | } 286 | -------------------------------------------------------------------------------- /src/downloader.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path' 2 | import * as os from 'node:os' 3 | import type { ExtensionContext } from 'coc.nvim' 4 | import { window } from 'coc.nvim' 5 | import extract from 'extract-zip' 6 | import type { Response } from 'node-fetch' 7 | import fetch from 'node-fetch' 8 | import * as fs from 'fs-extra' 9 | 10 | const ls_name = 'sumneko-lua-ls' 11 | 12 | export interface Release { 13 | version: string 14 | url: string 15 | } 16 | 17 | export async function getLatestRelease(): Promise { 18 | const headers = { 19 | 'Accept': 'application/json;api-version=6.1-preview.1;', 20 | 'Content-Type': 'application/json', 21 | 'user-agent': 'VSCode', 22 | } 23 | const body = JSON.stringify({ 24 | filters: [ 25 | { 26 | criteria: [ 27 | { 28 | filterType: 4, 29 | value: '3a15b5a7-be12-47e3-8445-88ee3eabc8b2', 30 | }, 31 | ], 32 | }, 33 | ], 34 | flags: 950, 35 | }) 36 | let response: Response 37 | try { 38 | response = await fetch('https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery ', { 39 | method: 'POST', 40 | headers, 41 | body, 42 | timeout: 10e3, 43 | }) 44 | } 45 | catch (err) { 46 | window.showErrorMessage(`[coc-sumneko]: Request failed! Please check your internet!`) 47 | console.error(err) 48 | return 49 | } 50 | 51 | if (!response.ok) { 52 | console.error(await response.text()) 53 | return 54 | } 55 | 56 | const osPlatform = ['linux', 'darwin', 'win32'].includes(os.platform()) ? os.platform() : 'linux' 57 | const targetPlatform = `${osPlatform}-${os.arch()}` 58 | 59 | const release = await response.json() 60 | 61 | const extension = release.results[0].extensions[0].versions[0] 62 | 63 | return { 64 | version: extension.version, 65 | url: `${extension.assetUri}/Microsoft.VisualStudio.Services.VSIXPackage?redirect=true&targetPlatform=${targetPlatform}&install=true`, 66 | } 67 | } 68 | 69 | export async function downloadServer(context: ExtensionContext, release?: Release): Promise { 70 | const statusItem = window.createStatusBarItem(0, { progress: true }) 71 | statusItem.show() 72 | 73 | if (!release) { 74 | statusItem.text = 'Fetching latest release information' 75 | release = await getLatestRelease() 76 | if (!release) { 77 | statusItem.hide() 78 | window.showMessage('Get latest release information failed', 'error') 79 | return 80 | } 81 | } 82 | 83 | statusItem.text = 'Downloading latest sumneko lua-language-server' 84 | 85 | const resp = await fetch(release.url, { 86 | headers: { 87 | 'user-agent': 'VSCode', 88 | }, 89 | }) 90 | if (!resp.ok) { 91 | statusItem.hide() 92 | throw new Error('Download failed! Maybe the provided target platform is not supported for now') 93 | } 94 | 95 | const buffer = await resp.buffer() 96 | 97 | const targetPath = path.join(context.storagePath, ls_name) 98 | const tempDir = await fs.mkdtemp(ls_name) 99 | const extTempFile = path.join(tempDir, ls_name) 100 | 101 | statusItem.text = `Writing temp file ${extTempFile}` 102 | await fs.writeFile(extTempFile, buffer) 103 | 104 | statusItem.text = `Removing old files` 105 | await fs.remove(targetPath) 106 | 107 | statusItem.text = `Extracting to ${targetPath}` 108 | await extract(extTempFile, { dir: targetPath }) 109 | 110 | const binPath = path.join(targetPath, 'extension', 'server', 'bin', 'lua-language-server') 111 | if (fs.existsSync(binPath)) 112 | await fs.chmod(binPath, '777') 113 | 114 | statusItem.text = `Removing temp file ${extTempFile}` 115 | await fs.remove(tempDir) 116 | 117 | window.showMessage(`Installed ${targetPath} successfully`) 118 | statusItem.hide() 119 | } 120 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path' 2 | import type { ExtensionContext } from 'coc.nvim' 3 | import { window } from 'coc.nvim' 4 | import { existsSync, mkdirSync, readFile, writeFile } from 'fs-extra' 5 | import * as cmds from './commands' 6 | import { Ctx } from './ctx' 7 | import { downloadServer } from './downloader' 8 | 9 | export async function activate(context: ExtensionContext): Promise { 10 | const ctx = new Ctx(context) 11 | if (!ctx.config.enabled) 12 | return 13 | 14 | const serverRoot = context.storagePath 15 | if (!existsSync(serverRoot)) 16 | mkdirSync(serverRoot) 17 | 18 | ctx.registerCommand('install', cmds.install) 19 | 20 | const bin = ctx.resolveBin() 21 | if (!bin) { 22 | let ret = 'Yes' 23 | if (ctx.config.prompt) { 24 | ret 25 | = (await window.showInformationMessage( 26 | 'Sumneko lua language server is not found, install now?', 27 | 'Yes', 28 | 'Cancel', 29 | )) || 'Yes' 30 | } 31 | if (ret === 'Yes') { 32 | try { 33 | await downloadServer(context) 34 | } 35 | catch (e) { 36 | console.error(e) 37 | window.showInformationMessage('Download Sumneko lua language server failed', 'error') 38 | return 39 | } 40 | } 41 | else { 42 | window.showInformationMessage( 43 | `You can run ':CocCommand sumneko-lua.install' to install server manually or provide setting 'serverDir'`, 44 | ) 45 | return 46 | } 47 | } 48 | 49 | ctx.registerCommand('version', cmds.version) 50 | ctx.registerCommand('restart', (ctx) => { 51 | return async () => { 52 | window.showInformationMessage(`Reloading sumneko lua-language-server...`) 53 | 54 | for (const sub of ctx.subscriptions) { 55 | try { 56 | sub.dispose() 57 | } 58 | catch (e) { 59 | console.error(e) 60 | } 61 | } 62 | 63 | await activate(context) 64 | 65 | window.showInformationMessage(`Reloaded sumneko lua-language-server`) 66 | } 67 | }) 68 | ctx.registerCommand('showTooltip', cmds.showTooltip) 69 | ctx.registerCommand('insertNvimLuaPluginLibrary', cmds.insertNvimLuaPluginLibrary) 70 | ctx.registerCommand('checkUpdate', () => async () => await ctx.checkUpdate()) 71 | ctx.registerCommand('downloadNvimLuaTypes', cmds.downloadNvimLuaTypes) 72 | 73 | await ctx.startServer() 74 | if (ctx.config.checkUpdate) { 75 | const dataPath = path.join(context.storagePath, 'checkUpdate') 76 | let lastCheck = 0 77 | if (existsSync(dataPath)) 78 | lastCheck = Number((await readFile(dataPath)).toString()) 79 | 80 | const now = Date.now() 81 | if (now - lastCheck > 4 * 60 * 60 * 1000) { 82 | await ctx.checkUpdate() 83 | await writeFile(dataPath, now.toString()) 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/neodev.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path' 2 | import { exec } from 'node:child_process' 3 | import { promisify } from 'node:util' 4 | import type { ExtensionContext } from 'coc.nvim' 5 | import { window, workspace } from 'coc.nvim' 6 | import * as fs from 'fs-extra' 7 | 8 | const typesDirName = 'neodev' 9 | 10 | export class Neodev { 11 | constructor(private readonly context: ExtensionContext) {} 12 | autoDownloaded = false 13 | 14 | async downloadTypes(): Promise { 15 | // TODO: check updates 16 | window.showInformationMessage('Start downloading nvim lua types') 17 | await fs.remove(this.repoDir) 18 | await promisify(exec)(`git clone https://github.com/folke/neodev.nvim.git ${this.repoDir} --depth=1`) 19 | if (this.typesExist) 20 | window.showInformationMessage(`Download nvim lua types successfully!`) 21 | else 22 | window.showErrorMessage('Download nvim lua types failed!') 23 | } 24 | 25 | private get repoDir(): string { 26 | return path.join(this.context.storagePath, typesDirName) 27 | } 28 | 29 | private get typesExist(): boolean { 30 | return fs.existsSync(this.repoDir) 31 | } 32 | 33 | async getTypesPath(): Promise { 34 | if (!this.typesExist && !this.autoDownloaded) { 35 | this.autoDownloaded = true 36 | await this.downloadTypes() 37 | } 38 | if (this.typesExist) { 39 | return path.join( 40 | this.repoDir, 41 | 'types', 42 | workspace.isNvim && Boolean(await workspace.nvim.call('luaeval', 'vim.version().prerelease')) ? 'nightly' : 'stable', 43 | ) 44 | } 45 | else { 46 | window.showWarningMessage('Please run command: installNvimLuaTypes') 47 | return '' 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "lib": ["es2017", "es2018"], 5 | "module": "commonjs", 6 | "moduleResolution": "node", 7 | "strict": true, 8 | "noImplicitAny": false, 9 | "declaration": false, 10 | "outDir": "lib", 11 | "sourceMap": true, 12 | "esModuleInterop": true 13 | }, 14 | "include": ["src"] 15 | } 16 | -------------------------------------------------------------------------------- /update-config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const fs = require('node:fs') 4 | const fetch = require('node-fetch') 5 | 6 | const packageJson = require('./package.json') 7 | const config = require('./coc-sumneko-lua.json') 8 | 9 | const overrids = { 10 | 'Lua.hint.enable': { 11 | default: true, 12 | }, 13 | 'Lua.misc.parameters': { 14 | default: [], 15 | markdownDescription: 'Additional command line parameters when starting the language service.', 16 | }, 17 | 'Lua.misc.executablePath': { 18 | markdownDescription: 'Specify the executable path.', 19 | }, 20 | } 21 | 22 | async function main() { 23 | const resp = await fetch('https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json') 24 | const schema = await resp.json() 25 | const properties = schema.properties 26 | 27 | // merge config 28 | console.log('merge config') 29 | Object.keys(properties).forEach((k) => { 30 | if (k.includes('.') || !properties[k].properties) 31 | config[`Lua.${k}`] = properties[k] 32 | }) 33 | Object.keys(overrids).forEach((key) => { 34 | config[key] = { ...config[key], ...overrids[key] } 35 | }) 36 | 37 | // write package.json 38 | console.log('write package.json') 39 | packageJson.contributes.configuration.properties = config 40 | fs.writeFileSync('./package.json', `${JSON.stringify(packageJson, null, 2)}\n`) 41 | 42 | // write settings.md 43 | console.log('write settings.md') 44 | const settingsFileStream = fs.createWriteStream('./settings.md') 45 | settingsFileStream.write(` 46 | # Get more information 47 | 48 | - [schema.json](https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json) 49 | - trigger completion in coc-settings 50 | `) 51 | Object.keys(config).forEach((key) => { 52 | const v = config[key] 53 | settingsFileStream.write( 54 | `## \`${key}\`\n- type: \`${v.type}\`\n- default: \`${JSON.stringify(v.default)}\`\n- description: ${ 55 | v.description ? v.description : v.markdownDescription 56 | }\n`, 57 | ) 58 | }) 59 | } 60 | 61 | main() 62 | --------------------------------------------------------------------------------