Skip to content
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

refactor(lua): call loadfile internally instead of luaL_loadfile #17200

Merged
merged 1 commit into from
Feb 18, 2022

Conversation

lewis6991
Copy link
Member

@lewis6991 lewis6991 commented Jan 26, 2022

A version of loadfile with the intention of being redefined to allow third-party plugins to provide instrumentation and caching.

This will allow impatient.nvim to cache Lua files in directories like plugin and after.

loadfile is still called via C so the only additional overhead is via the Lua-C API which shouldn't be too bad.

Obviously this will need some discussion (hence this is a draft), but I hope we agree on the overall goal.

EDIT: Changed so the Lua built-in loadfile is called instead of the direct C version luaL_loadfile.

@github-actions github-actions bot added the lua stdlib label Jan 26, 2022
@clason clason added the core Nvim core functionality or code label Jan 26, 2022
@clason clason requested a review from bfredl January 26, 2022 10:32
@lewis6991
Copy link
Member Author

Before I work on this any more, @bfredl are you OK with the premise of this PR?

@bfredl
Copy link
Member

bfredl commented Feb 1, 2022

@lewis6991 yes.

@lewis6991 lewis6991 changed the title feat(lua): add vim._loadfile refactor(lua): call loadfile internally Feb 2, 2022
@lewis6991 lewis6991 changed the title refactor(lua): call loadfile internally refactor(lua): call loadfile internally instead of luaL_loadfile Feb 2, 2022
@lewis6991 lewis6991 marked this pull request as ready for review February 2, 2022 17:49
@bfredl
Copy link
Member

bfredl commented Feb 6, 2022

Needs an update to tests:

2022-02-02T18:10:27.5497661Z test/helpers.lua:73: Expected objects to be the same.
2022-02-02T18:10:27.5497930Z Passed in:
2022-02-02T18:10:27.5498383Z (string) 'Vim(luafile):E5113: Error while calling lua chunk: attempt to call a nil value
2022-02-02T18:10:27.5498725Z stack traceback:'
2022-02-02T18:10:27.5498958Z Expected:
2022-02-02T18:10:27.5499559Z (string) 'Vim(luafile):E5112: Error while creating lua chunk: Xtest-functional-lua-commands-luafile:1: unexpected symbol near ')''

I haven't checked the test in detail but likely just putting in the new message should be fine.

@bfredl bfredl removed their request for review February 12, 2022 19:18
@lewis6991 lewis6991 requested a review from bfredl February 17, 2022 12:22
@lewis6991 lewis6991 force-pushed the _loadfile branch 2 times, most recently from 11d2ed6 to 7f44d62 Compare February 18, 2022 00:16
src/nvim/lua/executor.c Outdated Show resolved Hide resolved
.. instead of luaL_loadfile

allows files to be cached
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Nvim core functionality or code lua stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants