Fixed many of the filetype support modules to not use BufSetOption to load

This commit is contained in:
Justin Frank 2019-04-09 20:54:19 -07:00
parent 887a5223ac
commit 80ac46e09d
36 changed files with 712 additions and 738 deletions

View File

@ -8,8 +8,14 @@ hook global BufCreate .+\.(a(scii)?doc|asc) %{
set-option buffer filetype asciidoc set-option buffer filetype asciidoc
} }
hook -once global BufSetOption filetype=asciidoc %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group asciidoc-highlight global WinSetOption filetype=asciidoc %{
require-module asciidoc require-module asciidoc
add-highlighter window/asciidoc ref asciidoc
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/asciidoc }
} }
provide-module asciidoc %{ provide-module asciidoc %{
@ -40,12 +46,4 @@ add-highlighter shared/asciidoc/ regex ^:[-\w]+: 0:meta
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group asciidoc-highlight global WinSetOption filetype=asciidoc %{
add-highlighter window/asciidoc ref asciidoc
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/asciidoc }
}
} }

View File

@ -23,8 +23,39 @@ hook global BufCreate .*\.m %{
set-option buffer filetype objc set-option buffer filetype objc
} }
hook -once global BufSetOption filetype=(c|cpp|objc) %{ hook global WinSetOption filetype=(c|cpp|objc) %[
require-module c-family require-module c-family
evaluate-commands "set-option window static_words %%opt{%val{hook_param_capture_1}_static_words}"
hook -group "%val{hook_param_capture_1}-trim-indent" window ModeChange insert:.* c-family-trim-indent
hook -group "%val{hook_param_capture_1}-insert" window InsertChar \n c-family-insert-on-newline
hook -group "%val{hook_param_capture_1}-indent" window InsertChar \n c-family-indent-on-newline
hook -group "%val{hook_param_capture_1}-indent" window InsertChar \{ c-family-indent-on-opening-curly-brace
hook -group "%val{hook_param_capture_1}-indent" window InsertChar \} c-family-indent-on-closing-curly-brace
hook -group "%val{hook_param_capture_1}-insert" window InsertChar \} c-family-insert-on-closing-curly-brace
alias window alt "%val{hook_param_capture_1}-alternative-file"
hook -once -always window WinSetOption filetype=.* "
remove-hooks window %val{hook_param_capture_1}-.+
unalias window alt %val{hook_param_capture_1}-alternative-file
"
]
hook -group c-highlight global WinSetOption filetype=c %{
add-highlighter window/c ref c
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/c }
}
hook -group cpp-highlight global WinSetOption filetype=cpp %{
add-highlighter window/cpp ref cpp
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cpp }
}
hook -group objc-highlight global WinSetOption filetype=objc %{
add-highlighter window/objc ref objc
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/objc }
} }
@ -234,9 +265,7 @@ evaluate-commands %sh{
join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
# 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 "declare-option str-list c_static_words $(join "${keywords} ${attributes} ${types} ${macros}" ' ')"
set-option window static_words $(join "${keywords} ${attributes} ${types} ${macros}" ' ')
}"
# Highlight keywords # Highlight keywords
printf %s " printf %s "
@ -286,9 +315,7 @@ evaluate-commands %sh{
join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
# 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 "declare-option str-list cpp_static_words $(join "${keywords} ${attributes} ${entities} ${types} ${values}" ' ')"
set-option window static_words $(join "${keywords} ${attributes} ${entities} ${types} ${values}" ' ')
}"
# Highlight keywords # Highlight keywords
printf %s " printf %s "
@ -328,9 +355,7 @@ evaluate-commands %sh{
join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
# 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 "declare-option str-list objc_static_words $(join "${keywords} ${attributes} ${types} ${values} ${decorators}" ' ')"
set-option window static_words $(join "${keywords} ${attributes} ${types} ${values} ${decorators}" ' ')
}"
# Highlight keywords # Highlight keywords
printf %s " printf %s "
@ -342,37 +367,6 @@ evaluate-commands %sh{
" "
} }
hook global WinSetOption filetype=(c|cpp|objc) %[
hook -group "%val{hook_param_capture_1}-trim-indent" window ModeChange insert:.* c-family-trim-indent
hook -group "%val{hook_param_capture_1}-insert" window InsertChar \n c-family-insert-on-newline
hook -group "%val{hook_param_capture_1}-indent" window InsertChar \n c-family-indent-on-newline
hook -group "%val{hook_param_capture_1}-indent" window InsertChar \{ c-family-indent-on-opening-curly-brace
hook -group "%val{hook_param_capture_1}-indent" window InsertChar \} c-family-indent-on-closing-curly-brace
hook -group "%val{hook_param_capture_1}-insert" window InsertChar \} c-family-insert-on-closing-curly-brace
alias window alt "%val{hook_param_capture_1}-alternative-file"
hook -once -always window WinSetOption filetype=.* "
remove-hooks window %val{hook_param_capture_1}-.+
unalias window alt %val{hook_param_capture_1}-alternative-file
"
]
hook -group c-highlight global WinSetOption filetype=c %{
add-highlighter window/c ref c
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/c }
}
hook -group cpp-highlight global WinSetOption filetype=cpp %{
add-highlighter window/cpp ref cpp
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cpp }
}
hook -group objc-highlight global WinSetOption filetype=objc %{
add-highlighter window/objc ref objc
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/objc }
}
declare-option -docstring %{control the type of include guard to be inserted in empty headers declare-option -docstring %{control the type of include guard to be inserted in empty headers
Can be one of the following: Can be one of the following:
ifdef: old style ifndef/define guard ifdef: old style ifndef/define guard

View File

@ -8,8 +8,22 @@ hook global BufCreate .*[.](clj|cljc|cljs|cljx|edn) %{
set-option buffer filetype clojure set-option buffer filetype clojure
} }
hook -once global BufSetOption filetype=clojure %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=clojure %[
require-module clojure require-module clojure
set-option window static_words %opt{clojure_static_words}
hook window ModeChange insert:.* -group clojure-trim-indent clojure-trim-indent
hook window InsertChar \n -group clojure-indent clojure-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window clojure-.+ }
]
hook -group clojure-highlight global WinSetOption filetype=clojure %{
add-highlighter window/clojure ref clojure
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/clojure }
} }
provide-module clojure %{ provide-module clojure %{
@ -157,12 +171,11 @@ evaluate-commands %sh{
print_word_highlighter(core_fns, "function"); print_word_highlighter(core_fns, "function");
print_word_highlighter(core_vars, "variable"); print_word_highlighter(core_vars, "variable");
printf(" hook global WinSetOption filetype=clojure %%{\n"\ printf("declare-option str-list clojure_static_words ")
" set-option window static_words ");
print_static_words(keywords); print_static_words(keywords);
print_static_words(core_fns); print_static_words(core_fns);
print_static_words(core_vars); print_static_words(core_vars);
printf("\n }\n"); printf("\n");
} }
EOF EOF
} }
@ -199,18 +212,4 @@ define-command -hidden clojure-indent-on-new-line %{
} }
} }
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group clojure-highlight global WinSetOption filetype=clojure %{
add-highlighter window/clojure ref clojure
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/clojure }
}
hook global WinSetOption filetype=clojure %[
hook window ModeChange insert:.* -group clojure-trim-indent clojure-trim-indent
hook window InsertChar \n -group clojure-indent clojure-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window clojure-.+ }
]
} }

View File

@ -8,10 +8,26 @@ hook global BufCreate .*[.](css) %{
set-option buffer filetype css set-option buffer filetype css
} }
hook -once global BufSetOption filetype=css %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=css %[
require-module css require-module css
hook window ModeChange insert:.* -group css-trim-indent css-trim-indent
hook window InsertChar \n -group css-indent css-indent-on-new-line
hook window InsertChar \} -group css-indent css-indent-on-closing-curly-brace
set-option buffer extra_word_chars '_' '-'
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window css-.+ }
]
hook -group css-highlight global WinSetOption filetype=css %{
add-highlighter window/css ref css
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/css }
} }
provide-module css %[ provide-module css %[
# Highlighters # Highlighters
@ -64,21 +80,4 @@ define-command -hidden css-indent-on-closing-curly-brace %[
] ]
] ]
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group css-highlight global WinSetOption filetype=css %{
add-highlighter window/css ref css
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/css }
}
hook global WinSetOption filetype=css %[
hook window ModeChange insert:.* -group css-trim-indent css-trim-indent
hook window InsertChar \n -group css-indent css-indent-on-new-line
hook window InsertChar \} -group css-indent css-indent-on-closing-curly-brace
set-option buffer extra_word_chars '_' '-'
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window css-.+ }
]
] ]

View File

@ -8,8 +8,26 @@ hook global BufCreate .*\.di? %{
set-option buffer filetype d set-option buffer filetype d
} }
hook -once global BufSetOption filetype=d %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=d %{
require-module d require-module d
set-option window static_words %opt{d_static_words}
# cleanup trailing whitespaces when exiting insert mode
hook window ModeChange insert:.* -group d-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group d-indent d-indent-on-new-line
hook window InsertChar \{ -group d-indent d-indent-on-opening-curly-brace
hook window InsertChar \} -group d-indent d-indent-on-closing-curly-brace
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window d-.+ }
}
hook -group d-highlight global WinSetOption filetype=d %{
add-highlighter window/d ref d
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/d }
} }
provide-module d %🦀 provide-module d %🦀
@ -68,9 +86,7 @@ evaluate-commands %sh{
decorators="disable|property|nogc|safe|trusted|system" decorators="disable|property|nogc|safe|trusted|system"
# 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=d %{ printf %s\\n "declare-option str-list d_static_words ${keywords} ${attributes} ${types} ${values} ${decorators} ${properties}" | tr '|' ' '
set-option window static_words ${keywords} ${attributes} ${types} ${values} ${decorators} ${properties}
}" | tr '|' ' '
# Highlight keywords # Highlight keywords
printf %s " printf %s "
@ -119,22 +135,4 @@ define-command -hidden d-indent-on-closing-curly-brace %[
try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group d-highlight global WinSetOption filetype=d %{
add-highlighter window/d ref d
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/d }
}
hook global WinSetOption filetype=d %{
# cleanup trailing whitespaces when exiting insert mode
hook window ModeChange insert:.* -group d-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group d-indent d-indent-on-new-line
hook window InsertChar \{ -group d-indent d-indent-on-opening-curly-brace
hook window InsertChar \} -group d-indent d-indent-on-closing-curly-brace
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window d-.+ }
}
🦀 🦀

