Skip to content

Commit

Permalink
Some settings for ppreprocessors
Browse files Browse the repository at this point in the history
  • Loading branch information
kizu committed Jul 28, 2012
1 parent ab22e76 commit f1fbb99
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 12 deletions.
11 changes: 11 additions & 0 deletions Default (OSX).sublime-keymap
Expand Up @@ -42,4 +42,15 @@
"command": "hayaku_add_code_block",
"context": [{"key": "hayaku_add_code_block"}]
}

// Command prototype for inserting right indent for code block by enter in braces
, {
"keys": ["enter"],
"command": "insert_snippet",
"args": {"contents": "\n\t$1\n\t"},
"context": [
{"key": "preceding_text", "operator": "regex_match", "operand": ".*\\{$" },
{"key": "following_text", "operator": "regex_match", "operand": "^\\}" }
]
}
]
9 changes: 5 additions & 4 deletions Preferences.sublime-settings
Expand Up @@ -9,6 +9,11 @@
, "hayaku_CSS_whitespace_block_end_before": "\n\t"
, "hayaku_CSS_whitespace_block_end_after": ""

// Syntax quirks (for preprocessors)
, "hayaku_CSS_syntax_no_curly_braces": false // Don't print braces for code blocks
, "hayaku_CSS_syntax_no_semicolons": false // Don't print the semicolon at the end of rule
, "hayaku_CSS_syntax_no_colons": false // Don't print colon between property and value

// Unused settings, work in progress

// Prefixes
Expand All @@ -26,8 +31,4 @@
, "hayaku_CSS_default_unit": "px" // `w10` -> `width: 10px`
, "hayaku_CSS_default_unit_decimal": "em" // `w.5` -> `width: 10em`

, "hayaku_Stylus_no_curly_braces": false // Don't print braces for code blocks
, "hayaku_Stylus_no_semicolons": false // Don't print the semicolon at the end of rule
, "hayaku_Stylus_no_colons": false // Don't print colon between property and value

}
2 changes: 1 addition & 1 deletion Stylus.sublime-settings
@@ -1,5 +1,5 @@
{
"auto_complete": false
, "hayaku_CSS_whitespace_block_end_before": "\n"
, "hayaku_CSS_whitespace_block_end_after": "\n"
, "hayaku_CSS_whitespace_block_end_after": "\n"
}
25 changes: 19 additions & 6 deletions add_code_block.py
Expand Up @@ -76,14 +76,27 @@ def run(self, edit):
self.view.sel().clear()
self.view.sel().add(sublime.Region(len(found_insert_position.group(1)) + line.begin(), len(found_insert_position.group(1)) + line.begin()))

start_before = self.view.settings().get("hayaku_CSS_whitespace_block_start_before")
start_after = self.view.settings().get("hayaku_CSS_whitespace_block_start_after")
end_before = self.view.settings().get("hayaku_CSS_whitespace_block_end_before")
end_after = self.view.settings().get("hayaku_CSS_whitespace_block_end_after")
opening_brace = "{"
closing_brace = "}"

if self.view.settings().get("hayaku_Stylus_no_curly_braces"):
opening_brace = ""
closing_brace = ""
start_before = ""
end_before = ""

result = ''.join([
self.view.settings().get("hayaku_CSS_whitespace_block_start_before")
, "{"
, self.view.settings().get("hayaku_CSS_whitespace_block_start_after")
start_before
, opening_brace
, start_after
, "$0"
, self.view.settings().get("hayaku_CSS_whitespace_block_end_before")
, "}"
, self.view.settings().get("hayaku_CSS_whitespace_block_end_after")
, end_before
, closing_brace
, end_after
])
else:
# Place a caret + create a new line otherwise
Expand Down
2 changes: 1 addition & 1 deletion core
Submodule core updated 4 files
+2 −1 probe.py
+3 −0 segmentation_test.py
+13 −6 templates.py
+1 −0 test_data.py
2 changes: 2 additions & 0 deletions hayaku.py
Expand Up @@ -53,6 +53,8 @@ def run(self, edit):
property_, value, is_num, important = extracted
args = {
'whitespace': self.view.settings().get("hayaku_CSS_whitespace_after_colon"),
'disable_semicolon': self.view.settings().get("hayaku_CSS_syntax_no_semicolons"),
'disable_colon': self.view.settings().get("hayaku_CSS_syntax_no_colons"),
'property_': property_,
'value': value,
'is_num': is_num,
Expand Down

0 comments on commit f1fbb99

Please sign in to comment.