2018-02-01 02:33:44 +03:00
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global BufCreate .*/?[jJ]ustfile %{
|
|
|
|
set-option buffer filetype justfile
|
|
|
|
}
|
|
|
|
|
2019-04-12 01:54:58 +03:00
|
|
|
hook global WinSetOption filetype=justfile %{
|
2019-03-14 00:00:59 +03:00
|
|
|
require-module justfile
|
2019-04-12 01:54:58 +03:00
|
|
|
|
|
|
|
hook window InsertChar \n -group justfile-indent just-indent-on-new-line
|
|
|
|
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window justfile-.+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
hook -group justfile-highlight global WinSetOption filetype=justfile %{
|
|
|
|
add-highlighter window/justfile ref justfile
|
|
|
|
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/justfile }
|
2019-03-14 00:00:59 +03:00
|
|
|
}
|
|
|
|
|
2019-04-12 01:54:58 +03:00
|
|
|
|
2019-03-14 00:00:59 +03:00
|
|
|
provide-module justfile %{
|
|
|
|
|
2018-02-01 02:33:44 +03:00
|
|
|
# Indentation
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
define-command -hidden just-indent-on-new-line %{
|
|
|
|
evaluate-commands -draft -itersel %{
|
|
|
|
# preserve previous line indent
|
2019-10-22 12:02:06 +03:00
|
|
|
try %{ execute-keys -draft <semicolon>K<a-&> }
|
2018-02-01 02:33:44 +03:00
|
|
|
# cleanup trailing white spaces on previous line
|
|
|
|
try %{ execute-keys -draft k<a-x> s \h+$ <ret>"_d }
|
|
|
|
# copy '#' comment prefix and following white spaces
|
|
|
|
try %{ execute-keys -draft k <a-x> s ^\h*//\h* <ret> y jgh P }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Highlighters
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2018-07-01 12:53:35 +03:00
|
|
|
add-highlighter shared/justfile regions
|
|
|
|
add-highlighter shared/justfile/content default-region group
|
2018-07-02 13:59:12 +03:00
|
|
|
add-highlighter shared/justfile/comment region '#' '$' fill comment
|
|
|
|
add-highlighter shared/justfile/double_string region '"' (?<!\\)(\\\\)*" fill string
|
|
|
|
add-highlighter shared/justfile/single_string region "'" (?<!\\)(\\\\)*' fill string
|
|
|
|
add-highlighter shared/justfile/inline region '`' '`' ref sh
|
2018-07-01 12:53:35 +03:00
|
|
|
|
2018-11-28 12:39:18 +03:00
|
|
|
add-highlighter shared/justfile/shell region '^\h+' '^[^\h]' group
|
2018-07-01 12:53:35 +03:00
|
|
|
add-highlighter shared/justfile/shell/ ref sh
|
2018-11-28 12:39:18 +03:00
|
|
|
add-highlighter shared/justfile/shell/ regex '(\{{2})([\w-]+)(\}{2})' 1:operator 2:variable 3:operator
|
2018-07-01 12:53:35 +03:00
|
|
|
|
|
|
|
add-highlighter shared/justfile/content/ regex '^(@)?([\w-]+)(?:\s(.+))?\s?(:)(.+)?$' 1:operator 2:function 3:value 4:operator 5:type
|
|
|
|
add-highlighter shared/justfile/content/ regex '([=+])' 1:operator
|
|
|
|
add-highlighter shared/justfile/content/ regex '^([\w-]+)\s=' 1:value
|
2018-02-01 02:33:44 +03:00
|
|
|
|
2019-03-14 00:00:59 +03:00
|
|
|
}
|