-
Notifications
You must be signed in to change notification settings - Fork 119
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
[WIP] Use function name for decorators #335
Conversation
@@ -8,7 +8,7 @@ deps= | |||
pytest | |||
pytest-xdist | |||
pyuv: pyuv | |||
commands=python -m pytest -s | |||
commands=python -m pytest -s {posargs} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm adding this so I can do tox -e py36 test/test_decorators.py
'sync': rpc_sync, | ||
'opts': opts | ||
} | ||
return f | ||
return dec | ||
|
||
|
||
def capitalize_name(name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like this kind of magic. For plugins that use this, it would be better to break python conventions and name the implementation function literally what the vimL side name is. Also, _
is not forbidden in vimL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, a matter of style I think. I would no like to have a function/command named My_function_something
, and you can still pass a name if people want that name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referential transparency is more important than style. If an rplugin defines MySpecialCommand
to users, I would expect to find that name literally in the source, much more often than not.
'sync': rpc_sync, | ||
'opts': opts | ||
} | ||
return f | ||
return dec | ||
|
||
|
||
def autocmd(name, pattern='*', sync=False, allow_nested=False, eval=None): | ||
def autocmd(name=None, pattern='*', sync=False, allow_nested=False, eval=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be a concern that a plugin potentially can have multiple implementations of the autocmd with disjoint patterns. At least there should be a warning in the docs. (python doesn't give a warning on method shadowing, though we could hack it with a metaclass).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure about the autocmd, it doesn't have much sense here I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the parameter should be named event
, that's why I was confused here.
neovim/neovim#27949 will greatly simplify the implementation and interface of remote plugins, and will remove the need for decorators (which are just sugar to do things that can/should be done in the plain Lua part of a remote plugin). |
Sometimes is kind of redundant to write the function/command/autocmd name on each decorator. Also, this can help with cases like #334.
Please, let me know if you want this feature so, I can continue :), thanks
What is missing?