From 2f9214f5cb23936a5a9c08f95a380f4898e356fb Mon Sep 17 00:00:00 2001 From: Alex Armstrong Date: Fri, 19 Apr 2013 17:00:52 +0300 Subject: [PATCH 1/7] Quick nested list indenting A quick-and-dirty way to resolve issue #9 --- Default.sublime-keymap | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Default.sublime-keymap b/Default.sublime-keymap index 28a78b4..cd805a4 100644 --- a/Default.sublime-keymap +++ b/Default.sublime-keymap @@ -68,5 +68,17 @@ [ {"key": "selector", "operator": "equal", "operand": "text.html.markdown"} ] + }, + { "keys": ["tab"], "command": "indent", "context": + [ + { "key": "selector", "operator": "equal", "operand": "markup.list" } + ] + }, + { "keys": ["shift+tab"], "command": "unindent", "context": + [ + { "key": "selector", "operator": "equal", "operand": "markup.list" }, + // Should we enable the following setting check? + // { "key": "setting.shift_tab_unindent", "operator": "equal", "operand": true } + ] } ] From 90953bf8eac5b4d6590f249e0af775c398783a0e Mon Sep 17 00:00:00 2001 From: Alex Armstrong Date: Fri, 19 Apr 2013 19:24:32 +0300 Subject: [PATCH 2/7] Improve quick list indenting (by matching regex rather than scope) This one relies on a lovingly hand-crafted regex rather than syntax of the default Markdown.tmLanguage. Of course this should _really_ be addressed at the level of the syntax. But I digress: It supports the following list types (more or less in the order in which they appear in the regex): - + * 5. a. A. 5) a) A) (5) (a) (A) (@) (@label-5_) Because my attention is starting to wander, it does not support the [two spaces after a single capital letter followed by a period](http://johnmacfarlane.net/pandoc/README.html#fn1) rule, as well as roman numerals (e.g., `v)` or `III.`) There are probably other issues I haven't noticed as well. Such as those created by this excepionally long commit message :) --- Default.sublime-keymap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Default.sublime-keymap b/Default.sublime-keymap index cd805a4..3382482 100644 --- a/Default.sublime-keymap +++ b/Default.sublime-keymap @@ -71,12 +71,12 @@ }, { "keys": ["tab"], "command": "indent", "context": [ - { "key": "selector", "operator": "equal", "operand": "markup.list" } + { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-\\+\\*]|#.|(\\d+|[A-z])[\\.\\)]|\\((\\d+|[A-z])\\)|\\(\\@[\\w\\-]*\\))\\s+" } ] }, { "keys": ["shift+tab"], "command": "unindent", "context": [ - { "key": "selector", "operator": "equal", "operand": "markup.list" }, + { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-\\+\\*]|#.|(\\d+|[A-z])[\\.\\)]|\\((\\d+|[A-z])\\)|\\(\\@[\\w\\-]*\\))\\s+" } // Should we enable the following setting check? // { "key": "setting.shift_tab_unindent", "operator": "equal", "operand": true } ] From b0f0811cf7f1c5eeb33fe28cf0f3cf9784e4d3c5 Mon Sep 17 00:00:00 2001 From: Alex Armstrong Date: Fri, 19 Apr 2013 21:47:56 +0300 Subject: [PATCH 3/7] add support for "fake" roman numerals I call this "fake" because all I'm doing is matching IVXLCDM in either upper- or lowercase, without testing the validity of the construction. --- Default.sublime-keymap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Default.sublime-keymap b/Default.sublime-keymap index 3382482..fa2872d 100644 --- a/Default.sublime-keymap +++ b/Default.sublime-keymap @@ -71,12 +71,12 @@ }, { "keys": ["tab"], "command": "indent", "context": [ - { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-\\+\\*]|#.|(\\d+|[A-z])[\\.\\)]|\\((\\d+|[A-z])\\)|\\(\\@[\\w\\-]*\\))\\s+" } + { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-\\+\\*]|#.|(\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)[\\.\\)]|\\((\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)\\)|\\(\\@[\\w\\-]*\\))\\s+" } ] }, { "keys": ["shift+tab"], "command": "unindent", "context": [ - { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-\\+\\*]|#.|(\\d+|[A-z])[\\.\\)]|\\((\\d+|[A-z])\\)|\\(\\@[\\w\\-]*\\))\\s+" } + { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-\\+\\*]|#.|(\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)[\\.\\)]|\\((\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)\\)|\\(\\@[\\w\\-]*\\))\\s+" } // Should we enable the following setting check? // { "key": "setting.shift_tab_unindent", "operator": "equal", "operand": true } ] From 7c94f6ac6c0e013599492c9287f3858484bd6439 Mon Sep 17 00:00:00 2001 From: Alex Armstrong Date: Sun, 5 May 2013 11:18:28 +0300 Subject: [PATCH 4/7] Match `#.`-style lists properly --- Default.sublime-keymap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Default.sublime-keymap b/Default.sublime-keymap index fa2872d..55603bf 100644 --- a/Default.sublime-keymap +++ b/Default.sublime-keymap @@ -71,12 +71,12 @@ }, { "keys": ["tab"], "command": "indent", "context": [ - { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-\\+\\*]|#.|(\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)[\\.\\)]|\\((\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)\\)|\\(\\@[\\w\\-]*\\))\\s+" } + { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-\\+\\*]|#\\.|(\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)[\\.\\)]|\\((\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)\\)|\\(\\@[\\w\\-]*\\))\\s+" } ] }, { "keys": ["shift+tab"], "command": "unindent", "context": [ - { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-\\+\\*]|#.|(\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)[\\.\\)]|\\((\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)\\)|\\(\\@[\\w\\-]*\\))\\s+" } + { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-\\+\\*]|#\\.|(\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)[\\.\\)]|\\((\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)\\)|\\(\\@[\\w\\-]*\\))\\s+" } // Should we enable the following setting check? // { "key": "setting.shift_tab_unindent", "operator": "equal", "operand": true } ] From b3cea56abeace6419aa7697d972d571ee1a763e0 Mon Sep 17 00:00:00 2001 From: Alex Armstrong Date: Sun, 5 May 2013 19:12:27 +0300 Subject: [PATCH 5/7] Restricted list (un)indenting to the markdown syntax. Thanks to @vovkkk for patiently pointing this out. --- Default.sublime-keymap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Default.sublime-keymap b/Default.sublime-keymap index 55603bf..6a229c3 100644 --- a/Default.sublime-keymap +++ b/Default.sublime-keymap @@ -71,11 +71,13 @@ }, { "keys": ["tab"], "command": "indent", "context": [ + { "key": "selector", "operator": "equal", "operand": "text.html.markdown" }, { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-\\+\\*]|#\\.|(\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)[\\.\\)]|\\((\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)\\)|\\(\\@[\\w\\-]*\\))\\s+" } ] }, { "keys": ["shift+tab"], "command": "unindent", "context": [ + { "key": "selector", "operator": "equal", "operand": "text.html.markdown" }, { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-\\+\\*]|#\\.|(\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)[\\.\\)]|\\((\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)\\)|\\(\\@[\\w\\-]*\\))\\s+" } // Should we enable the following setting check? // { "key": "setting.shift_tab_unindent", "operator": "equal", "operand": true } From 1a7efbef2f0c1758d6c245f0087689280260911f Mon Sep 17 00:00:00 2001 From: Alex Armstrong Date: Tue, 16 Jul 2013 12:55:35 +0300 Subject: [PATCH 6/7] Do not indent with tab when autocomplete is visible --- Default.sublime-keymap | 1 + 1 file changed, 1 insertion(+) diff --git a/Default.sublime-keymap b/Default.sublime-keymap index 6a229c3..60265f0 100644 --- a/Default.sublime-keymap +++ b/Default.sublime-keymap @@ -72,6 +72,7 @@ { "keys": ["tab"], "command": "indent", "context": [ { "key": "selector", "operator": "equal", "operand": "text.html.markdown" }, + { "key": "auto_complete_visible", "operator": "equal", "operand": false }, { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-\\+\\*]|#\\.|(\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)[\\.\\)]|\\((\\d+|[A-z]|[IVXLCDM]+|[ivxlcdm]+)\\)|\\(\\@[\\w\\-]*\\))\\s+" } ] }, From b79c9ec35d50186fceca5a2b427f0b88148dcd9f Mon Sep 17 00:00:00 2001 From: Alex Armstrong Date: Thu, 25 Jul 2013 09:01:24 +0300 Subject: [PATCH 7/7] Add Line with Smart List Use `Ctrl+Enter` on a list to quickly add a new item. --- Add Line with Smart List.sublime-macro | 4 ++++ Default.sublime-keymap | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 Add Line with Smart List.sublime-macro diff --git a/Add Line with Smart List.sublime-macro b/Add Line with Smart List.sublime-macro new file mode 100644 index 0000000..a13b1cf --- /dev/null +++ b/Add Line with Smart List.sublime-macro @@ -0,0 +1,4 @@ +[ + {"command": "move_to", "args": {"to": "hardeol"}}, + {"command": "smart_list"} +] diff --git a/Default.sublime-keymap b/Default.sublime-keymap index 60265f0..62fcdff 100644 --- a/Default.sublime-keymap +++ b/Default.sublime-keymap @@ -15,6 +15,12 @@ { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-+\\**]|\\d+\\.+)\\s+" } ] }, + { "keys": ["ctrl+enter"], "command": "run_macro_file", "args": {"file": "res://Packages/SmartMarkdown/Add Line with Smart List.sublime-macro"}, "context": + [ + { "key": "selector", "operator": "equal", "operand": "text.html.markdown" }, + { "key": "preceding_text", "operator": "regex_contains", "operand": "^\\s*([-+\\**\\>\\|%]+|[(]?\\d+[.)]+)\\s+" } + ] + }, { "keys": ["enter"], "command": "smart_list", "context": [ { "key": "selector", "operator": "equal", "operand": "text.html.markdown" },