commit 69758e29182a1e5a5184f61e167402b998c70c1b
parent c81ff490dce22e31d63d74f2955f29eecf0b11a3
Author: zeertzjq <zeertzjq@outlook.com>
Date: Thu, 4 Dec 2025 08:51:32 +0800
vim-patch:85fc83f: runtime(sml): Update syntax, improve special constant matching
- Match \dE\d real literal form
- Match all string escape sequences
- Add related tests
closes: vim/vim#18723
https://github.com/vim/vim/commit/85fc83f8490b957e3dbb3b7f51fbd7264a7208b6
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
Diffstat:
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/runtime/syntax/sml.vim b/runtime/syntax/sml.vim
@@ -3,7 +3,8 @@
" Filenames: *.sml *.sig
" Maintainer: Markus Mottl <markus.mottl@gmail.com>
" Previous Maintainer: Fabrizio Zeno Cornelli <zeno@filibusta.crema.unimi.it> (invalid)
-" Last Change: 2025 Nov 07 - Update Number Regex
+" Last Change: 2025 Nov 11 - Improve special constant matching (Doug Kearns)
+" 2025 Nov 07 - Update Number Regex
" 2022 Apr 01
" 2015 Aug 31 - Fixed opening of modules (Ramana Kumar)
" 2006 Oct 23 - Fixed character highlighting bug (MM)
@@ -137,9 +138,25 @@ syn match smlConstructor "\u\(\w\|'\)*\>"
" Module prefix
syn match smlModPath "\u\(\w\|'\)*\."he=e-1
-syn match smlCharacter +#"\\""\|#"."\|#"\\\d\d\d"+
-syn match smlCharErr +#"\\\d\d"\|#"\\\d"+
-syn region smlString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell
+" Strings and Characters
+syn match smlEscapeErr "\\." contained
+syn match smlEscape "\\[abtnvfr"\\]" contained
+syn match smlEscapeErr "\\^." contained
+syn match smlEscape "\\^[@A-Z[\\\]^_]" contained
+syn match smlEscapeErr "\\\d\{1,2}" contained
+syn match smlEscape "\\\d\{3}" contained
+syn match smlEscapeErr "\\u\x\{0,3}" contained
+syn match smlEscape "\\u\x\{4}" contained
+syn match smlEscape "\\\_[[:space:]]\+\\" contained
+syn cluster smlEscape contains=smlEscape,smlEscapeErr
+
+syn region smlString start=+"+ end=+"+ contains=@smlEscape,@Spell
+
+syn match smlCharacter +#"[^\\"]"+
+syn match smlCharacter +#"\\."+ contains=@smlEscape
+syn match smlCharacter +#"\\^."+ contains=@smlEscape
+syn match smlCharacter +#"\\\d\{3}"+ contains=@smlEscape
+syn match smlCharacter +#"\\u\x\{4}"+ contains=@smlEscape
syn match smlFunDef "=>"
syn match smlRefAssign ":="
@@ -156,7 +173,8 @@ syn match smlNumber "\~\=\<\d\+\>"
syn match smlNumber "\~\=\<0x\x\+\>"
syn match smlWord "\<0w\d\+\>"
syn match smlWord "\<0wx\x\+\>"
-syn match smlReal "\~\=\<\d\+\.\d\+\%([eE]\~\=\d\+\)\=\>"
+syn match smlReal "\~\=\<\d\+\.\d\+\>"
+syn match smlReal "\~\=\<\d\+\%(\.\d\+\)\=[eE]\~\=\d\+\>"
" Synchronization
syn sync minlines=20
@@ -181,7 +199,7 @@ hi def link smlCommentErr Error
hi def link smlEndErr Error
hi def link smlThenErr Error
-hi def link smlCharErr Error
+hi def link smlEscapeErr Error
hi def link smlComment Comment
@@ -213,6 +231,7 @@ hi def link smlNumber Number
hi def link smlWord Number
hi def link smlReal Float
hi def link smlString String
+hi def link smlEscape Special
hi def link smlType Type
hi def link smlTodo Todo
hi def link smlEncl Keyword