Skip to content

Add highlight for extra operators #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Add highlight for extra operators #9

wants to merge 1 commit into from

Conversation

monkoose
Copy link
Contributor

@monkoose monkoose commented Feb 23, 2017

Simplest possible solution for this proposal, will match any number of any characters in -+\*/%<>^&|~!= where \* is just *. Now it can match any of bitwise, comparison, extended assignment operators. Am i missing anything? But as said it will match any number of characters, should we update Error section for any possible error like <=>, => etc or it would be too verbose. And if you type something like this you just don't know python, and we here create syntax highlighting not an helper for newbies? But obviosly it will help to find misstypes.

Needs better description in README. I don't know how to describe this highlight group properly.

@nfnty
Copy link
Member

nfnty commented Feb 23, 2017

This is not a good implementation. All matches need to be exact. It's the linter's job to warn about mistyped operators.

@monkoose
Copy link
Contributor Author

monkoose commented Feb 23, 2017

Hm, i do not agree. You can't use any of this characters in your code in other situations then operators(and comment and strings have precedance over them). And it will be more complex to implement each operator because you actually can write things like that a+b a+10 a + b a+'hello' a > b a >= b a >>= b etc etc. It's possible but will be complex regexs for no reason.
Do you see any problem wit hcurrent impementation, can you desribe atleast one?

@nfnty
Copy link
Member

nfnty commented Feb 23, 2017

Reason is that you don't want highlighting for bogus operators, so that you can immediately see if you've typed something that isn't a builtin operator, like ! or >>=.

The regex won't be very complex at all, as anything that can be broken down into other operators won't need to be added. Just add everything from this list: https://docs.python.org/3/library/operator.html#mapping-operators-to-functions

Also call the option variable g:python_highlight_operators.

@nfnty nfnty closed this in f7105bd Feb 24, 2017
@nfnty
Copy link
Member

nfnty commented Feb 24, 2017

It's now implemented with proper error highlighting.

@monkoose
Copy link
Contributor Author

@nfnty >>= and <<= are actual assignment operators
https://docs.python.org/3/c-api/number.html#c.PyNumber_InPlaceLshift

@nfnty
Copy link
Member

nfnty commented Feb 24, 2017

My bad, I'll fix it.

@monkoose monkoose deleted the extraoperators branch February 25, 2017 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants