full PC config setup
shifting towards manual symlinks for more complex setup than laptop, allows for GUI settings changes to actually apply, and is much easier than nix-ifying every config
This commit is contained in:
149 files changed
+9539
-478
No files matched your search
@@ -0,0 +1,158 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAllPatterns = getAllPatterns;
|
||||
exports.savePattern = savePattern;
|
||||
exports.deletePattern = deletePattern;
|
||||
exports.renamePattern = renamePattern;
|
||||
exports.patternExists = patternExists;
|
||||
const vscode = __importStar(require("vscode"));
|
||||
const C = __importStar(require("./constants"));
|
||||
/**
|
||||
* Get patterns from settings and add runtime IDs
|
||||
*/
|
||||
function getPatternsByScope(scope) {
|
||||
const config = vscode.workspace.getConfiguration(C.CONFIG_NAMESPACE);
|
||||
const configKey = scope === 'global' ? C.CONFIG_KEY_USER_PATTERNS : C.CONFIG_KEY_WORKSPACE_PATTERNS;
|
||||
let storedPatterns;
|
||||
if (scope === 'global') {
|
||||
storedPatterns = config.inspect(C.CONFIG_KEY_USER_PATTERNS)?.globalValue || [];
|
||||
}
|
||||
else {
|
||||
storedPatterns = config.inspect(C.CONFIG_KEY_WORKSPACE_PATTERNS)?.workspaceValue || [];
|
||||
}
|
||||
// Add runtime IDs and ensure scope is set
|
||||
return storedPatterns.map((p, index) => ({
|
||||
...p,
|
||||
id: `${scope}-${index}`, // Index-based runtime ID
|
||||
scope: scope
|
||||
}));
|
||||
}
|
||||
function getAllPatterns() {
|
||||
const workspace = getPatternsByScope('workspace');
|
||||
const global = getPatternsByScope('global');
|
||||
// Return all patterns - duplicates across scopes are allowed
|
||||
return [...workspace, ...global];
|
||||
}
|
||||
async function savePattern(pattern) {
|
||||
const config = vscode.workspace.getConfiguration(C.CONFIG_NAMESPACE);
|
||||
const configKey = pattern.scope === 'global' ? C.CONFIG_KEY_USER_PATTERNS : C.CONFIG_KEY_WORKSPACE_PATTERNS;
|
||||
const target = pattern.scope === 'global'
|
||||
? vscode.ConfigurationTarget.Global
|
||||
: vscode.ConfigurationTarget.Workspace;
|
||||
// Read fresh patterns with runtime IDs
|
||||
const patternsWithIds = getPatternsByScope(pattern.scope);
|
||||
// Find existing pattern by ID (runtime ID tells us the index it came from)
|
||||
const existingIndex = patternsWithIds.findIndex(p => p.id === pattern.id);
|
||||
const isUpdate = existingIndex !== -1;
|
||||
// Strip runtime ID before saving
|
||||
const { id, ...storedPattern } = pattern;
|
||||
// Create array of stored patterns (without IDs)
|
||||
let storedPatterns = patternsWithIds.map(p => {
|
||||
const { id, ...stored } = p;
|
||||
return stored;
|
||||
});
|
||||
if (isUpdate) {
|
||||
// Update existing pattern IN PLACE (maintains order)
|
||||
storedPatterns[existingIndex] = storedPattern;
|
||||
}
|
||||
else {
|
||||
// New pattern - add at beginning
|
||||
storedPatterns.unshift(storedPattern);
|
||||
}
|
||||
// Save to settings (without IDs)
|
||||
await config.update(configKey, storedPatterns, target);
|
||||
// Only show message if it's a new pattern (not an update)
|
||||
if (!isUpdate) {
|
||||
vscode.window.showInformationMessage(`✅ Pattern "${pattern.label}" saved to ${pattern.scope} settings`);
|
||||
}
|
||||
}
|
||||
async function deletePattern(id, scope) {
|
||||
const config = vscode.workspace.getConfiguration(C.CONFIG_NAMESPACE);
|
||||
const configKey = scope === 'global' ? C.CONFIG_KEY_USER_PATTERNS : C.CONFIG_KEY_WORKSPACE_PATTERNS;
|
||||
const target = scope === 'global'
|
||||
? vscode.ConfigurationTarget.Global
|
||||
: vscode.ConfigurationTarget.Workspace;
|
||||
// Read fresh patterns with runtime IDs
|
||||
const patternsWithIds = getPatternsByScope(scope);
|
||||
// Find pattern by runtime ID
|
||||
const patternToDelete = patternsWithIds.find(p => p.id === id);
|
||||
if (!patternToDelete) {
|
||||
vscode.window.showWarningMessage(`Pattern not found in ${scope} settings`);
|
||||
return;
|
||||
}
|
||||
// Filter out the pattern and strip IDs
|
||||
const storedPatterns = patternsWithIds
|
||||
.filter(p => p.id !== id)
|
||||
.map(p => {
|
||||
const { id, ...stored } = p;
|
||||
return stored;
|
||||
});
|
||||
// Save updated list (without IDs)
|
||||
await config.update(configKey, storedPatterns, target);
|
||||
vscode.window.showInformationMessage(`🗑️ Pattern "${patternToDelete.label}" deleted from ${scope} settings`);
|
||||
}
|
||||
async function renamePattern(id, newLabel, scope) {
|
||||
const config = vscode.workspace.getConfiguration(C.CONFIG_NAMESPACE);
|
||||
const configKey = scope === 'global' ? C.CONFIG_KEY_USER_PATTERNS : C.CONFIG_KEY_WORKSPACE_PATTERNS;
|
||||
const target = scope === 'global'
|
||||
? vscode.ConfigurationTarget.Global
|
||||
: vscode.ConfigurationTarget.Workspace;
|
||||
// Read fresh patterns with runtime IDs
|
||||
const patternsWithIds = getPatternsByScope(scope);
|
||||
// Find pattern by runtime ID
|
||||
const pattern = patternsWithIds.find(p => p.id === id);
|
||||
if (!pattern) {
|
||||
vscode.window.showWarningMessage(`Pattern not found in ${scope} settings`);
|
||||
return;
|
||||
}
|
||||
const oldLabel = pattern.label;
|
||||
// Update label and strip IDs for saving
|
||||
const storedPatterns = patternsWithIds.map(p => {
|
||||
const { id: _id, ...stored } = p;
|
||||
if (p.id === id) {
|
||||
return { ...stored, label: newLabel };
|
||||
}
|
||||
return stored;
|
||||
});
|
||||
// Save updated list (without IDs)
|
||||
await config.update(configKey, storedPatterns, target);
|
||||
vscode.window.showInformationMessage(`✏️ Pattern renamed from "${oldLabel}" to "${newLabel}" in ${scope} settings`);
|
||||
}
|
||||
function patternExists(label, scope) {
|
||||
const patterns = getPatternsByScope(scope);
|
||||
return patterns.some(p => p.label === label);
|
||||
}
|
||||
//# sourceMappingURL=storage.js.map
|
||||
Reference in new issue
Block a user