Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dennykorsukewitz committed Nov 24, 2023
1 parent 8573da1 commit 53c3a06
Show file tree
Hide file tree
Showing 23 changed files with 588 additions and 12 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

# Sublime-Package

**Sublime-Package** is a Sublime Text package generator for [yeoman](https://yeoman.io/), which creates scaffold for a sublime-package.
**Sublime-Package** is a Sublime Text package **GENERATOR** for [yeoman](https://yeoman.io/), which creates scaffold for a sublime-package.

We are all lazy 🦥 and only want to code 👨‍💻 if it is not already exists. \
So i created this yeoman generator to easy get an scaffold for a sublime-package.
So I created this yeoman generator to easily get a framework for a Sublime package.

| Repository | GitHub | Npm |
| ------ | ------ | ------ |
Expand All @@ -16,7 +16,7 @@ So i created this yeoman generator to easy get an scaffold for a sublime-package

| Status |
| ------ |
| [![GitHub commits since tagged version](https://img.shields.io/github/commits-since/dennykorsukewitz/generator-sublime-package/0.0.1/dev)](https://github.com/dennykorsukewitz/generator-sublime-package/compare/0.0.1...dev) ![GitHub Workflow Lint](https://github.com/dennykorsukewitz/generator-sublime-package/actions/workflows/lint.yml/badge.svg?branch=dev&style=flat&label=Lint) ![GitHub Workflow Pages](https://github.com/dennykorsukewitz/generator-sublime-package/actions/workflows/pages.yml/badge.svg?branch=dev&style=flat&label=GitHub%20Pages) |
| [![GitHub commits since tagged version](https://img.shields.io/github/commits-since/dennykorsukewitz/generator-sublime-package/0.0.1/dev)](https://github.com/dennykorsukewitz/generator-sublime-package/compare/0.0.1...dev) ![GitHub Workflow Lint](https://github.com/dennykorsukewitz/generator-sublime-package/actions/workflows/lint.yml/badge.svg?branch=dev&style=flat&label=Lint) ![GitHub Workflow UnitTest](https://github.com/dennykorsukewitz/generator-sublime-package/actions/workflows/unittest.yml/badge.svg?branch=dev&style=flat&label=UnitTest) ![GitHub Workflow Pages](https://github.com/dennykorsukewitz/generator-sublime-package/actions/workflows/pages.yml/badge.svg?branch=dev&style=flat&label=GitHub%20Pages) |

---

Expand All @@ -38,7 +38,6 @@ The following files can be created.
| menu | TODO | TODO |
| plugin | SublimePackage.py | Creates a new python plugin. |
| | SublimePackage.sublime-settings | Creates a SublimePackage.sublime-settings file to stores configuration data. |
| preferences | TODO | TODO |
| readme | README.md | A README is often the first item a visitor will see when visiting your repository.|
| settings | SublimePackage.sublime-settings | Creates a SublimePackage.sublime-settings file to stores configuration data. |
| snippets | snipptes/SublimePackage.sublime-snippet | Snippets are smart templates that will insert text for you, adapting it to their context. |
Expand Down
9 changes: 7 additions & 2 deletions generators/keymap/USAGE
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
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.
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.
Default.sublime-keymap: *.sublime-keymap files contain a JSON array that contains JSON objects to specify the key bindings.

Default (Linux).sublime-keymap
Default (OSX).sublime-keymap
Default (Windows).sublime-keymap
24 changes: 23 additions & 1 deletion generators/keymap/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,36 @@ const config = {
name: 'keymap_shortcut',
message: 'What is the shortcut of your command?',
type: 'input',
default: 'super+ctrl+alt+k',
default: 'ctrl+alt+k',
},
{
name: 'keymap_command',
message: 'What is the name of your command?',
type: 'input',
default: '${config.package_name_pascal_case}',
},
{
name: 'keymap_os',
message: 'For which operating system do you need a keymap?',
type: 'checkbox',
choices: [
{
name: 'Windows',
value: 'Default (Windows)',
checked: true,
},
{
name: 'OSX',
value: 'Default (OSX)',
checked: true,
},
{
name: 'Linux',
value: 'Default (Linux)',
checked: true,
},
],
},
],
};
module.exports = config;
13 changes: 8 additions & 5 deletions generators/keymap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ module.exports = class extends Generator {
...answers,
};

this.renderTemplate(
this.templatePath('Default.sublime-keymap'),
this.destinationPath('Default.sublime-keymap'),
data,
);
answers.keymap_os.forEach(os => {
this.renderTemplate(
this.templatePath('Default.sublime-keymap'),
this.destinationPath(`${os}.sublime-keymap`),
data,
);
});

}

// conflicts - Where conflicts are handled (used internally)
Expand Down
8 changes: 8 additions & 0 deletions generators/macro/USAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Description:
Creates a Snippet file. Snippets are smart templates that will insert text for you, adapting it to their context.

Example:
yo sublime-package:snippet

This will create:
snipptes/SublimePackage.sublime-snippet: Snippets are smart templates that will insert text for you, adapting it to their context.
41 changes: 41 additions & 0 deletions generators/macro/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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: 6,
versions: {
'4.0.x': '',
},
prompts: [
{
name: 'snippet_file_name',
message: 'What is the name of your new snippet file (snippet file name)?',
type: 'input',
default: '${config.package_name_pascal_case}',
},
{
name: 'snippet_content',
message: 'What is the content?',
type: 'input',
default: 'Hello World!',
},
{
name: 'snippet_tab_trigger',
message: 'What is the name of your new snippet file (snippet file name)?',
type: 'input',
default: 'hello_world',
},
{
name: 'snippet_description',
message: 'What is the name of your new snippet file (snippet file name)?',
type: 'input',
default: 'Say hello world!',
},
{
name: 'snippet_scope',
message: 'What is the name of your new snippet file (snippet file name)?',
type: 'input',
default: 'source.python',
},
],
};
module.exports = config;
73 changes: 73 additions & 0 deletions generators/macro/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('snippet.sublime-snippet'),
this.destinationPath(`snipptes/${data.snippet_file_name}.sublime-snippet`),
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);
}
};

