Closed anntzer closed 8 years ago
I added this fix into this file to test for myself, and it seems to mess up the formatting of float literals, (e.g., with 100.5, the "100" part will be Normal and the ".5" part will be Number). Any thoughts on how to fix this? I'm not that great with regex.
Actually managed to fix it by changing it to
syn match pythonBtInIsolator "\(\.\)\@<!\<\k\+\D\>" contains=pythonBuiltinFunc,pythonStatement
(added \D to the keyword search)
@jevogel Can you create a pull request?
However it seems containedin=pythonBtInIsolator
is redundant and can be removed. And the regexp probably also can be simplified.
So I've tried a simplified version of the patch. It works but it breaks highlighting for numbers even with the fix from @jevogel. For example complex numbers, hexadecimal numbers and error checking for numbers don't work. Also I don't really like to use \@<!
which can be really slow. So I think it's a bad idea to apply the patch.
Can you detail in which aspects complex, hexadecimals and number error checking are broken? They seem to work fine for me with @jevogel's patch. Performance can be improved by only doing 1-character lookbehind, "\(\.\)\@1<!\<\K\+\>"
. (\K = \k but excluding digits)
@anntzer try my fork https://github.com/purpleP/python-syntax.git
congma/vim-syntax-python@21886ee963f4df89b198404ee4cc4165cc476de3 prevents "builtins" from being highlighted when they appear as attributes of another object. It would be nice to port this fix to this repo too.
Note that the fix is incomplete as it assumes there are no spaces around the dot, whereas python actually allows arbitrary whitespace there (subject to normal line continuation rules).