From 0c1f58ad896052f0c7fbb8bb4e86a299eb32584e Mon Sep 17 00:00:00 2001 From: Alex Leferry 2 Date: Mon, 14 Jul 2014 22:53:47 +0200 Subject: [PATCH 1/7] add rc/sass.kak --- rc/sass.kak | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 rc/sass.kak diff --git a/rc/sass.kak b/rc/sass.kak new file mode 100644 index 00000000..f1f61ab5 --- /dev/null +++ b/rc/sass.kak @@ -0,0 +1,71 @@ +# http://sass-lang.com +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufSetOption mimetype=text/x-sass %{ + set buffer filetype sass +} + +hook global BufCreate .*[.](sass) %{ + set buffer filetype sass +} + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +addhl -group / regions -default code sass \ + string '"' (? + # remove trailing white spaces + try %{ exec -draft s \h+$ d } + } +} + +def -hidden _sass_indent_on_new_line %{ + eval -draft -itersel %{ + # preserve previous line indent + try %{ exec -draft K } + # filter previous line + try %{ exec -draft k : _sass_filter_around_selections } + # copy '/' comment prefix and following white spaces + try %{ exec -draft k x s ^\h*\K/\h* y j p } + # avoid indent after properties and comments + try %{ exec -draft k x [:/] j } + } +} + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=sass %{ + addhl ref sass + + hook window InsertEnd .* -group sass-hooks _sass_filter_around_selections + hook window InsertChar \n -group sass-indent _sass_indent_on_new_line +} + +hook global WinSetOption filetype=(?!sass).* %{ + rmhl sass + rmhooks window sass-indent + rmhooks window sass-hooks +} From d2388929f1f05cc48cff826a74e2a34133b85603 Mon Sep 17 00:00:00 2001 From: Alex Leferry 2 Date: Mon, 14 Jul 2014 22:55:51 +0200 Subject: [PATCH 2/7] add rc/haml.kak --- rc/haml.kak | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 rc/haml.kak diff --git a/rc/haml.kak b/rc/haml.kak new file mode 100644 index 00000000..20a898e9 --- /dev/null +++ b/rc/haml.kak @@ -0,0 +1,75 @@ +# http://haml.info +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufSetOption mimetype=text/x-haml %{ + set buffer filetype haml +} + +hook global BufCreate .*[.](haml) %{ + set buffer filetype haml +} + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +addhl -group / regions -default code haml \ + comment ^\h*/ $ '' \ + eval ^\h*%([A-Za-z][A-Za-z0-9_-]*)([#.][A-Za-z][A-Za-z0-9_-]*)?\{\K|#\{\K (?=\}) \{ \ + eval ^\h*[=-]\K (?=[^|]\n) '' \ + coffee ^\h*:coffee\K (?=^\h*[%=-]) '' \ + sass ^\h*:sass\K (?=^\h*[%=-]) '' + +# Filters +# http://haml.info/docs/yardoc/file.REFERENCE.html#filters + +addhl -group /haml/comment fill comment + +addhl -group /haml/eval ref ruby +addhl -group /haml/coffee ref coffee +addhl -group /haml/sass ref sass + +addhl -group /haml/code regex ^\h*(:[a-z]+|-|=)|^(!!!)$ 0:meta +addhl -group /haml/code regex ^\h*%([A-Za-z][A-Za-z0-9_-]*)([#.][A-Za-z][A-Za-z0-9_-]*)? 1:keyword 2:identifier + +# Commands +# ‾‾‾‾‾‾‾‾ + +def -hidden _haml_filter_around_selections %{ + eval -draft -itersel %{ + exec + # remove trailing white spaces + try %{ exec -draft s \h+$ d } + } +} + +def -hidden _haml_indent_on_new_line %{ + eval -draft -itersel %{ + # preserve previous line indent + try %{ exec -draft K } + # filter previous line + try %{ exec -draft k : _haml_filter_around_selections } + # copy '/' comment prefix and following white spaces + try %{ exec -draft k x s ^\h*\K/\h* y j p } + # indent after lines beginning with : or - + try %{ exec -draft k x ^\h*[:-] j } + } +} + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=haml %{ + addhl ref haml + + hook window InsertEnd .* -group haml-hooks _haml_filter_around_selections + hook window InsertChar \n -group haml-indent _haml_indent_on_new_line +} + +hook global WinSetOption filetype=(?!haml).* %{ + rmhl haml + rmhooks window haml-indent + rmhooks window haml-hooks +} From 163d310371c5bd1cdeab06f0ca9598129b786d52 Mon Sep 17 00:00:00 2001 From: Alex Leferry 2 Date: Mon, 14 Jul 2014 23:08:26 +0200 Subject: [PATCH 3/7] add rc/coffee.kak --- rc/coffee.kak | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 rc/coffee.kak diff --git a/rc/coffee.kak b/rc/coffee.kak new file mode 100644 index 00000000..2d2cc420 --- /dev/null +++ b/rc/coffee.kak @@ -0,0 +1,87 @@ +# http://coffeescript.org +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufSetOption mimetype=text/x-coffee %{ + set buffer filetype coffee +} + +hook global BufCreate .*[.](coffee) %{ + set buffer filetype coffee +} + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +addhl -group / regions -default code coffee \ + double_string '"""' '"""' '' \ + single_string "'''" "'''" '' \ + comment '###' '###' '' \ + regex '///' ///[gimy]* '' \ + double_string '"' (? 0:type +addhl -group /coffee/code regex \<(document|false|no|null|off|on|parent|self|this|true|undefined|window|yes)\> 0:value +addhl -group /coffee/code regex \<(and|is|isnt|not|or)\> 0:operator +addhl -group /coffee/code regex \<(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|function|if|implements|import|in|instanceof|interface|let|native|new|package|private|protected|public|return|static|super|switch|throw|try|typeof|var|void|while|with|yield)\> 0:keyword + +# Commands +# ‾‾‾‾‾‾‾‾ + +def -hidden _coffee_filter_around_selections %{ + eval -draft -itersel %{ + exec + # remove trailing white spaces + try %{ exec -draft s \h+$ d } + } +} + +def -hidden _coffee_indent_on_new_line %{ + eval -draft -itersel %{ + # preserve previous line indent + try %{ exec -draft K } + # filter previous line + try %{ exec -draft k : _coffee_filter_around_selections } + # copy '#' comment prefix and following white spaces + try %{ exec -draft k x s ^\h*\K#\h* y j p } + # indent after lines beginning with token and ending with -> + try %_ exec -draft k x ^\h*(case|catch|class|else|finally|for|function|if|switch|try|while|with)|(->)$ j _ + } +} + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=coffee %{ + addhl ref coffee + + hook window InsertEnd .* -group coffee-hooks _coffee_filter_around_selections + hook window InsertChar \n -group coffee-indent _coffee_indent_on_new_line +} + +hook global WinSetOption filetype=(?!coffee).* %{ + rmhl coffee + rmhooks window coffee-indent + rmhooks window coffee-hooks +} From 2e8956356b761b521584d18e9d6514026168f67b Mon Sep 17 00:00:00 2001 From: Alex Leferry 2 Date: Tue, 15 Jul 2014 23:32:17 +0200 Subject: [PATCH 4/7] add rc/cucumber.kak --- rc/cucumber.kak | 98 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 rc/cucumber.kak diff --git a/rc/cucumber.kak b/rc/cucumber.kak new file mode 100644 index 00000000..fd3a557e --- /dev/null +++ b/rc/cucumber.kak @@ -0,0 +1,98 @@ +# http://cukes.info +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufSetOption mimetype=text/x-cucumber %{ + set buffer filetype cucumber +} + +hook global BufCreate .*[.](feature|story) %{ + set buffer filetype cucumber +} + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +addhl -group / regions -default code cucumber \ + language ^\h*#\h*language: $ '' \ + comment ^\h*# $ '' + +addhl -group /cucumber/language fill meta +addhl -group /cucumber/comment fill comment + +addhl -group /cucumber/language regex \S+$ 0:value + +# Spoken languages +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ +# https://github.com/cucumber/cucumber/wiki/Spoken-languages +# +# curl --location https://github.com/cucumber/gherkin/raw/master/lib/gherkin/i18n.json +# +# { +# "en": { +# "name": "English", +# "native": "English", +# "feature": "Feature|Business Need|Ability", +# "background": "Background", +# "scenario": "Scenario", +# "scenario_outline": "Scenario Outline|Scenario Template", +# "examples": "Examples|Scenarios", +# "given": "*|Given", +# "when": "*|When", +# "then": "*|Then", +# "and": "*|And", +# "but": "*|But" +# }, +# … +# } +# +# jq 'with_entries({ key: .key, value: .value | del(.name) | del(.native) | join("|") })' +# +# { +# "en": "Feature|Business Need|Ability|Background|Scenario|Scenario Outline|Scenario Template|Examples|Scenarios|*|Given|*|When|*|Then|*|And|*|But", +# … +# } + +addhl -group /cucumber/code regex \<(Feature|Business\h+Need|Ability|Background|Scenario|Scenario\h+Outline|Scenario\h+Template|Examples|Scenarios|Given|When|Then|And|But)\> 0:keyword + +# Commands +# ‾‾‾‾‾‾‾‾ + +def -hidden _cucumber_filter_around_selections %{ + eval -draft -itersel %{ + exec + # remove trailing white spaces + try %{ exec -draft s \h+$ d } + } +} + +def -hidden _cucumber_indent_on_new_line %{ + eval -draft -itersel %{ + # preserve previous line indent + try %{ exec -draft K } + # filter previous line + try %{ exec -draft k : _cucumber_filter_around_selections } + # copy '#' comment prefix and following white spaces + try %{ exec -draft k x s ^\h*\K#\h* y j p } + # indent after lines containing : + try %{ exec -draft k x : j } + } +} + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=cucumber %{ + addhl ref cucumber + + hook window InsertEnd .* -group cucumber-hooks _cucumber_filter_around_selections + hook window InsertChar \n -group cucumber-indent _cucumber_indent_on_new_line +} + +hook global WinSetOption filetype=(?!cucumber).* %{ + rmhl cucumber + rmhooks window cucumber-indent + rmhooks window cucumber-hooks +} From fce9d1804103ef5a62ba332b9508de082cc39920 Mon Sep 17 00:00:00 2001 From: Alex Leferry 2 Date: Mon, 21 Jul 2014 01:00:59 +0200 Subject: [PATCH 5/7] add rc/scss.kak --- rc/scss.kak | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 rc/scss.kak diff --git a/rc/scss.kak b/rc/scss.kak new file mode 100644 index 00000000..e52e4d22 --- /dev/null +++ b/rc/scss.kak @@ -0,0 +1,48 @@ +# http://sass-lang.com +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +# require css.kak + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufSetOption mimetype=text/x-scss %{ + set buffer filetype scss +} + +hook global BufCreate .*[.](scss) %{ + set buffer filetype scss +} + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +addhl -group / group scss + +addhl -group /scss ref css + +addhl -group /scss regex @[A-Za-z][A-Za-z0-9_-]* 0:meta + +# Commands +# ‾‾‾‾‾‾‾‾ + +def -hidden _scss_filter_around_selections _css_filter_around_selections +def -hidden _scss_indent_on_new_line _css_indent_on_new_line +def -hidden _scss_indent_on_closing_curly_brace _css_indent_on_closing_curly_brace + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=scss %[ + addhl ref scss + + hook window InsertEnd .* -group scss-hooks _scss_filter_around_selections + hook window InsertChar \n -group scss-indent _scss_indent_on_new_line + hook window InsertChar \} -group scss-indent _scss_indent_on_closing_curly_brace +] + +hook global WinSetOption filetype=(?!scss).* %{ + rmhl scss + rmhooks window scss-indent + rmhooks window scss-hooks +} From a9aad2a9c9ef2a79dbf2faebc2fee9fe80371f96 Mon Sep 17 00:00:00 2001 From: Alex Leferry 2 Date: Mon, 21 Jul 2014 01:18:49 +0200 Subject: [PATCH 6/7] add rc/rust.kak --- rc/rust.kak | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 rc/rust.kak diff --git a/rc/rust.kak b/rc/rust.kak new file mode 100644 index 00000000..3be4ace6 --- /dev/null +++ b/rc/rust.kak @@ -0,0 +1,97 @@ +# http://rust-lang.org +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufSetOption mimetype=text/x-rust %{ + set buffer filetype rust +} + +hook global BufCreate .*[.](rust|rs) %{ + set buffer filetype rust +} + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +addhl -group / regions -default code rust \ + string '"' (? 0:value +addhl -group /rust/code regex \<(&&|\|\|)\> 0:operator +addhl -group /rust/code regex \<((match|if|else)|(as)|(assert)|(fail)|(yield)|(break|box|continue)|(extern)|(for|in|if|impl|let)|(loop|once|priv|pub)|(return)|(unsafe|while)|(use)|(fn)|(proc))\> 0:keyword +addhl -group /rust/code regex \<((mod|trait|struct|enum|type)|(mut|ref|static)|(const)|(alignof|be|do|offsetof|pure|sizeof|typeof))\> 0:attribute +addhl -group /rust/code regex \<((int|uint|float|char|bool|u8|u16|u32|u64|f32)|(f64|i8|i16|i32|i64|str))\> 0:type +addhl -group /rust/code regex \<(((Share|Copy|Send|Sized)|(Add|Sub|Mul|Div|Rem|Neg|Not)|(BitAnd|BitOr|BitXor)|(Drop)|(Shl|Shr|Index)|(Option)|(Some|None)|(Result)|(Ok|Err))|((Any|AnyOwnExt|AnyRefExt|AnyMutRefExt)|(Ascii|AsciiCast|OwnedAsciiCast|AsciiStr|IntoBytes)|(ToCStr)|(Char)|(Clone)|(Eq|Ord|TotalEq|TotalOrd|Ordering|Equiv)|(Less|Equal|Greater)|(Container|Mutable|Map|MutableMap|Set|MutableSet)|(FromIterator|Extendable)|(Iterator|DoubleEndedIterator|RandomAccessIterator|CloneableIterator)|(OrdIterator|MutableDoubleEndedIterator|ExactSize)|(Num|NumCast|CheckedAdd|CheckedSub|CheckedMul)|(Signed|Unsigned|Round)|(Primitive|Int|Float|ToPrimitive|FromPrimitive)|(GenericPath|Path|PosixPath|WindowsPath)|(RawPtr)|(Buffer|Writer|Reader|Seek)|(Str|StrVector|StrSlice|OwnedStr|IntoMaybeOwned|StrBuf)|(ToStr|IntoStr)|(Tuple1|Tuple2|Tuple3|Tuple4)|(Tuple5|Tuple6|Tuple7|Tuple8)|(Tuple9|Tuple10|Tuple11|Tuple12)|(ImmutableEqVector|ImmutableTotalOrdVector|ImmutableCloneableVector)|(OwnedVector|OwnedCloneableVector|OwnedEqVector)|(MutableVector|MutableTotalOrdVector)|(Vector|VectorVector|CloneableVector|ImmutableVector)))\> 0:identifier + +# Commands +# ‾‾‾‾‾‾‾‾ + +def -hidden _rust_filter_around_selections %{ + eval -draft -itersel %{ + exec + # remove trailing white spaces + try %{ exec -draft s \h+$ d } + } +} + +def -hidden _rust_indent_on_new_line %~ + eval -draft -itersel %_ + # preserve previous line indent + try %{ exec -draft K } + # filter previous line + try %{ exec -draft k : _rust_filter_around_selections } + # copy // comments prefix and following white spaces + try %{ exec -draft k x s ^\h*\K//\h* y j p } + # indent after lines ending with { or ( + try %[ exec -draft k [{(]\h*$ j ] + # align to opening paren of previous line + try %{ exec -draft [( \`\([^\n]+\n[^\n]*\n?\' s \`\(\h*.|.\' & } + # indent after visibility specifier + try %[ exec -draft k ^\h*(public|private|protected):\h*$ j ] + # indent after if|else|while|for + try %[ exec -draft ) M B \`(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\' s \`|.\' 1 1 ] + _ +~ + +def -hidden _rust_indent_on_opening_curly_brace %[ + eval -draft -itersel %_ + # align indent with opening paren when { is entered on a new line after the closing paren + try %[ exec -draft h ) M \`\(.*\)\h*\n\h*\{\' s \`|.\' 1 ] + _ +] + +def -hidden _rust_indent_on_closing_curly_brace %[ + eval -draft -itersel %_ + # align to opening curly brace when alone on a line + try %[ exec -draft ^\h+\}$ h m s \`|.\' 1 ] + # add ; after } if class or struct definition + try %[ exec -draft h m (class|struct) \`(class|struct)[^{}\n]+(\n)?\s*\{\' m a \; ] + _ +] + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=rust %[ + addhl ref rust + + hook window InsertEnd .* -group rust-hooks _rust_filter_around_selections + hook window InsertChar \n -group rust-indent _rust_indent_on_new_line + hook window InsertChar \{ -group rust-indent _rust_indent_on_opening_curly_brace + hook window InsertChar \} -group rust-indent _rust_indent_on_closing_curly_brace +] + +hook global WinSetOption filetype=(?!rust).* %{ + rmhl rust + rmhooks window rust-indent + rmhooks window rust-hooks +} From 507040e8e30f08b85506c177557938cc5067d164 Mon Sep 17 00:00:00 2001 From: Alex Leferry 2 Date: Mon, 21 Jul 2014 01:42:03 +0200 Subject: [PATCH 7/7] add rc/ragel.kak --- rc/ragel.kak | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 rc/ragel.kak diff --git a/rc/ragel.kak b/rc/ragel.kak new file mode 100644 index 00000000..496d3042 --- /dev/null +++ b/rc/ragel.kak @@ -0,0 +1,80 @@ +# http://complang.org/ragel +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +# ragel.kak does not try to detect host language. + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufSetOption mimetype=text/x-ragel %{ + set buffer filetype ragel +} + +hook global BufCreate .*[.](ragel|rl) %{ + set buffer filetype ragel +} + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +addhl -group / regions -default code ragel \ + string '"' (? 0:value +addhl -group /ragel/code regex %%\{|\}%%|<\w+> 0:identifier +addhl -group /ragel/code regex :=|=>|->|:>|:>>|<: 0:operator +addhl -group /ragel/code regex \<(action|alnum|alpha|any|ascii|case|cntrl|contained|context|data|digit|empty|eof|err|error|exec|export|exports|extend|fblen|fbreak|fbuf|fc|fcall|fcurs|fentry|fexec|fgoto|fhold|first_final|fnext|fpc|fret|from|fstack|ftargs|graph|import|include|init|inwhen|lerr|lower|machine|nocs|noend|noerror|nofinal|noprefix|outwhen|postpop|prepush|print|punct|range|space|start|to|upper|when|write|xdigit|zlen)\> 0:keyword + +# Commands +# ‾‾‾‾‾‾‾‾ + +def -hidden _ragel_filter_around_selections %{ + eval -draft -itersel %{ + exec + # remove trailing white spaces + try %{ exec -draft s \h+$ d } + } +} + +def -hidden _ragel_indent_on_char " + eval -draft -itersel %_ + # align closer token to its opener when alone on a line + try %/ exec -draft ^\h+[]})]$ m s \`|.\' 1 / + try %/ exec -draft ^\h+ [*]$ [*]$ s \`|.\' 1 / + _ +" + +def -hidden _ragel_indent_on_new_line " + eval -draft -itersel ' + # preserve previous line indent + try %{ exec -draft K } + # filter previous line + try %{ exec -draft k : _ragel_filter_around_selections } + # copy _#_ comment prefix and following white spaces + try %{ exec -draft k x s ^\h*\K#\h* y j p } + # indent after lines ending with opener token + try %_ exec -draft k x [[{(*]$ j _ + ' +" + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=ragel %{ + addhl ref ragel + + hook window InsertEnd .* -group ragel-hooks _ragel_filter_around_selections + hook window InsertChar .* -group ragel-indent _ragel_indent_on_char + hook window InsertChar \n -group ragel-indent _ragel_indent_on_new_line +} + +hook global WinSetOption filetype=(?!ragel).* %{ + rmhl ragel + rmhooks window ragel-indent + rmhooks window ragel-hooks +}