hare.vim

[vim] Hare vim plugin
git clone https://git.torresjrjr.com/hare.vim.git
Log | Files | Refs | README | LICENSE

commit 38e7db637b68e1fa944ed0fe9be61159b663e820
parent d2dd8c098fa7b294235c4d9fb27ca526f6ad9fe4
Author: Amelia Clarke <me@rsaihe.dev>
Date:   Mon, 22 Aug 2022 19:45:43 -0700

syntax: reorganize number literals

This commit completely reorganizes the syntax highlighting for number
literals. The hareNumbers highlight group has been removed, as it is
unnecessary. Additionally, the hareFloat group is now linked to Float
rather than Number to better match the semantics of the default
highlight groups.

The syntax detection for floating-point numbers occurs later in the file
so as to prevent digits before and after '.' from being recognized as
two separate numbers.

Signed-off-by: Amelia Clarke <me@rsaihe.dev>

Diffstat:
Msyntax/hare.vim | 26++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/syntax/hare.vim b/syntax/hare.vim @@ -36,19 +36,15 @@ syn match hareQuestionMark "?" syn region hareString start=+\z(["']\)+ end=+\z1+ skip=+\\\\\|\\\z1+ contains=hareEscape syn region hareString start=+`+ end=+`+ contains=hareEscapeRaw -"adapted from c.vim -"integer number, or floating point number without a dot and with "f". -syn match hareNumbers display transparent "\v<\d" contains=hareNumber,hareOctal,hareBinary,hareFloat -syn match hareNumber display contained "\v\d+([Ee][-+]?\d+)?(z|[iu](8|16|32|64)?)?" -"hex number -syn match hareNumber display contained "\v0x\x+(z|[iu](8|16|32|64)?)?" -"octal number -syn match hareOctal display contained "\v0o\o+(z|[iu](8|16|32|64)?)?" -"binary number -syn match hareBinary display contained '\v0b[01]+(z|[iu](8|16|32|64)?)?' -syn match hareFloat display contained "\v\d+([Ee][-+]?\d+)?(f32|f64)" -"floating point number, with dot, optional exponent -syn match hareFloat display contained "\v\d+\.\d+([Ee][-+]?\d+)?(f32|f64)?" +" Number literals. +syn match hareNumber "\v(\.@1<!|\.\.)\zs<\d+([Ee][+-]?\d+)?(z|[iu](8|16|32|64)?)?>" display +syn match hareNumber "\v(\.@1<!|\.\.)\zs<0b[01]+(z|[iu](8|16|32|64)?)?>" display +syn match hareNumber "\v(\.@1<!|\.\.)\zs<0o\o+(z|[iu](8|16|32|64)?)?>" display +syn match hareNumber "\v(\.@1<!|\.\.)\zs<0x\x+(z|[iu](8|16|32|64)?)?>" display + +" Floating-point number literals. +syn match hareFloat "\v<\d+\.\d+([Ee][+-]?\d+)?(f32|f64)?>" display +syn match hareFloat "\v<\d+([Ee][+-]?\d+)?(f32|f64)>" display syn match hareSpaceError display excludenl "\v\s+$" syn match hareSpaceError display "\v +\t"me=e-1 @@ -68,17 +64,15 @@ syn keyword hareType valist syn keyword hareNull null syn keyword hareBoolean true false -hi def link hareBinary Number hi def link hareBoolean Boolean hi def link hareBuiltin Function hi def link hareComment Comment hi def link hareConditional Conditional -hi def link hareFloat Number +hi def link hareFloat Float hi def link hareKeyword Keyword hi def link hareLabel Label hi def link hareNull Constant hi def link hareNumber Number -hi def link hareOctal Number hi def link hareOperator Operator hi def link harePreProc PreProc hi def link hareQuestionMark Special