axelf4/vim-strip-trailing-whitespace

Does not work in vim without lua compiled in

jototland opened this issue · 8 comments

The plugin fails to load on (regular) Vim without Lua.

Explanation: On line 197 there is a 'has("nvim")'-if-statement, with a lua statement on line 198.

As I understand it, lua is required on neovim because of the listener API, but the plugin itself works fine on regular VIM, without lua, if it wasn't for the offending statement on line 198.

Without lua compiled in, the statement on line 198 is syntactically invalid, and the plugin will fail.

Possible fixes: move the lua-statement to a separate file, or hide it in a string with :execute.

Hmm, it would not surprise me if that were the case but AFAICT it works fine for me on Vim 8.2.13 without the +lua feature. What error are you getting and with what Vim version?

You are right. It is not a syntactical error, and it is not a problem with lua not being compiled in. This seems to be a problem only when lua is dynamically linked into vim, but the correct version of lua is not installed somewhere vim can find it. I tested with two versions of vim for windows.

The version of vim from the windows package manager scoop. When typing :version in vim, I get -lua. This version works fine.

The version of vim from the windows package manager chocolatey. When typing :version in vim, I get +lua/dyn. I get the error message:

Error detected while processing BufEnter Autocommands for "*"..function <SNR>34_OnBufEnter:
line 4:
E370: Could not load library lua53.dll
Lua library cannot be loaded.

The next question would then be: is the problem solved when installing lua53 from chocolatey? And the answer is yes.

I guess you could define this a someone elses fault: either the package managers or vim itself. On the other hand, it should be an easy fix in your code.

I can also mention that the scoop version og gvim has lua dynamically linked. And produces exactly the same error.

@jototland Could you please check if the support-broken-lua branch fixes the problem? Would also be great if the Chocolatey/Scoop packages got fixed.

the problem happened on Vim, not on Neovim (the changes in your commit 0a198ff are all hidden behind if has('nvim'). BTW: The Vim behaviour was just fixed: vim/vim@c8970b9

As chrisbra wrote above, this is now fixed in vim (and he was the one who fixed it).

I've put the following into my vimrc to only load the plugin if you either have neovim, lua, patch-8.2.1908, or if lua is not dynamically loaded.

    if has("nvim") || has("lua") || has("patch-8.2.1908")
        \ || match(execute("version"), "+lua/dyn") ==# -1
        call minpac#add('axelf4/vim-strip-trailing-whitespace')
    endif

I think I will merge the fix anyway to avoid having to bump the minimum supported Vim version.

the problem happened on Vim, not on Neovim (the changes in your commit 0a198ff are all hidden behind if has('nvim').

But that was the bug, wasn't it? Vim tried loading the lua library even though it was behind if.