summaryrefslogtreecommitdiff
path: root/rc/filetype/meson.kak
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2021-01-13 15:43:20 +0100
committerIsaac Freund <ifreund@ifreund.xyz>2021-01-13 15:44:38 +0100
commit233b9902751e8038776a33b6b63dc4f63ca61850 (patch)
tree27f163a807ac45cc23dd84d09bbf0a7c8f968e0c /rc/filetype/meson.kak
parentdf7b33bc7b9da897d1d0127b54ae1e629d2334ff (diff)
meson: improve highlighting, add static words
Now all functions are highlighted and builtins are highlighted with their own face.
Diffstat (limited to 'rc/filetype/meson.kak')
-rw-r--r--rc/filetype/meson.kak41
1 files changed, 34 insertions, 7 deletions
diff --git a/rc/filetype/meson.kak b/rc/filetype/meson.kak
index 06c8af79..362af325 100644
--- a/rc/filetype/meson.kak
+++ b/rc/filetype/meson.kak
@@ -14,6 +14,9 @@ hook global BufCreate (.*/|^)(meson\.build|meson_options\.txt) %{
hook -group meson-highlight global WinSetOption filetype=meson %{
require-module meson
+
+ set-option window static_words %opt{meson_static_words}
+
add-highlighter window/meson ref meson
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/meson }
}
@@ -31,12 +34,6 @@ add-highlighter shared/meson/comment region '(\h|^)#' '$' fill comment
add-highlighter shared/meson/string_multiline region "'''" "'''" fill string
add-highlighter shared/meson/string_single region "'" (?<!\\)(\\\\)*' fill string
-# control flow
-add-highlighter shared/meson/code/ regex '\b(?:if|else|endif|elif|foreach|endforeach|break|continue)\b' 0:keyword
-
-# primitive values
-add-highlighter shared/meson/code/ regex '\b(?:true|false)\b' 0:value
-
# integer literals
add-highlighter shared/meson/code/ regex '\b\d+\b' 0:value
@@ -45,6 +42,36 @@ add-highlighter shared/meson/code/ regex '(?:\+|-|\*|/|%|!=|=|<|>|\?|:)' 0:opera
add-highlighter shared/meson/code/ regex '\b(?:and|not|or|in)\b' 0:operator
# functions
-add-highlighter shared/meson/code/ regex "(?:add_global_arguments|add_global_link_arguments|add_languages|add_project_arguments|add_project_link_arguments|add_test_setup|alias_target|assert|benchmark|both_libraries|build_machine|build_target|configuration_data|configure_file|custom_target|declare_dependency|dependency|disabler|environment|error|executable|files|find_library|find_program|generator|get_option|get_variable|gettext|host_machine|import|include_directories|install_data|install_headers|install_man|install_subdir|is_disabler|is_variable|jar|join_paths|library|meson|message|option|project|run_command|run_target|set_variable|shared_library|shared_module|static_library|subdir|subdir_done|subproject|summary|target_machine|test|vcs_tag|warning)\b" 0:function
+add-highlighter shared/meson/code/ regex "\b(\w+)\(" 1:function
+
+evaluate-commands %sh{
+ values="true false"
+
+ keywords="if else endif elif foreach endforeach break continue"
+
+ builtins="add_global_arguments add_global_link_arguments add_languages
+ add_project_arguments add_project_link_arguments add_test_setup
+ alias_target assert benchmark both_libraries build_machine build_target
+ configuration_data configure_file custom_target declare_dependency
+ dependency disabler environment error executable files find_library
+ find_program generator get_option get_variable gettext host_machine
+ import include_directories install_data install_headers install_man
+ install_subdir is_disabler is_variable jar join_paths library meson
+ message option project run_command run_target set_variable shared_library
+ shared_module static_library subdir subdir_done subproject summary
+ target_machine test vcs_tag warning"
+
+ join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
+
+ # Add the language's grammar to the static completion list
+ printf %s\\n "declare-option str-list meson_static_words $(join "${values} ${keywords} ${builtins}" ' ')"
+
+ # Highlight keywords
+ printf %s "
+ add-highlighter shared/meson/code/ regex '\b($(join "${values}" '|'))\b' 0:value
+ add-highlighter shared/meson/code/ regex '\b($(join "${keywords}" '|'))\b' 0:keyword
+ add-highlighter shared/meson/code/ regex '\b($(join "${builtins}" '|'))\b\(' 1:builtin
+ "
+}
ยง