Skip to content

Commit e39f11e

Browse files
committed
Add support for broken Vim Lua installs
Just parsing the :lua command, with it never being evaluated, can cause the error E370: Could not load library lua53.dll Lua library cannot be loaded. if Vim is missing patch 8.2.1908 and compiled with the +lua/dyn feature, but Lua is unavailable. This commit fixes the issue by wrapping the command in :execute. Closes: #6
1 parent 6d235b4 commit e39f11e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

plugin/strip_trailing_whitespace.vim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,12 @@ function s:OnBufEnter() abort
195195
if exists('b:stw_root') | return | endif
196196
let [b:stw_root, b:stw_count] = [v:null, 0]
197197
if has('nvim')
198-
lua vim.api.nvim_buf_attach(0, false, {
198+
" Parsing the lua Ex command can fail on broken Vim <8.2.1908 installs
199+
execute 'lua vim.api.nvim_buf_attach(0, false, {
199200
\ on_lines = function(_, bufnr, _, firstline, lastline, new_lastline)
200201
\ vim.api.nvim_call_function("StripTrailingWhitespaceListener", {bufnr, firstline + 1, lastline + 1, new_lastline - lastline,
201202
\ {{lnum = firstline + 1, ["end"] = lastline + 1, added = new_lastline - lastline, col = 1}}})
202-
\ end, })
203+
\ end, })'
203204
else
204205
call listener_add('StripTrailingWhitespaceListener')
205206
endif

0 commit comments

Comments
 (0)