wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.91k stars 263 forks source link

tree-sitter-refactor fails every first install of packer #102

Open datwaft opened 4 years ago

datwaft commented 4 years ago

Hello, the plugin tree-sitter-refactor fails every first install of packer.

Screenshot ![image](https://user-images.githubusercontent.com/37723586/100273742-e3130480-2f22-11eb-99a9-733c7ebd88b3.png)

But after the first install the plugin works and updates normally.

How to reproduce the bug

To reproduce the bug you should at least have the minimal configuration.

# Uninstall packer like this
rm -rdf ~/.local/share/nvim/site/pack/packer
# Install it like this
git clone https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/opt/packer.nvim

After that enter nvim and do a :PackerInstall.

Minimal configuration

Minimal packer configuration ```lua vim.cmd [[ packadd packer.nvim ]] return require'packer'.startup(function() use { 'wbthomason/packer.nvim', opt = true } use { 'nvim-treesitter/nvim-treesitter' } use { 'nvim-treesitter/nvim-treesitter-refactor', -- Even without the requires it doesn't work requires = 'nvim-treesitter/nvim-treesitter' } use { 'romgrk/nvim-treesitter-context', -- Even without the requires it doesn't work requires = 'nvim-treesitter/nvim-treesitter' } end) ```

Full configuration

Here is the full packer configuration, you can see the whole configuration in my nvim repository here: https://github.com/datwaft/nvim/tree/0afbd5eaba9a01d0788eadbaceafd80e7dbdbb9c

Full packer configuration ```lua vim.cmd [[ packadd packer.nvim ]] vim.cmd [[ autocmd BufWritePost plugins.lua PackerCompile ]] return require'packer'.startup(function() use { 'wbthomason/packer.nvim', opt = true } use { 'svermeulen/vimpeccable' } use { 'bluz71/vim-nightfly-guicolors', config = require'plugins.colorscheme' } use { 'itchyny/lightline.vim', config = require'plugins.lightline' } use { 'markonm/traces.vim' } use { 'kyazdani42/nvim-web-devicons' } use { 'lambdalisue/glyph-palette.vim' } use { 'kshenoy/vim-signature' } use { 'mhinz/vim-signify' } use { 'unblevable/quick-scope', config = require'plugins.quickscope' } use { 'rrethy/vim-hexokinase', run = 'make hexokinase' } use { 'psliwka/vim-smoothie' } use { 'sheerun/vim-polyglot' } use { 'nvim-treesitter/nvim-treesitter', config = require'plugins.treesitter' } use { 'nvim-treesitter/nvim-treesitter-refactor', requires = 'nvim-treesitter/nvim-treesitter' } use { 'romgrk/nvim-treesitter-context', requires = 'nvim-treesitter/nvim-treesitter' } use { 'neoclide/coc.nvim', branch = 'release', config = require'plugins.coc', } use { 'wellle/targets.vim' } use { 'michaeljsmith/vim-indent-object' } use { 'bkad/camelcasemotion', config = require'plugins.camelcasemotion' } use { 'tpope/vim-commentary' } use { 'machakann/vim-sandwich' } use { 'machakann/vim-swap' } use { 'tommcdo/vim-exchange' } use { 'mbbill/undotree' } use { 'lambdalisue/gina.vim' } use { 'tpope/vim-abolish' } use { 'junegunn/fzf', run = function() vim.fn['fzf#install']() end } use { 'junegunn/fzf.vim' } use { 'christoomey/vim-tmux-navigator', config = require'plugins.tmuxnavigator' } use { 'jpalardy/vim-slime', config = require'plugins.slime' } end) ```

messages command

[packer] Error in coroutine: .../pack/packer/opt/packer.nvim/lua/packer/plugin_utils.lua:108: Vim(lua):E5108: Error executing lua ...vim-treesitter-refactor/l
ua/nvim-treesitter-refactor.lua:1: module 'nvim-treesitter.query' not found:^@^Ino field package.preload['nvim-treesitter.query']^@^Ino file './nvim-treesitte
r/query.lua'^@^Ino file '/home/datwaft/downloads/neovim/.deps/usr/share/luajit-2.1.0-beta3/nvim-treesitter/query.lua'^@^Ino file '/usr/local/share/lua/5.1/nvi
m-treesitter/query.lua'^@^Ino file '/usr/local/share/lua/5.1/nvim-treesitter/query/init.lua'^@^Ino file '/home/datwaft/downloads/neovim/.deps/usr/share/lua/5.
1/nvim-treesitter/query.lua'^@^Ino file '/home/datwaft/downloads/neovim/.deps/usr/share/lua/5.1/nvim-treesitter/query/init.lua'^@^Ino file './nvim-treesitter/
query.so'^@^Ino file '/usr/local/lib/lua/5.1/nvim-treesitter/query.so'^@^Ino file '/home/datwaft/downloads/neovim/.deps/usr/lib/lua/5.1/nvim-treesitter/query.
so'^@^Ino file '/usr/local/lib/lua/5.1/loadall.so'^@^Ino file './nvim-treesitter.so'^@^Ino file '/usr/local/lib/lua/5.1/nvim-treesitter.so'^@^Ino file '/home/
datwaft/downloads/neovim/.deps/usr/lib/lua/5.1/nvim-treesitter.so'^@^Ino file '/usr/local/lib/lua/5.1/loadall.so
wbthomason commented 4 years ago

Ah! I see what's going on here. The bad news is I'm not sure what should be done to fix it.

The line throwing the error is one which sources an updated (or just installed) plugin to make it available without a restart. As you guessed in #95, it seems like nvim-treesitter-refactor is getting installed before nvim-treesitter has completed installing (I'm guessing it's a smaller repo or something of the sort) and trying to load nvim-treesitter, which causes this failure.

The conundrum is how to fix this. Options include:

datwaft commented 4 years ago

I would prefer the second one, that is the functionality I would expect from requires or maybe after.

Thanks!

wbthomason commented 4 years ago

Related to existing proposed rework of require semantics in #87.