View File

@ -8,11 +8,29 @@ hook global BufCreate .*\.dart %{
set-option buffer filetype dart set-option buffer filetype dart
} }
hook -once global BufSetOption filetype=dart %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=dart %{
require-module dart require-module dart
set-option window static_words %opt{dart_static_words}
# cleanup trailing whitespaces when exiting insert mode
hook window ModeChange insert:.* -group dart-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group dart-indent dart-indent-on-new-line
hook window InsertChar \{ -group dart-indent dart-indent-on-opening-curly-brace
hook window InsertChar \} -group dart-indent dart-indent-on-closing-curly-brace
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window dart-.+ }
} }
provide-module dart %{ hook -group dart-highlight global WinSetOption filetype=dart %{
add-highlighter window/dart ref dart
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dart }
}
provide-module dart %🦀
# Highlighters # Highlighters
# ‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾
@ -44,9 +62,7 @@ evaluate-commands %sh{
classes="[A-Z][a-zA-Z0-9]*" classes="[A-Z][a-zA-Z0-9]*"
# 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=dart %{ printf %s\\n "declare-option str-list dart_static_words ${keywords} ${attributes} ${types} ${values}" | tr '|' ' '
set-option window static_words ${keywords} ${attributes} ${types} ${values}
}" | tr '|' ' '
# Highlight keywords # Highlight keywords
printf %s " printf %s "
@ -93,23 +109,4 @@ define-command -hidden dart-indent-on-closing-curly-brace %[
try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
# Initialization 🦀
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group dart-highlight global WinSetOption filetype=dart %{
add-highlighter window/dart ref dart
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dart }
}
hook global WinSetOption filetype=dart %{
# cleanup trailing whitespaces when exiting insert mode
hook window ModeChange insert:.* -group dart-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group dart-indent dart-indent-on-new-line
hook window InsertChar \{ -group dart-indent dart-indent-on-opening-curly-brace
hook window InsertChar \} -group dart-indent dart-indent-on-closing-curly-brace
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window dart-.+ }
}
# balancing }}}
}

View File

@ -10,8 +10,17 @@ hook global BufCreate .*/?Dockerfile(\.\w+)?$ %{
set-option buffer filetype dockerfile set-option buffer filetype dockerfile
} }
hook -once global BufSetOption filetype=dockerfile %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=dockerfile %{
require-module dockerfile require-module dockerfile
set-option window static_words %opt{dockerfile_static_words}
}
hook -group dockerfile-highlight global WinSetOption filetype=dockerfile %{
add-highlighter window/dockerfile ref dockerfile
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dockerfile }
} }
provide-module dockerfile %{ provide-module dockerfile %{
@ -31,9 +40,7 @@ evaluate-commands %sh{
keywords="${keywords}|MAINTAINER|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR" keywords="${keywords}|MAINTAINER|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR"
# 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=dockerfile %{ printf %s\\n "declare-option str-list dockerfile_static_words ONBUILD|${keywords}" | tr '|' ' '
set window static_words ONBUILD|${keywords}
}" | tr '|' ' '
# Highlight keywords # Highlight keywords
printf %s " printf %s "
@ -45,12 +52,4 @@ evaluate-commands %sh{
add-highlighter shared/dockerfile/code/ regex '\$\{[\w_]+\}' 0:value add-highlighter shared/dockerfile/code/ regex '\$\{[\w_]+\}' 0:value
add-highlighter shared/dockerfile/code/ regex '\$[\w_]+' 0:value add-highlighter shared/dockerfile/code/ regex '\$[\w_]+' 0:value
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group dockerfile-highlight global WinSetOption filetype=dockerfile %{
add-highlighter window/dockerfile ref dockerfile
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dockerfile }
}
} }

View File

@ -8,10 +8,24 @@ hook global BufCreate .*[.](ex|exs) %{
set-option buffer filetype elixir set-option buffer filetype elixir
} }
hook -once global BufSetOption filetype=elixir %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=elixir %{
require-module elixir require-module elixir
hook window ModeChange insert:.* -group elixir-trim-indent elixir-trim-indent
hook window InsertChar \n -group elixir-indent elixir-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elixir-.+ }
} }
hook -group elixir-highlight global WinSetOption filetype=elixir %{
add-highlighter window/elixir ref elixir
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/elixir }
}
provide-module elixir %[ provide-module elixir %[
# Highlighters # Highlighters
@ -66,19 +80,4 @@ define-command -hidden elixir-indent-on-new-line %{
} }
} }
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group elixir-highlight global WinSetOption filetype=elixir %{
add-highlighter window/elixir ref elixir
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/elixir }
}
hook global WinSetOption filetype=elixir %{
hook window ModeChange insert:.* -group elixir-trim-indent elixir-trim-indent
hook window InsertChar \n -group elixir-indent elixir-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elixir-.+ }
}
] ]

View File

@ -8,8 +8,26 @@ hook global BufCreate .*\.go %{
set-option buffer filetype go set-option buffer filetype go
} }
hook -once global BufSetOption filetype=go %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=go %{
require-module go require-module go
set-option window static_words %opt{go_static_words}
# cleanup trailing whitespaces when exiting insert mode
hook window ModeChange insert:.* -group go-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group go-indent go-indent-on-new-line
hook window InsertChar \{ -group go-indent go-indent-on-opening-curly-brace
hook window InsertChar \} -group go-indent go-indent-on-closing-curly-brace
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window go-.+ }
}
hook -group go-highlight global WinSetOption filetype=go %{
add-highlighter window/go ref go
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/go }
} }
provide-module go %🦀 provide-module go %🦀
@ -29,26 +47,26 @@ add-highlighter shared/go/code/ regex %{-?([0-9]*\.(?!0[xX]))?\b([0-9]+|0[xX][0-
evaluate-commands %sh{ evaluate-commands %sh{
# Grammar # Grammar
keywords="break|default|func|interface|select|case|defer|go|map|struct" keywords='break default func interface select case defer go map struct
keywords="${keywords}|chan|else|goto|package|switch|const|fallthrough|if|range|type" chan else goto package switch const fallthrough if range type
keywords="${keywords}|continue|for|import|return|var" continue for import return var'
types="bool|byte|chan|complex128|complex64|error|float32|float64|int|int16|int32" types='bool byte chan complex128 complex64 error float32 float64 int int16 int32
types="${types}|int64|int8|interface|intptr|map|rune|string|struct|uint|uint16|uint32|uint64|uint8" int64 int8 interface intptr map rune string struct uint uint16 uint32 uint64 uint8'
values="false|true|nil|iota" values='false true nil iota'
functions="append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover" functions='append cap close complex copy delete imag len make new panic print println real recover'
join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
# 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=go %{ printf %s\\n "declare-option str-list go_static_words $(join "${keywords} ${attributes} ${types} ${values} ${functions}" ' ')"
set-option window static_words ${keywords} ${attributes} ${types} ${values} ${functions}
}" | tr '|' ' '
# Highlight keywords # Highlight keywords
printf %s " printf %s "
add-highlighter shared/go/code/ regex \b(${keywords})\b 0:keyword add-highlighter shared/go/code/ regex \b($(join "${keywords}" '|'))\b 0:keyword
add-highlighter shared/go/code/ regex \b(${attributes})\b 0:attribute add-highlighter shared/go/code/ regex \b($(join "${attributes}" '|'))\b 0:attribute
add-highlighter shared/go/code/ regex \b(${types})\b 0:type add-highlighter shared/go/code/ regex \b($(join "${types}" '|'))\b 0:type
add-highlighter shared/go/code/ regex \b(${values})\b 0:value add-highlighter shared/go/code/ regex \b($(join "${values}" '|'))\b 0:value
add-highlighter shared/go/code/ regex \b(${functions})\b 0:builtin add-highlighter shared/go/code/ regex \b($(join "${functions}" '|'))\b 0:builtin
" "
} }
@ -84,22 +102,4 @@ define-command -hidden go-indent-on-closing-curly-brace %[
try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group go-highlight global WinSetOption filetype=go %{
add-highlighter window/go ref go
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/go }
}
hook global WinSetOption filetype=go %{
# cleanup trailing whitespaces when exiting insert mode
hook window ModeChange insert:.* -group go-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group go-indent go-indent-on-new-line
hook window InsertChar \{ -group go-indent go-indent-on-opening-curly-brace
hook window InsertChar \} -group go-indent go-indent-on-closing-curly-brace
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window go-.+ }
}
🦀 🦀

View File

@ -8,10 +8,25 @@ hook global BufCreate .*[.](hs) %{
set-option buffer filetype haskell set-option buffer filetype haskell
} }
hook -once global BufSetOption filetype=haskell %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=haskell %{
require-module haskell require-module haskell
set-option window extra_word_chars '_' "'"
hook window ModeChange insert:.* -group haskell-trim-indent haskell-trim-indent
hook window InsertChar \n -group haskell-indent haskell-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window haskell-.+ }
} }
hook -group haskell-highlight global WinSetOption filetype=haskell %{
add-highlighter window/haskell ref haskell
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/haskell }
}
provide-module haskell %[ provide-module haskell %[
# Highlighters # Highlighters
@ -94,20 +109,4 @@ define-command -hidden haskell-indent-on-new-line %{
} }
} }
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group haskell-highlight global WinSetOption filetype=haskell %{
add-highlighter window/haskell ref haskell
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/haskell }
}
hook global WinSetOption filetype=haskell %{
set-option window extra_word_chars '_' "'"
hook window ModeChange insert:.* -group haskell-trim-indent haskell-trim-indent
hook window InsertChar \n -group haskell-indent haskell-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window haskell-.+ }
}
] ]

