2017-10-10 10:23:25 +02:00
|
|
|
|
|
|
|
# requires rc/base/javascript.kak
|
|
|
|
|
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global BufCreate .*[.](ts)x? %{
|
2017-11-03 08:34:41 +01:00
|
|
|
set-option buffer filetype typescript
|
2017-10-10 10:23:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Highlighters
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-10-28 05:00:51 +02:00
|
|
|
add-highlighter shared/ regions -default code typescript \
|
2017-10-21 09:56:36 +02:00
|
|
|
double_string '"' (?<!\\)(\\\\)*" '' \
|
|
|
|
single_string "'" (?<!\\)(\\\\)*' '' \
|
|
|
|
literal "`" (?<!\\)(\\\\)*` '' \
|
|
|
|
comment // '$' '' \
|
|
|
|
comment /\* \*/ '' \
|
|
|
|
regex / (?<!\\)(\\\\)*/[gimuy]* '' \
|
|
|
|
division '[\w\)\]](/|(\h+/\h+))' '\w' '' # Help Kakoune to better detect /…/ literals
|
|
|
|
|
|
|
|
# Regular expression flags are: g → global match, i → ignore case, m → multi-lines, u → unicode, y → sticky
|
|
|
|
# https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
|
|
|
|
|
2017-10-28 05:00:51 +02:00
|
|
|
add-highlighter shared/typescript/double_string ref javascript/double_string
|
|
|
|
add-highlighter shared/typescript/single_string ref javascript/single_string
|
|
|
|
add-highlighter shared/typescript/regex ref javascript/regex
|
|
|
|
add-highlighter shared/typescript/comment ref javascript/comment
|
|
|
|
add-highlighter shared/typescript/literal ref javascript/literal
|
|
|
|
add-highlighter shared/typescript/code ref javascript/code
|
2017-10-21 09:56:36 +02:00
|
|
|
|
2017-10-28 05:00:51 +02:00
|
|
|
add-highlighter shared/typescript/code regex \b(array|boolean|date|number|object|regexp|string|symbol)\b 0:type
|
2017-10-10 10:23:25 +02:00
|
|
|
|
|
|
|
# Keywords grabbed from https://github.com/Microsoft/TypeScript/issues/2536
|
2017-10-28 05:00:51 +02:00
|
|
|
add-highlighter shared/typescript/code regex \b(enum|as|implements|interface|package|private|protected|public|static|constructor|declare|get|module|set|type|from|of|readonly)\b 0:keyword
|
2017-10-10 10:23:25 +02:00
|
|
|
|
|
|
|
# Initialization
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-10-28 05:00:51 +02:00
|
|
|
hook -group typescript-highlight global WinSetOption filetype=typescript %{ add-highlighter window ref typescript }
|
2017-10-10 10:23:25 +02:00
|
|
|
|
|
|
|
hook global WinSetOption filetype=javascript %{
|
2018-01-21 00:35:05 +01:00
|
|
|
hook window ModeChange insert:.* -group typescript-hooks javascript-filter-around-selections
|
2017-10-10 10:23:25 +02:00
|
|
|
hook window InsertChar .* -group typescript-indent javascript-indent-on-char
|
|
|
|
hook window InsertChar \n -group typescript-indent javascript-indent-on-new-line
|
|
|
|
}
|
|
|
|
|
2017-10-28 05:00:51 +02:00
|
|
|
hook -group typescript-highlight global WinSetOption filetype=(?!typescript).* %{ remove-highlighter window/typescript }
|
2017-10-10 10:23:25 +02:00
|
|
|
|
|
|
|
hook global WinSetOption filetype=(?!typescript).* %{
|
|
|
|
remove-hooks window typescript-indent
|
|
|
|
remove-hooks window typescript-hooks
|
|
|
|
}
|