2018-02-01 00:33:44 +01:00
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global BufCreate .*/?[jJ]ustfile %{
|
|
|
|
set-option buffer filetype justfile
|
|
|
|
}
|
|
|
|
|
2019-04-12 00:54:58 +02:00
|
|
|
hook global WinSetOption filetype=justfile %{
|
2019-03-13 22:00:59 +01:00
|
|
|
require-module justfile
|
2019-04-12 00:54:58 +02:00
|
|
|
|
2022-05-08 15:01:25 +02:00
|
|
|
hook window ModeChange pop:insert:.* -group justfile-trim-indent justfile-trim-indent
|
2023-02-24 08:41:16 +01:00
|
|
|
hook window InsertChar \n -group justfile-insert just-insert-on-new-line
|
2019-04-12 00:54:58 +02: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-13 22:00:59 +01:00
|
|
|
}
|
|
|
|
|
2019-04-12 00:54:58 +02:00
|
|
|
|
2019-03-13 22:00:59 +01:00
|
|
|
provide-module justfile %{
|
|
|
|
|
2018-02-01 00:33:44 +01:00
|
|
|
# Indentation
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2022-05-08 15:01:25 +02:00
|
|
|
define-command -hidden justfile-trim-indent %{
|
|
|
|
evaluate-commands -no-hooks -draft -itersel %{
|
2022-03-16 23:20:07 +01:00
|
|
|
execute-keys x
|
2022-05-08 15:01:25 +02:00
|
|
|
# remove trailing white spaces
|
|
|
|
try %{ execute-keys -draft s \h + $ <ret> d }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-24 08:41:16 +01:00
|
|
|
define-command -hidden just-insert-on-new-line %{
|
|
|
|
# copy '#' comment prefix and following white spaces
|
|
|
|
try %{ execute-keys -draft k x s ^\h*//\h* <ret> y jgh P }
|
|
|
|
}
|
|
|
|
|
2018-02-01 00:33:44 +01:00
|
|
|
define-command -hidden just-indent-on-new-line %{
|
|
|
|
evaluate-commands -draft -itersel %{
|
|
|
|
# preserve previous line indent
|
2019-10-22 11:02:06 +02:00
|
|
|
try %{ execute-keys -draft <semicolon>K<a-&> }
|
2018-02-01 00:33:44 +01:00
|
|
|
# cleanup trailing white spaces on previous line
|
2022-03-16 23:20:07 +01:00
|
|
|
try %{ execute-keys -draft kx s \h+$ <ret>"_d }
|
2018-02-01 00:33:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Highlighters
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2018-07-01 11:53:35 +02:00
|
|
|
add-highlighter shared/justfile regions
|
2020-09-14 23:04:09 +02:00
|
|
|
|
2018-07-01 11:53:35 +02:00
|
|
|
add-highlighter shared/justfile/content default-region group
|
2020-09-14 23:04:09 +02:00
|
|
|
add-highlighter shared/justfile/content/recipe regex '^@?([\w-]+)([^\n]*):(?!=)([^\n]*)' 1:function 2:meta 3:keyword
|
|
|
|
add-highlighter shared/justfile/content/assignments regex ^([\w-]+\h*:=\h*[^\n]*) 1:meta
|
|
|
|
add-highlighter shared/justfile/content/operator regex '((^@|:=|=|\+|\(|\)))' 1:operator
|
|
|
|
add-highlighter shared/justfile/content/strings regions
|
|
|
|
add-highlighter shared/justfile/content/strings/double region '"' (?<!\\)(\\\\)*" fill string
|
|
|
|
add-highlighter shared/justfile/content/strings/single region "'" (?<!\\)(\\\\)*' fill string
|
|
|
|
|
2018-07-02 12:59:12 +02:00
|
|
|
add-highlighter shared/justfile/comment region '#' '$' fill comment
|
2020-09-14 23:04:09 +02:00
|
|
|
|
2018-07-02 12:59:12 +02:00
|
|
|
add-highlighter shared/justfile/inline region '`' '`' ref sh
|
2018-07-01 11:53:35 +02:00
|
|
|
|
2020-09-15 23:10:40 +02:00
|
|
|
add-highlighter shared/justfile/body region '^\h+' '^[^\h]' group
|
|
|
|
add-highlighter shared/justfile/body/interpreters regions
|
|
|
|
add-highlighter shared/justfile/body/interpreters/defaultshell default-region group
|
|
|
|
add-highlighter shared/justfile/body/interpreters/defaultshell/ ref sh
|
|
|
|
add-highlighter shared/justfile/body/interpreters/defaultshell/ regex '^\h+(@)' 1:operator
|
|
|
|
|
2020-09-15 23:17:45 +02:00
|
|
|
add-highlighter shared/justfile/body/interpreters/bash region '^\h+#!\h?/usr/bin/env bash' '^[^\h]' ref sh
|
|
|
|
add-highlighter shared/justfile/body/interpreters/sh region '^\h+#!\h?/usr/bin/env sh' '^[^\h]' ref sh
|
|
|
|
|
2020-09-22 07:24:29 +02:00
|
|
|
add-highlighter shared/justfile/body/ regex '(\{{2})([\w-]+(?:\(\))?)(\}{2})' 1:operator 2:variable 3:operator
|
2018-07-01 11:53:35 +02:00
|
|
|
|
2018-02-01 00:33:44 +01:00
|
|
|
|
2019-03-13 22:00:59 +01:00
|
|
|
}
|