Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dennykorsukewitz committed Nov 22, 2023
1 parent 1b933e7 commit 2ab37a0
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The following files can be created.
| | messages/version.txt | When a package is upgraded, Package Control looks through each key in the messages.json file sand shows the content of the text file that is a value of any key that is higher than the previous version of the package the user has installed. |
| | messages.json | Messaging is controlled by a file named messages.json in the root of the package. |
| commands | SublimePackage.sublime-commands | SublimePackage.sublime-commands is a file to register your new command / plugin for the Command Palette. |
| keymap | TODO | TODO |
| keymap | Default.sublime-keymap | Creates a Default.sublime-keymap file. Default.sublime-keymap files contain the key bindings (shortcuts) for a command. The JSON objects must contain a keys and command key, and may also contain a args key if the command requires arguments. |
| macros | TODO | TODO |
| menu | TODO | TODO |
| plugin | SublimePackage.py | Creates a new python plugin. |
Expand Down
8 changes: 8 additions & 0 deletions generators/keymap/USAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Description:
Creates a Default.sublime-keymap file. Default.sublime-keymap files contain a JSON array that contains JSON objects to specify the key bindings. The JSON objects must contain a keys and command key, and may also contain a args key if the command requires arguments.

Example:
yo sublime-package:keymap

This will create:
Default.sublime-keymap: *.sublime-keymap files contain a JSON array that contains JSON objects to specify the key bindings.
23 changes: 23 additions & 0 deletions generators/keymap/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const config = {
name: 'Keymap',
description: 'Creates a Default.sublime-keymap file. Default.sublime-keymap files contain the key bindings (shortcuts) for a command.',
priority: 4,
versions: {
'4.0.x': '',
},
prompts: [
{
name: 'keymap_shortcut',
message: 'What is the shortcut of your command?',
type: 'input',
default: 'super+ctrl+alt+k',
},
{
name: 'keymap_command',
message: 'What is the name of your command?',
type: 'input',
default: '${config.package_name_pascal_case}',
},
],
};
module.exports = config;
73 changes: 73 additions & 0 deletions generators/keymap/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
'use strict';
/* eslint no-empty-function: ["error", { "allow": ["methods"] }] */

const Generator = require('yeoman-generator');
const chalk = require('chalk');
const yosay = require('yosay');
const path = require('path');
const helper = require('./../../src/helper.js');
const generator = path.basename(__dirname);
const generator_config = require('./config.js');

let config = {};
let answers = {};

module.exports = class extends Generator {
// initializing - Your initialization methods (checking current project state, getting configs, etc)
async initializing() {

// create or update config
await helper.InitConfig(this, generator_config);

// get current config
config = this.config.getAll();
config.generator_name = generator_config.name || generator;
config.generator_description = '\n' + generator_config.description || '';
}

// prompting - Where you prompt users for options (where you’d call this.prompt())
async prompting() {
this.log(
yosay(
`${chalk.green(config.generator_name)} ${config.generator_description}`,
),
);

generator_config.prompts = helper.InterpolatePrompts(this, config, generator_config.prompts);
answers = await this.prompt(generator_config.prompts);
}

// configuring - Saving configurations and configure the project (creating .editorconfig files and other metadata files)
configuring() {}

// default - If the method name doesn’t match a priority, it will be pushed to this group.
default() {}

// writing - Where you write the generator specific files (routes, controllers, etc)
writing() {

// merge data
const data = {
...config,
...answers,
};

this.renderTemplate(
this.templatePath('Default.sublime-keymap'),
this.destinationPath('Default.sublime-keymap'),
data,
);
}

// conflicts - Where conflicts are handled (used internally)
conflicts() { }

// install - Where installations are run (npm, bower)
install() {}

// end - Called last, cleanup, say good bye, etc
end() {
helper.End(this, config);
}
};

3 changes: 3 additions & 0 deletions generators/keymap/templates/Default.sublime-keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
{ "keys": ["<%= keymap_shortcut %>"], "command": "<%= keymap_command %>" },
]
2 changes: 1 addition & 1 deletion generators/settings/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = {
name: 'Settings',
description: 'Creates a SublimePackage.sublime-settings file to stores configuration data.',
priority: 4,
priority: 5,
versions: {
'4.0.x': '',
},
Expand Down
2 changes: 1 addition & 1 deletion generators/snippet/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = {
name: 'Snippet',
description: 'Creates a Snippet file. Snippets are smart templates that will insert text for you, adapting it to their context.',
priority: 5,
priority: 6,
versions: {
'4.0.x': '',
},
Expand Down

0 comments on commit 2ab37a0

Please sign in to comment.