-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Source lua files (if any) from rtp when loading a plugin #1157
Conversation
Neovim 0.5.0 allows lua files to be used in runtime files (such as plugin, ftdetect, etc.) as well as vimscript files. Indeed, some plugins have `plugin/*.lua` scripts only, but not `plugin/*.vim`; such plugins cannot be sourced and work properly if it is lazy-loaded.
I think this still would need more thoroughly tested, but not sure how I would cover all the possible scenarios. It looks like that this has only in effect when it comes to lazy-loading (or manually calling |
Any plan to merg this PR? |
I don't use Neovim anymore, so I can't verify if it works as described. But if any of you can test it and confirm that it works, I'll merge the PR. |
" it seems that the plugin/*.lua runtime files are being sourced even without this patch (not sure why and where it happens...)" I thinks this is neovim's behavior, once you add plugin's directory into It is easy to test Use following script as neovim's config, set nocompatible
"telescope
execute 'set runtimepath+='.$HOME.'/.vim/bundle/plenary.nvim'
execute 'set runtimepath+='.$HOME.'/.vim/bundle/telescope.nvim'
filetype plugin indent on
syntax on
syntax enable
set background=dark
set termguicolors
colorscheme default
set t_Co=256
Here is the start log:
|
Why we need this PR? I found some of neovim plugins can't be lazy loaded using vim-plug. Following is an example code of lazy loading. "Do not load plugin by default.
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate', 'on': []}
Plug 'nvim-treesitter/nvim-treesitter-refactor', {'on': []}
Plug 'nvim-treesitter/nvim-treesitter-context', {'on': []}
function! LoadPlugins(timer) abort
call plug#load(['nvim-treesitter', 'nvim-treesitter-refactor', 'nvim-treesitter-context'])
"require setup module of treesittier(lua/treesittier_nvim.lua)
call v:lua.require("treesittier_nvim")
endfunction
"run LoadPlugins function after 300ms
call timer_start(300, function('LoadPlugins'), {'repeat': 1}) Following plugins only have lua files in
After apply this PR, plugins that are mentioned above can be lazy-loaded, I think this PR is OK to merge. |
It does not, unfortunately. I mean—it's not enough for the Their README recommends the following: Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Note there's no Lines 1056 to 1061 in 154f60b
runtimepath isn't updated as it doesn't need to change (s:loaded[name] == 1 ). Neovim, however, seems to cache the available lua modules (lua/*.lua , not plugin/*.lua ) only when runtimepath is (re)set (more about this at https://neovim.io/doc/user/lua.html#lua-package-path). So when plugin/nvim-treesitter.lua tries to require("nvim-treesitter").setup() , it fails:
Adding If anyone wants to play in the same environment I'm doing this in, then: FROM debian:unstable@sha256:0862a2d6f153cb5287d7a4e25869cb5a8852765e62ff370e970d9cfcc26658aa
RUN apt-get update -y
RUN apt-get install -q -y curl git build-essential
RUN curl -LSsf https://github.com/neovim/neovim/releases/download/v0.9.4/nvim-linux64.tar.gz | tar xz
RUN sh -c 'curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/154f60b7ecbfb158a497e751aacab590247c69d4/plug.vim'
RUN mkdir -p ~/.config/nvim \
&& echo "call plug#begin()" >>~/.config/nvim/vimrc.vim \
&& echo "Plug 'nvim-treesitter/nvim-treesitter', #{do: ':TSUpdate', commit: '075a64addc33390028ea124a1046a43497f05cd1'}" >>~/.config/nvim/vimrc.vim \
&& echo "call plug#end()" >>~/.config/nvim/vimrc.vim \
&& echo "vim.cmd.source(vim.fn.stdpath('config') .. '/vimrc.vim')" >>~/.config/nvim/init.lua \
&& : docker build -t nvim-treesitter-lua-bug .
docker run --rm -it nvim-treesitter-lua-bug:latest |
Merged, thank you all for your help! |
Neovim 0.5.0 allows lua files to be used in runtime files (such as
plugin, ftdetect, etc.) as well as vimscript files. Indeed, some
plugins have
plugin/*.lua
scripts only, but notplugin/*.vim
;such plugins cannot be sourced and work properly if it is lazy-loaded.