Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mwrock committed Apr 2, 2012
0 parents commit 2d96de0
Show file tree
Hide file tree
Showing 182 changed files with 8,988 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
*.sublime-workspace
*.exe
16 changes: 16 additions & 0 deletions PackageAssets/SublimePackages/AAAPackageDev/.hgignore
@@ -0,0 +1,16 @@
syntax: glob

*.pyc
_*.txt
*.cache
*.sublime-project
*.sublime-workspace
sample-grammar.js
Manifest
MANIFEST

dist/
build/
data/
Doc/
_ref/
9 changes: 9 additions & 0 deletions PackageAssets/SublimePackages/AAAPackageDev/AAA.py
@@ -0,0 +1,9 @@
import sublime

import os
import sys

# Makes sublime_lib package available for all packages.
if not os.path.join(sublime.packages_path(), "AAAPackageDev/Lib") in sys.path:
sys.path.append(os.path.join(sublime.packages_path(), "AAAPackageDev/Lib"))
print "[AAAPackageDev] Added sublime_lib to sys.path."
Binary file added PackageAssets/SublimePackages/AAAPackageDev/AAA.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions PackageAssets/SublimePackages/AAAPackageDev/LICENSE.txt
@@ -0,0 +1 @@
The license under which this package is released.
Empty file.
@@ -0,0 +1,63 @@
KEY_UP = "up"
KEY_DOWN = "down"
KEY_RIGHT = "right"
KEY_LEFT = "left"
KEY_INSERT = "insert"
KEY_HOME = "home"
KEY_END = "end"
KEY_PAGEUP = "pageup"
KEY_PAGEDOWN = "pagedown"
KEY_BACKSPACE = "backspace"
KEY_DELETE = "delete"
KEY_TAB = "tab"
KEY_ENTER = "enter"
KEY_PAUSE = "pause"
KEY_ESCAPE = "escape"
KEY_SPACE = "space"
KEY_KEYPAD0 = "keypad0"
KEY_KEYPAD1 = "keypad1"
KEY_KEYPAD2 = "keypad2"
KEY_KEYPAD3 = "keypad3"
KEY_KEYPAD4 = "keypad4"
KEY_KEYPAD5 = "keypad5"
KEY_KEYPAD6 = "keypad6"
KEY_KEYPAD7 = "keypad7"
KEY_KEYPAD8 = "keypad8"
KEY_KEYPAD9 = "keypad9"
KEY_KEYPAD_PERIOD = "keypad_period"
KEY_KEYPAD_DIVIDE = "keypad_divide"
KEY_KEYPAD_MULTIPLY = "keypad_multiply"
KEY_KEYPAD_MINUS = "keypad_minus"
KEY_KEYPAD_PLUS = "keypad_plus"
KEY_KEYPAD_ENTER = "keypad_enter"
KEY_CLEAR = "clear"
KEY_F1 = "f1"
KEY_F2 = "f2"
KEY_F3 = "f3"
KEY_F4 = "f4"
KEY_F5 = "f5"
KEY_F6 = "f6"
KEY_F7 = "f7"
KEY_F8 = "f8"
KEY_F9 = "f9"
KEY_F10 = "f10"
KEY_F11 = "f11"
KEY_F12 = "f12"
KEY_F13 = "f13"
KEY_F14 = "f14"
KEY_F15 = "f15"
KEY_F16 = "f16"
KEY_F17 = "f17"
KEY_F18 = "f18"
KEY_F19 = "f19"
KEY_F20 = "f20"
KEY_SYSREQ = "sysreq"
KEY_BREAK = "break"
KEY_CONTEXT_MENU = "context_menu"
KEY_BROWSER_BACK = "browser_back"
KEY_BROWSER_FORWARD = "browser_forward"
KEY_BROWSER_REFRESH = "browser_refresh"
KEY_BROWSER_STOP = "browser_stop"
KEY_BROWSER_SEARCH = "browser_search"
KEY_BROWSER_FAVORITES = "browser_favorites"
KEY_BROWSER_HOME = "browser_home"
@@ -0,0 +1,25 @@
import sublime

import os


