vim-plug
vim-plug copied to clipboard
Why use `plug#()` as a function name ?
The function name plug#()
seems a little strange, and it's my first time to see such name in vimL.
Is it like plug#a_func()
, but a_func
becomes empty string?
Is there any trick that you use such a name?
https://github.com/junegunn/vim-plug/blob/8fdabfba0b5a1b0616977a32d9e04b4b98a6016a/plug.vim#L266
The function name plug#() might seem a little strange, but in VimL (Vim Scripting Language), it's a valid function name. It's not a call to another function like a_func(), but rather it's the actual name of the function being defined.
In VimL, function names can contain special characters like #, and they are not limited to alphanumeric characters. As a plugin author, I might use such names to avoid potential naming conflicts with other functions or scripts.
To understand how the function works, I would need to look at its implementation within the vim-plug plugin codebase. Unfortunately, the provided code snippet only shows the command definition, not the actual function implementation.
To find out how the function works, I would need to locate its implementation within the vim-plug plugin codebase, typically in the same file or in a file included by the plugin. From the command definition, I can see that the function takes arguments (
Regarding naming conventions, there is no strict rule for using special characters like # in function names in VimL. However, it's common for plugin authors like me to use such characters to indicate that the function is part of a plugin and not a standard Vim function.
In summary, the function name plug#() is valid VimL syntax and is used in the context of the vim-plug plugin. To understand its behavior fully, I would need to find its implementation within the plugin's codebase.
- It's a part of the public API so I have two choices. 1. a name that starts with an uppercase letter, or 2. a name that starts with
plug#
prefix that matches the name of the file. - Other functions have
plug#
prefix, so using the prefix is more consistent - It's a function backing
Plug
command, so I decided to name itplug#
to match that. Yeah, it's a bit weird but I liked it better than something likeplug#add
.