View File

@ -12,10 +12,29 @@ hook global BufCreate .*\.xml %{
set-option buffer filetype xml set-option buffer filetype xml
} }
hook -once global BufSetOption filetype=(html|xml) %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=(html|xml) %{
require-module html require-module html
hook window ModeChange insert:.* -group "%val{hook_param_capture_1}-trim-indent" html-trim-indent
hook window InsertChar '>' -group "%val{hook_param_capture_1}-indent" html-indent-on-greater-than
hook window InsertChar \n -group "%val{hook_param_capture_1}-indent" html-indent-on-new-line
hook -once -always window WinSetOption "filetype=.*" "
remove-hooks window ""%val{hook_param_capture_1}-.+""
"
} }
hook -group html-highlight global WinSetOption filetype=(html|xml) %{
add-highlighter "window/%val{hook_param_capture_1}" ref html
hook -once -always window WinSetOption "filetype=.*" "
remove-highlighter ""window/%val{hook_param_capture_1}""
"
}
provide-module html %[ provide-module html %[
try %{ try %{
@ -65,24 +84,4 @@ define-command -hidden html-indent-on-new-line %{
try %{ execute-keys -draft k <a-x> <a-k> <lt>(?!area)(?!base)(?!br)(?!col)(?!command)(?!embed)(?!hr)(?!img)(?!input)(?!keygen)(?!link)(?!menuitem)(?!meta)(?!param)(?!source)(?!track)(?!wbr)(?!/)(?!>)[a-zA-Z0-9_-]+[^>]*?>$ <ret> j <a-gt> } } try %{ execute-keys -draft k <a-x> <a-k> <lt>(?!area)(?!base)(?!br)(?!col)(?!command)(?!embed)(?!hr)(?!img)(?!input)(?!keygen)(?!link)(?!menuitem)(?!meta)(?!param)(?!source)(?!track)(?!wbr)(?!/)(?!>)[a-zA-Z0-9_-]+[^>]*?>$ <ret> j <a-gt> } }
} }
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group html-highlight global WinSetOption filetype=(html|xml) %{
add-highlighter "window/%val{hook_param_capture_1}" ref html
hook -once -always window WinSetOption "filetype=.*" "
remove-highlighter ""window/%val{hook_param_capture_1}""
"
}
hook global WinSetOption filetype=(html|xml) %{
hook window ModeChange insert:.* -group "%val{hook_param_capture_1}-trim-indent" html-trim-indent
hook window InsertChar '>' -group "%val{hook_param_capture_1}-indent" html-indent-on-greater-than
hook window InsertChar \n -group "%val{hook_param_capture_1}-indent" html-indent-on-new-line
hook -once -always window WinSetOption "filetype=.*" "
remove-hooks window ""%val{hook_param_capture_1}-.+""
"
}
] ]

View File

@ -13,6 +13,34 @@ hook -once global BufSetOption filetype=(java|type)script %{
require-module javascript require-module javascript
} }
# 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 %🦀 provide-module javascript %🦀
# Commands # Commands
@ -93,23 +121,6 @@ define-command -hidden init-javascript-filetype -params 1 %~
# Keywords are collected at # Keywords are collected at
# https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords # https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords
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|if|import|in|instanceof|let|new|of|return|static|super|switch|throw|try|typeof|var|void|while|with|yield)\b 0:keyword 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|if|import|in|instanceof|let|new|of|return|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 init-javascript-filetype javascript

View File

@ -9,9 +9,27 @@ hook global BufCreate .*[.](json) %{
} }
hook -once global BufSetOption filetype=json %{ hook -once global BufSetOption filetype=json %{
require-module json
} }
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=json %{
require-module json
hook window ModeChange insert:.* -group json-trim-indent json-trim-indent
hook window InsertChar .* -group json-indent json-indent-on-char
hook window InsertChar \n -group json-indent json-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window json-.+ }
}
hook -group json-highlight global WinSetOption filetype=json %{
add-highlighter window/json ref json
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/json }
}
provide-module json %( provide-module json %(
# Highlighters # Highlighters
@ -49,20 +67,4 @@ define-command -hidden json-indent-on-new-line %<
> >
> >
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group json-highlight global WinSetOption filetype=json %{
add-highlighter window/json ref json
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/json }
}
hook global WinSetOption filetype=json %{
hook window ModeChange insert:.* -group json-trim-indent json-trim-indent
hook window InsertChar .* -group json-indent json-indent-on-char
hook window InsertChar \n -group json-indent json-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window json-.+ }
}
) )

View File

@ -8,8 +8,27 @@ hook global BufCreate (.*/)?(kakrc|.*.kak) %{
set-option buffer filetype kak set-option buffer filetype kak
} }
hook -once global BufSetOption filetype=kak %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=kak %~
require-module kak require-module kak
set-option window static_words %opt{kak_static_words}
hook window InsertChar \n -group kak-indent kak-indent-on-new-line
hook window InsertChar [>)}\]] -group kak-indent kak-indent-on-closing-matching
hook window InsertChar (?![[{(<>)}\]])[^\s\w] -group kak-indent kak-indent-on-closing-char
# cleanup trailing whitespaces on current line insert end
hook window ModeChange insert:.* -group kak-trim-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
set-option buffer extra_word_chars '_' '-'
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kak-.+ }
~
hook -group kak-highlight global WinSetOption filetype=kak %{
add-highlighter window/kakrc ref kakrc
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/kakrc }
} }
provide-module kak %🦀 provide-module kak %🦀
@ -52,10 +71,7 @@ evaluate-commands %sh{
join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
# 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=kak %{ printf %s\\n "declare-option str-list kak_static_words $(join "${keywords} ${attributes} ${types} ${values}" ' ')'"
set-option window static_words $(join "${keywords} ${attributes} ${types} ${values}" ' ')'
set-option -- window extra_word_chars '_' '-'
}"
# Highlight keywords (which are always surrounded by whitespace) # Highlight keywords (which are always surrounded by whitespace)
printf '%s\n' "add-highlighter shared/kakrc/code/keywords regex (?:\s|\A)\K($(join "${keywords}" '|'))(?:(?=\s)|\z) 0:keyword printf '%s\n' "add-highlighter shared/kakrc/code/keywords regex (?:\s|\A)\K($(join "${keywords}" '|'))(?:(?=\s)|\z) 0:keyword
@ -98,23 +114,4 @@ define-command -hidden kak-indent-on-closing-char %{
try %{ execute-keys -draft -itersel <a-h><a-k>^\h*\Q %val{hook_param} \E$<ret>gi<a-f> %val{hook_param} <a-T>%<a-k>\w*\Q %val{hook_param} \E$<ret> s \A|.\z<ret> gi 1<a-&> } try %{ execute-keys -draft -itersel <a-h><a-k>^\h*\Q %val{hook_param} \E$<ret>gi<a-f> %val{hook_param} <a-T>%<a-k>\w*\Q %val{hook_param} \E$<ret> s \A|.\z<ret> gi 1<a-&> }
} }
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group kak-highlight global WinSetOption filetype=kak %{
add-highlighter window/kakrc ref kakrc
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/kakrc }
}
hook global WinSetOption filetype=kak %~
hook window InsertChar \n -group kak-indent kak-indent-on-new-line
hook window InsertChar [>)}\]] -group kak-indent kak-indent-on-closing-matching
hook window InsertChar (?![[{(<>)}\]])[^\s\w] -group kak-indent kak-indent-on-closing-char
# cleanup trailing whitespaces on current line insert end
hook window ModeChange insert:.* -group kak-trim-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
set-option buffer extra_word_chars '_' '-'
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kak-.+ }
~
🦀 🦀

View File

@ -8,10 +8,18 @@ hook global BufCreate .*\.tex %{
set-option buffer filetype latex set-option buffer filetype latex
} }
hook -once global BufSetOption filetype=latex %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=latex %{
require-module latex require-module latex
} }
hook -group latex-highlight global WinSetOption filetype=latex %{
add-highlighter window/latex ref latex
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/latex }
}
provide-module latex %( provide-module latex %(
# Highlighters # Highlighters
@ -32,12 +40,4 @@ add-highlighter shared/latex/content/ regex '\\(emph|textit)\{([^}]+)\}' 2:defau
# Bold text # Bold text
add-highlighter shared/latex/content/ regex '\\textbf\{([^}]+)\}' 1:default+b add-highlighter shared/latex/content/ regex '\\textbf\{([^}]+)\}' 1:default+b
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group latex-highlight global WinSetOption filetype=latex %{
add-highlighter window/latex ref latex
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/latex }
}
) )

View File

@ -8,8 +8,21 @@ hook global BufCreate .*[.](lisp) %{
set-option buffer filetype lisp set-option buffer filetype lisp
} }
hook -once global BufSetOption filetype=lisp %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=lisp %{
require-module lisp require-module lisp
hook window ModeChange insert:.* -group lisp-trim-indent lisp-trim-indent
hook window InsertChar \n -group lisp-indent lisp-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window lisp-.+ }
}
hook -group lisp-highlight global WinSetOption filetype=lisp %{
add-highlighter window/lisp ref lisp
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/lisp }
} }
provide-module lisp %{ provide-module lisp %{
@ -64,19 +77,4 @@ define-command -hidden lisp-indent-on-new-line %{
} }
} }
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group lisp-highlight global WinSetOption filetype=lisp %{
add-highlighter window/lisp ref lisp
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/lisp }
}
hook global WinSetOption filetype=lisp %{
hook window ModeChange insert:.* -group lisp-trim-indent lisp-trim-indent
hook window InsertChar \n -group lisp-indent lisp-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window lisp-.+ }
}
} }

