mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-01-10 17:08:29 +08:00
e2490c0f7f
* Remove Code.Fragment backport * Fix tests compatibility with Elixir 1.13 * Implement signature intellisense * Don't show signatures on module attributes * Add tests for calls with do-end block * Unify spec formatting * Insert parentheses when completing a function call * Send all text until cursor in signature request * Add configuration for completion/signature popups (#693) * Add editor settings form * Add configuration for intellisense defaults * Read fresh settings when editor mounts * Scope attribute names * Fix disabled button styling * Simplify signature box and enable by default * Split settings into system and user sections * Update lib/livebook_web/live/settings_live.ex Co-authored-by: José Valim <jose.valim@dashbit.co> * Update lib/livebook_web/live/settings_live.ex Co-authored-by: José Valim <jose.valim@dashbit.co> Co-authored-by: José Valim <jose.valim@dashbit.co> * Fix spacing in documentation tests Co-authored-by: José Valim <jose.valim@dashbit.co>
37 lines
989 B
JavaScript
37 lines
989 B
JavaScript
const SETTINGS_KEY = "livebook:settings";
|
|
|
|
const DEFAULT_SETTINGS = {
|
|
editor_auto_completion: true,
|
|
editor_auto_signature: true,
|
|
};
|
|
|
|
/**
|
|
* Stores the given settings in local storage.
|
|
*
|
|
* The given attributes are merged into the current settings.
|
|
*/
|
|
export function storeLocalSettings(settings) {
|
|
const prevSettings = loadLocalSettings();
|
|
const newSettings = { ...prevSettings, ...settings };
|
|
|
|
try {
|
|
const json = JSON.stringify(newSettings);
|
|
localStorage.setItem(SETTINGS_KEY, json);
|
|
} catch (error) {
|
|
console.error(`Failed to store local settings, reason: ${error.message}`);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Loads settings from local storage.
|
|
*/
|
|
export function loadLocalSettings() {
|
|
try {
|
|
const json = localStorage.getItem(SETTINGS_KEY);
|
|
const settings = json ? JSON.parse(json) : {};
|
|
return { ...DEFAULT_SETTINGS, ...settings };
|
|
} catch (error) {
|
|
console.error(`Failed to load local settings, reason: ${error.message}`);
|
|
return DEFAULT_SETTINGS;
|
|
}
|
|
}
|