vim-python / python-syntax

Python syntax highlighting for Vim
MIT License
438 stars 84 forks source link

Numbers with a trailing dot (eg. `1.`) should be highlighted as floats, not as ints #41

Closed anntzer closed 5 years ago

anntzer commented 6 years ago

... because they are floats, not ints.

anntzer commented 6 years ago

I think just

diff --git a/syntax/python.vim b/syntax/python.vim
index 913da9d..72d13c4 100644
--- a/syntax/python.vim
+++ b/syntax/python.vim
@@ -326,7 +326,7 @@ else

   syn match   pythonFloat       '\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=\>' display
   syn match   pythonFloat       '\<\d\%([_0-9]*\d\)\=[eE][+-]\=\d\%([_0-9]*\d\)\=[jJ]\=\>' display
-  syn match   pythonFloat       '\<\d\%([_0-9]*\d\)\=\.\d\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=' display
+  syn match   pythonFloat       '\<\d\%([_0-9]*\d\)\=\.\d\=\%([_0-9]*\d\)\=\%([eE][+-]\=\d\%([_0-9]*\d\)\=\)\=[jJ]\=' display
 endif

 "

(i.e. adding a \= after the \d after the decimal dot) fixes the issue.

nfnty commented 6 years ago

Open a PR and I'll merge it.

anntzer commented 6 years ago

Please apply the patch above.

nfnty commented 5 years ago

Thanks!