FTYPE_EXT_KEYMAP = ".sublime-keymap"
FTYPE_EXT_COMPLETIONS = ".sublime-completions"
FTYPE_EXT_SNIPPET = ".sublime-snippet"
FTYPE_EXT_BUILD = ".sublime-build"
FTYPE_EXT_SETTINGS = ".sublime-settings"
FTYPE_EXT_TMPREFERENCES = ".tmPreferences"
FTYPE_EXT_TMLANGUAGE = ".tmLanguage"


def root_at_packages(*leafs):
"""Combines leafs with path to Sublime's Packages folder.
"""
return os.path.join(sublime.packages_path(), *leafs)


def root_at_data(*leafs):
"""Combines leafs with Sublime's ``Data`` folder.
"""
data = os.path.join(os.path.split(sublime.packages_path())[0])
return os.path.join(data, *leafs)
@@ -0,0 +1 @@
from ._view import *
@@ -0,0 +1,43 @@
import contextlib


def append(view, text):
"""Appends text to view."""
with in_one_edit(view) as edit:
view.insert(edit, view.size(), text)


@contextlib.contextmanager
def in_one_edit(view):
"""Context manager to group edits in a view.
Example:
...
with in_one_edit(view):
...
...
"""
try:
edit = view.begin_edit()
yield edit
finally:
view.end_edit(edit)


def has_sels(view):
"""Returns ``True`` if ``view`` has one selection or more.``
"""
return len(view.sel()) > 0


def has_file_ext(view, ext):
"""Returns ``True`` if view has file extension ``ext``.
``ext`` may be specified with or without leading ``.``.
"""
if not view.file_name(): return False
if not ext.strip().replace('.', ''): return False

if not ext.startswith('.'):
ext = '.' + ext

return view.file_name().endswith(ext)
Empty file.
30 changes: 30 additions & 0 deletions PackageAssets/SublimePackages/AAAPackageDev/Main.sublime-menu
@@ -0,0 +1,30 @@
[
{
"id": "tools",
"children":
[
{
"id": "packages",
"caption": "Packages",
"children":
[
{
"caption": "Package Development",
"children":
[
{ "caption": "New Package…", "command": "new_package" },
{ "caption": "Delete Package…", "command": "delete_package" },
{ "caption": "-" },
{ "caption": "New Syntax Definition", "command": "new_syntax_def" },
{ "caption": "New Syntax Definition from Buffer", "command": "new_syntax_def_from_buffer" },
{ "caption": "-" },
{ "caption": "New Raw Snippet…", "command": "new_raw_snippet" },
{ "caption": "New Raw Snippet from Snippet…", "command": "new_raw_snippet_from_snippet" },
{ "caption": "Generate Snippet from Raw Snippet", "command": "generate_snippet_from_raw_snippet" }
]
}
]
}
]
}
]
156 changes: 156 additions & 0 deletions PackageAssets/SublimePackages/AAAPackageDev/README.rst
@@ -0,0 +1,156 @@
=============
AAAPackageDev
=============

status: beta

Overview
========

AAAPackageDev helps create and edit snippets, completions files, build systems
and other Sublime Text extensions.

The general workflow looks like this:

- run ``new_*`` command (``new_raw_snippet``, ``new_completions``, ``new_syntax_def``...)
- edit file (with specific snippets, completions, higlighting, build systems...)
- save file

AAAPackageDev ``new_*`` commands are typically accessible through the *Command
Palette* (``Ctrl+Shift+P``).


Getting Started
===============

#. Download and install `AAAPackageDev`_. (See `installation instructions`_ for ``.sublime-package`` files.)
#. Access commands from **Tools | Packages | Package Development** or the *Command Palette* (``Ctrl+Shift+P``).

.. _AAAPackageDev: https://bitbucket.org/guillermooo/aaapackagedev/downloads/AAAPackageDev.sublime-package
.. _installation instructions: http://sublimetext.info/docs/en/extensibility/packages.html#installation-of-packages


Syntax Definition Development
=============================

In AAAPackageDev, syntax definitions are written in JSON. Because Sublime Text
uses ``.tmLanguage`` files, though, they need to be converted before use. The
conversion is done through the included build system ``Json to tmLanguage``.

Creating a New Syntax Definition
********************************

#. Create new template (through **Tools | Packages | Package Development**) or the *Command Palette*
#. Select ``Json to tmLanguage`` build system from **Tools | Build System**
#. Press ``F7``

