Shougo / dein.vim

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

gitsigns.nvim installed with dein.vim outputs error messages #452

Closed ogaken-1 closed 2 years ago

ogaken-1 commented 2 years ago

Warning: I will close the bug issue without the minimal init.vim and the reproduce ways.

Problems summary

When opening a file under git management with gitsigns.nvim running, an error message is output and gitsigns.nvim does not work.

This did not occur when gitsigns.nvim was installed by several ways other than dein.vim.

Expected

When a file under git control is opened, no error message should be output and the git status should be displayed in signcolumn.

Environment Information (Required!)

NVIM v0.7.0-dev Build type: RelWithDebInfo LuaJIT 2.1.0-beta3 Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-hRSI9h/neovim-0.7.0~ubuntu1+git202204091504-8055f9857-dd05b3569=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=malloc -Wsuggest-attribute=cold -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/neovim-hRSI9h/neovim-0.7.0~ubuntu1+git202204091504-8055f9857-dd05b3569/build/config -I/build/neovim-hRSI9h/neovim-0.7.0~ubuntu1+git202204091504-8055f9857-dd05b3569/src -I/build/neovim-hRSI9h/neovim-0.7.0~ubuntu1+git202204091504-8055f9857-dd05b3569/.deps/usr/include -I/usr/include -I/build/neovim-hRSI9h/neovim-0.7.0~ubuntu1+git202204091504-8055f9857-dd05b3569/build/src/nvim/auto -I/build/neovim-hRSI9h/neovim-0.7.0~ubuntu1+git202204091504-8055f9857-dd05b3569/build/include Compiled by buildd@ubuntu

Features: +acl +iconv +tui See ":help feature-compile"

  システム vimrc: "$VIM/sysinit.vim"
   省略時の $VIM: "/usr/share/nvim"

Run :checkhealth for more info


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

init.vim

```vim
const s:vimdir = fnamemodify(expand('<sfile>'), ':h')
const s:deinpath = s:vimdir . '/dein.vim'
const s:deincache = s:vimdir . '/cache'

if !isdirectory(s:deinpath)
        execute '!git clone https://github.com/Shougo/dein.vim.git ' . s:deinpath
endif
execute 'set runtimepath^=' . s:deinpath

" ----------------- dein install start -----------------
call dein#begin(s:deincache)

call dein#add('lewis6991/gitsigns.nvim')

call dein#end()

if dein#check_install() | call dein#install() | endif
" ----------------- dein install end -----------------

lua require('gitsigns').setup()

The reproduce ways from Vim starting (Required!)

  1. create a new directory and move there
  2. put the above init.vim
  3. execute git init
  4. execute nvim -Nu init.vim init.vim

Screen shot (if possible)

deinvim

vimplug

no-pkgman

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

:mes

Error executing luv callback:
.../dein/cache/.cache/init.vim/.dein/lua/gitsigns/async.lua:75: The coroutine failed with this message: [string ":lua"]:4: E5560: vimL function must not be called in a lua loop callback
stack traceback:
        [C]: in function 'require'
        ...t/dein/cache/.cache/init.vim/.dein/lua/gitsigns/diff.lua:8: in function 'run_diff'
        ...ein/cache/.cache/init.vim/.dein/lua/gitsigns/manager.lua:221: in function 'fn'
        ...in/cache/.cache/init.vim/.dein/lua/gitsigns/debounce.lua:71: in function 'update'
        ...s-test/dein/cache/.cache/init.vim/.dein/lua/gitsigns.lua:296: in function 'attach0'
        ...s-test/dein/cache/.cache/init.vim/.dein/lua/gitsigns.lua:344: in function 'attach'
        ...s-test/dein/cache/.cache/init.vim/.dein/lua/gitsigns.lua:567: in function <...s-test/dein/cache/.cache/init.vim/.dein/lua/gitsigns.lua:505>
stack traceback:
        [C]: in function 'error'
        .../dein/cache/.cache/init.vim/.dein/lua/gitsigns/async.lua:75: in function 'callback'
        ...st/dein/cache/.cache/init.vim/.dein/lua/gitsigns/git.lua:183: in function 'callback'
        .../cache/.cache/init.vim/.dein/lua/gitsigns/subprocess.lua:66: in function <.../cache/.cache/init.vim/.dein/lua/gitsigns/subprocess.lua:52>
lewis6991 commented 2 years ago

Reduced minimal init.vim that doesn't require gitsigns:

const s:vimdir = fnamemodify(expand('<sfile>'), ':h')
const s:deinpath = s:vimdir . '/dein.vim'
const s:deincache = s:vimdir . '/cache'

if !isdirectory(s:deinpath)
        execute '!git clone https://github.com/Shougo/dein.vim.git ' . s:deinpath
endif
execute 'set runtimepath^=' . s:deinpath

" ----------------- dein install start -----------------
call dein#begin(s:deincache)
call dein#end()

lua << EOF
local timer = vim.loop.new_timer()
timer:start(0, 0, function()
  timer:stop()
  timer:close()
  require('vim.lsp')
end)

EOF
lewis6991 commented 2 years ago

Problem is here: https://github.com/Shougo/dein.vim/blob/fe4ba1b8916a4d64373a9bd28e0489df3fdeaef2/autoload/dein/min.vim#L50-L57

Don't call vim.fn in a package loader. This prevents require from being used in a fast event.

Shougo commented 2 years ago

OK. It is bug of dein.vim. It is hard to fix though...

Shougo commented 2 years ago

Fixed.