14 changes: 14 additions & 0 deletions generators/macro/templates/macro.sublime-macro
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"command": "move_to",
"args": {
"to": "#"
}
},
{
"command": "insert",
"args": {
"characters": "\n"
}
}
]
19 changes: 19 additions & 0 deletions generators/menu/USAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Description:
Creates a *.sublime-menu file. Define Menubar and various right-click menus.
File name is significant because it determine which element (Menubar/statusbar/...) is affected.

Example:
yo sublime-package:menu

This will create:
Context.sublime-menu Right click on main buffer.
Encoding.sublime-menu Left click on "Encoding" section in statusbar.
Find in Files.sublime-menu Left click on "..." button on Where field of Find_in_files.
Indentation.sublime-menu Left click on "Indentation" section in statusbar.
Line Endings.sublime-menu Left click on "Line Ending" section in statusbar.
Main.sublime-menu Main Menu bar.
Side Bar.sublime-menu Right click on items in Sidebar.
Syntax.sublime-menu Left click on current syntax section in statusbar e.g. 'Plain Text'.
Side Bar Mount Point.sublime-menu Right click on main folders in Sidebar.
Tab Context.sublime-menu Right click on Tab bar.
Widget Context.sublime-menu Right click on text field of any widget (i.e: search panel or output panel).
73 changes: 73 additions & 0 deletions generators/menu/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const config = {
name: 'Menu',
description: 'Creates a *.sublime-menu file. Define Menubar and various right-click menus. Creates a *.sublime-menu file.',
priority: 7,
versions: {
'4.0.x': '',
},
prompts: [
{
name: 'menu_types',
message: 'Which menu do you need?',
type: 'checkbox',
choices: [
{
name: 'Main',
value: 'Main',
checked: true,
},
{
name: 'Context',
value: 'Context',
checked: false,
},
{
name: 'Encoding',
value: 'Encoding',
checked: false,
},
{
name: 'Find in Files',
value: 'Find in Files',
checked: false,
},
{
name: 'Indentation',
value: 'Indentation',
checked: false,
},
{
name: 'Line Endings',
value: 'Line Endings',
checked: false,
},
{
name: 'Side Bar',
value: 'Side Bar',
checked: false,
},
{
name: 'Side Bar Mount Point',
value: 'Side Bar Mount Point',
checked: false,
},
{
name: 'Syntax',
value: 'Syntax',
checked: false,
},
{
name: 'Tab Context',
value: 'Tab Context',
checked: false,
},
{
name: 'Widget Context',
value: 'Widget Context',
checked: false,
},
],
},
],
};
module.exports = config;
Loading

0 comments on commit 53c3a06

Please sign in to comment.