{"id":19364546,"url":"https://github.com/math2001/package_setting_context","last_synced_at":"2026-06-13T18:31:36.816Z","repository":{"id":74806780,"uuid":"82035821","full_name":"math2001/package_setting_context","owner":"math2001","description":"A Sublime Text plugin to be able to use plugin settings in key bindings' context. ","archived":false,"fork":false,"pushed_at":"2019-10-27T23:09:53.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-06T20:53:00.500Z","etag":null,"topics":["dependency","package-control","sublime-text"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/math2001.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-15T08:08:28.000Z","updated_at":"2019-10-27T23:09:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"1ffbff3a-3172-4ce1-b7d1-2ce304ae1be2","html_url":"https://github.com/math2001/package_setting_context","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/math2001%2Fpackage_setting_context","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/math2001%2Fpackage_setting_context/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/math2001%2Fpackage_setting_context/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/math2001%2Fpackage_setting_context/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/math2001","download_url":"https://codeload.github.com/math2001/package_setting_context/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240483765,"owners_count":19808636,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency","package-control","sublime-text"],"created_at":"2024-11-10T07:37:40.536Z","updated_at":"2025-11-16T18:04:46.787Z","avatar_url":"https://github.com/math2001.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# package_setting_context\n\nThis \"package\" is a dependency for *your* package(s). It allows your users to enable/disable a key\nbinding by simply changing your package's settings. And all it requires you to do is to add:\n\n```json\n\"context\": [\n    { \"key\": \"package_setting.SettingsFileName.setting_to_enable_this_key_binding\" }\n]\n```\n\nThat's it!\n\nTo make things clearer, here's when it's decomposed:\n\n1. `package_setting.`: this prefix is needed and the exact same in every cases.\n2. `SettingsFileName`: this part might be a bit more confusing. It the name of the setting file *without the extension* in which you write custom settings for the package. It usually is the same as the package name. It also usually have the extension `.sublime-settings`.\n3. `setting_to_enable_this_key_binding`: simply the setting's name. It can be a bit more than that though, keep reading to get more :wink:\n\n## Overview\n\nA `YourPackage.sublime-settings` file:\n\n```json\n{\n    \"enabled_shortcut_my_super_command\": true\n}\n```\n\n```json\n[\n    {\n        \"keys\": [\"ctrl+l\"],\n        \"command\": \"my_super_command\",\n        \"context\": [\n            { \"key\": \"package_setting.YourPackage.enabled_shortcut_my_super_command\" }\n        ]\n    }\n]\n```\n\nAnd this shortcut will work. But if you set `YourPackage.sublime-settings`'s content to:\n\n```json\n{\n    \"enabled_shortcut_my_super_command\": false\n}\n```\n\nYou guessed it: this key binding wouldn't work any more. Pretty handy, right?\n\n## Further infos\n\nIn the overview's example, the `operator: equal` and `operand: true` is implicit, but you can of\ncourse change it:\n\n```json\n[\n    {\n        \"keys\": [\"ctrl+l\"],\n        \"command\": \"my_super_command\",\n        \"context\": [\n            { \"key\": \"package_setting.YourPackage.enabled_shortcut_my_super_command\",\n              \"operand\": \"not_equal\",\n              \"operator\": \"a string for example!\"}\n        ]\n    }\n]\n```\n\nThe `key` is quiet clever too. Have a look:\n\nIn `Hello.sublime-settings`:\n\n```json\n{\n    \"my_setting\": {\n        \"my_key\": [\"my\", \"list\", {\n            \"and\": \"it goes on and\",\n            \"on\": true\n        }]\n    }\n}\n```\n\nAnd your key binding:\n\n```json\n[\n    {\n        \"keys\": [\"ctrl+l\"],\n        \"command\": \"my_super_command\",\n        \"context\": [\n            { \"key\": \"package_setting.SettingsFileName.my_setting.my_key.2.on\"}\n        ]\n    }\n]\n```\n\nAnd it works!\n\n## How to use it\n\n### If you want to use this in your package\n\nIf you want to use this feature in your *package*, just [add it as a dependency][]. So, for example\n\nIn your `dependencies.json`\n\n```json\n{\n    \"*\": {\n        \"*\": [\n            \"package_setting_context\"\n        ]\n    }\n}\n```\n\n### If you want to use this in your regular keymap\n\nWhat you can do is actually set this as a dependency to your `User` package. Create the file\n`Packages/User/dependencies.json`, and set the same content as above\n\n\n[add it as a dependency]: https://packagecontrol.io/docs/dependencies\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmath2001%2Fpackage_setting_context","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmath2001%2Fpackage_setting_context","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmath2001%2Fpackage_setting_context/lists"}