mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
Merge pull request #14788 from shadmansaleh/fix/lua_runtime1
fixup(runtime): Fix lua runtime files not listed in :scriptnames
This commit is contained in:
commit
9c7132cda4
@ -831,16 +831,16 @@ ShellFilterPost After executing a shell command with
|
||||
":{range}!cmd", ":w !cmd" or ":r !cmd".
|
||||
Can be used to check for any changed files.
|
||||
*SourcePre*
|
||||
SourcePre Before sourcing a Vim script. |:source|
|
||||
SourcePre Before sourcing a vim/lua file. |:source|
|
||||
<afile> is the name of the file being sourced.
|
||||
*SourcePost*
|
||||
SourcePost After sourcing a Vim script. |:source|
|
||||
SourcePost After sourcing a vim/lua file. |:source|
|
||||
<afile> is the name of the file being sourced.
|
||||
Not triggered when sourcing was interrupted.
|
||||
Also triggered after a SourceCmd autocommand
|
||||
was triggered.
|
||||
*SourceCmd*
|
||||
SourceCmd When sourcing a Vim script. |:source|
|
||||
SourceCmd When sourcing a vim/lua file. |:source|
|
||||
<afile> is the name of the file being sourced.
|
||||
The autocommand must source this file.
|
||||
|Cmd-event|
|
||||
|
@ -2809,10 +2809,6 @@ int do_source(char_u *fname, int check_other, int is_vimrc)
|
||||
proftime_T wait_start;
|
||||
bool trigger_source_post = false;
|
||||
|
||||
if (path_with_extension((const char *)fname, "lua")) {
|
||||
return (int)nlua_exec_file((const char *)fname);
|
||||
}
|
||||
|
||||
p = expand_env_save(fname);
|
||||
if (p == NULL) {
|
||||
return retval;
|
||||
@ -3005,10 +3001,15 @@ int do_source(char_u *fname, int check_other, int is_vimrc)
|
||||
firstline = p;
|
||||
}
|
||||
|
||||
// Call do_cmdline, which will call getsourceline() to get the lines.
|
||||
do_cmdline(firstline, getsourceline, (void *)&cookie,
|
||||
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT);
|
||||
retval = OK;
|
||||
if (path_with_extension((const char *)fname, "lua")) {
|
||||
// Source the file as lua
|
||||
retval = (int)nlua_exec_file((const char *)fname);
|
||||
} else {
|
||||
// Call do_cmdline, which will call getsourceline() to get the lines.
|
||||
do_cmdline(firstline, getsourceline, (void *)&cookie,
|
||||
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT);
|
||||
retval = OK;
|
||||
}
|
||||
|
||||
if (l_do_profiling == PROF_YES) {
|
||||
// Get "si" again, "script_items" may have been reallocated.
|
||||
|
@ -1811,7 +1811,7 @@ static bool do_user_initialization(void)
|
||||
|
||||
char_u *init_lua_path = (char_u *)stdpaths_user_conf_subpath("init.lua");
|
||||
if (os_path_exists(init_lua_path)
|
||||
&& nlua_exec_file((const char *)init_lua_path)) {
|
||||
&& do_source(init_lua_path, true, DOSO_VIMRC)) {
|
||||
os_setenv("MYVIMRC", (const char *)init_lua_path, 1);
|
||||
char_u *vimrc_path = (char_u *)stdpaths_user_conf_subpath("init.vim");
|
||||
|
||||
|
@ -526,12 +526,25 @@ describe('runtime:', function()
|
||||
local plugin_folder_path = table.concat({plugin_path, 'plugin'}, pathsep)
|
||||
local plugin_file_path = table.concat({plugin_folder_path, 'plugin.lua'},
|
||||
pathsep)
|
||||
local profiler_file = 'test_startuptime.log'
|
||||
|
||||
mkdir_p(plugin_folder_path)
|
||||
write_file(plugin_file_path, [[vim.g.lua_plugin = 2]])
|
||||
|
||||
clear{ args_rm={'-u'}, env={ XDG_CONFIG_HOME=xconfig }}
|
||||
clear{ args_rm={'-u'}, args={'--startuptime', profiler_file}, env={ XDG_CONFIG_HOME=xconfig }}
|
||||
|
||||
eq(2, eval('g:lua_plugin'))
|
||||
-- Check if plugin_file_path is listed in :scriptname
|
||||
local scripts = meths.exec(':scriptnames', true)
|
||||
assert.Truthy(scripts:find(plugin_file_path))
|
||||
|
||||
-- Check if plugin_file_path is listed in startup profile
|
||||
local profile_reader = io.open(profiler_file, 'r')
|
||||
local profile_log = profile_reader:read('*a')
|
||||
profile_reader:close()
|
||||
assert.Truthy(profile_log :find(plugin_file_path))
|
||||
|
||||
os.remove(profiler_file)
|
||||
rmdir(plugin_path)
|
||||
end)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user