diff options
| author | Maxime Coste <mawww@kakoune.org> | 2019-04-25 11:59:42 +0100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2019-04-25 11:59:42 +0100 |
| commit | 0cc89b2b9f3cdeff960bd55a865ee0f52fa98d25 (patch) | |
| tree | bd4860272e271f215e4d9ba7d2049be9f44ac211 /rc/filetype/javascript.kak | |
| parent | 429eeb252c6e7ac8512c2bd98ed3b18c62d7f37b (diff) | |
| parent | f49644e8ee8b2450f28b82d74fcf823d81f2ae1c (diff) | |
Merge remote-tracking branch 'laelath/provides-requires'
Diffstat (limited to 'rc/filetype/javascript.kak')
| -rw-r--r-- | rc/filetype/javascript.kak | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/rc/filetype/javascript.kak b/rc/filetype/javascript.kak index c02c6aab..6f60a4ec 100644 --- a/rc/filetype/javascript.kak +++ b/rc/filetype/javascript.kak @@ -9,6 +9,34 @@ hook global BufCreate .*[.](ts)x? %{ set-option buffer filetype typescript } +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=(javascript|typescript) %{ + require-module javascript + + hook window ModeChange insert:.* -group "%val{hook_param_capture_1}-trim-indent" javascript-trim-indent + hook window InsertChar .* -group "%val{hook_param_capture_1}-indent" javascript-indent-on-char + hook window InsertChar \n -group "%val{hook_param_capture_1}-indent" javascript-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* " + remove-hooks window %val{hook_param_capture_1}-.+ + " +} + +hook -group javascript-highlight global WinSetOption filetype=javascript %{ + add-highlighter window/javascript ref javascript + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/javascript } +} + +hook -group typescript-highlight global WinSetOption filetype=typescript %{ + add-highlighter window/typescript ref typescript + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/typescript } +} + + +provide-module javascript %§ + # Commands # ‾‾‾‾‾‾‾‾ @@ -89,23 +117,6 @@ define-command -hidden init-javascript-filetype -params 1 %~ # https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get # https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set add-highlighter "shared/%arg{1}/code/" regex \b(async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|export|extends|finally|for|function|get|if|import|in|instanceof|let|new|of|return|set|static|super|switch|throw|try|typeof|var|void|while|with|yield)\b 0:keyword - - # Initialization - # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - - hook -group "%arg{1}-highlight" global WinSetOption "filetype=%arg{1}" " - add-highlighter window/%arg{1} ref %arg{1} - - hook -once -always window WinSetOption filetype=.* %%{ remove-highlighter window/%arg{1} } - " - - hook global WinSetOption "filetype=%arg{1}" " - hook window ModeChange insert:.* -group %arg{1}-trim-indent javascript-trim-indent - hook window InsertChar .* -group %arg{1}-indent javascript-indent-on-char - hook window InsertChar \n -group %arg{1}-indent javascript-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %%{ remove-hooks window %arg{1}-.+ } - " ~ init-javascript-filetype javascript @@ -117,3 +128,5 @@ add-highlighter shared/typescript/code/ regex \b(array|boolean|date|number|objec # Keywords grabbed from https://github.com/Microsoft/TypeScript/issues/2536 add-highlighter shared/typescript/code/ regex \b(as|constructor|declare|enum|from|implements|interface|module|namespace|package|private|protected|public|readonly|static|type)\b 0:keyword + +§ |
