Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix a loader bug: from_lua #820

Merged
merged 2 commits into from
Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/luasnip.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*luasnip.txt* For NVIM v0.8.0 Last change: 2023 March 08
*luasnip.txt* For NVIM v0.8.0 Last change: 2023 March 11

==============================================================================
Table of Contents *luasnip-table-of-contents*
Expand Down
8 changes: 3 additions & 5 deletions lua/luasnip/loaders/from_lua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ local M = {}

local function load_files(ft, files, add_opts)
for _, file in ipairs(files) do
local func_string = path_mod.read_file(file)

local load_ok, func = pcall(loadstring, func_string)
if not load_ok then
local func, error_msg = loadfile(file)
if error_msg then
log.error("Failed to load %s\n: %s", file, func)
error("Failed to load " .. file .. "\n: " .. func)
error(string.format("Failed to load %s\n: %s", file, func))
end

-- the loaded file may add snippets to these tables, they'll be
Expand Down