From 51005623ca7ac1fc124880c755bf0554abd5e681 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 8 Nov 2023 14:53:37 +0100 Subject: [PATCH] nano: add syntax highlighting for ucode scripts Introduce local syntax highlighting support for ucode scripts, like it is done already for uci configuration files. Ref: https://github.com/jow-/ucode/issues/178 Signed-off-by: Jo-Philipp Wich (cherry picked from commit d8a574f7f0eb2f5970119a2b0527048583054180) --- utils/nano/Makefile | 3 ++- utils/nano/files/ucode.nanorc | 51 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 utils/nano/files/ucode.nanorc diff --git a/utils/nano/Makefile b/utils/nano/Makefile index e68b289501..4400b780f2 100644 --- a/utils/nano/Makefile +++ b/utils/nano/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=nano PKG_VERSION:=7.2 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/nano @@ -140,6 +140,7 @@ define Package/nano-full/install $(INSTALL_DIR) $(1)/etc $(1)/usr/share/nano $(INSTALL_DATA) ./files/nanorc $(1)/etc/nanorc $(INSTALL_DATA) ./files/uci.nanorc $(1)/usr/share/nano + $(INSTALL_DATA) ./files/ucode.nanorc $(1)/usr/share/nano $(CP) $(PKG_INSTALL_DIR)/usr/share/nano/* $(1)/usr/share/nano endef diff --git a/utils/nano/files/ucode.nanorc b/utils/nano/files/ucode.nanorc new file mode 100644 index 0000000000..96c7848e21 --- /dev/null +++ b/utils/nano/files/ucode.nanorc @@ -0,0 +1,51 @@ +## Syntax highlighting for OpenWrt ucode scripts. + +syntax ucode "/ucode/|\.u[ct]$" +header "^#!.*\" +comment "//" + +# Declarations +color green "\<(let|const|function|this)\>" + +# Arrow functions +color green "(\<\w+\>|\([[:alnum:][:space:]_,.]*\))[[:space:]]*=>" + +# Flow control and keywords +color brightyellow "\<(while|if|else|elif|switch|case|default|for|in|endif|endfor|endwhile|endfunction)\>" +color brightyellow "\<(export|import|try|catch|delete)\>" + +# Exit points +color magenta "\<(break|continue|return)\>" + +# Numeric literals +color cyan "\<([0-9]+\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\>" +color cyan "\<0[xX][[:xdigit:]]+(\.[[:xdigit:]]+)?\>" +color cyan "\<(0[oO][0-7]+|0[bB][01]+|[0-9]+)\>" + +# Special values +color cyan "\<(true|false|null|NaN|Infinity)\>" + +# Strings +color brightmagenta ""([^"\{%#}]|\\.|\{[^"\{%#]|[%#}][^"\}]|[{%#}]\\.)*[{%#}]?"" +color brightmagenta "'([^'\{%#}]|\\.|\{[^'\{%#]|[%#}][^'\}]|[{%#}]\\.)*[{%#}]?'" +color brightmagenta "`([^`\{%#}]|\\.|\{[^`\{%#]|[%#}][^`\}]|[{%#}]\\.)*[{%#}]?`" + +# Template string expressions +color normal start="\$\{" end="}" + +# Comments +color brightblue "(^|[[:blank:]])//.*" +color brightblue start="(^|[[:space:]])/\*" end="\*/" +color brightblue start="\{#" end="#\}" + +# Trailing whitespace. +color ,green "[[:space:]]+$" + +# Text outside template directives +color slate start="[}%#]\}" end="\{[{%#]" +color slate start="^#!" end="\{[{%#]" +color slate "^([^{%#}]|\{[^{%#]|[%#}][^}])+\{[{%#]" + +# Template tags +color white "\{[{%][+-]?|-?[%}]\}" +color brightblue "\{#[+-]?|-?#\}" -- 2.30.2