c-family.kak: use space separated words list
This commit is contained in:
parent
a131edb9b3
commit
5791632a98
|
@ -154,24 +154,26 @@ define-command -hidden c-family-insert-on-newline %[ evaluate-commands -draft %[
|
||||||
add-highlighter shared/c/code regex %{\b-?(0x[0-9a-fA-F]+|\d+)[fdiu]?|'((\\.)?|[^'\\])'} 0:value
|
add-highlighter shared/c/code regex %{\b-?(0x[0-9a-fA-F]+|\d+)[fdiu]?|'((\\.)?|[^'\\])'} 0:value
|
||||||
%sh{
|
%sh{
|
||||||
# Grammar
|
# Grammar
|
||||||
keywords="asm|break|case|continue|default|do|else|for|goto|if|return"
|
keywords="asm break case continue default do else for goto if return
|
||||||
keywords="${keywords}|sizeof|switch|while"
|
sizeof switch while"
|
||||||
attributes="auto|const|enum|extern|inline|register|restrict|static|struct"
|
attributes="auto const enum extern inline register restrict static struct
|
||||||
attributes="${attributes}|typedef|union|volatile"
|
typedef union volatile"
|
||||||
types="char|double|float|int|long|short|signed|size_t|unsigned|void"
|
types="char double float int long short signed size_t unsigned void"
|
||||||
values="NULL"
|
values="NULL"
|
||||||
|
|
||||||
|
join() { printf "%s" "$1" | tr -s ' \n' "$2"; }
|
||||||
|
|
||||||
# Add the language's grammar to the static completion list
|
# Add the language's grammar to the static completion list
|
||||||
printf %s\\n "hook global WinSetOption filetype=c %{
|
printf '%s\n' "hook global WinSetOption filetype=c %{
|
||||||
set-option window static_words '${keywords}:${attributes}:${types}:${values}'
|
set-option window static_words '$(join "${keywords}:${attributes}:${types}:${values}" ':')'
|
||||||
}" | sed 's,|,:,g'
|
}"
|
||||||
|
|
||||||
# Highlight keywords
|
# Highlight keywords
|
||||||
printf %s "
|
printf %s "
|
||||||
add-highlighter shared/c/code regex \b(${keywords})\b 0:keyword
|
add-highlighter shared/c/code regex \b($(join "${keywords}" '|'))\b 0:keyword
|
||||||
add-highlighter shared/c/code regex \b(${attributes})\b 0:attribute
|
add-highlighter shared/c/code regex \b($(join "${attributes}" '|'))\b 0:attribute
|
||||||
add-highlighter shared/c/code regex \b(${types})\b 0:type
|
add-highlighter shared/c/code regex \b($(join "${types}" '|'))\b 0:type
|
||||||
add-highlighter shared/c/code regex \b(${values})\b 0:value
|
add-highlighter shared/c/code regex \b($(join "${values}" '|'))\b 0:value
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,33 +182,32 @@ add-highlighter shared/cpp/code regex %{\b-?(0x[0-9a-fA-F]+|\d+)[fdiu]?|'((\\.)?
|
||||||
|
|
||||||
%sh{
|
%sh{
|
||||||
# Grammar
|
# Grammar
|
||||||
keywords="alignas|alignof|and|and_eq|asm|bitand|bitor|break|case|catch"
|
keywords="alignas alignof and and_eq asm bitand bitor break case catch
|
||||||
keywords="${keywords}|compl|const_cast|continue|decltype|default|delete"
|
compl const_cast continue decltype default delete do dynamic_cast
|
||||||
keywords="${keywords}|do|dynamic_cast|else|explicit|for|goto|if|new|not"
|
else explicit for goto if new not not_eq operator or or_eq
|
||||||
keywords="${keywords}|not_eq|operator|or|or_eq|reinterpret_cast|return"
|
reinterpret_cast return sizeof static_assert static_cast switch
|
||||||
keywords="${keywords}|sizeof|static_assert|static_cast|switch|throw|try"
|
throw try typeid using while xor xor_eq"
|
||||||
keywords="${keywords}|typeid|using|while|xor|xor_eq"
|
attributes="auto class const constexpr enum extern final friend inline
|
||||||
attributes="auto|class|const|constexpr|enum|extern|final|friend|inline"
|
mutable namespace noexcept override private protected public
|
||||||
attributes="${attributes}|mutable|namespace|noexcept|override|private"
|
register static struct template thread_local typedef typename
|
||||||
attributes="${attributes}|protected|public|register|static|struct|template"
|
union virtual volatile"
|
||||||
attributes="${attributes}|thread_local|typedef|typename|union|virtual"
|
types="bool byte char char16_t char32_t double float int long max_align_t
|
||||||
attributes="${attributes}|volatile"
|
nullptr_t ptrdiff_t short signed size_t unsigned void wchar_t"
|
||||||
types="bool|byte|char|char16_t|char32_t|double|float|int|long|max_align_t"
|
values="NULL false nullptr this true"
|
||||||
types="${types}|nullptr_t|ptrdiff_t|short|signed|size_t|unsigned|void"
|
|
||||||
types="${types}|wchar_t"
|
join() { printf "%s" "$1" | tr -s ' \n' "$2"; }
|
||||||
values="NULL|false|nullptr|this|true"
|
|
||||||
|
|
||||||
# Add the language's grammar to the static completion list
|
# Add the language's grammar to the static completion list
|
||||||
printf %s\\n "hook global WinSetOption filetype=cpp %{
|
printf %s\\n "hook global WinSetOption filetype=cpp %{
|
||||||
set-option window static_words '${keywords}:${attributes}:${types}:${values}'
|
set-option window static_words '$(join "${keywords}:${attributes}:${types}:${values}" ':')'
|
||||||
}" | sed 's,|,:,g'
|
}"
|
||||||
|
|
||||||
# Highlight keywords
|
# Highlight keywords
|
||||||
printf %s "
|
printf %s "
|
||||||
add-highlighter shared/cpp/code regex \b(${keywords})\b 0:keyword
|
add-highlighter shared/cpp/code regex \b($(join "${keywords}" '|'))\b 0:keyword
|
||||||
add-highlighter shared/cpp/code regex \b(${attributes})\b 0:attribute
|
add-highlighter shared/cpp/code regex \b($(join "${attributes}" '|'))\b 0:attribute
|
||||||
add-highlighter shared/cpp/code regex \b(${types})\b 0:type
|
add-highlighter shared/cpp/code regex \b($(join "${types}" '|'))\b 0:type
|
||||||
add-highlighter shared/cpp/code regex \b(${values})\b 0:value
|
add-highlighter shared/cpp/code regex \b($(join "${values}" '|'))\b 0:value
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,30 +226,31 @@ add-highlighter shared/objc/code regex %{\b-?\d+[fdiu]?|'((\\.)?|[^'\\])'} 0:val
|
||||||
|
|
||||||
%sh{
|
%sh{
|
||||||
# Grammar
|
# Grammar
|
||||||
keywords="break|case|continue|default|do|else|for|goto|if|return|switch"
|
keywords="break case continue default do else for goto if return switch
|
||||||
keywords="${keywords}|while"
|
while"
|
||||||
attributes="IBAction|IBOutlet|__block|assign|auto|const|copy|enum|extern"
|
attributes="IBAction IBOutlet __block assign auto const copy enum extern
|
||||||
attributes="${attributes}|inline|nonatomic|readonly|retain|static|strong"
|
inline nonatomic readonly retain static strong struct typedef
|
||||||
attributes="${attributes}|struct|typedef|union|volatile|weak"
|
union volatile weak"
|
||||||
types="BOOL|CGFloat|NSInteger|NSString|NSUInteger|bool|char|float"
|
types="BOOL CGFloat NSInteger NSString NSUInteger bool char float
|
||||||
types="${types}|instancetype|int|long|short|signed|size_t|unsigned|void"
|
instancetype int long short signed size_t unsigned void"
|
||||||
values="FALSE|NO|NULL|TRUE|YES|id|nil|self|super"
|
values="FALSE NO NULL TRUE YES id nil self super"
|
||||||
decorators="autoreleasepool|catch|class|end|implementation|interface"
|
decorators="autoreleasepool catch class end implementation interface
|
||||||
decorators="${decorators}|property|protocol|selector|synchronized"
|
property protocol selector synchronized synthesize try"
|
||||||
decorators="${decorators}|synthesize|try"
|
|
||||||
|
join() { printf "%s" "$1" | tr -s ' \n' "$2"; }
|
||||||
|
|
||||||
# Add the language's grammar to the static completion list
|
# Add the language's grammar to the static completion list
|
||||||
printf %s\\n "hook global WinSetOption filetype=objc %{
|
printf %s\\n "hook global WinSetOption filetype=objc %{
|
||||||
set-option window static_words '${keywords}:${attributes}:${types}:${values}:${decorators}'
|
set-option window static_words '$(join "${keywords}:${attributes}:${types}:${values}:${decorators}" ':')'
|
||||||
}" | sed 's,|,:,g'
|
}"
|
||||||
|
|
||||||
# Highlight keywords
|
# Highlight keywords
|
||||||
printf %s "
|
printf %s "
|
||||||
add-highlighter shared/objc/code regex \b(${keywords})\b 0:keyword
|
add-highlighter shared/objc/code regex \b($(join "${keywords}" '|'))\b 0:keyword
|
||||||
add-highlighter shared/objc/code regex \b(${attributes})\b 0:attribute
|
add-highlighter shared/objc/code regex \b($(join "${attributes}" '|'))\b 0:attribute
|
||||||
add-highlighter shared/objc/code regex \b(${types})\b 0:type
|
add-highlighter shared/objc/code regex \b($(join "${types}" '|'))\b 0:type
|
||||||
add-highlighter shared/objc/code regex \b(${values})\b 0:value
|
add-highlighter shared/objc/code regex \b($(join "${values}" '|'))\b 0:value
|
||||||
add-highlighter shared/objc/code regex @(${decorators})\b 0:attribute
|
add-highlighter shared/objc/code regex @($(join "${decorators}" '|'))\b 0:attribute
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user