View File

@ -8,10 +8,30 @@ hook global BufCreate .*[.](lua) %{
set-option buffer filetype lua set-option buffer filetype lua
} }
hook -once global BufSetOption filetype=lua %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=lua %{
require-module lua require-module lua
hook window InsertChar .* -group lua-indent lua-indent-on-char
hook window InsertChar \n -group lua-indent lua-indent-on-new-line
hook window InsertChar \n -group lua-insert lua-insert-on-new-line
alias window alt lua-alternative-file
hook -once -always window WinSetOption filetype=.* %{
remove-hooks window lua-.+
unalias window alt lua-alternative-file
}
} }
hook -group lua-highlight global WinSetOption filetype=lua %{
add-highlighter window/lua ref lua
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/lua }
}
provide-module lua %[ provide-module lua %[
# Highlighters # Highlighters
@ -87,25 +107,4 @@ define-command -hidden lua-insert-on-new-line %[
] ]
] ]
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group lua-highlight global WinSetOption filetype=lua %{
add-highlighter window/lua ref lua
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/lua }
}
hook global WinSetOption filetype=lua %{
hook window InsertChar .* -group lua-indent lua-indent-on-char
hook window InsertChar \n -group lua-indent lua-indent-on-new-line
hook window InsertChar \n -group lua-insert lua-insert-on-new-line
alias window alt lua-alternative-file
hook -once -always window WinSetOption filetype=.* %{
remove-hooks window lua-.+
unalias window alt lua-alternative-file
}
}
] ]

View File

@ -5,8 +5,21 @@ hook global BufCreate .*(/?[mM]akefile|\.mk) %{
set-option buffer filetype makefile set-option buffer filetype makefile
} }
hook -once global BufSetOption filetype=makefile %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=makefile %{
require-module makefile require-module makefile
set-option window static_words %opt{makefile_static_words}
hook window InsertChar \n -group makefile-indent makefile-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window makefile-.+ }
}
hook -group makefile-highlight global WinSetOption filetype=makefile %{
add-highlighter window/makefile ref makefile
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/makefile }
} }
provide-module makefile %{ provide-module makefile %{
@ -28,9 +41,7 @@ evaluate-commands %sh{
keywords="ifeq|ifneq|ifdef|ifndef|else|endif|define|endef" keywords="ifeq|ifneq|ifdef|ifndef|else|endif|define|endef"
# 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=makefile %{ printf %s\\n "declare-option str-list makefile_static_words ${keywords}" | tr '|' ' '
set-option window static_words ${keywords}
}" | tr '|' ' '
# Highlight keywords # Highlight keywords
printf %s "add-highlighter shared/makefile/content/ regex \b(${keywords})\b 0:keyword" printf %s "add-highlighter shared/makefile/content/ regex \b(${keywords})\b 0:keyword"
@ -52,17 +63,4 @@ define-command -hidden makefile-indent-on-new-line %{
} }
} }
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group makefile-highlight global WinSetOption filetype=makefile %{
add-highlighter window/makefile ref makefile
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/makefile }
}
hook global WinSetOption filetype=makefile %{
hook window InsertChar \n -group makefile-indent makefile-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window makefile-.+ }
}
} }

View File

@ -8,8 +8,24 @@ hook global BufCreate .*\.nim(s|ble)? %{
set-option buffer filetype nim set-option buffer filetype nim
} }
hook -once global BufSetOption filetype=nim %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=nim %{
require-module nim require-module nim
set-option window static_words %opt{nim_static_words}
hook window InsertChar \n -group nim-indent nim-indent-on-new-line
# cleanup trailing whitespaces on current line insert end
hook window ModeChange insert:.* -group nim-trim-indent %{ try %{ exec -draft \; <a-x> s ^\h+$ <ret> d } }
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window nim-.+ }
}
hook -group nim-highlight global WinSetOption filetype=nim %{
add-highlighter window/nim ref nim
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/nim }
} }
provide-module nim %{ provide-module nim %{
@ -57,9 +73,7 @@ evaluate-commands %sh{
static_words="$(join "${keywords} ${types} ${operator} ${values}" ' ')" static_words="$(join "${keywords} ${types} ${operator} ${values}" ' ')"
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
printf %s "hook global WinSetOption filetype=nim %{ printf %s\\n "declare-option str-list nim_static_words ${static_words}"
set-option window static_words ${static_words}
}"
keywords="$(join "${keywords}" '|')" keywords="$(join "${keywords}" '|')"
operators="$(join "${operators}" '|')" operators="$(join "${operators}" '|')"
@ -101,20 +115,4 @@ def -hidden nim-indent-on-new-line %{
} }
} }
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group nim-highlight global WinSetOption filetype=nim %{
add-highlighter window/nim ref nim
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/nim }
}
hook global WinSetOption filetype=nim %{
hook window InsertChar \n -group nim-indent nim-indent-on-new-line
# cleanup trailing whitespaces on current line insert end
hook window ModeChange insert:.* -group nim-trim-indent %{ try %{ exec -draft \; <a-x> s ^\h+$ <ret> d } }
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window nim-.+ }
}
} }

View File

@ -8,8 +8,17 @@ hook global BufCreate .*\.mli? %{
set-option buffer filetype ocaml set-option buffer filetype ocaml
} }
hook -once global BufSetOption filetype=ocaml %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=ocaml %{
require-module ocaml require-module ocaml
set-option window static_words %opt{ocaml_static_words}
}
hook -group ocaml-highlight global WinSetOption filetype=ocaml %{
add-highlighter window/ocaml ref ocaml
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ocaml }
} }
provide-module ocaml %{ provide-module ocaml %{
@ -22,24 +31,19 @@ add-highlighter shared/ocaml/code default-region group
add-highlighter shared/ocaml/string region '"' (?<!\\)(\\\\)*" fill string add-highlighter shared/ocaml/string region '"' (?<!\\)(\\\\)*" fill string
add-highlighter shared/ocaml/comment region \Q(* \Q*) fill comment add-highlighter shared/ocaml/comment region \Q(* \Q*) fill comment
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group ocaml-highlight global WinSetOption filetype=ocaml %{
add-highlighter window/ocaml ref ocaml
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ocaml }
}
# Macro # Macro
# ‾‾‾‾‾ # ‾‾‾‾‾
evaluate-commands %sh{ evaluate-commands %sh{
keywords=and:as:asr:assert:begin:class:constraint:do:done:downto:else:end:exception:external:false:for:fun:function:functor:if:in:include:inherit:initializer:land:lazy:let:lor:lsl:lsr:lxor:match:method:mod:module:mutable:new:nonrec:object:of:open:or:private:rec:sig:struct:then:to:true:try:type:val:virtual:when:while:with keywords="and|as|asr|assert|begin|class|constraint|do|done|downto|else|end|exception|external|false"
echo " keywords="${keywords}|for|fun|function|functor|if|in|include|inherit|initializer|land|lazy|let|lor"
add-highlighter shared/ocaml/code/ regex \b($(printf $keywords | tr : '|'))\b 0:keyword keywords="${keywords}|lsl|lsr|lxor|match|method|mod|module|mutable|new|nonrec|object|of|open|or"
hook global WinSetOption filetype=ocaml %{ keywords="${keywords}|private|rec|sig|struct|then|to|true|try|type|val|virtual|when|while|with"
set-option window static_words $keywords
} printf %s\\n "declare-option str-list ocaml_static_words ${keywords}" | tr '|' ' '
printf %s "
add-highlighter shared/ocaml/code/ regex \b(${keywords})\b 0:keyword
" "
} }

View File

@ -8,8 +8,26 @@ hook global BufCreate .*\.(t|p[lm])$ %{
set-option buffer filetype perl set-option buffer filetype perl
} }
hook -once global BufSetOption filetype=perl %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=perl %{
require-module perl require-module perl
set-option window static_words %opt{perl_static_words}
# cleanup trailing whitespaces when exiting insert mode
hook window ModeChange insert:.* -group perl-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group perl-indent perl-indent-on-new-line
hook window InsertChar \{ -group perl-indent perl-indent-on-opening-curly-brace
hook window InsertChar \} -group perl-indent perl-indent-on-closing-curly-brace
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window perl-.+ }
}
hook -group perl-highlight global WinSetOption filetype=perl %{
add-highlighter window/perl ref perl
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/perl }
} }
provide-module perl %🦀 provide-module perl %🦀
@ -26,31 +44,31 @@ add-highlighter shared/perl/comment region (?<!\$)(?<!\\)# $
evaluate-commands %sh{ evaluate-commands %sh{
# Grammar # Grammar
keywords="else|lock|qw|elsif|lt|qx|eq|exp|ne|sub|for|no|my|not|tr|goto|and|foreach|or|break|exit|unless|cmp|ge|package|until|continue|gt|while|if|qq|xor|do|le|qr|return" keywords="else lock qw elsif lt qx eq exp ne sub for no my not tr goto and foreach or break exit unless cmp ge package until continue gt while if qq xor do le qr return"
attributes="END|AUTOLOAD|BEGIN|CHECK|UNITCHECK|INIT|DESTROY" attributes="END AUTOLOAD BEGIN CHECK UNITCHECK INIT DESTROY
attributes="${attributes}|length|setpgrp|endgrent|link|setpriority|endhostent|listen|setprotoent|endnetent|local|setpwent" length setpgrp endgrent link setpriority endhostent listen setprotoent endnetent local setpwent
attributes="${attributes}|endprotoent|localtime|setservent|endpwent|log|setsockopt|endservent|lstat|shift|eof|map|shmctl|eval|mkdir|shmget|exec|msgctl|shmread" endprotoent localtime setservent endpwent log setsockopt endservent lstat shift eof map shmctl eval mkdir shmget exec msgctl shmread
attributes="${attributes}|exists|msgget|shmwrite|msgrcv|shutdown|fcntl|msgsnd|sin|fileno|sleep|flock|next|socket|fork|socketpair|format|oct|sort" exists msgget shmwrite msgrcv shutdown fcntl msgsnd sin fileno sleep flock next socket fork socketpair format oct sort
attributes="${attributes}|formline|open|splice|getc|opendir|split|getgrent|ord|sprintf|getgrgid|our|sqrt|getgrnam|pack|srand|gethostbyaddr|pipe|stat|gethostbyname" formline open splice getc opendir split getgrent ord sprintf getgrgid our sqrt getgrnam pack srand gethostbyaddr pipe stat gethostbyname
attributes="${attributes}|pop|state|gethostent|pos|study|getlogin|print|substr|getnetbyaddr|printf|symlink|abs|getnetbyname|prototype|syscall|accept|getnetent" pop state gethostent pos study getlogin print substr getnetbyaddr printf symlink abs getnetbyname prototype syscall accept getnetent
attributes="${attributes}|push|sysopen|alarm|getpeername|quotemeta|sysread|atan2|getpgrp|rand|sysseek|getppid|read|system|getpriority|readdir|syswrite|bind" push sysopen alarm getpeername quotemeta sysread atan2 getpgrp rand sysseek getppid read system getpriority readdir syswrite bind
attributes="${attributes}|getprotobyname|readline|tell|binmode|getprotobynumber|readlink|telldir|bless|getprotoent|readpipe|tie|getpwent|recv|tied|caller" getprotobyname readline tell binmode getprotobynumber readlink telldir bless getprotoent readpipe tie getpwent recv tied caller
attributes="${attributes}|getpwnam|redo|time|chdir|getpwuid|ref|times|getservbyname|rename|truncate|chmod|getservbyport|require|uc|chomp|getservent|reset|ucfirst" getpwnam redo time chdir getpwuid ref times getservbyname rename truncate chmod getservbyport require uc chomp getservent reset ucfirst
attributes="${attributes}|chop|getsockname|umask|chown|getsockopt|reverse|undef|chr|glob|rewinddir|chroot|gmtime|rindex|unlink|close|rmdir|unpack" chop getsockname umask chown getsockopt reverse undef chr glob rewinddir chroot gmtime rindex unlink close rmdir unpack
attributes="${attributes}|closedir|grep|say|unshift|connect|hex|scalar|untie|cos|index|seek|use|crypt|seekdir|utime|dbmclose|int|select|values|dbmopen|ioctl|semctl" closedir grep say unshift connect hex scalar untie cos index seek use crypt seekdir utime dbmclose int select values dbmopen ioctl semctl
attributes="${attributes}|vec|defined|join|semget|wait|delete|keys|semop|waitpid|kill|send|wantarray|die|last|setgrent|warn|dump|lc|sethostent|write|each|lcfirst|setnetent" vec defined join semget wait delete keys semop waitpid kill send wantarray die last setgrent warn dump lc sethostent write each lcfirst setnetent"
values="ARGV|STDERR|STDOUT|ARGVOUT|STDIN|__DATA__|__END__|__FILE__|__LINE__|__PACKAGE__" values="ARGV STDERR STDOUT ARGVOUT STDIN __DATA__ __END__ __FILE__ __LINE__ __PACKAGE__"
join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
# 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=perl %{ printf %s\\n "declare-option str-list perl_static_words $(join "${keywords} ${attributes} ${values}" ' ')"
set-option window static_words ${keywords} ${attributes} ${values}
}" | tr '|' ' '
# Highlight keywords # Highlight keywords
printf %s " printf %s "
add-highlighter shared/perl/code/ regex \b(${keywords})\b 0:keyword add-highlighter shared/perl/code/ regex \b($(join "${keywords}" '|'))\b 0:keyword
add-highlighter shared/perl/code/ regex \b(${attributes})\b 0:attribute add-highlighter shared/perl/code/ regex \b($(join "${attributes}" '|'))\b 0:attribute
add-highlighter shared/perl/code/ regex \b(${values})\b 0:value add-highlighter shared/perl/code/ regex \b($(join "${values}" '|'))\b 0:value
" "
} }
@ -101,22 +119,4 @@ define-command -hidden perl-indent-on-closing-curly-brace %[
try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group perl-highlight global WinSetOption filetype=perl %{
add-highlighter window/perl ref perl
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/perl }
}
hook global WinSetOption filetype=perl %{
# cleanup trailing whitespaces when exiting insert mode
hook window ModeChange insert:.* -group perl-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group perl-indent perl-indent-on-new-line
hook window InsertChar \{ -group perl-indent perl-indent-on-opening-curly-brace
hook window InsertChar \} -group perl-indent perl-indent-on-closing-curly-brace
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window perl-.+ }
}
🦀 🦀

