2014-07-16 01:32:17 +04:00
|
|
|
# http://cukes.info
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global BufCreate .*[.](feature|story) %{
|
2017-11-03 10:34:41 +03:00
|
|
|
set-option buffer filetype cucumber
|
2014-07-16 01:32:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Highlighters
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2018-07-01 12:53:35 +03:00
|
|
|
add-highlighter shared/cucumber regions
|
|
|
|
add-highlighter shared/cucumber/code default-region group
|
2018-07-02 13:59:12 +03:00
|
|
|
add-highlighter shared/cucumber/language region ^\h*#\h*language: $ group
|
|
|
|
add-highlighter shared/cucumber/comment region ^\h*# $ fill comment
|
2014-07-16 01:32:17 +04:00
|
|
|
|
2018-07-01 12:53:35 +03:00
|
|
|
add-highlighter shared/cucumber/language/ fill meta
|
|
|
|
add-highlighter shared/cucumber/language/ regex \S+$ 0:value
|
2014-07-16 01:32:17 +04:00
|
|
|
|
|
|
|
# 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",
|
|
|
|
# …
|
|
|
|
# }
|
|
|
|
|
2018-07-01 12:53:35 +03:00
|
|
|
add-highlighter shared/cucumber/code/ regex \b(Feature|Business\h+Need|Ability|Background|Scenario|Scenario\h+Outline|Scenario\h+Template|Examples|Scenarios|Given|When|Then|And|But)\b 0:keyword
|
2014-07-16 01:32:17 +04:00
|
|
|
|
|
|
|
# Commands
|
|
|
|
# ‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command -hidden cucumber-filter-around-selections %{
|
2015-11-04 12:48:47 +03:00
|
|
|
# remove trailing white spaces
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
|
2014-07-16 01:32:17 +04:00
|
|
|
}
|
|
|
|
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command -hidden cucumber-indent-on-new-line %{
|
2017-11-03 11:09:45 +03:00
|
|
|
evaluate-commands -draft -itersel %{
|
2017-01-11 16:56:48 +03:00
|
|
|
# copy '#' comment prefix and following white spaces
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft k <a-x> s ^\h*\K#\h* <ret> y gh j P }
|
2014-07-16 01:32:17 +04:00
|
|
|
# preserve previous line indent
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft \; K <a-&> }
|
2014-07-16 01:32:17 +04:00
|
|
|
# filter previous line
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft k : cucumber-filter-around-selections <ret> }
|
2014-07-16 01:32:17 +04:00
|
|
|
# indent after lines containing :
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft <space> k x <a-k> : <ret> j <a-gt> }
|
2014-07-16 01:32:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Initialization
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2018-07-01 12:53:35 +03:00
|
|
|
hook -group cucumber-highlight global WinSetOption filetype=cucumber %{ add-highlighter window/cucumber ref cucumber }
|
2014-07-16 01:32:17 +04:00
|
|
|
|
2016-09-25 16:15:07 +03:00
|
|
|
hook global WinSetOption filetype=cucumber %{
|
2018-01-21 02:35:05 +03:00
|
|
|
hook window ModeChange insert:.* -group cucumber-hooks cucumber-filter-around-selections
|
2017-01-13 03:56:30 +03:00
|
|
|
hook window InsertChar \n -group cucumber-indent cucumber-indent-on-new-line
|
2014-07-16 01:32:17 +04:00
|
|
|
}
|
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
hook -group cucumber-highlight global WinSetOption filetype=(?!cucumber).* %{ remove-highlighter window/cucumber }
|
2016-09-28 09:45:01 +03:00
|
|
|
|
2014-07-16 01:32:17 +04:00
|
|
|
hook global WinSetOption filetype=(?!cucumber).* %{
|
2017-01-04 03:07:45 +03:00
|
|
|
remove-hooks window cucumber-indent
|
|
|
|
remove-hooks window cucumber-hooks
|
2014-07-16 01:32:17 +04:00
|
|
|
}
|