2014-07-15 23:32:17 +02:00
|
|
|
# http://cukes.info
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global BufCreate .*[.](feature|story) %{
|
2017-11-03 08:34:41 +01:00
|
|
|
set-option buffer filetype cucumber
|
2014-07-15 23:32:17 +02:00
|
|
|
}
|
|
|
|
|
2019-04-12 00:54:58 +02:00
|
|
|
# Initialization
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global WinSetOption filetype=cucumber %{
|
2019-03-13 22:00:59 +01:00
|
|
|
require-module cucumber
|
2019-04-12 00:54:58 +02:00
|
|
|
|
2022-04-30 11:22:47 +02:00
|
|
|
hook window ModeChange pop:insert:.* -group cucumber-trim-indent cucumber-trim-indent
|
2021-04-17 10:17:01 +02:00
|
|
|
hook window InsertChar \n -group cucumber-insert cucumber-insert-on-new-line
|
2019-04-12 00:54:58 +02:00
|
|
|
hook window InsertChar \n -group cucumber-indent cucumber-indent-on-new-line
|
|
|
|
|
|
|
|
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window cucumber-.+ }
|
2019-03-13 22:00:59 +01:00
|
|
|
}
|
|
|
|
|
2019-04-12 00:54:58 +02:00
|
|
|
hook -group cucumber-highlight global WinSetOption filetype=cucumber %{
|
|
|
|
add-highlighter window/cucumber ref cucumber
|
|
|
|
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cucumber }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-13 22:00:59 +01:00
|
|
|
provide-module cucumber %{
|
|
|
|
|
2014-07-15 23:32:17 +02:00
|
|
|
# Highlighters
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2018-07-01 11:53:35 +02:00
|
|
|
add-highlighter shared/cucumber regions
|
|
|
|
add-highlighter shared/cucumber/code default-region group
|
2018-07-02 12:59:12 +02:00
|
|
|
add-highlighter shared/cucumber/language region ^\h*#\h*language: $ group
|
|
|
|
add-highlighter shared/cucumber/comment region ^\h*# $ fill comment
|
2014-07-15 23:32:17 +02:00
|
|
|
|
2018-07-01 11:53:35 +02:00
|
|
|
add-highlighter shared/cucumber/language/ fill meta
|
|
|
|
add-highlighter shared/cucumber/language/ regex \S+$ 0:value
|
2014-07-15 23:32:17 +02: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 11:53:35 +02: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-15 23:32:17 +02:00
|
|
|
|
|
|
|
# Commands
|
|
|
|
# ‾‾‾‾‾‾‾‾
|
|
|
|
|
2018-12-19 10:10:26 +01:00
|
|
|
define-command -hidden cucumber-trim-indent %{
|
2015-11-04 10:48:47 +01:00
|
|
|
# remove trailing white spaces
|
2022-03-16 23:20:07 +01:00
|
|
|
try %{ execute-keys -draft -itersel x s \h+$ <ret> d }
|
2014-07-15 23:32:17 +02:00
|
|
|
}
|
|
|
|
|
2021-04-17 10:17:01 +02:00
|
|
|
define-command -hidden cucumber-insert-on-new-line %{
|
2017-11-03 09:09:45 +01:00
|
|
|
evaluate-commands -draft -itersel %{
|
2017-01-11 14:56:48 +01:00
|
|
|
# copy '#' comment prefix and following white spaces
|
2022-03-16 23:20:07 +01:00
|
|
|
try %{ execute-keys -draft k x s ^\h*\K#\h* <ret> y gh j P }
|
2021-04-17 10:17:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
define-command -hidden cucumber-indent-on-new-line %{
|
|
|
|
evaluate-commands -draft -itersel %{
|
2014-07-15 23:32:17 +02:00
|
|
|
# preserve previous line indent
|
2019-10-22 11:02:06 +02:00
|
|
|
try %{ execute-keys -draft <semicolon> K <a-&> }
|
2014-07-15 23:32:17 +02:00
|
|
|
# filter previous line
|
2018-12-19 10:10:26 +01:00
|
|
|
try %{ execute-keys -draft k : cucumber-trim-indent <ret> }
|
2014-07-15 23:32:17 +02:00
|
|
|
# indent after lines containing :
|
2022-04-15 00:14:17 +02:00
|
|
|
try %{ execute-keys -draft , k x <a-k> : <ret> j <a-gt> }
|
2014-07-15 23:32:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-13 22:00:59 +01:00
|
|
|
}
|