View File

@ -5,8 +5,22 @@ hook global BufCreate .*[.](php) %{
set-option buffer filetype php set-option buffer filetype php
} }
hook -once global BufSetOption filetype=php %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=php %{
require-module php require-module php
hook window ModeChange insert:.* -group php-trim-indent php-trim-indent
hook window InsertChar .* -group php-indent php-indent-on-char
hook window InsertChar \n -group php-indent php-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window php-.+ }
}
hook -group php-highlight global WinSetOption filetype=php %{
add-highlighter window/php-file ref php-file
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/php-file }
} }
provide-module php %( provide-module php %(
@ -80,20 +94,4 @@ define-command -hidden php-indent-on-new-line %<
> >
> >
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group php-highlight global WinSetOption filetype=php %{
add-highlighter window/php-file ref php-file
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/php-file }
}
hook global WinSetOption filetype=php %{
hook window ModeChange insert:.* -group php-trim-indent php-trim-indent
hook window InsertChar .* -group php-indent php-indent-on-char
hook window InsertChar \n -group php-indent php-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window php-.+ }
}
) )

View File

@ -8,8 +8,24 @@ hook global BufCreate .*[.](pony) %{
set-option buffer filetype pony set-option buffer filetype pony
} }
hook -once global BufSetOption filetype=pony %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=pony %{
require-module pony require-module pony
set-option window static_words %opt{pony_static_words}
hook window InsertChar \n -group pony-indent pony-indent-on-new-line
# cleanup trailing whitespaces on current line insert end
hook window ModeChange insert:.* -group pony-trim-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pony-.+ }
}
hook -group pony-highlight global WinSetOption filetype=pony %{
add-highlighter window/pony ref pony
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter pony }
} }
provide-module pony %{ provide-module pony %{
@ -39,9 +55,7 @@ evaluate-commands %sh{
# Add the language's grammar to the static completion list # Add the language's grammar to the static completion list
static_words="${values} ${meta} ${keywords} ${types_decl} ${capabilities}" static_words="${values} ${meta} ${keywords} ${types_decl} ${capabilities}"
static_words="${static_words} ${struct}" static_words="${static_words} ${struct}"
printf %s\\n "hook global WinSetOption filetype=pony %{ printf %s\\n "declare-option str-list pony_static_words ${static_words}" | tr '|' ' '
set-option window static_words ${static_words}
}" | tr '|' ' '
# Highlight keywords # Highlight keywords
printf %s " printf %s "
@ -81,20 +95,4 @@ define-command -hidden pony-indent-on-new-line %{
} }
} }
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group pony-highlight global WinSetOption filetype=pony %{
add-highlighter window/pony ref pony
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter pony }
}
hook global WinSetOption filetype=pony %{
hook window InsertChar \n -group pony-indent pony-indent-on-new-line
# cleanup trailing whitespaces on current line insert end
hook window ModeChange insert:.* -group pony-trim-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pony-.+ }
}
} }

View File

@ -7,8 +7,24 @@ hook global BufCreate .*\.proto$ %{
set-option buffer filetype protobuf set-option buffer filetype protobuf
} }
hook -once global BufSetOption filetype=protobuf %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=protobuf %[
require-module protobuf require-module protobuf
set-option window static_words %opt{protobuf_static_words}
hook -group protobuf-indent window InsertChar \n protobuf-indent-on-newline
hook -group protobuf-indent window InsertChar \{ protobuf-indent-on-opening-curly-brace
hook -group protobuf-indent window InsertChar \} protobuf-indent-on-closing-curly-brace
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window protobuf-.+ }
]
hook -group protobuf-highlight global WinSetOption filetype=protobuf %{
add-highlighter window/protobuf ref protobuf
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/protobuf }
} }
provide-module protobuf %[ provide-module protobuf %[
@ -26,31 +42,30 @@ add-highlighter shared/protobuf/code/ regex %{(0x)?[0-9]+\b} 0:value
evaluate-commands %sh{ evaluate-commands %sh{
# Grammer # Grammer
keywords="default|deprecated|enum|extend|import|message|oneof|option" keywords='default deprecated enum extend import message oneof option
keywords="${keywords}|package|service|syntax" package service syntax'
attributes="optional|repeated|required" attributes='optional repeated required'
types="double|float|int32|int64|uint32|uint64|sint32|sint64|fixed32|fixed64" types='double float int32 int64 uint32 uint64 sint32 sint64 fixed32 fixed64
types="${types}|sfixed32|sfixed64|bool|string|bytes|rpc" sfixed32 sfixed64 bool string bytes rpc'
values="false|true" values='false true'
join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
# Add the language's grammer to the static completion list # Add the language's grammer to the static completion list
printf '%s\n' "hook global WinSetOption filetype=protobuf %{ printf %s\\n "declare-option str-list protobuf_static_words $(join "${keywords} ${attributes} ${types} ${values}" ' ')"
set-option window static_words ${keywords} ${attributes} ${types} ${values}
}" | tr '|' ' '
# Highlight keywords # Highlight keywords
printf %s " printf %s "
add-highlighter shared/protobuf/code/keywords regex \b(${keywords})\b 0:keyword add-highlighter shared/protobuf/code/keywords regex \b($(join "${keywords}" '|'))\b 0:keyword
add-highlighter shared/protobuf/code/attributes regex \b(${attributes})\b 0:attribute add-highlighter shared/protobuf/code/attributes regex \b($(join "${attributes}" '|'))\b 0:attribute
add-highlighter shared/protobuf/code/types regex \b(${types})\b 0:type add-highlighter shared/protobuf/code/types regex \b($(join "${types}" '|'))\b 0:type
add-highlighter shared/protobuf/code/values regex \b(${values})\b 0:value add-highlighter shared/protobuf/code/values regex \b($(join "${values}" '|'))\b 0:value
" "
} }
# Commands # Commands
# ‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾
define-command -hidden protobuf-indent-on-newline %~ define-command -hidden protobuf-indent-on-newline %~
evaluate-commands -draft -itersel %[ evaluate-commands -draft -itersel %[
# preserve previous line indent # preserve previous line indent
@ -74,20 +89,4 @@ define-command -hidden protobuf-indent-on-closing-curly-brace %[
try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ] try %[ execute-keys -itersel -draft <a-h><a-k>^\h+\}$<ret>hms\A|.\z<ret>1<a-&> ]
] ]
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group protobuf-highlight global WinSetOption filetype=protobuf %{
add-highlighter window/protobuf ref protobuf
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/protobuf }
}
hook global WinSetOption filetype=protobuf %[
hook -group protobuf-indent window InsertChar \n protobuf-indent-on-newline
hook -group protobuf-indent window InsertChar \{ protobuf-indent-on-opening-curly-brace
hook -group protobuf-indent window InsertChar \} protobuf-indent-on-closing-curly-brace
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window protobuf-.+ }
]
] ]

