diff --git a/gui.py b/gui.py index 5732733..cc107e6 100644 --- a/gui.py +++ b/gui.py @@ -1,13 +1,17 @@ import logging +import os from typing import Optional import sublime +from ._config import CONFIG + logger = logging.getLogger() __all__ = [ + "edit_settings", "show_message", "remove_status", "get_view_window", @@ -29,6 +33,17 @@ # SETTINGS.add_on_change("password", reload_if_needed) +def edit_settings(): + # sublime.run_command("open_file", {"file": CONFIG.SIMPLENOTE_SETTINGS_FILE_PATH}) + sublime.run_command( + "edit_settings", + { + "base_file": os.path.join(CONFIG.SIMPLENOTE_PACKAGE_DIR, CONFIG.SIMPLENOTE_SETTINGS_FILE_PATH), + "default": "// Simplenote Settings - User\n{\n\t$0\n}\n", + }, + ) + + def _show_message(message: str = ""): if not isinstance(message, str): try: diff --git a/simplenotecommands.py b/simplenotecommands.py index d7582e9..f2f3e5d 100644 --- a/simplenotecommands.py +++ b/simplenotecommands.py @@ -7,7 +7,7 @@ import sublime_plugin from ._config import CONFIG -from .gui import close_view, open_view, remove_status, show_message +from .gui import close_view, edit_settings, open_view, remove_status, show_message from .models import Note from .operations import NoteCreator, NoteDeleter, NotesIndicator, NoteUpdater, OperationManager from .simplenote import clear_orphaned_filepaths, on_note_changed @@ -248,7 +248,6 @@ def start(): global SIMPLENOTE_STARTED settings = sublime.load_settings(CONFIG.SIMPLENOTE_SETTINGS_FILE_PATH) - logger.info(("SIMPLENOTE_SETTINGS_FILE_PATH", CONFIG.SIMPLENOTE_SETTINGS_FILE_PATH)) username = settings.get("username") password = settings.get("password") @@ -256,11 +255,8 @@ def start(): sync() SIMPLENOTE_STARTED = True else: - sublime.active_window().open_file(CONFIG.SIMPLENOTE_SETTINGS_FILE_PATH) - show_message( - "Simplenote: Please configure username/password, Please check settings file: %s" - % CONFIG.SIMPLENOTE_SETTINGS_FILE_PATH - ) + edit_settings() + show_message("Simplenote: Please configure username/password, Please check settings file.") sublime.set_timeout(remove_status, 2000) SIMPLENOTE_STARTED = False return SIMPLENOTE_STARTED