Closed purpleP closed 7 years ago
I think they're great, but options are welcome.
Is there anything specific now that hasn't got an option?
Btw, I had to remove the kwargs highlighting as it was buggy. A better implementation is welcome though.
@nfnty Buggy? Hmm, it works for me. Show me example where it wasn't working. By the way it wouldn't work in the case where the open parenthesis isn't visible in the screen and that's by design (performance)
There are a lot of cases being mishighlighted. Anything matching \i\+=
is highlighted, even though not being a kwarg: test((test=test))
, test({test=})
etc. The implementation is very fragile and prone to breakage. To implement this properly would mean needing to parse exactly like the interpreter.
@nfnty Well, both of you examples aren't valid python. I think it's reasonable compromise to expect invalid python to be highlighted improperly. By the same reasoning you can disable highlighting of python keywords, because in blabla def some
def
would be highlighted as a keyword.
However if you have examples of valid python code that would be highlighted improperly I would try to cover them.
test(var=='test')
The kwarg mishighlighting is only the minor problem for now. The regions are being misapplied, which will introduce problems down the road.
@nfnty Well, that code isn't pythonformat comliant, right? But anyway, this particular case is easy to fix. What about regions being misapplied?
@nfnty
diff --git a/syntax/python.vim b/syntax/python.vim index 752ce01..b783f2d 100644 --- a/syntax/python.vim +++ b/syntax/python.vim @@ -217,7 +217,7 @@ syn region FunctionParameters start='(' end=')' display contains= \ pythonNone, \ pythonBuiltinFunc, \ pythonBoolean nextgroup=pythonRaiseFromStatement display contained -syn match OptionalParameters /\i\ze=/ display contained +syn match OptionalParameters /\i\ze=(=)\@!/ display contained " " Decorators (new in Python 2.4) " I just added negative lookahead.
It's valid Python code, also highlighting should be as strict as possible.
Use commit c8300301fb9e2c18988eac4f15c0e15e4abd48bd (commit before removal) so that we're talking about the same thing.
test((test, test))
^^^^^^^^^^^^
The marked area is being matched as a pythonFunctionArgs
region, when it's not. It's not simple to fix properly as that would entail parsing for functions inside the function args.
BTW, you can use the plugin gerw/vim-HiLinkTrace to trace highlighting.
Continue discussion in #14.
I've added some highlightings that I like, but not everyone might like them. So here's a screenshot that displays all the features I've added.
We can make syntax file more customizable on demand (as soon as anyone will ask for it I mean).