Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased
<!-- Add all new changes here. They will be moved under a version at release -->
* `FIX` Improve type narrow with **literal alias type** during completion and signature help
* `NEW` Setting: `Lua.type.inferTableSize`: A Small Table array can be infered
* `NEW` Add custom repository support for addonManager. New configuration setting: `Lua.addonManager.repositoryBranch` and `Lua.addonManager.repositoryPath`

## 3.12.0
`2024-10-30`
Expand Down
4 changes: 2 additions & 2 deletions client/src/addon_manager/commands/enable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createChildLogger } from "../services/logging.service";
import { setConfig } from "../../languageserver";
import { WebVue } from "../panels/WebVue";
import { NotificationLevels } from "../types/webvue";
import { ADDONS_DIRECTORY } from "../config";
import { ADDONS_DIRECTORY, getStorageUri } from "../config";

type Message = {
data: {
Expand Down Expand Up @@ -51,7 +51,7 @@ export default async (context: vscode.ExtensionContext, message: Message) => {
for (const folder of selectedFolders) {
try {
const installLocation = vscode.Uri.joinPath(
context.globalStorageUri,
getStorageUri(context),
"addonManager",
ADDONS_DIRECTORY
);
Expand Down
4 changes: 2 additions & 2 deletions client/src/addon_manager/commands/getAddons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import * as vscode from "vscode";
import { createChildLogger } from "../services/logging.service";
import addonManager from "../services/addonManager.service";
import { WebVue } from "../panels/WebVue";
import { ADDONS_DIRECTORY } from "../config";
import { ADDONS_DIRECTORY, getStorageUri } from "../config";

const localLogger = createChildLogger("Get Remote Addons");

export default async (context: vscode.ExtensionContext) => {
WebVue.setLoadingState(true);

const installLocation = vscode.Uri.joinPath(
context.globalStorageUri,
getStorageUri(context),
"addonManager",
ADDONS_DIRECTORY
);
Expand Down
4 changes: 2 additions & 2 deletions client/src/addon_manager/commands/open.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as vscode from "vscode";
import { createChildLogger } from "../services/logging.service";
import { ADDONS_DIRECTORY } from "../config";
import { ADDONS_DIRECTORY, getStorageUri } from "../config";

const localLogger = createChildLogger("Open Addon");

export default async (
context: vscode.ExtensionContext,
message: { data: { name: string } }
) => {
const extensionStorageURI = context.globalStorageUri;
const extensionStorageURI = getStorageUri(context);
const uri = vscode.Uri.joinPath(
extensionStorageURI,
"addonManager",
Expand Down
3 changes: 2 additions & 1 deletion client/src/addon_manager/commands/refreshAddons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import * as vscode from "vscode";
import addonManager from "../services/addonManager.service";
import { ADDONS_DIRECTORY } from "../config";
import { WebVue } from "../panels/WebVue";
import { getStorageUri } from "../config"

export default async (context: vscode.ExtensionContext) => {
WebVue.setLoadingState(true);

const installLocation = vscode.Uri.joinPath(
context.globalStorageUri,
getStorageUri(context),
"addonManager",
ADDONS_DIRECTORY
);
Expand Down
18 changes: 16 additions & 2 deletions client/src/addon_manager/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import * as vscode from "vscode";

// Development
export const DEVELOPMENT_IFRAME_URL = "http://127.0.0.1:5173";

// GitHub Repository Info
export const REPOSITORY_PATH = "https://github.com/LuaLS/LLS-Addons.git";
export const REPOSITORY = {
PATH: "https://github.com/LuaLS/LLS-Addons.git",
DEFAULT_BRANCH: "main",
}

export const REPOSITORY_OWNER = "carsakiller";
export const REPOSITORY_NAME = "LLS-Addons";
export const REPOSITORY_DEFAULT_BRANCH = "main";
export const REPOSITORY_ISSUES_URL =
"https://github.com/LuaLS/vscode-lua/issues/new?template=bug_report.yml";
export const ADDONS_DIRECTORY = "addons";
Expand All @@ -18,3 +23,12 @@ export const LIBRARY_SETTING = "Lua.workspace.library";
export const PLUGIN_FILENAME = "plugin.lua";
export const CONFIG_FILENAME = "config.json";
export const INFO_FILENAME = "info.json";

let useGlobal = true
export function getStorageUri(context: vscode.ExtensionContext) {
return useGlobal ? context.globalStorageUri : (context.storageUri ?? context.globalStorageUri)
}

export function setGlobalStorageUri(use: boolean) {
useGlobal = use
}
12 changes: 11 additions & 1 deletion client/src/addon_manager/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createChildLogger, logger } from "./services/logging.service";
import dayjs from "dayjs";
import RelativeTime from "dayjs/plugin/relativeTime";
import { git, setupGit } from "./services/git.service";
import { GIT_DOWNLOAD_URL } from "./config";
import { GIT_DOWNLOAD_URL, REPOSITORY, setGlobalStorageUri } from "./config";
import { NotificationLevels } from "./types/webvue";
import * as languageServer from "../languageserver";

Expand All @@ -28,6 +28,16 @@ export async function activate(context: vscode.ExtensionContext) {
const fileLogger = new VSCodeLogFileTransport(context.logUri, {
level: "debug",
});

// update config
const repositoryPath = globalConfig.get("repositoryPath") as string
const repositoryBranch = globalConfig.get("repositoryBranch") as string
if ((repositoryPath || repositoryBranch) && context.storageUri) {
REPOSITORY.PATH = !!repositoryPath ? repositoryPath : REPOSITORY.PATH
REPOSITORY.DEFAULT_BRANCH = !!repositoryBranch ? repositoryBranch : REPOSITORY.DEFAULT_BRANCH
setGlobalStorageUri(false)
}


// Register command to open addon manager
context.subscriptions.push(
Expand Down
9 changes: 4 additions & 5 deletions client/src/addon_manager/services/git.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import * as vscode from "vscode";
import simpleGit from "simple-git";
import filesystem from "./filesystem.service";
import { createChildLogger } from "./logging.service";
import { REPOSITORY_NAME, REPOSITORY_PATH } from "../config";
import { REPOSITORY_NAME, REPOSITORY, getStorageUri } from "../config";

const localLogger = createChildLogger("Git");

export const git = simpleGit({ trimmed: true });

export const setupGit = async (context: vscode.ExtensionContext) => {
const storageURI = vscode.Uri.joinPath(
context.globalStorageUri,
getStorageUri(context),
"addonManager"
);
await filesystem.createDirectory(storageURI);
Expand All @@ -24,8 +24,7 @@ export const setupGit = async (context: vscode.ExtensionContext) => {
localLogger.debug(
`Attempting to clone ${REPOSITORY_NAME} to ${storageURI.fsPath}`
);
const options = { "--depth": 1 };
await git.clone(REPOSITORY_PATH, storageURI.fsPath, options);
await git.clone(REPOSITORY.PATH, storageURI.fsPath);
localLogger.debug(
`Cloned ${REPOSITORY_NAME} to ${storageURI.fsPath}`
);
Expand All @@ -41,7 +40,7 @@ export const setupGit = async (context: vscode.ExtensionContext) => {
try {
await git.fetch();
await git.pull();
await git.checkout("main");
await git.checkout(REPOSITORY.DEFAULT_BRANCH);
} catch (e) {
localLogger.warn(`Failed to pull ${REPOSITORY_NAME}!`);
throw e;
Expand Down
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@
"scope": "resource",
"type": "boolean"
},
"Lua.addonManager.repositoryBranch": {
"default": "",
"markdownDescription": "%config.addonManager.repositoryBranch%",
"scope": "resource",
"type": "string"
},
"Lua.addonManager.repositoryPath": {
"default": "",
"markdownDescription": "%config.addonManager.repositoryPath%",
"scope": "resource",
"type": "string"
},
"Lua.codeLens.enable": {
"default": false,
"markdownDescription": "%config.codeLens.enable%",
Expand Down
3 changes: 3 additions & 0 deletions package.nls.ja-jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"command.startServer": "Lua: (debug) Start Language Server",
"command.stopServer": "Lua: (debug) Stop Language Server",
"config.addonManager.enable": "Whether the addon manager is enabled or not.",
"config.addonManager.repositoryBranch": "Specifies the git branch used by the addon manager.",
"config.addonManager.repositoryPath": "Specifies the git path used by the addon manager.",
"config.codeLens.enable": "Enable code lens.",
"config.color.mode": "Color mode.",
"config.color.mode.Grammar": "Grammar color.",
Expand Down Expand Up @@ -222,6 +224,7 @@
"config.type.castNumberToInteger": "Allowed to assign the `number` type to the `integer` type.",
"config.type.checkTableShape": "Strictly check the shape of the table.\n",
"config.type.inferParamType": "When a parameter type is not annotated, it is inferred from the function's call sites.\n\nWhen this setting is `false`, the type of the parameter is `any` when it is not annotated.\n",
"config.type.inferTableSize": "TODO: Needs documentation",
"config.type.weakNilCheck": "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",
"config.type.weakUnionCheck": "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",
"config.typeFormat.config": "Configures the formatting behavior while typing Lua code.",
Expand Down
3 changes: 3 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"command.startServer": "Lua: (debug) Start Language Server",
"command.stopServer": "Lua: (debug) Stop Language Server",
"config.addonManager.enable": "Whether the addon manager is enabled or not.",
"config.addonManager.repositoryBranch": "Specifies the git branch used by the addon manager.",
"config.addonManager.repositoryPath": "Specifies the git path used by the addon manager.",
"config.codeLens.enable": "Enable code lens.",
"config.color.mode": "Color mode.",
"config.color.mode.Grammar": "Grammar color.",
Expand Down Expand Up @@ -222,6 +224,7 @@
"config.type.castNumberToInteger": "Allowed to assign the `number` type to the `integer` type.",
"config.type.checkTableShape": "Strictly check the shape of the table.\n",
"config.type.inferParamType": "When a parameter type is not annotated, it is inferred from the function's call sites.\n\nWhen this setting is `false`, the type of the parameter is `any` when it is not annotated.\n",
"config.type.inferTableSize": "TODO: Needs documentation",
"config.type.weakNilCheck": "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",
"config.type.weakUnionCheck": "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",
"config.typeFormat.config": "Configures the formatting behavior while typing Lua code.",
Expand Down
3 changes: 3 additions & 0 deletions package.nls.pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"command.startServer": "Lua: (debug) Start Language Server",
"command.stopServer": "Lua: (debug) Stop Language Server",
"config.addonManager.enable": "Whether the addon manager is enabled or not.",
"config.addonManager.repositoryBranch": "Specifies the git branch used by the addon manager.",
"config.addonManager.repositoryPath": "Specifies the git path used by the addon manager.",
"config.codeLens.enable": "Enable code lens.",
"config.color.mode": "Color mode.",
"config.color.mode.Grammar": "Grammar color.",
Expand Down Expand Up @@ -222,6 +224,7 @@
"config.type.castNumberToInteger": "Allowed to assign the `number` type to the `integer` type.",
"config.type.checkTableShape": "对表的形状进行严格检查。\n",
"config.type.inferParamType": "When the parameter type is not annotated, the parameter type is inferred from the function's incoming parameters.\n\nWhen this setting is `false`, the type of the parameter is `any` when it is not annotated.\n",
"config.type.inferTableSize": "TODO: Needs documentation",
"config.type.weakNilCheck": "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",
"config.type.weakUnionCheck": "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",
"config.typeFormat.config": "Configures the formatting behavior while typing Lua code.",
Expand Down
3 changes: 3 additions & 0 deletions package.nls.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"command.startServer": "Lua: (debug) 启动服务器",
"command.stopServer": "Lua: (debug) 停止服务器",
"config.addonManager.enable": "是否启用扩展的附加插件管理器(Addon Manager)",
"config.addonManager.repositoryBranch": "指定插件管理器(Addon Manager)使用的git仓库分支",
"config.addonManager.repositoryPath": "指定插件管理器(Addon Manager)使用的git仓库路径",
"config.codeLens.enable": "启用代码度量。",
"config.color.mode": "着色模式。",
"config.color.mode.Grammar": "语法着色。",
Expand Down Expand Up @@ -222,6 +224,7 @@
"config.type.castNumberToInteger": "允许将 `number` 类型赋给 `integer` 类型。",
"config.type.checkTableShape": "对表的形状进行严格检查。\n",
"config.type.inferParamType": "未注释参数类型时,参数类型由函数传入参数推断。\n\n如果设置为 \"false\",则在未注释时,参数类型为 \"any\"。\n",
"config.type.inferTableSize": "TODO: Needs documentation",
"config.type.weakNilCheck": "对联合类型进行类型检查时,忽略其中的 `nil`。\n\n此设置为 `false` 时,`numer|nil` 类型无法赋给 `number` 类型;为 `true` 是则可以。\n",
"config.type.weakUnionCheck": "联合类型中只要有一个子类型满足条件,则联合类型也满足条件。\n\n此设置为 `false` 时,`number|boolean` 类型无法赋给 `number` 类型;为 `true` 时则可以。\n",
"config.typeFormat.config": "配置输入Lua代码时的格式化行为",
Expand Down
3 changes: 3 additions & 0 deletions package.nls.zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"command.startServer": "Lua: (debug) Start Language Server",
"command.stopServer": "Lua: (debug) Stop Language Server",
"config.addonManager.enable": "Whether the addon manager is enabled or not.",
"config.addonManager.repositoryBranch": "Specifies the git branch used by the addon manager.",
"config.addonManager.repositoryPath": "Specifies the git path used by the addon manager.",
"config.codeLens.enable": "Enable code lens.",
"config.color.mode": "著色模式。",
"config.color.mode.Grammar": "語法著色。",
Expand Down Expand Up @@ -222,6 +224,7 @@
"config.type.castNumberToInteger": "允許將 `number` 類型賦值給 `integer` 類型。",
"config.type.checkTableShape": "对表的形状进行严格检查。\n",
"config.type.inferParamType": "未注释参数类型时,参数类型由函数传入参数推断。\n\n如果设置为 \"false\",则在未注释时,参数类型为 \"any\"。\n",
"config.type.inferTableSize": "TODO: Needs documentation",
"config.type.weakNilCheck": "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",
"config.type.weakUnionCheck": "同位類型中只要有一個子類型滿足條件,則同位類型也滿足條件。\n\n此設定為 `false` 時,`number|boolean` 類型無法賦給 `number` 類型;為 `true` 時則可以。\n",
"config.typeFormat.config": "Configures the formatting behavior while typing Lua code.",
Expand Down
27 changes: 27 additions & 0 deletions setting/schema-ja-jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"properties": {
"enable": {
"$ref": "#/properties/addonManager.enable"
},
"repositoryBranch": {
"$ref": "#/properties/addonManager.repositoryBranch"
},
"repositoryPath": {
"$ref": "#/properties/addonManager.repositoryPath"
}
}
},
Expand All @@ -14,6 +20,18 @@
"scope": "resource",
"type": "boolean"
},
"addonManager.repositoryBranch": {
"default": "",
"markdownDescription": "Specifies the git branch used by the addon manager.",
"scope": "resource",
"type": "string"
},
"addonManager.repositoryPath": {
"default": "",
"markdownDescription": "Specifies the git path used by the addon manager.",
"scope": "resource",
"type": "string"
},
"codeLens": {
"properties": {
"enable": {
Expand Down Expand Up @@ -3313,6 +3331,9 @@
"inferParamType": {
"$ref": "#/properties/type.inferParamType"
},
"inferTableSize": {
"$ref": "#/properties/type.inferTableSize"
},
"weakNilCheck": {
"$ref": "#/properties/type.weakNilCheck"
},
Expand All @@ -3339,6 +3360,12 @@
"scope": "resource",
"type": "boolean"
},
"type.inferTableSize": {
"default": 10,
"markdownDescription": "TODO: Needs documentation",
"scope": "resource",
"type": "integer"
},
"type.weakNilCheck": {
"default": false,
"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",
Expand Down
27 changes: 27 additions & 0 deletions setting/schema-pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"properties": {
"enable": {
"$ref": "#/properties/addonManager.enable"
},
"repositoryBranch": {
"$ref": "#/properties/addonManager.repositoryBranch"
},
"repositoryPath": {
"$ref": "#/properties/addonManager.repositoryPath"
}
}
},
Expand All @@ -14,6 +20,18 @@
"scope": "resource",
"type": "boolean"
},
"addonManager.repositoryBranch": {
"default": "",
"markdownDescription": "Specifies the git branch used by the addon manager.",
"scope": "resource",
"type": "string"
},
"addonManager.repositoryPath": {
"default": "",
"markdownDescription": "Specifies the git path used by the addon manager.",
"scope": "resource",
"type": "string"
},
"codeLens": {
"properties": {
"enable": {
Expand Down Expand Up @@ -3313,6 +3331,9 @@
"inferParamType": {
"$ref": "#/properties/type.inferParamType"
},
"inferTableSize": {
"$ref": "#/properties/type.inferTableSize"
},
"weakNilCheck": {
"$ref": "#/properties/type.weakNilCheck"
},
Expand All @@ -3339,6 +3360,12 @@
"scope": "resource",
"type": "boolean"
},
"type.inferTableSize": {
"default": 10,
"markdownDescription": "TODO: Needs documentation",
"scope": "resource",
"type": "integer"
},
"type.weakNilCheck": {
"default": false,
"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",
Expand Down
Loading