junegunn / vim-plug

:hibiscus: Minimalist Vim Plugin Manager
https://junegunn.github.io/vim-plug/
MIT License
33.89k stars 1.9k forks source link

Why use `plug#()` as a function name ? #1195

Closed sisrfeng closed 5 months ago

sisrfeng commented 2 years ago

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

FrodoBaggins74524 commented 1 year ago

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 () and is called when the Plug command is executed in Vim.

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.

junegunn commented 5 months ago