[
  {
    "path": ".eslintignore",
    "content": "/lib\nnode_module\n"
  },
  {
    "path": ".eslintrc",
    "content": "{\n  \"root\": true,\n  \"extends\": \"josa-typescript\",\n  \"env\": {\n    \"jest\": true\n  }\n}\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: Main\n\non: push\n\njobs:\n  test:\n    strategy:\n      fail-fast: false\n      matrix:\n        node: [ 16, 18 ]\n        os:\n          - ubuntu-latest\n          - macos-latest\n          # - windows-latest\n    runs-on: ${{ matrix.os }}\n    steps:\n      - uses: actions/checkout@v3\n      - uses: actions/setup-node@v3\n        with: { node-version: '${{ matrix.node }}' }\n      - run: npm ci\n      - run: npm run build\n      - run: npm run test --color\n      - run: npm run lint\n\n"
  },
  {
    "path": ".github/workflows/publish.yml",
    "content": "name: Publish\n\non:\n  schedule:\n    - cron:  '5 0 * * *'\n  workflow_dispatch:\n    inputs:\n      version:\n        type: choice\n        description: ''\n        default: patch\n        options:\n          - major\n          - minor\n          - patch\n\njobs:\n  publish:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: josa42/actions/npm-publish@main\n        with:\n          version: '${{ inputs.version }}'\n          npm-token: '${{ secrets.NPM_TOKEN }}'\n"
  },
  {
    "path": ".github/workflows/update-settings.yml",
    "content": "name: Settings\n\non:\n  schedule:\n    - cron:  '0 0 * * *'\n  workflow_dispatch:\n\njobs:\n  update:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: josa42/actions/update@main\n        with:\n          run-update: |\n            node ./scripts/update-settings.js\n          run-tests: |\n            npm ci\n            npm run build\n            npm run lint\n            npm run test\n"
  },
  {
    "path": ".gitignore",
    "content": "lib\nnode_modules\nyarn-error.log\n/.tmp\n.DS_Store\n"
  },
  {
    "path": ".node-version",
    "content": "v18\n"
  },
  {
    "path": ".npmignore",
    "content": "*.map\n*.ts\n/.eslintignore\n/.eslintrc\n/.github/\n/.node-version\n/.vim/\n/lib/**/*.test.js\n/lib/__mocks__/\n/scripts/\n/src/\n/tsconfig.json\n/tslint.json\n"
  },
  {
    "path": ".npmrc",
    "content": "legacy-peer-deps=true\n"
  },
  {
    "path": ".vim/coc-settings.json",
    "content": "{\n  \"coc.preferences.formatOnSaveFiletypes\": [\"javascript\", \"typescript\", \"json\"]\n}\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2019 Josa Gesell\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# coc-lua\n\n![test](https://github.com/josa42/coc-lua/workflows/Main/badge.svg)\n\n--------------------------------------------------------------------------------\n\nLua language server extension using [`LuaLS/lua-language-server`](https://github.com/LuaLS/lua-language-server)\nfor [`coc.nvim`](https://github.com/neoclide/coc.nvim).\n\n## Install\n\nIn your vim/neovim, run command:\n\n```\n:CocInstall coc-lua\n```\n\n## Features\n\nSee\n- [`LuaLS/lua-language-server`](https://github.com/LuaLS/lua-language-server)\n\n## Commands\n\n| Key               | Description             |\n|-------------------|-------------------------|\n| **`lua.version`** | Print extension version |\n| **`lua.update`**  | Update language server  |\n\n## Settings\n\n| Key              | Description                                    | Default |\n|------------------|------------------------------------------------|---------|\n| **`lua.enable`** | set to `false` to disable lua language server. | `true`  |\n\nTrigger completion in `coc-settings.json` to get complete list.\n\n### LuaLS/lua-language-server\n\n| Key | Description | Default |\n|-----|-------------|---------|\n| **`Lua.addonManager.enable`** | Set the on/off state for the addon manager. | true |\n| **`Lua.codeLens.enable`** | Enable code lens. |  |\n| **`Lua.completion.autoRequire`** | When the input looks like a file name, automatically `require` this file. | true |\n| **`Lua.completion.callSnippet`** | Shows function call snippets. | \"Disable\" |\n| **`Lua.completion.displayContext`** | 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. |  |\n| **`Lua.completion.enable`** | Enable completion. | true |\n| **`Lua.completion.keywordSnippet`** | Shows keyword syntax snippets. | \"Replace\" |\n| **`Lua.completion.postfix`** | The symbol used to trigger the postfix suggestion. | \"@\" |\n| **`Lua.completion.requireSeparator`** | The separator used when `require`. | \".\" |\n| **`Lua.completion.showParams`** | Display parameters in completion list. When the function has multiple definitions, they will be displayed separately. | true |\n| **`Lua.completion.showWord`** | Show contextual words in suggestions. | \"Fallback\" |\n| **`Lua.completion.workspaceWord`** | Whether the displayed context word contains the content of other files in the workspace. | true |\n| **`Lua.diagnostics.disable`** | Disabled diagnostic (Use code in hover brackets). | [] |\n| **`Lua.diagnostics.disableScheme`** | Do not diagnose Lua files that use the following scheme. | [\"git\"] |\n| **`Lua.diagnostics.enable`** | Enable diagnostics. | true |\n| **`Lua.diagnostics.globals`** | Defined global variables. | [] |\n| **`Lua.diagnostics.ignoredFiles`** | How to diagnose ignored files. | \"Opened\" |\n| **`Lua.diagnostics.libraryFiles`** | How to diagnose files loaded via `Lua.workspace.library`. | \"Opened\" |\n| **`Lua.diagnostics.unusedLocalExclude`** | Do not diagnose `unused-local` when the variable name matches the following pattern. | [] |\n| **`Lua.diagnostics.workspaceDelay`** | Latency (milliseconds) for workspace diagnostics. | 3000 |\n| **`Lua.diagnostics.workspaceEvent`** | Set the time to trigger workspace diagnostics. | \"OnSave\" |\n| **`Lua.diagnostics.workspaceRate`** | 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. | 100 |\n| **`Lua.doc.packageName`** | 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. | [] |\n| **`Lua.doc.privateName`** | 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. | [] |\n| **`Lua.doc.protectedName`** | 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. | [] |\n| **`Lua.format.defaultConfig`** | The default format configuration. Has a lower priority than `.editorconfig` file in the workspace.<br>Read [formatter docs](https://github.com/CppCXY/EmmyLuaCodeStyle/tree/master/docs) to learn usage. | {} |\n| **`Lua.format.enable`** | Enable code formatter. | true |\n| **`Lua.hint.arrayIndex`** | Show hints of array index when constructing a table. | \"Auto\" |\n| **`Lua.hint.await`** | If the called function is marked `---@async`, prompt `await` at the call. | true |\n| **`Lua.hint.enable`** | Enable inlay hint. |  |\n| **`Lua.hint.paramName`** | Show hints of parameter name at the function call. | \"All\" |\n| **`Lua.hint.paramType`** | Show type hints at the parameter of the function. | true |\n| **`Lua.hint.semicolon`** | If there is no semicolon at the end of the statement, display a virtual semicolon. | \"SameLine\" |\n| **`Lua.hint.setType`** | Show hints of type at assignment operation. |  |\n| **`Lua.hover.enable`** | Enable hover. | true |\n| **`Lua.hover.enumsLimit`** | When the value corresponds to multiple types, limit the number of types displaying. | 5 |\n| **`Lua.hover.expandAlias`** | Whether to expand the alias. For example, expands `---@alias myType boolean|number` appears as `boolean|number`, otherwise it appears as `myType'. | true |\n| **`Lua.hover.previewFields`** | When hovering to view a table, limits the maximum number of previews for fields. | 50 |\n| **`Lua.hover.viewNumber`** | Hover to view numeric content (only if literal is not decimal). | true |\n| **`Lua.hover.viewString`** | Hover to view the contents of a string (only if the literal contains an escape character). | true |\n| **`Lua.hover.viewStringMax`** | The maximum length of a hover to view the contents of a string. | 1000 |\n| **`Lua.misc.executablePath`** | Specify the executable path in VSCode. |  |\n| **`Lua.misc.parameters`** | [Command line parameters](https://github.com/LuaLS/lua-telemetry-server/tree/master/method) when starting the language server in VSCode. | [] |\n| **`Lua.runtime.fileEncoding`** | File encoding. The `ansi` option is only available under the `Windows` platform. | \"utf8\" |\n| **`Lua.runtime.meta`** | Format of the directory name of the meta files. | \"${version} ${language} ${encoding}\" |\n| **`Lua.runtime.nonstandardSymbol`** | Supports non-standard symbols. Make sure that your runtime environment supports these symbols. | [] |\n| **`Lua.runtime.path`** | When using `require`, how to find the file based on the input name.<br>Setting this config to `?/init.lua` means that when you enter `require 'myfile'`, `${workspace}/myfile/init.lua` will be searched from the loaded files.<br>if `runtime.pathStrict` is `false`, `${workspace}/**/myfile/init.lua` will also be searched.<br>If you want to load files outside the workspace, you need to set `Lua.workspace.library` first. | [\"?.lua\",\"?/init.lua\"] |\n| **`Lua.runtime.pathStrict`** | When enabled, `runtime.path` will only search the first level of directories, see the description of `runtime.path`. |  |\n| **`Lua.runtime.plugin`** | Plugin path. Please read [wiki](https://github.com/LuaLS/lua-language-server/wiki/Plugins) to learn more. |  |\n| **`Lua.runtime.pluginArgs`** | Additional arguments for the plugin. | [] |\n| **`Lua.runtime.special`** | The custom global variables are regarded as some special built-in variables, and the language server will provide special support<br>The following example shows that 'include' is treated as' require '.<br>```json<br>\"Lua.runtime.special\" : {<br>    \"include\" : \"require\"<br>}<br>``` | {} |\n| **`Lua.runtime.unicodeName`** | Allows Unicode characters in name. |  |\n| **`Lua.runtime.version`** | Lua runtime version. | \"Lua 5.4\" |\n| **`Lua.semantic.annotation`** | Semantic coloring of type annotations. | true |\n| **`Lua.semantic.enable`** | Enable semantic color. You may need to set `editor.semanticHighlighting.enabled` to `true` to take effect. | true |\n| **`Lua.semantic.keyword`** | Semantic coloring of keywords/literals/operators. You only need to enable this feature if your editor cannot do syntax coloring. |  |\n| **`Lua.semantic.variable`** | Semantic coloring of variables/fields/parameters. | true |\n| **`Lua.signatureHelp.enable`** | Enable signature help. | true |\n| **`Lua.spell.dict`** | Custom words for spell checking. | [] |\n| **`Lua.type.castNumberToInteger`** | Allowed to assign the `number` type to the `integer` type. | true |\n| **`Lua.type.weakNilCheck`** | When checking the type of union type, ignore the `nil` in it.<br><br>When this setting is `false`, the `number|nil` type cannot be assigned to the `number` type. It can be with `true`. |  |\n| **`Lua.type.weakUnionCheck`** | Once one subtype of a union type meets the condition, the union type also meets the condition.<br><br>When this setting is `false`, the `number|boolean` type cannot be assigned to the `number` type. It can be with `true`. |  |\n| **`Lua.window.progressBar`** | Show progress bar in status bar. | true |\n| **`Lua.window.statusBar`** | Show extension status in status bar. | true |\n| **`Lua.workspace.checkThirdParty`** | Automatic detection and adaptation of third-party libraries, currently supported libraries are:<br><br>* OpenResty<br>* Cocos4.0<br>* LÖVE<br>* LÖVR<br>* skynet<br>* Jass | true |\n| **`Lua.workspace.ignoreDir`** | Ignored files and directories (Use `.gitignore` grammar). | [\".vscode\"] |\n| **`Lua.workspace.ignoreSubmodules`** | Ignore submodules. | true |\n| **`Lua.workspace.library`** | 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. | [] |\n| **`Lua.workspace.maxPreload`** | Max preloaded files. | 5000 |\n| **`Lua.workspace.preloadFileSize`** | Skip files larger than this value (KB) when preloading. | 500 |\n| **`Lua.workspace.useGitIgnore`** | Ignore files list in `.gitignore` . | true |\n| **`Lua.workspace.userThirdParty`** | 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) | [] |\n## Development\n\n1. Run `npm run build` or `npm run build:watch`\n2. Link extension: `npm run link` / `npm run unlink`\n\n## Credit\n\n- [`LuaLS/lua-language-server`](https://github.com/LuaLS/lua-language-server#credit)\n\n## License\n\n[MIT © Josa Gesell](LICENSE)\n"
  },
  {
    "path": "jest.config.js",
    "content": "module.exports = {\n  roots: [\"<rootDir>/src\"],\n  testMatch: [\"**/__tests__/**/*.+(ts|tsx|js)\", \"**/?(*.)+(spec|test).+(ts|tsx|js)\"],\n  transform: {\n    \"^.+\\\\.(ts|tsx)$\": \"ts-jest\",\n  },\n}\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"coc-lua\",\n  \"version\": \"2.0.6\",\n  \"description\": \"lua extension for coc\",\n  \"author\": \"josa@gesell.me\",\n  \"license\": \"MIT\",\n  \"main\": \"lib/extension.js\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/josa42/coc-lua.git\"\n  },\n  \"engines\": {\n    \"coc\": \"^0.0.82\",\n    \"node\": \">=16\"\n  },\n  \"keywords\": [\n    \"coc.nvim\",\n    \"languageserver\",\n    \"lua\"\n  ],\n  \"scripts\": {\n    \"clean\": \"rimraf lib\",\n    \"build\": \"tsc -p tsconfig.json\",\n    \"build:watch\": \"tsc --watch -p tsconfig.json\",\n    \"prepare\": \"npm run clean && npm run build\",\n    \"lint:fix\": \"eslint . --ext .ts,.js --fix\",\n    \"lint\": \"eslint . --ext .ts,.js\",\n    \"test\": \"jest\"\n  },\n  \"activationEvents\": [\n    \"onLanguage:lua\",\n    \"onCommand:lua.version\",\n    \"onCommand:lua.update\"\n  ],\n  \"contributes\": {\n    \"configuration\": {\n      \"type\": \"object\",\n      \"title\": \"lua\",\n      \"properties\": {\n        \"lua.enable\": {\n          \"type\": \"boolean\",\n          \"default\": true\n        },\n        \"lua.checkForUpdates\": {\n          \"description\": \"Check for LuaLS/lua-language-server updates on start.\",\n          \"type\": \"string\",\n          \"default\": \"inform\",\n          \"enum\": [\n            \"disabled\",\n            \"inform\",\n            \"ask\",\n            \"install\"\n          ]\n        },\n        \"lua.installPreReleases\": {\n          \"description\": \"Install latest pre-release of LuaLS/lua-language-server.\",\n          \"type\": \"boolean\",\n          \"default\": false\n        },\n        \"lua.trace.server\": {\n          \"type\": \"string\",\n          \"default\": \"off\",\n          \"enum\": [\n            \"off\",\n            \"messages\",\n            \"verbose\"\n          ]\n        },\n        \"Lua.addonManager.enable\": {\n          \"default\": true,\n          \"markdownDescription\": \"Set the on/off state for the addon manager.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.codeLens.enable\": {\n          \"default\": false,\n          \"markdownDescription\": \"Enable code lens.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.completion.autoRequire\": {\n          \"default\": true,\n          \"markdownDescription\": \"When the input looks like a file name, automatically `require` this file.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.completion.callSnippet\": {\n          \"default\": \"Disable\",\n          \"enum\": [\n            \"Disable\",\n            \"Both\",\n            \"Replace\"\n          ],\n          \"markdownDescription\": \"Shows function call snippets.\",\n          \"markdownEnumDescriptions\": [\n            \"Only shows `function name`.\",\n            \"Shows `function name` and `call snippet`.\",\n            \"Only shows `call snippet.`\"\n          ],\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.completion.displayContext\": {\n          \"default\": 0,\n          \"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.\",\n          \"scope\": \"resource\",\n          \"type\": \"integer\"\n        },\n        \"Lua.completion.enable\": {\n          \"default\": true,\n          \"markdownDescription\": \"Enable completion.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.completion.keywordSnippet\": {\n          \"default\": \"Replace\",\n          \"enum\": [\n            \"Disable\",\n            \"Both\",\n            \"Replace\"\n          ],\n          \"markdownDescription\": \"Shows keyword syntax snippets.\",\n          \"markdownEnumDescriptions\": [\n            \"Only shows `keyword`.\",\n            \"Shows `keyword` and `syntax snippet`.\",\n            \"Only shows `syntax snippet`.\"\n          ],\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.completion.postfix\": {\n          \"default\": \"@\",\n          \"markdownDescription\": \"The symbol used to trigger the postfix suggestion.\",\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.completion.requireSeparator\": {\n          \"default\": \".\",\n          \"markdownDescription\": \"The separator used when `require`.\",\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.completion.showParams\": {\n          \"default\": true,\n          \"markdownDescription\": \"Display parameters in completion list. When the function has multiple definitions, they will be displayed separately.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.completion.showWord\": {\n          \"default\": \"Fallback\",\n          \"enum\": [\n            \"Enable\",\n            \"Fallback\",\n            \"Disable\"\n          ],\n          \"markdownDescription\": \"Show contextual words in suggestions.\",\n          \"markdownEnumDescriptions\": [\n            \"Always show context words in suggestions.\",\n            \"Contextual words are only displayed when suggestions based on semantics cannot be provided.\",\n            \"Do not display context words.\"\n          ],\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.completion.workspaceWord\": {\n          \"default\": true,\n          \"markdownDescription\": \"Whether the displayed context word contains the content of other files in the workspace.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.diagnostics.disable\": {\n          \"default\": [],\n          \"items\": {\n            \"enum\": [\n              \"action-after-return\",\n              \"ambiguity-1\",\n              \"ambiguous-syntax\",\n              \"args-after-dots\",\n              \"assign-type-mismatch\",\n              \"await-in-sync\",\n              \"block-after-else\",\n              \"break-outside\",\n              \"cast-local-type\",\n              \"cast-type-mismatch\",\n              \"circle-doc-class\",\n              \"close-non-object\",\n              \"code-after-break\",\n              \"codestyle-check\",\n              \"count-down-loop\",\n              \"deprecated\",\n              \"different-requires\",\n              \"discard-returns\",\n              \"doc-field-no-class\",\n              \"duplicate-doc-alias\",\n              \"duplicate-doc-field\",\n              \"duplicate-doc-param\",\n              \"duplicate-index\",\n              \"duplicate-set-field\",\n              \"empty-block\",\n              \"err-assign-as-eq\",\n              \"err-c-long-comment\",\n              \"err-comment-prefix\",\n              \"err-do-as-then\",\n              \"err-eq-as-assign\",\n              \"err-esc\",\n              \"err-nonstandard-symbol\",\n              \"err-then-as-do\",\n              \"exp-in-action\",\n              \"global-in-nil-env\",\n              \"index-in-func-name\",\n              \"invisible\",\n              \"jump-local-scope\",\n              \"keyword\",\n              \"local-limit\",\n              \"lowercase-global\",\n              \"lua-doc-miss-sign\",\n              \"luadoc-error-diag-mode\",\n              \"luadoc-miss-alias-extends\",\n              \"luadoc-miss-alias-name\",\n              \"luadoc-miss-arg-name\",\n              \"luadoc-miss-cate-name\",\n              \"luadoc-miss-class-extends-name\",\n              \"luadoc-miss-class-name\",\n              \"luadoc-miss-diag-mode\",\n              \"luadoc-miss-diag-name\",\n              \"luadoc-miss-field-extends\",\n              \"luadoc-miss-field-name\",\n              \"luadoc-miss-fun-after-overload\",\n              \"luadoc-miss-generic-name\",\n              \"luadoc-miss-local-name\",\n              \"luadoc-miss-module-name\",\n              \"luadoc-miss-operator-name\",\n              \"luadoc-miss-param-extends\",\n              \"luadoc-miss-param-name\",\n              \"luadoc-miss-see-name\",\n              \"luadoc-miss-sign-name\",\n              \"luadoc-miss-symbol\",\n              \"luadoc-miss-type-name\",\n              \"luadoc-miss-vararg-type\",\n              \"luadoc-miss-version\",\n              \"malformed-number\",\n              \"miss-end\",\n              \"miss-esc-x\",\n              \"miss-exp\",\n              \"miss-exponent\",\n              \"miss-field\",\n              \"miss-loop-max\",\n              \"miss-loop-min\",\n              \"miss-method\",\n              \"miss-name\",\n              \"miss-sep-in-table\",\n              \"miss-space-between\",\n              \"miss-symbol\",\n              \"missing-parameter\",\n              \"missing-return\",\n              \"missing-return-value\",\n              \"need-check-nil\",\n              \"need-paren\",\n              \"nesting-long-mark\",\n              \"newfield-call\",\n              \"newline-call\",\n              \"no-unknown\",\n              \"no-visible-label\",\n              \"not-yieldable\",\n              \"param-type-mismatch\",\n              \"redefined-label\",\n              \"redefined-local\",\n              \"redundant-parameter\",\n              \"redundant-return\",\n              \"redundant-return-value\",\n              \"redundant-value\",\n              \"return-type-mismatch\",\n              \"set-const\",\n              \"spell-check\",\n              \"trailing-space\",\n              \"unbalanced-assignments\",\n              \"undefined-doc-class\",\n              \"undefined-doc-name\",\n              \"undefined-doc-param\",\n              \"undefined-env-child\",\n              \"undefined-field\",\n              \"undefined-global\",\n              \"unexpect-dots\",\n              \"unexpect-efunc-name\",\n              \"unexpect-lfunc-name\",\n              \"unexpect-symbol\",\n              \"unicode-name\",\n              \"unknown-attribute\",\n              \"unknown-cast-variable\",\n              \"unknown-diag-code\",\n              \"unknown-operator\",\n              \"unknown-symbol\",\n              \"unreachable-code\",\n              \"unsupport-symbol\",\n              \"unused-function\",\n              \"unused-label\",\n              \"unused-local\",\n              \"unused-vararg\"\n            ],\n            \"type\": \"string\"\n          },\n          \"markdownDescription\": \"Disabled diagnostic (Use code in hover brackets).\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        },\n        \"Lua.diagnostics.disableScheme\": {\n          \"default\": [\n            \"git\"\n          ],\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"markdownDescription\": \"Do not diagnose Lua files that use the following scheme.\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        },\n        \"Lua.diagnostics.enable\": {\n          \"default\": true,\n          \"markdownDescription\": \"Enable diagnostics.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.diagnostics.globals\": {\n          \"default\": [],\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"markdownDescription\": \"Defined global variables.\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        },\n        \"Lua.diagnostics.ignoredFiles\": {\n          \"default\": \"Opened\",\n          \"enum\": [\n            \"Enable\",\n            \"Opened\",\n            \"Disable\"\n          ],\n          \"markdownDescription\": \"How to diagnose ignored files.\",\n          \"markdownEnumDescriptions\": [\n            \"Always diagnose these files.\",\n            \"Only when these files are opened will it be diagnosed.\",\n            \"These files are not diagnosed.\"\n          ],\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.diagnostics.libraryFiles\": {\n          \"default\": \"Opened\",\n          \"enum\": [\n            \"Enable\",\n            \"Opened\",\n            \"Disable\"\n          ],\n          \"markdownDescription\": \"How to diagnose files loaded via `Lua.workspace.library`.\",\n          \"markdownEnumDescriptions\": [\n            \"Always diagnose these files.\",\n            \"Only when these files are opened will it be diagnosed.\",\n            \"These files are not diagnosed.\"\n          ],\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.diagnostics.unusedLocalExclude\": {\n          \"default\": [],\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"markdownDescription\": \"Do not diagnose `unused-local` when the variable name matches the following pattern.\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        },\n        \"Lua.diagnostics.workspaceDelay\": {\n          \"default\": 3000,\n          \"markdownDescription\": \"Latency (milliseconds) for workspace diagnostics.\",\n          \"scope\": \"resource\",\n          \"type\": \"integer\"\n        },\n        \"Lua.diagnostics.workspaceEvent\": {\n          \"default\": \"OnSave\",\n          \"enum\": [\n            \"OnChange\",\n            \"OnSave\",\n            \"None\"\n          ],\n          \"markdownDescription\": \"Set the time to trigger workspace diagnostics.\",\n          \"markdownEnumDescriptions\": [\n            \"Trigger workspace diagnostics when the file is changed.\",\n            \"Trigger workspace diagnostics when the file is saved.\",\n            \"Disable workspace diagnostics.\"\n          ],\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.diagnostics.workspaceRate\": {\n          \"default\": 100,\n          \"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.\",\n          \"scope\": \"resource\",\n          \"type\": \"integer\"\n        },\n        \"Lua.doc.packageName\": {\n          \"default\": [],\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"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.\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        },\n        \"Lua.doc.privateName\": {\n          \"default\": [],\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"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.\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        },\n        \"Lua.doc.protectedName\": {\n          \"default\": [],\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"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.\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        },\n        \"Lua.format.defaultConfig\": {\n          \"additionalProperties\": false,\n          \"default\": {},\n          \"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\",\n          \"patternProperties\": {\n            \".*\": {\n              \"default\": \"\",\n              \"type\": \"string\"\n            }\n          },\n          \"scope\": \"resource\",\n          \"title\": \"defaultConfig\",\n          \"type\": \"object\"\n        },\n        \"Lua.format.enable\": {\n          \"default\": true,\n          \"markdownDescription\": \"Enable code formatter.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.hint.arrayIndex\": {\n          \"default\": \"Auto\",\n          \"enum\": [\n            \"Enable\",\n            \"Auto\",\n            \"Disable\"\n          ],\n          \"markdownDescription\": \"Show hints of array index when constructing a table.\",\n          \"markdownEnumDescriptions\": [\n            \"Show hints in all tables.\",\n            \"Show hints only when the table is greater than 3 items, or the table is a mixed table.\",\n            \"Disable hints of array index.\"\n          ],\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.hint.await\": {\n          \"default\": true,\n          \"markdownDescription\": \"If the called function is marked `---@async`, prompt `await` at the call.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.hint.enable\": {\n          \"default\": false,\n          \"markdownDescription\": \"Enable inlay hint.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.hint.paramName\": {\n          \"default\": \"All\",\n          \"enum\": [\n            \"All\",\n            \"Literal\",\n            \"Disable\"\n          ],\n          \"markdownDescription\": \"Show hints of parameter name at the function call.\",\n          \"markdownEnumDescriptions\": [\n            \"All types of parameters are shown.\",\n            \"Only literal type parameters are shown.\",\n            \"Disable parameter hints.\"\n          ],\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.hint.paramType\": {\n          \"default\": true,\n          \"markdownDescription\": \"Show type hints at the parameter of the function.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.hint.semicolon\": {\n          \"default\": \"SameLine\",\n          \"enum\": [\n            \"All\",\n            \"SameLine\",\n            \"Disable\"\n          ],\n          \"markdownDescription\": \"If there is no semicolon at the end of the statement, display a virtual semicolon.\",\n          \"markdownEnumDescriptions\": [\n            \"All statements display virtual semicolons.\",\n            \"When two statements are on the same line, display a semicolon between them.\",\n            \"Disable virtual semicolons.\"\n          ],\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.hint.setType\": {\n          \"default\": false,\n          \"markdownDescription\": \"Show hints of type at assignment operation.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.hover.enable\": {\n          \"default\": true,\n          \"markdownDescription\": \"Enable hover.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.hover.enumsLimit\": {\n          \"default\": 5,\n          \"markdownDescription\": \"When the value corresponds to multiple types, limit the number of types displaying.\",\n          \"scope\": \"resource\",\n          \"type\": \"integer\"\n        },\n        \"Lua.hover.expandAlias\": {\n          \"default\": true,\n          \"markdownDescription\": \"Whether to expand the alias. For example, expands `---@alias myType boolean|number` appears as `boolean|number`, otherwise it appears as `myType'.\\n\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.hover.previewFields\": {\n          \"default\": 50,\n          \"markdownDescription\": \"When hovering to view a table, limits the maximum number of previews for fields.\",\n          \"scope\": \"resource\",\n          \"type\": \"integer\"\n        },\n        \"Lua.hover.viewNumber\": {\n          \"default\": true,\n          \"markdownDescription\": \"Hover to view numeric content (only if literal is not decimal).\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.hover.viewString\": {\n          \"default\": true,\n          \"markdownDescription\": \"Hover to view the contents of a string (only if the literal contains an escape character).\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.hover.viewStringMax\": {\n          \"default\": 1000,\n          \"markdownDescription\": \"The maximum length of a hover to view the contents of a string.\",\n          \"scope\": \"resource\",\n          \"type\": \"integer\"\n        },\n        \"Lua.misc.executablePath\": {\n          \"default\": \"\",\n          \"markdownDescription\": \"Specify the executable path in VSCode.\",\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.misc.parameters\": {\n          \"default\": [],\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"markdownDescription\": \"[Command line parameters](https://github.com/LuaLS/lua-telemetry-server/tree/master/method) when starting the language server in VSCode.\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        },\n        \"Lua.runtime.fileEncoding\": {\n          \"default\": \"utf8\",\n          \"enum\": [\n            \"utf8\",\n            \"ansi\",\n            \"utf16le\",\n            \"utf16be\"\n          ],\n          \"markdownDescription\": \"File encoding. The `ansi` option is only available under the `Windows` platform.\",\n          \"markdownEnumDescriptions\": [\n            \"\",\n            \"\",\n            \"\",\n            \"\"\n          ],\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.runtime.meta\": {\n          \"default\": \"${version} ${language} ${encoding}\",\n          \"markdownDescription\": \"Format of the directory name of the meta files.\",\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.runtime.nonstandardSymbol\": {\n          \"default\": [],\n          \"items\": {\n            \"enum\": [\n              \"//\",\n              \"/**/\",\n              \"`\",\n              \"+=\",\n              \"-=\",\n              \"*=\",\n              \"/=\",\n              \"%=\",\n              \"^=\",\n              \"//=\",\n              \"|=\",\n              \"&=\",\n              \"<<=\",\n              \">>=\",\n              \"||\",\n              \"&&\",\n              \"!\",\n              \"!=\",\n              \"continue\"\n            ],\n            \"type\": \"string\"\n          },\n          \"markdownDescription\": \"Supports non-standard symbols. Make sure that your runtime environment supports these symbols.\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        },\n        \"Lua.runtime.path\": {\n          \"default\": [\n            \"?.lua\",\n            \"?/init.lua\"\n          ],\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"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\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        },\n        \"Lua.runtime.pathStrict\": {\n          \"default\": false,\n          \"markdownDescription\": \"When enabled, `runtime.path` will only search the first level of directories, see the description of `runtime.path`.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.runtime.plugin\": {\n          \"default\": \"\",\n          \"markdownDescription\": \"Plugin path. Please read [wiki](https://github.com/LuaLS/lua-language-server/wiki/Plugins) to learn more.\",\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.runtime.pluginArgs\": {\n          \"default\": [],\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"markdownDescription\": \"Additional arguments for the plugin.\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        },\n        \"Lua.runtime.special\": {\n          \"additionalProperties\": false,\n          \"default\": {},\n          \"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\",\n          \"patternProperties\": {\n            \".*\": {\n              \"default\": \"require\",\n              \"enum\": [\n                \"_G\",\n                \"rawset\",\n                \"rawget\",\n                \"setmetatable\",\n                \"require\",\n                \"dofile\",\n                \"loadfile\",\n                \"pcall\",\n                \"xpcall\",\n                \"assert\",\n                \"error\",\n                \"type\",\n                \"os.exit\"\n              ],\n              \"type\": \"string\"\n            }\n          },\n          \"scope\": \"resource\",\n          \"title\": \"special\",\n          \"type\": \"object\"\n        },\n        \"Lua.runtime.unicodeName\": {\n          \"default\": false,\n          \"markdownDescription\": \"Allows Unicode characters in name.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.runtime.version\": {\n          \"default\": \"Lua 5.4\",\n          \"enum\": [\n            \"Lua 5.1\",\n            \"Lua 5.2\",\n            \"Lua 5.3\",\n            \"Lua 5.4\",\n            \"LuaJIT\"\n          ],\n          \"markdownDescription\": \"Lua runtime version.\",\n          \"markdownEnumDescriptions\": [\n            \"\",\n            \"\",\n            \"\",\n            \"\",\n            \"\"\n          ],\n          \"scope\": \"resource\",\n          \"type\": \"string\"\n        },\n        \"Lua.semantic.annotation\": {\n          \"default\": true,\n          \"markdownDescription\": \"Semantic coloring of type annotations.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.semantic.enable\": {\n          \"default\": true,\n          \"markdownDescription\": \"Enable semantic color. You may need to set `editor.semanticHighlighting.enabled` to `true` to take effect.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.semantic.keyword\": {\n          \"default\": false,\n          \"markdownDescription\": \"Semantic coloring of keywords/literals/operators. You only need to enable this feature if your editor cannot do syntax coloring.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.semantic.variable\": {\n          \"default\": true,\n          \"markdownDescription\": \"Semantic coloring of variables/fields/parameters.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.signatureHelp.enable\": {\n          \"default\": true,\n          \"markdownDescription\": \"Enable signature help.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.spell.dict\": {\n          \"default\": [],\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"markdownDescription\": \"Custom words for spell checking.\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        },\n        \"Lua.type.castNumberToInteger\": {\n          \"default\": true,\n          \"markdownDescription\": \"Allowed to assign the `number` type to the `integer` type.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.type.weakNilCheck\": {\n          \"default\": false,\n          \"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\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.type.weakUnionCheck\": {\n          \"default\": false,\n          \"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\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.window.progressBar\": {\n          \"default\": true,\n          \"markdownDescription\": \"Show progress bar in status bar.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.window.statusBar\": {\n          \"default\": true,\n          \"markdownDescription\": \"Show extension status in status bar.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.workspace.checkThirdParty\": {\n          \"default\": true,\n          \"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\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.workspace.ignoreDir\": {\n          \"default\": [\n            \".vscode\"\n          ],\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"markdownDescription\": \"Ignored files and directories (Use `.gitignore` grammar).\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        },\n        \"Lua.workspace.ignoreSubmodules\": {\n          \"default\": true,\n          \"markdownDescription\": \"Ignore submodules.\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.workspace.library\": {\n          \"default\": [],\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"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.\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        },\n        \"Lua.workspace.maxPreload\": {\n          \"default\": 5000,\n          \"markdownDescription\": \"Max preloaded files.\",\n          \"scope\": \"resource\",\n          \"type\": \"integer\"\n        },\n        \"Lua.workspace.preloadFileSize\": {\n          \"default\": 500,\n          \"markdownDescription\": \"Skip files larger than this value (KB) when preloading.\",\n          \"scope\": \"resource\",\n          \"type\": \"integer\"\n        },\n        \"Lua.workspace.useGitIgnore\": {\n          \"default\": true,\n          \"markdownDescription\": \"Ignore files list in `.gitignore` .\",\n          \"scope\": \"resource\",\n          \"type\": \"boolean\"\n        },\n        \"Lua.workspace.userThirdParty\": {\n          \"default\": [],\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"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)\",\n          \"scope\": \"resource\",\n          \"type\": \"array\"\n        }\n      }\n    },\n    \"commands\": [\n      {\n        \"command\": \"lua.version\",\n        \"title\": \"Print extension version\"\n      },\n      {\n        \"command\": \"lua.update\",\n        \"title\": \"Update lua-lsp\"\n      }\n    ]\n  },\n  \"devDependencies\": {\n    \"@chemzqm/tsconfig\": \"^0.0.3\",\n    \"@types/jest\": \"^29.4.0\",\n    \"@types/node\": \"^18.14.0\",\n    \"@types/tar\": \"^6.1.4\",\n    \"@types/which\": \"^2.0.2\",\n    \"@typescript-eslint/eslint-plugin\": \"^5.52.0\",\n    \"@typescript-eslint/parser\": \"^5.52.0\",\n    \"coc.nvim\": \"0.0.82\",\n    \"eslint\": \"8.34.0\",\n    \"eslint-config-josa-typescript\": \"^0.1.2\",\n    \"jest\": \"^29.4.3\",\n    \"rimraf\": \"^4.1.2\",\n    \"ts-jest\": \"^29.0.5\",\n    \"typescript\": \"^4.9.5\"\n  },\n  \"dependencies\": {\n    \"tar\": \"^6.1.13\",\n    \"tslib\": \"^2.5.0\",\n    \"which\": \"^3.0.0\"\n  }\n}\n"
  },
  {
    "path": "scripts/nvim.sh",
    "content": "#!/bin/bash\n\nDIR=\"$(cd -- \"$(dirname -- \"${BASH_SOURCE[0]}\")/..\" &> /dev/null && pwd)\"\nTMP=\"$DIR/.tmp\"\n\n# rm -rf $TMP\nmkdir -p $TMP/{share/nvim,state,cache,config/nvim/syntax}\n\nPLUGGED=\"$TMP/share/data/plugged\"\nPLUG_FILE=\"$TMP/share/nvim/site/autoload/plug.vim\"\nPLUG_URL='https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'\n\ncat > $TMP/config/nvim/init.lua <<EOF\nvim.cmd [[\n  call plug#begin('$PLUGGED')\n  Plug 'josa42/theme-theonedark', { 'rtp': 'dist/vim' }\n  Plug 'neoclide/coc.nvim', {'branch': 'release'}\n  Plug '$DIR'\n  call plug#end()\n]]\n\nif vim.tbl_contains(vim.fn.getcompletion('', 'color'), 'theonedark') then\n  vim.cmd('colorscheme theonedark')\nend\n\nvim.opt.encoding = 'utf-8'\nvim.opt.hidden = true\nvim.opt.backup = false\nvim.opt.writebackup = false\nvim.opt.cmdheight = 2\nvim.opt.updatetime = 300\nvim.opt.shortmess:append('c')\nvim.opt.signcolumn = 'yes'\nvim.opt.number = true\nvim.opt.listchars = 'tab:» ,extends:›,precedes:‹,nbsp:·,space:·,trail:·'\nvim.opt.list = true\nvim.opt.tabstop = 2\nvim.opt.softtabstop = 2\nvim.opt.shiftwidth = 2\nvim.opt.expandtab = false\n\nvim.api.nvim_set_keymap('i', '<c-space>', 'coc#refresh()', { silent = true, expr = true })\nvim.api.nvim_set_keymap('n', 'gd', '<Plug>(coc-definition)', { silent = true })\nvim.api.nvim_set_keymap('n', 'gf', 'CocAction(\"format\")', { silent = true, expr = true })\nvim.api.nvim_set_keymap(\"i\", \"<cr>\", [[coc#pum#visible() ? coc#pum#confirm() : \"\\<CR>\"]], { silent = true, expr = true, expr = true, replace_keycodes = false })\n\nfunction _G.__coc()\n  local info = vim.b.coc_diagnostic_info or {}\n  local parts = {\n    'E' .. (info.error or 0),\n    'W' .. (info.warning or 0),\n    (vim.g.coc_status or ''),\n  }\n  return vim.fn.join(parts, ' ')\nend\n\nvim.opt.statusline = '%{v:lua.__coc()}'\n\nvim.cmd [[\n  hi CocUnderline gui=undercurl term=undercurl\n  hi CocErrorHighlight ctermfg=red  guifg=#c4384b gui=undercurl term=undercurl\n  hi CocWarningHighlight ctermfg=yellow guifg=#c4ab39 gui=undercurl term=undercurl\n]]\nEOF\n\ncat > $TMP/config/nvim/coc-settings.json <<EOF\n{\n  \"Lua\": {}\n}\nEOF\n\nexport XDG_CONFIG_HOME=$TMP/config\nexport XDG_CACHE_HOME=$TMP/cache\nexport XDG_DATA_HOME=$TMP/share\nexport XDG_STATE_HOME=$TMP/state\n\n\nif [[ ! -f \"$PLUG_FILE\" ]]; then\n  curl -sSfLo $PLUG_FILE --create-dirs $PLUG_URL\n  nvim --headless +'PlugInstall | PlugUpdate| qa!'\nfi\n\nnvim \"$@\"\n\n"
  },
  {
    "path": "scripts/update-settings.js",
    "content": "#!/usr/bin/env node\n\nconst fs = require(\"fs\")\nconst https = require(\"https\")\nconst path = require(\"path\")\n\nconst pkgPath = path.join(__dirname, \"..\", \"package.json\")\n\nconst rmKey = [\"Lua.awakened.cat\", \"Lua.develop.enable\", \"Lua.develop.debuggerPort\", \"Lua.develop.debuggerWait\"]\n\nasync function run() {\n  const settings = fixSchema(JSON.parse(\n    await get(\"https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json\")\n  ))\n  const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"))\n  const props = pkg.contributes.configuration.properties\n\n  Object.keys(props)\n    .filter((k) => k.match(/^Lua\\./))\n    .sort((a, b) => a.localeCompare(b))\n    .forEach((k) => delete props[k])\n\n  rmKey.forEach((k) => delete settings.properties[k])\n\n  Object.assign(props, {\n    ...Object.fromEntries(\n      Object.entries(settings.properties)\n        .filter(([,value]) => !value.properties)\n        .map(([key,value]) => [`Lua.${key}`, value])\n\n    )\n  })\n\n  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, \"  \") + \"\\n\")\n\n  const sections = parseMarkdown(await fs.promises.readFile(path.join(__dirname, \"..\", \"README.md\"), \"utf-8\"))\n  await updateTable(sections)\n\n  const out = sections.flatMap(({ title, lines }) => [title, ...lines]).join(\"\\n\")\n  await fs.promises.writeFile(path.join(__dirname, \"..\", \"README.md\"), out)\n}\n\nasync function get(sourceUrl) {\n  let reponseData = \"\"\n\n  return new Promise((resolve, reject) => {\n    const get = (url) =>\n      https.get(url, (res) => {\n        const { statusCode } = res\n\n        if (statusCode === 301 || statusCode === 302) {\n          return get(res.headers.location)\n        }\n\n        res\n          .on(\"data\", (data) => (reponseData += data))\n          .on(\"end\", () => resolve(reponseData))\n          .on(\"error\", (err) => reject(err))\n      })\n\n    return get(sourceUrl)\n  })\n}\n\nasync function updateTable(sections) {\n  const pkg = JSON.parse(await fs.promises.readFile(path.join(__dirname, \"..\", \"package.json\")))\n\n  let lines = Object.entries(pkg.contributes.configuration.properties)\n    .filter(([k]) => k.startsWith('Lua.'))\n    .sort((p1, p2) => p1[0].localeCompare(p2[0]))\n    .flatMap(([k, v]) => {\n      const lines = [\n      ]\n\n      if (!v.properties) {\n        lines.push(`| **\\`${k}\\`** | ${v?.markdownDescription.trim().split(/\\n/).join(\"<br>\") ?? ''} | ${v.default ? JSON.stringify(v.default) : ''} |`)\n      }\n      return lines\n    })\n\n  lines = [\n    '| Key | Description | Default |',\n    '|-----|-------------|---------|',\n    ...lines,\n  ]\n\n  sections.find((s) => s.title === \"### LuaLS/lua-language-server\").lines = [\"\", ...lines]\n}\n\nfunction parseMarkdown(source) {\n  let section\n\n  return source.split(\"\\n\").reduce((sections, line) => {\n    if (line.startsWith(\"#\")) {\n      section = { title: line, lines: [] }\n      sections.push(section)\n    } else {\n      section.lines.push(line)\n    }\n\n    return sections\n  }, [])\n}\n\nfunction fixSchema(schema, base = undefined) {\n  base = base ?? schema\n\n  if (schema['$ref']) {\n    const [,key,prop] = schema['$ref'].match(/^#\\/([^/]+)\\/(.*)/) ?? []\n\n    if (!key || !prop || !base[key]?.[prop]) {\n      console.log(Object.keys(base[key]))\n      throw new Error(`ref / \"${prop}\" not found: ${schema['$ref']}`)\n    }\n\n    return base[key]?.[prop]\n  }\n\n  if (schema.properties) {\n    Object.entries(schema.properties).forEach(([key, value]) => {\n      schema.properties[key] = fixSchema(value, base)\n    })\n  }\n\n  if (schema.patternProperties) {\n    Object.entries(schema.patternProperties).forEach(([key, value]) => {\n      if (key === '') {\n        delete schema.patternProperties[key]\n        key = '.*'\n      }\n\n      schema.patternProperties[key] = fixSchema(value, base)\n    })\n  }\n\n  return schema\n}\n\nrun()\n"
  },
  {
    "path": "src/__mocks__/coc.nvim.ts",
    "content": "export const workspace = {\n  getConfiguration() {\n    return { get: () => ({}) }\n  },\n}\nexport const window = {}\n\nexport default {}\n"
  },
  {
    "path": "src/commands.ts",
    "content": "import fs from \"fs\"\nimport path from \"path\"\nimport { installLuaLs } from \"./utils/installer\"\nimport { window, LanguageClient } from \"coc.nvim\"\n\nexport async function version(): Promise<void> {\n  const { version } = JSON.parse(fs.readFileSync(path.resolve(__dirname, \"..\", \"package.json\"), \"utf-8\"))\n  window.showMessage(`coc-lua: ${version}`, \"more\")\n}\n\nexport async function update(client: LanguageClient): Promise<void> {\n  await installLuaLs(true)\n\n  if (client.needsStop()) {\n    await client.stop()\n    client.start()\n  }\n}\n"
  },
  {
    "path": "src/extension.ts",
    "content": "import { commands, ExtensionContext, LanguageClient, ServerOptions, services, LanguageClientOptions } from \"coc.nvim\"\n\nimport { installLuaLs, luaLsCommandAndArgs, checkForUpdate } from \"./utils/installer\"\nimport { commandExists } from \"./utils/tools\"\nimport { version, update } from \"./commands\"\nimport { setStoragePath, getConfig } from \"./utils/config\"\n\nexport async function activate(context: ExtensionContext): Promise<void> {\n  setStoragePath(context.storagePath)\n\n  const config = getConfig()\n  if (config.enable === false) {\n    return\n  }\n\n  if (config.checkForUpdates !== \"disabled\") {\n    setTimeout(() => checkForUpdate(config.checkForUpdates), 0)\n  }\n\n  const client = await createClient()\n\n  context.subscriptions.push(\n    services.registLanguageClient(client),\n    commands.registerCommand(\"lua.version\", () => version()),\n    commands.registerCommand(\"lua.update\", async () => update(client))\n  )\n}\n\nasync function createClient(): Promise<LanguageClient> {\n  const [command, args] = await luaLsCommandAndArgs()\n\n  if (!(await commandExists(command))) {\n    await installLuaLs()\n  }\n\n  const serverOptions: ServerOptions = { command, args }\n\n  const clientOptions: LanguageClientOptions = {\n    documentSelector: [\"lua\"],\n    progressOnInitialization: true,\n    initializationOptions: {\n      changeConfiguration: true,\n    }\n  }\n\n  return new LanguageClient(\"lua\", \"lua\", serverOptions, clientOptions)\n}\n"
  },
  {
    "path": "src/utils/config.ts",
    "content": "import fs from \"fs\"\nimport os from \"os\"\nimport path from \"path\"\nimport { workspace } from \"coc.nvim\"\n\ninterface LuaConfig {\n  enable: boolean\n  checkForUpdates: \"disabled\" | \"inform\" | \"ask\" | \"install\"\n  installPreReleases: boolean\n}\n\nexport function getConfig(): LuaConfig {\n  return workspace.getConfiguration().get<LuaConfig>(\"lua\")\n}\n\ninterface State {\n  storagePath?: string\n}\n\nconst state: State = {}\n\nexport function setStoragePath(dir: string): void {\n  state.storagePath = dir\n}\n\nexport async function configDir(...names: string[]): Promise<string> {\n  const storage =\n    state.storagePath ||\n    ((): string => {\n      const home = os.homedir()\n      return path.join(home, \".config\", \"coc\", \"lua\")\n    })()\n\n  const dir = path.join(storage, ...names)\n\n  return new Promise((resolve) => {\n    fs.mkdirSync(dir, { recursive: true })\n    resolve(dir)\n  })\n}\n"
  },
  {
    "path": "src/utils/db.ts",
    "content": "import * as fs from \"fs\"\nimport * as path from \"path\"\nimport { configDir } from \"./config\"\n\ntype DBValue = string | number | boolean | undefined\n\ninterface DB {\n  [key: string]: DBValue\n}\n\nasync function dbPath(): Promise<string> {\n  const dir = await configDir()\n  return path.join(dir, \"db.json\")\n}\n\nasync function write(data: DB): Promise<void> {\n  await fs.promises.writeFile(await dbPath(), JSON.stringify(data, null, \"  \"))\n}\n\nasync function read(): Promise<DB> {\n  try {\n    return JSON.parse(await fs.promises.readFile(await dbPath(), \"utf-8\")) as DB\n  } catch (err) {\n    return {}\n  }\n}\n\nexport async function dbSet<T extends DBValue>(key: string, value: T): Promise<void> {\n  const db = await read()\n  db[key] = value\n  await write(db)\n}\n\nexport async function dbGet<T extends DBValue>(key: string, defaultValue?: T): Promise<T> {\n  const db = await read()\n  const value = db[key]\n\n  if (value !== undefined) {\n    return value as T\n  }\n\n  return defaultValue\n}\n"
  },
  {
    "path": "src/utils/installer.test.ts",
    "content": "import * as fs from \"fs\"\nimport * as path from \"path\"\nimport * as os from \"os\"\n\nimport { install, osEnv } from \"./installer\"\n\ndescribe(\"installer\", () => {\n  let tmpDir: string\n\n  beforeEach(async () => {\n    tmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), \"foo-\"))\n  })\n\n  afterEach(async () => {\n    await fs.promises.rm(tmpDir, { recursive: true })\n  })\n\n  it(\"should install\", async () => {\n    jest.setTimeout(30000)\n\n    await install(tmpDir)\n\n    const { bin } = osEnv()\n\n    expect(fs.existsSync(path.join(tmpDir, \"main.lua\"))).toBeTruthy()\n    expect(fs.existsSync(path.join(tmpDir, bin))).toBeTruthy()\n  })\n})\n"
  },
  {
    "path": "src/utils/installer.ts",
    "content": "import * as crypto from \"crypto\"\nimport * as fs from \"fs\"\nimport * as https from \"https\"\nimport * as os from \"os\"\nimport * as path from \"path\"\nimport * as tar from \"tar\"\n\nimport { window } from \"coc.nvim\"\n\nimport { configDir } from \"./config\"\nimport { showInstallStatus } from \"./tools\"\nimport { dbGet, dbSet } from \"./db\"\n\nconst luaLsDir = \"lua-language-server\"\nconst oneDayMS = 24 * 60 * 60 * 1000\n\nconst fsp = fs.promises\n\nconst osPlatform = os.platform()\nconst tmpBaseDir = os.tmpdir()\n\nconst { join } = path\n\nconst latestURL = 'https://api.github.com/repos/LuaLS/lua-language-server/releases/latest'\n\nconst pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '../../package.json'), 'utf-8')) as {version: string}\n\nconst DBKey = {\n  VERSION: 'installed-version',\n  PUBLISHED_AT: 'installed-version-published-at',\n  LAST_UPDATE_CHECK: \"last-update-check\",\n}\n\ninterface LatestResponse {\n  tag_name: string\n  published_at: string\n  assets: Array<{\n    name: string\n    browser_download_url: string\n  }>\n}\n\ninterface Version {\n  version: string\n  publishedAt: number\n}\n\ninterface Release extends Version {\n  url: string\n}\n\n\nasync function getLatestRelease(filePath: string): Promise<Release> {\n  const { assets, tag_name: version, published_at } = await getJSON<LatestResponse>(latestURL)\n  const { browser_download_url: url } =  assets.find(({ name }) => name.endsWith(filePath)) ?? {}\n\n  return { version, publishedAt: new Date(published_at).getTime(), url }\n}\n\nasync function getLatestVersion(): Promise<Version> {\n  const { tag_name: version, published_at } = await getJSON<LatestResponse>(latestURL)\n\n  return { version, publishedAt: new Date(published_at).getTime() }\n}\n\nexport async function install(dir: string): Promise<void> {\n  const { tarFile } = osEnv()\n  const { url, version, publishedAt } = await getLatestRelease(tarFile)\n  await downloadTar(url, dir)\n  await dbSet(DBKey.VERSION, version)\n  await dbSet(DBKey.PUBLISHED_AT, publishedAt)\n}\n\nasync function downloadTar(sourceUrl: string, targetPath: string) {\n  const dir = await mkTmpDir(sourceUrl)\n\n  if (osPlatform === 'win32') {\n    throw new Error('Windows is not currently supported')\n\n  } else {\n    const tarTmpPath = join(dir.path, \"tmp.tar.gz\")\n\n    await download(sourceUrl, tarTmpPath)\n    await tar.x({ file: tarTmpPath, cwd: targetPath, strip: 0 })\n  }\n\n  await dir.dispose()\n}\n\nasync function mkTmpDir(key: string): Promise<{ path: string; dispose: () => Promise<void> }> {\n  const hash = crypto.createHash(\"md5\").update(key).digest(\"hex\")\n  const dir = join(tmpBaseDir, hash)\n\n  await fsp.mkdir(dir, { recursive: true })\n\n  return { path: dir, dispose: async () => fsp.rm(dir, { recursive: true }) }\n}\n\nasync function download(sourceUrl: string, targetPath: string): Promise<void> {\n  const file = fs.createWriteStream(targetPath)\n\n  return new Promise((resolve, reject) => {\n    const get = (url: string) =>\n      https.get(url, (res) => {\n        const { statusCode } = res\n\n        if (statusCode === 301 || statusCode === 302) {\n          return get(res.headers.location)\n        }\n\n        res\n          .on(\"data\", (data) => file.write(data))\n          .on(\"end\", () => (file.end(), setTimeout(() => resolve(), 5)))\n          .on(\"error\", (err: Error) => reject(err))\n      })\n\n    return get(sourceUrl)\n  })\n}\n\nexport function osEnv(): { tarFile: string; bin: string } {\n  switch (osPlatform) {\n    case \"darwin\":\n      return {\n        tarFile: process.arch === 'arm64'\n          ? \"darwin-arm64.tar.gz\"\n          : \"darwin-x64.tar.gz\",\n        bin: join(\"bin\", \"lua-language-server\"),\n      }\n    case \"linux\":\n      return {\n        tarFile: process.arch === 'arm64'\n          ? \"linux-arm64.tar.gz\"\n          : \"linux-x64.tar.gz\",\n        bin: join(\"bin\", \"lua-language-server\"),\n      }\n    case \"win32\":\n      return {\n        tarFile: \"win32-x64.zip\",\n        bin: join(\"bin\", \"lua-language-server.exe\"),\n      }\n  }\n  return { tarFile: \"\", bin: \"\" }\n}\n\nexport async function checkForUpdate(action: \"disabled\" | \"inform\" | \"ask\" | \"install\"): Promise<void> {\n  if (!(await shouldCheck())) {\n    return\n  }\n\n  const statusItem = window.createStatusBarItem(90, { progress: true })\n  statusItem.text = \"Check for updates\"\n  statusItem.show()\n\n  try {\n    const rinfo = (await getLatestVersion())\n    const linfo = await dbGet<number>(DBKey.PUBLISHED_AT)\n    if (rinfo.publishedAt > linfo) {\n      handleUpdateAction(action, rinfo.version)\n    }\n  } catch (err) {\n    window.showMessage(JSON.stringify(err), \"error\")\n  }\n\n  statusItem.hide()\n}\n\nasync function shouldCheck(): Promise<boolean> {\n  const now = new Date().getTime()\n  const last = await dbGet(DBKey.LAST_UPDATE_CHECK, -1)\n  const diff = now - last\n\n  if (last === -1 || diff > oneDayMS) {\n    await dbSet(DBKey.LAST_UPDATE_CHECK, now)\n    return true\n  }\n\n  return false\n}\n\nasync function handleUpdateAction(action: \"disabled\" | \"inform\" | \"ask\" | \"install\", version: string) {\n  switch (action) {\n    case \"ask\":\n      if (await window.showPrompt(`LuaLS/lua-language-server ${version} is available. Install?`)) {\n        installLuaLs(true)\n      }\n      break\n    case \"install\":\n      installLuaLs(true)\n      break\n    case \"inform\":\n      window.showMessage(`LuaLS/lua-language-server ${version} is available. Run \":CocCommand lua.update\"`)\n      break\n  }\n}\n\nexport async function installLuaLs(force = false): Promise<void> {\n  if (!force && (await luaLsExists())) {\n    return\n  }\n\n  await showInstallStatus(\"LuaLS/lua-language-server\", async () => {\n    await install(await configDir(luaLsDir))\n  })\n}\n\nexport async function luaLsCommandAndArgs(): Promise<[string, string[]]> {\n  const baseDir = await configDir(luaLsDir)\n\n  const { bin } = osEnv()\n  return [path.join(baseDir, bin), [\"-E\", path.join(baseDir, \"main.lua\")]]\n}\n\nasync function luaLsExists(): Promise<boolean> {\n  const [bin] = await luaLsCommandAndArgs()\n  return new Promise((resolve) => fs.open(bin, \"r\", (err) => resolve(err === null)))\n}\n\nconst getOptions = {\n    headers: {\n        'User-Agent': `coc-lua/${pkg.version}`,\n    }\n}\n\nasync function getJSON<R>(url: string): Promise<R> {\n  return new Promise((resolve, reject) => {\n    https\n      .get(url, getOptions, (resp) => {\n        let data = \"\"\n\n        resp.on(\"data\", (chunk) => (data += chunk))\n        resp.on(\"end\", () => {\n          resolve(JSON.parse(data) as R)\n        })\n      })\n      .on(\"error\", (err) => reject(err))\n  })\n}\n"
  },
  {
    "path": "src/utils/tools.ts",
    "content": "import which from \"which\"\nimport { window } from \"coc.nvim\"\n\nexport async function commandExists(bin: string): Promise<boolean> {\n  return Boolean(await which(bin, { nothrow: true }))\n}\n\nexport async function showInstallStatus(name: string, fn: () => Promise<void>): Promise<void> {\n  const statusItem = window.createStatusBarItem(90, { progress: true })\n\n  statusItem.text = `Installing '${name}'`\n  statusItem.show()\n\n  try {\n    await fn()\n    window.showMessage(`Installed '${name}'`)\n  } catch (err) {\n    window.showMessage(`Failed to install '${name}': ${err}`, \"error\")\n    statusItem.hide()\n    throw err\n  }\n\n  statusItem.hide()\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"extends\": \"./node_modules/@chemzqm/tsconfig/tsconfig.json\",\n  \"compilerOptions\": {\n    \"outDir\": \"lib\",\n    \"target\": \"es2015\",\n    \"module\": \"commonjs\",\n    \"noImplicitThis\": true,\n    \"moduleResolution\": \"node\",\n    \"importHelpers\": true,\n    \"lib\": [\"es2018\"],\n    \"plugins\": []\n  },\n  \"include\": [\n    \"src\"\n  ],\n  \"exclude\": [\n  ],\n  \"moduleResolution\": \"node\"\n}\n"
  }
]