From 8ad6746cc884acfa09e4fb954f38917b3d4cf90c Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 15 Apr 2020 01:02:10 +0200 Subject: [PATCH 1/2] Add basic highlighting for meson --- rc/filetype/meson.kak | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 rc/filetype/meson.kak diff --git a/rc/filetype/meson.kak b/rc/filetype/meson.kak new file mode 100644 index 00000000..00f91a51 --- /dev/null +++ b/rc/filetype/meson.kak @@ -0,0 +1,50 @@ +# meson syntax highlighting for kakoune (https://mesonbuild.com) +# +# For reference see: +# https://mesonbuild.com/Syntax.html +# https://github.com/mesonbuild/meson/blob/master/data/syntax-highlighting/vim/syntax/meson.vim + +## Detection + +hook global BufCreate (.*/|^)meson\.build %{ + set-option buffer filetype meson +} + +## Initialization + +hook -group meson-highlight global WinSetOption filetype=meson %{ + require-module meson + add-highlighter window/meson ref meson + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/meson } +} + +provide-module meson %§ + +## Highlighters + +add-highlighter shared/meson regions +add-highlighter shared/meson/code default-region group + +add-highlighter shared/meson/comment region '(\h|^)#' '$' fill comment + +# TODO: highlight escape sequences within strings +add-highlighter shared/meson/string_multiline region "'''" "'''" fill string +add-highlighter shared/meson/string_single region "'" (?|\?|:)' 0:operator +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 + +§ From b0fb7fce63993f7e967b82a7b58726c0186c90e3 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 15 Apr 2020 02:49:21 +0200 Subject: [PATCH 2/2] Highlight meson_options.txt as well --- rc/filetype/meson.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/filetype/meson.kak b/rc/filetype/meson.kak index 00f91a51..06c8af79 100644 --- a/rc/filetype/meson.kak +++ b/rc/filetype/meson.kak @@ -6,7 +6,7 @@ ## Detection -hook global BufCreate (.*/|^)meson\.build %{ +hook global BufCreate (.*/|^)(meson\.build|meson_options\.txt) %{ set-option buffer filetype meson }