Shougo / dein.vim

:zap: Dark powered Vim/Neovim plugin manager
MIT License
3.42k stars 197 forks source link

Hooks can not be functions #398

Closed hackaugusto closed 3 years ago

hackaugusto commented 3 years ago

Problems summary

The hook documentation says that these hooks can be functions, however, providing a function to a hook results in a runtime error.

Example hook:

https://github.com/Shougo/dein.vim/blob/f817ef6a3a710cd397f538f131385b4fab99e5f8/doc/dein.txt#L879

Code checking the hook type:

https://github.com/Shougo/dein.vim/blob/f817ef6a3a710cd397f538f131385b4fab99e5f8/autoload/dein/util.vim#L334-L339

Expected

Either the hook should be allowed to be a function or the documentation should be updated

Environment Information (Required!)

Provide a minimal .vimrc with less than 50 lines (Required!)

" Your minimal .vimrc
set runtimepath^=~/path/to/dein.nvim/
function TreeSitterUpdateParsers()
endfunction
call dein#begin(path)
call dein#add('nvim-treesitter/nvim-treesitter', {'hook_post_update': function('TreeSitterUpdateParsers')})
call dein#end()

The reproduce ways from Vim starting (Required!)

run call dein#clear_state() and open neovim

Screen shot (if possible)

image

Upload the log messages by :redir and :message (if errored)

[dein] nvim-treesitter: "hook_post_update" must be string

Shougo commented 3 years ago

Please read this.

HOOKS                           *dein-hooks*

        The string will be split by the lines.
        It is useful for the plugins initialization.
        Note: The Function hooks cannot be cached.  You must
        initialize it.
Shougo commented 3 years ago

Please don't make a lie in the minimal vimrc. You have called dein#save_state() in init.vim.

But it is not included in the vimrc. So you have not tested the vimrc.

Either the hook should be allowed to be a function or the documentation should be updated

It cannot be allowed because function objects cannot be cached. It is not magic.