View File

@ -12,10 +12,24 @@ hook global BufCreate .*[.](pug|jade) %{
set-option buffer filetype pug set-option buffer filetype pug
} }
hook -once global BufSetOption filetype=pug %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=pug %{
require-module pug require-module pug
hook window ModeChange insert:.* -group pug-trim-indent pug-trim-indent
hook window InsertChar \n -group pug-indent pug-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pug-.+ }
} }
hook -group pug-highlight global WinSetOption filetype=pug %{
add-highlighter window/pug ref pug
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/pug }
}
provide-module pug %{ provide-module pug %{
# Highlighters # Highlighters
@ -64,19 +78,4 @@ define-command -hidden pug-indent-on-new-line %{
} }
} }
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group pug-highlight global WinSetOption filetype=pug %{
add-highlighter window/pug ref pug
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/pug }
}
hook global WinSetOption filetype=pug %{
hook window ModeChange insert:.* -group pug-trim-indent pug-trim-indent
hook window InsertChar \n -group pug-indent pug-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pug-.+ }
}
} }

View File

@ -8,8 +8,23 @@ hook global BufCreate .*[.](py) %{
set-option buffer filetype python set-option buffer filetype python
} }
hook -once global BufSetOption filetype=python %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=python %{
require-module python require-module python
set-option window static_words %opt{python_static_words}
hook window InsertChar \n -group python-indent python-indent-on-new-line
# cleanup trailing whitespaces on current line insert end
hook window ModeChange insert:.* -group python-trim-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window python-.+ }
}
hook -group python-highlight global WinSetOption filetype=python %{
add-highlighter window/python ref python
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/python }
} }
provide-module python %{ provide-module python %{
@ -42,79 +57,79 @@ add-highlighter shared/python/docstring/ region '\.\.\. \K' '\z' ref python
evaluate-commands %sh{ evaluate-commands %sh{
# Grammar # Grammar
values="True|False|None|self|inf" values="True False None self inf"
meta="import|from" meta="import from"
# attributes and methods list based on https://docs.python.org/3/reference/datamodel.html # attributes and methods list based on https://docs.python.org/3/reference/datamodel.html
attributes="__annotations__|__closure__|__code__|__defaults__|__dict__|__doc__" attributes="__annotations__ __closure__ __code__ __defaults__ __dict__ __doc__
attributes="${attributes}|__globals__|__kwdefaults__|__module__|__name__|__qualname__" __globals__ __kwdefaults__ __module__ __name__ __qualname__"
methods="__abs__|__add__|__aenter__|__aexit__|__aiter__|__and__|__anext__" methods="__abs__ __add__ __aenter__ __aexit__ __aiter__ __and__ __anext__
methods="${methods}|__await__|__bool__|__bytes__|__call__|__complex__|__contains__" __await__ __bool__ __bytes__ __call__ __complex__ __contains__
methods="${methods}|__del__|__delattr__|__delete__|__delitem__|__dir__|__divmod__" __del__ __delattr__ __delete__ __delitem__ __dir__ __divmod__
methods="${methods}|__enter__|__eq__|__exit__|__float__|__floordiv__|__format__" __enter__ __eq__ __exit__ __float__ __floordiv__ __format__
methods="${methods}|__ge__|__get__|__getattr__|__getattribute__|__getitem__" __ge__ __get__ __getattr__ __getattribute__ __getitem__
methods="${methods}|__gt__|__hash__|__iadd__|__iand__|__ifloordiv__|__ilshift__" __gt__ __hash__ __iadd__ __iand__ __ifloordiv__ __ilshift__
methods="${methods}|__imatmul__|__imod__|__imul__|__index__|__init__" __imatmul__ __imod__ __imul__ __index__ __init__
methods="${methods}|__init_subclass__|__int__|__invert__|__ior__|__ipow__" __init_subclass__ __int__ __invert__ __ior__ __ipow__
methods="${methods}|__irshift__|__isub__|__iter__|__itruediv__|__ixor__|__le__" __irshift__ __isub__ __iter__ __itruediv__ __ixor__ __le__
methods="${methods}|__len__|__length_hint__|__lshift__|__lt__|__matmul__" __len__ __length_hint__ __lshift__ __lt__ __matmul__
methods="${methods}|__missing__|__mod__|__mul__|__ne__|__neg__|__new__|__or__" __missing__ __mod__ __mul__ __ne__ __neg__ __new__ __or__
methods="${methods}|__pos__|__pow__|__radd__|__rand__|__rdivmod__|__repr__" __pos__ __pow__ __radd__ __rand__ __rdivmod__ __repr__
methods="${methods}|__reversed__|__rfloordiv__|__rlshift__|__rmatmul__|__rmod__" __reversed__ __rfloordiv__ __rlshift__ __rmatmul__ __rmod__
methods="${methods}|__rmul__|__ror__|__round__|__rpow__|__rrshift__|__rshift__" __rmul__ __ror__ __round__ __rpow__ __rrshift__ __rshift__
methods="${methods}|__rsub__|__rtruediv__|__rxor__|__set__|__setattr__" __rsub__ __rtruediv__ __rxor__ __set__ __setattr__
methods="${methods}|__setitem__|__set_name__|__slots__|__str__|__sub__" __setitem__ __set_name__ __slots__ __str__ __sub__
methods="${methods}|__truediv__|__xor__" __truediv__ __xor__"
# built-in exceptions https://docs.python.org/3/library/exceptions.html # built-in exceptions https://docs.python.org/3/library/exceptions.html
exceptions="ArithmeticError|AssertionError|AttributeError|BaseException|BlockingIOError" exceptions="ArithmeticError AssertionError AttributeError BaseException BlockingIOError
exceptions="${exceptions}|BrokenPipeError|BufferError|BytesWarning|ChildProcessError" BrokenPipeError BufferError BytesWarning ChildProcessError
exceptions="${exceptions}|ConnectionAbortedError|ConnectionError|ConnectionRefusedError" ConnectionAbortedError ConnectionError ConnectionRefusedError
exceptions="${exceptions}|ConnectionResetError|DeprecationWarning|EOFError|Exception" ConnectionResetError DeprecationWarning EOFError Exception
exceptions="${exceptions}|FileExistsError|FileNotFoundError|FloatingPointError|FutureWarning" FileExistsError FileNotFoundError FloatingPointError FutureWarning
exceptions="${exceptions}|GeneratorExit|ImportError|ImportWarning|IndentationError" GeneratorExit ImportError ImportWarning IndentationError
exceptions="${exceptions}|IndexError|InterruptedError|IsADirectoryError|KeyboardInterrupt" IndexError InterruptedError IsADirectoryError KeyboardInterrupt
exceptions="${exceptions}|KeyError|LookupError|MemoryError|ModuleNotFoundError|NameError" KeyError LookupError MemoryError ModuleNotFoundError NameError
exceptions="${exceptions}|NotADirectoryError|NotImplementedError|OSError|OverflowError" NotADirectoryError NotImplementedError OSError OverflowError
exceptions="${exceptions}|PendingDeprecationWarning|PermissionError|ProcessLookupError" PendingDeprecationWarning PermissionError ProcessLookupError
exceptions="${exceptions}|RecursionError|ReferenceError|ResourceWarning|RuntimeError" RecursionError ReferenceError ResourceWarning RuntimeError
exceptions="${exceptions}|RuntimeWarning|StopAsyncIteration|StopIteration|SyntaxError" RuntimeWarning StopAsyncIteration StopIteration SyntaxError
exceptions="${exceptions}|SyntaxWarning|SystemError|SystemExit|TabError|TimeoutError|TypeError" SyntaxWarning SystemError SystemExit TabError TimeoutError TypeError
exceptions="${exceptions}|UnboundLocalError|UnicodeDecodeError|UnicodeEncodeError|UnicodeError" UnboundLocalError UnicodeDecodeError UnicodeEncodeError UnicodeError
exceptions="${exceptions}|UnicodeTranslateError|UnicodeWarning|UserWarning|ValueError|Warning" UnicodeTranslateError UnicodeWarning UserWarning ValueError Warning
exceptions="${exceptions}|ZeroDivisionError" ZeroDivisionError"
# Keyword list is collected using `keyword.kwlist` from `keyword` # Keyword list is collected using `keyword.kwlist` from `keyword`
keywords="and|as|assert|async|await|break|class|continue|def|del|elif|else|except|exec" keywords="and as assert async await break class continue def del elif else except exec
keywords="${keywords}|finally|for|global|if|in|is|lambda|nonlocal|not|or|pass|print" finally for global if in is lambda nonlocal not or pass print
keywords="${keywords}|raise|return|try|while|with|yield" raise return try while with yield"
types="bool|buffer|bytearray|bytes|complex|dict|file|float|frozenset|int" types="bool buffer bytearray bytes complex dict file float frozenset int
types="${types}|list|long|memoryview|object|set|str|tuple|unicode|xrange" list long memoryview object set str tuple unicode xrange"
functions="abs|all|any|ascii|bin|breakpoint|callable|chr|classmethod|compile|complex" functions="abs all any ascii bin breakpoint callable chr classmethod compile complex
functions="${functions}|delattr|dict|dir|divmod|enumerate|eval|exec|filter" delattr dict dir divmod enumerate eval exec filter
functions="${functions}|format|frozenset|getattr|globals|hasattr|hash|help" format frozenset getattr globals hasattr hash help
functions="${functions}|hex|id|__import__|input|isinstance|issubclass|iter" hex id __import__ input isinstance issubclass iter
functions="${functions}|len|locals|map|max|memoryview|min|next|oct|open|ord" len locals map max memoryview min next oct open ord
functions="${functions}|pow|print|property|range|repr|reversed|round" pow print property range repr reversed round
functions="${functions}|setattr|slice|sorted|staticmethod|sum|super|type|vars|zip" setattr slice sorted staticmethod sum super type vars zip"
join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
# 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=python %{ printf %s\\n "declare-option str-list python_static_words $(join "${values} ${meta} ${attributes} ${methods} ${exceptions} ${keywords} ${types} ${functions}" ' ')"
set-option window static_words ${values} ${meta} ${attributes} ${methods} ${exceptions} ${keywords} ${types} ${functions}
}" | tr '|' ' '
# Highlight keywords # Highlight keywords
printf %s " printf %s "
add-highlighter shared/python/code/ regex '\b(${values})\b' 0:value add-highlighter shared/python/code/ regex '\b($(join "${values}" '|'))\b' 0:value
add-highlighter shared/python/code/ regex '\b(${meta})\b' 0:meta add-highlighter shared/python/code/ regex '\b($(join "${meta}" '|'))\b' 0:meta
add-highlighter shared/python/code/ regex '\b(${attribute})\b' 0:attribute add-highlighter shared/python/code/ regex '\b($(join "${attribute}" '|'))\b' 0:attribute
add-highlighter shared/python/code/ regex '\bdef\s+(${methods})\b' 1:function add-highlighter shared/python/code/ regex '\bdef\s+($(join "${methods}" '|'))\b' 1:function
add-highlighter shared/python/code/ regex '\b(${exceptions})\b' 0:function add-highlighter shared/python/code/ regex '\b($(join "${exceptions}" '|'))\b' 0:function
add-highlighter shared/python/code/ regex '\b(${keywords})\b' 0:keyword add-highlighter shared/python/code/ regex '\b($(join "${keywords}" '|'))\b' 0:keyword
add-highlighter shared/python/code/ regex '\b(${functions})\b\(' 1:builtin add-highlighter shared/python/code/ regex '\b($(join "${functions}" '|'))\b\(' 1:builtin
add-highlighter shared/python/code/ regex '\b(${types})\b' 0:type add-highlighter shared/python/code/ regex '\b($(join "${types}" '|'))\b' 0:type
add-highlighter shared/python/code/ regex '@[\w_]+\b' 0:attribute add-highlighter shared/python/code/ regex '@[\w_]+\b' 0:attribute
" "
} }
@ -138,19 +153,4 @@ define-command -hidden python-indent-on-new-line %{
} }
} }
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group python-highlight global WinSetOption filetype=python %{
add-highlighter window/python ref python
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/python }
}
hook global WinSetOption filetype=python %{
hook window InsertChar \n -group python-indent python-indent-on-new-line
# cleanup trailing whitespaces on current line insert end
hook window ModeChange insert:.* -group python-trim-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window python-.+ }
}
} }

