mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 00:38:17 +00:00
startup: allow lua files as session one
This commit is contained in:
@@ -1069,9 +1069,14 @@ static void command_line_scan(mparm_T *parmp)
|
|||||||
} else {
|
} else {
|
||||||
a = argv[0];
|
a = argv[0];
|
||||||
}
|
}
|
||||||
size_t s_size = STRLEN(a) + 4;
|
|
||||||
|
size_t s_size = STRLEN(a) + 9;
|
||||||
char *s = xmalloc(s_size);
|
char *s = xmalloc(s_size);
|
||||||
snprintf(s, s_size, "so %s", a);
|
if (path_with_extension(a, "lua")) {
|
||||||
|
snprintf(s, s_size, "luafile %s", a);
|
||||||
|
} else {
|
||||||
|
snprintf(s, s_size, "so %s", a);
|
||||||
|
}
|
||||||
parmp->cmds_tofree[parmp->n_commands] = true;
|
parmp->cmds_tofree[parmp->n_commands] = true;
|
||||||
parmp->commands[parmp->n_commands++] = s;
|
parmp->commands[parmp->n_commands++] = s;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -493,3 +493,27 @@ describe('user config init', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe('user session', function()
|
||||||
|
local xhome = 'Xhome'
|
||||||
|
local pathsep = helpers.get_pathsep()
|
||||||
|
local session_file = table.concat({xhome, 'session.lua'}, pathsep)
|
||||||
|
|
||||||
|
before_each(function()
|
||||||
|
rmdir(xhome)
|
||||||
|
|
||||||
|
mkdir(xhome)
|
||||||
|
write_file(session_file, [[
|
||||||
|
vim.g.lua_session = 1
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
after_each(function()
|
||||||
|
rmdir(xhome)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('loads session from the provided lua file', function()
|
||||||
|
clear{ args={'-S', session_file }, env={ HOME=xhome }}
|
||||||
|
eq(1, eval('g:lua_session'))
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
Reference in New Issue
Block a user