To reload changes to a syntax definition, you must restart Sublime Text.

Other included resources for syntax definition development:

* Snippets


Package Development
===================

Resources for package development are in a very early stage.

Commands
********

``new_package()``
Window command. Prompts for a name and creates a new package skeleton in ``Packages``.

``delete_package()``
Window command. Opens file browser at ``Packages``.


.. Completions
.. -----------
..
.. * sublime text plugin dev (off by default)
.. Will clutter your completions list in any kind of python dev.
.. To turn on, change scope selector so ``source.python``.
Build System Development
========================

* Syntax definition for ``.build-system`` files.


Key Map Development
===================

* Syntax definition for ``.sublime-keymap`` files.
* Completions
* Snippets


Snippet Development
===================

AAAPackageDev provides a means to edit snippets using snippets. These snippets
are called *raw snippets*. You can use snippets and snippet-like syntax in many
files, but if you want to create ``.sublime-snippet`` files, you need to convert
raw snippets first. This converion is done with a command.

Inside ``AAAPackageDev/Support`` you will find a ``.sublime-keymap`` file.
The key bindings in it are included for reference. If you want them to work,
you need to copy the contents over to your personal ``.sublime-keymap`` file
under ``Packages/User``.

Creating Snippets
*****************

#. Create new raw snippet with included commands (**Tools | Packages | Package Development** or *Command Palette*)
#. Edit snippet
#. If needed, convert to ``.sublime-snippet`` with included command

You can use raw snippets directly in some files, like ``.sublime-completions`` files.


Completions Development
=======================

* Syntax definition for ``.sublime-completions`` files
* Snippets

You can use raw snippets directly in the ``contents`` element of a trigger-based
completion.


Settings File Development
=========================

* Syntax definition for ``.sublime-settings`` files
* Snippets


About Snippets in AAAPackageDev
===============================

The ``AAAPackageDev/Snippets`` folder contains many snippets for all kinds of
development mentioned above. These snippets follow memorable rules to make their
use easy.

The snippets used more often have short tab triggers like ``f`` (*field*),
``c`` (*completion*), ``k`` (*key binding*), etc. In cases where increasingly
complex items of a similar kind might exist (numbered fields, fields with place
holders and fields with substitutions in the case of snippets), their tab triggers
will consist in a repeated character, like ``f``, ``ff`` and ``fff``.

As a rule of thumb, the more complex the snippet, the longer its tab trigger.

Also, ``i`` (for *item*) is often a generic synonym for the most common snippet
in a type of file. In such cases, ``ii`` and even longer tab triggers might work
too for consistency.


Sublime Library
===============

AAAPackageDev includes ``sublime_lib``, a Python package with utilities for
plugin developers. Once AAAPackageDev is installed, ``sublime_lib`` will be
importable from any plugin residing in ``Packages``.
5 changes: 5 additions & 0 deletions PackageAssets/SublimePackages/AAAPackageDev/RELEASE.txt
@@ -0,0 +1,5 @@
0.5
- Escaped regexp syntax def. (For regexes in JSON files.)
- Improvements to syntax defs for .sublime-keymap and .sublime-build.
- .sublime-build files will load their specific syntax automatically.
- Improved documentation.
@@ -0,0 +1,8 @@
{
"scope": "source.sublimecommands",

"completions": [
{ "trigger": "c", "contents": "{ \"caption\": \"$1\", \"command\": \"$2\" }" },
{ "trigger": "i", "contents": "{ \"caption\": \"$1\", \"command\": \"$2\" }" }
]
}
@@ -0,0 +1,8 @@
{
"scope": "source.sublimecompletions",

"completions": [
{ "trigger": "c", "contents": "{ \"trigger\": \"$1\", \"contents\": \"$2\" }$0" },
{ "trigger": "i", "contents": "{ \"triggers\": \"$1\", \"contents\": \"$2\" }$0" }
]
}
@@ -0,0 +1,7 @@
<snippet>
<content><![CDATA["args": {
"$1": "$2"$0
}]]></content>
<scope>source.sublimekeymap</scope>
<tabTrigger>args</tabTrigger>
</snippet>

0 comments on commit 2d96de0

Please sign in to comment.