View File

@ -10,8 +10,22 @@ hook global BufCreate .*[.](ragel|rl) %{
set-option buffer filetype ragel set-option buffer filetype ragel
} }
hook -once global BufSetOption filetype=ragel %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=ragel %{
require-module ragel require-module ragel
hook window ModeChange insert:.* -group ragel-trim-indent ragel-trim-indent
hook window InsertChar .* -group ragel-indent ragel-indent-on-char
hook window InsertChar \n -group ragel-indent ragel-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window ragel-.+ }
}
hook -group ragel-highlight global WinSetOption filetype=ragel %{
add-highlighter window/ragel ref ragel
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ragel }
} }
provide-module ragel %🦀 provide-module ragel %🦀
@ -59,20 +73,4 @@ define-command -hidden ragel-indent-on-new-line %<
> >
> >
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group ragel-highlight global WinSetOption filetype=ragel %{
add-highlighter window/ragel ref ragel
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ragel }
}
hook global WinSetOption filetype=ragel %{
hook window ModeChange insert:.* -group ragel-trim-indent ragel-trim-indent
hook window InsertChar .* -group ragel-indent ragel-indent-on-char
hook window InsertChar \n -group ragel-indent ragel-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window ragel-.+ }
}
🦀 🦀

View File

@ -8,8 +8,29 @@ hook global BufCreate .*(([.](rb))|(irbrc)|(pryrc)|(Brewfile)|(Capfile|[.]cap)|(
set-option buffer filetype ruby set-option buffer filetype ruby
} }
hook -once global BufSetOption filetype=ruby %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=ruby %{
require-module ruby require-module ruby
set-option window static_words %opt{ruby_static_words}
hook window InsertChar .* -group ruby-indent ruby-indent-on-char
hook window InsertChar \n -group ruby-insert ruby-insert-on-new-line
hook window InsertChar \n -group ruby-indent ruby-indent-on-new-line
alias window alt ruby-alternative-file
hook -once -always window WinSetOption filetype=.* %{
remove-hooks window ruby-.+
unalias window alt ruby-alternative-file
}
}
hook -group ruby-highlight global WinSetOption filetype=ruby %{
add-highlighter window/ruby ref ruby
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ruby }
} }
provide-module ruby %[ provide-module ruby %[
@ -61,9 +82,7 @@ evaluate-commands %sh{
meta="require|include|extend" meta="require|include|extend"
# 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=ruby %{ printf %s\\n "declare-option str-list ruby_static_words ${keywords} ${attributes} ${values} ${meta}" | tr '|' ' '
set-option window static_words ${keywords} ${attributes} ${values} ${meta}
}" | tr '|' ' '
# Highlight keywords # Highlight keywords
printf %s " printf %s "
@ -152,25 +171,4 @@ define-command -hidden ruby-insert-on-new-line %[
] ]
] ]
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group ruby-highlight global WinSetOption filetype=ruby %{
add-highlighter window/ruby ref ruby
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ruby }
}
hook global WinSetOption filetype=ruby %{
hook window InsertChar .* -group ruby-indent ruby-indent-on-char
hook window InsertChar \n -group ruby-insert ruby-insert-on-new-line
hook window InsertChar \n -group ruby-indent ruby-indent-on-new-line
alias window alt ruby-alternative-file
hook -once -always window WinSetOption filetype=.* %{
remove-hooks window ruby-.+
unalias window alt ruby-alternative-file
}
}
] ]

View File

@ -8,10 +8,32 @@ hook global BufCreate .*[.](rust|rs) %{
set-option buffer filetype rust set-option buffer filetype rust
} }
hook -once global BufSetOption filetype=rust %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=rust %[
require-module rust require-module rust
hook window ModeChange insert:.* -group rust-trim-indent rust-trim-indent
hook window InsertChar \n -group rust-indent rust-indent-on-new-line
hook window InsertChar \{ -group rust-indent rust-indent-on-opening-curly-brace
hook window InsertChar [)}] -group rust-indent rust-indent-on-closing
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window rust-.+ }
]
hook -group rust-highlight global WinSetOption filetype=rust %{
add-highlighter window/rust ref rust
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/rust }
} }
# Configuration
# ‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=rust %[
set window formatcmd 'rustfmt'
]
provide-module rust %🦀 provide-module rust %🦀
# Highlighters # Highlighters
@ -77,27 +99,4 @@ define-command -hidden rust-indent-on-closing %[
_ _
] ]
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group rust-highlight global WinSetOption filetype=rust %{
add-highlighter window/rust ref rust
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/rust }
}
hook global WinSetOption filetype=rust %[
hook window ModeChange insert:.* -group rust-trim-indent rust-trim-indent
hook window InsertChar \n -group rust-indent rust-indent-on-new-line
hook window InsertChar \{ -group rust-indent rust-indent-on-opening-curly-brace
hook window InsertChar [)}] -group rust-indent rust-indent-on-closing
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window rust-.+ }
]
# Configuration
# ‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=rust %[
set window formatcmd 'rustfmt'
]
🦀 🦀

View File

@ -8,8 +8,24 @@ hook global BufCreate (.*/)?(.*\.(scm|ss|sld)) %{
set-option buffer filetype scheme set-option buffer filetype scheme
} }
hook -once global BufSetOption filetype=scheme %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=scheme %{
require-module scheme require-module scheme
set-option window static_words %opt{scheme_static_words}
set-option buffer extra_word_chars '_' '-' '!' '%' '?' '<' '>' '='
hook window InsertEnd .* -group scheme-trim-indent lisp-trim-indent
hook window InsertChar \n -group scheme-indent lisp-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scheme-.+ }
}
hook -group scheme-highlight global WinSetOption filetype=scheme %{
add-highlighter window/scheme ref scheme
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scheme }
} }
provide-module scheme %{ provide-module scheme %{
@ -105,9 +121,9 @@ evaluate-commands %sh{ exec awk -f - <<'EOF'
} }
BEGIN { BEGIN {
printf("hook global WinSetOption filetype=scheme %%{ set-option window static_words "); printf("declare-option str-list scheme_static_words ");
print_words(keywords); print_words(meta); print_words(operators); print_words(builtins); print_words(keywords); print_words(meta); print_words(operators); print_words(builtins);
printf(" }\n") printf("\n");
add_word_highlighter(keywords, "keyword"); add_word_highlighter(keywords, "keyword");
add_word_highlighter(meta, "meta"); add_word_highlighter(meta, "meta");
@ -121,21 +137,4 @@ evaluate-commands %sh{ exec awk -f - <<'EOF'
EOF EOF
} }
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group scheme-highlight global WinSetOption filetype=scheme %{
add-highlighter window/scheme ref scheme
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scheme }
}
hook global WinSetOption filetype=scheme %{
set-option buffer extra_word_chars '_' '-' '!' '%' '?' '<' '>' '='
hook window InsertEnd .* -group scheme-trim-indent lisp-trim-indent
hook window InsertChar \n -group scheme-indent lisp-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scheme-.+ }
}
} }

View File

@ -8,10 +8,26 @@ hook global BufCreate .*[.](scss) %{
set-option buffer filetype scss set-option buffer filetype scss
} }
hook -once global BufSetOption filetype=scss %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=scss %[
require-module scss require-module scss
hook window ModeChange insert:.* -group scss-trim-indent scss-trim-indent
hook window InsertChar \n -group scss-indent scss-indent-on-new-line
hook window InsertChar \} -group scss-indent scss-indent-on-closing-curly-brace
set-option buffer extra_word_chars '_' '-'
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scss-.+ }
]
hook -group scss-highlight global WinSetOption filetype=scss %{
add-highlighter window/scss ref scss
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scss }
} }
provide-module scss %[ provide-module scss %[
require-module css require-module css
@ -33,21 +49,4 @@ define-command -hidden scss-trim-indent css-trim-indent
define-command -hidden scss-indent-on-new-line css-indent-on-new-line define-command -hidden scss-indent-on-new-line css-indent-on-new-line
define-command -hidden scss-indent-on-closing-curly-brace css-indent-on-closing-curly-brace define-command -hidden scss-indent-on-closing-curly-brace css-indent-on-closing-curly-brace
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group scss-highlight global WinSetOption filetype=scss %{
add-highlighter window/scss ref scss
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scss }
}
hook global WinSetOption filetype=scss %[
hook window ModeChange insert:.* -group scss-trim-indent scss-trim-indent
hook window InsertChar \n -group scss-indent scss-indent-on-new-line
hook window InsertChar \} -group scss-indent scss-indent-on-closing-curly-brace
set-option buffer extra_word_chars '_' '-'
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scss-.+ }
]
] ]

View File

@ -2,8 +2,14 @@ hook global BufCreate .*\.(z|ba|c|k|mk)?sh(rc|_profile)? %{
set-option buffer filetype sh set-option buffer filetype sh
} }
hook -once global BufSetOption filetype=sh %{ hook global WinSetOption filetype=sh %{
require-module sh require-module sh
set-option window static_words %opt{sh_static_words}
}
hook -group sh-highlight global WinSetOption filetype=sh %{
add-highlighter window/sh ref sh
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/sh }
} }
provide-module sh %[ provide-module sh %[
@ -29,9 +35,7 @@ evaluate-commands %sh{
join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
# 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=sh %{ printf %s\\n "declare-option str-list sh_static_words $(join "${keywords}" ' ')"
set-option window static_words $(join "${keywords}" ' ')
}"
# Highlight keywords # Highlight keywords
printf %s "add-highlighter shared/sh/code/ regex \b($(join "${keywords}" '|'))\b 0:keyword" printf %s "add-highlighter shared/sh/code/ regex \b($(join "${keywords}" '|'))\b 0:keyword"
@ -44,9 +48,4 @@ add-highlighter shared/sh/code/function regex ^\h*(\w+)\h*\(\) 1:function
add-highlighter shared/sh/code/unscoped_expansion regex \$(\w+|#|@|\?|\$|!|-|\*) 0:value add-highlighter shared/sh/code/unscoped_expansion regex \$(\w+|#|@|\?|\$|!|-|\*) 0:value
add-highlighter shared/sh/double_string/expansion regex \$(\w+|\{.+?\}) 0:value add-highlighter shared/sh/double_string/expansion regex \$(\w+|\{.+?\}) 0:value
hook -group sh-highlight global WinSetOption filetype=sh %{
add-highlighter window/sh ref sh
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/sh }
}
] ]

View File

@ -8,10 +8,20 @@ hook global BufCreate .*/?(?i)sql %{
set-option buffer filetype sql set-option buffer filetype sql
} }
hook -once global BufSetOption filetype=sql %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=sql %{
require-module sql require-module sql
set-option window static_words %opt{sql_static_words}
} }
hook -group sql-highlight global WinSetOption filetype=sql %{
add-highlighter window/sql ref sql
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/sql }
}
provide-module sql %{ provide-module sql %{
# Highlighters # Highlighters
@ -86,9 +96,7 @@ evaluate-commands %sh{
data_types="${data_types}|Time|Ole Object|Hyperlink|Lookup Wizard" data_types="${data_types}|Time|Ole Object|Hyperlink|Lookup Wizard"
# 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=sql %{ printf %s\\n "declare-option str-list sql_static_words ${keywords} ${operators} ${functions} ${data_types} ${data_types_fn} NULL" | tr '|' ' '
set-option window static_words ${keywords} ${operators} ${functions} ${data_types} ${data_types_fn} NULL
}" | tr '|' ' '
# Highlight keywords # Highlight keywords
printf %s " printf %s "
@ -104,12 +112,4 @@ add-highlighter shared/sql/code/ regex '\+|-|\*|/|%|&|\||^|=|>|<|>=|<=|<>|\+=|-=
add-highlighter shared/sql/code/ regex \bNULL\b 0:value add-highlighter shared/sql/code/ regex \bNULL\b 0:value
add-highlighter shared/sql/code/ regex \b\d+(?:\.\d+)?\b 0:value add-highlighter shared/sql/code/ regex \b\d+(?:\.\d+)?\b 0:value
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group sql-highlight global WinSetOption filetype=sql %{
add-highlighter window/sql ref sql
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/sql }
}
} }

View File

@ -2,10 +2,16 @@ hook global BufCreate .*\.(swift) %{
set-option buffer filetype swift set-option buffer filetype swift
} }
hook -once global BufSetOption filetype=swift %{ hook global WinSetOption filetype=swift %{
require-module swift require-module swift
} }
hook -group swift-highlight global WinSetOption filetype=swift %{
add-highlighter window/swift ref swift
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/swift }
}
provide-module swift %{ provide-module swift %{
add-highlighter shared/swift regions add-highlighter shared/swift regions
@ -28,9 +34,4 @@ add-highlighter shared/swift/code/ regex "\b(Bool|String|UInt|UInt16|UInt32|UInt
add-highlighter shared/swift/code/ regex "\b(IBAction|IBOutlet)\b" 0:attribute add-highlighter shared/swift/code/ regex "\b(IBAction|IBOutlet)\b" 0:attribute
add-highlighter shared/swift/code/ regex "@\w+\b" 0:attribute add-highlighter shared/swift/code/ regex "@\w+\b" 0:attribute
hook -group swift-highlight global WinSetOption filetype=swift %{
add-highlighter window/swift ref swift
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/swift }
}
} }

View File

@ -5,10 +5,18 @@ hook global BufCreate .*\.\d+ %{
set-option buffer filetype troff set-option buffer filetype troff
} }
hook -once global BufSetOption filetype=troff %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=troff %{
require-module troff require-module troff
} }
hook -group troff-highlight global WinSetOption filetype=troff %{
add-highlighter window/troff ref troff
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/troff }
}
provide-module troff %{ provide-module troff %{
# Highlighters # Highlighters
@ -27,12 +35,4 @@ add-highlighter shared/troff/ regex '^\.BR\s+(\S+)' 1:+b
add-highlighter shared/troff/ regex '^\.I\s+([^\n]+)' 1:+i add-highlighter shared/troff/ regex '^\.I\s+([^\n]+)' 1:+i
add-highlighter shared/troff/ regex '^\.B\s+([^\n]+)' 1:+b add-highlighter shared/troff/ regex '^\.B\s+([^\n]+)' 1:+b
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group troff-highlight global WinSetOption filetype=troff %{
add-highlighter window/troff ref troff
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/troff }
}
} }

View File

@ -8,10 +8,17 @@ hook global BufCreate .*/?Tup(file|rules)(\.\w+)?$ %{
set-option buffer filetype tupfile set-option buffer filetype tupfile
} }
hook -once global BufSetOption filetype=tupfile %{ # Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group tupfile-highlight global WinSetOption filetype=tupfile %{
require-module tupfile require-module tupfile
add-highlighter window/tupfile ref tupfile
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/tupfile }
} }
provide-module tupfile %{ provide-module tupfile %{
# Highlighters # Highlighters
@ -30,12 +37,4 @@ add-highlighter shared/tupfile/code/ regex '^\h*\b(ifn?eq|ifn?def|else|endif|err
add-highlighter shared/tupfile/code/ regex '^\h*\b(&?[\w_]+)\s*[:+]?=' 1:keyword add-highlighter shared/tupfile/code/ regex '^\h*\b(&?[\w_]+)\s*[:+]?=' 1:keyword
add-highlighter shared/tupfile/code/ regex '`[^`\n]+`' 0:meta add-highlighter shared/tupfile/code/ regex '`[^`\n]+`' 0:meta
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group tupfile-highlight global WinSetOption filetype=tupfile %{
add-highlighter window/tupfile ref tupfile
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/tupfile }
}
} }