mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 22:48:34 +00:00
feat(runtime): Allow lua to be used in compiler
This commit is contained in:
@@ -1208,8 +1208,8 @@ not "b:current_compiler". What the command actually does is the following:
|
||||
- Delete the "current_compiler" and "b:current_compiler" variables.
|
||||
- Define the "CompilerSet" user command. With "!" it does ":set", without "!"
|
||||
it does ":setlocal".
|
||||
- Execute ":runtime! compiler/{name}.vim". The plugins are expected to set
|
||||
options with "CompilerSet" and set the "current_compiler" variable to the
|
||||
- Execute ":runtime! compiler/{name}.(vim|lua)". The plugins are expected to
|
||||
set options with "CompilerSet" and set the "current_compiler" variable to the
|
||||
name of the compiler.
|
||||
- Delete the "CompilerSet" user command.
|
||||
- Set "b:current_compiler" to the value of "current_compiler".
|
||||
|
@@ -2421,6 +2421,7 @@ void ex_compiler(exarg_T *eap)
|
||||
if (*eap->arg == NUL) {
|
||||
// List all compiler scripts.
|
||||
do_cmdline_cmd("echo globpath(&rtp, 'compiler/*.vim')"); // NOLINT
|
||||
do_cmdline_cmd("echo globpath(&rtp, 'compiler/*.lua')"); // NOLINT
|
||||
} else {
|
||||
size_t bufsize = STRLEN(eap->arg) + 14;
|
||||
buf = xmalloc(bufsize);
|
||||
@@ -2444,9 +2445,13 @@ void ex_compiler(exarg_T *eap)
|
||||
do_unlet(S_LEN("b:current_compiler"), true);
|
||||
|
||||
snprintf((char *)buf, bufsize, "compiler/%s.vim", eap->arg);
|
||||
if (source_in_path(p_rtp, buf, DIP_ALL) == FAIL) {
|
||||
// Try lua compiler
|
||||
snprintf((char *)buf, bufsize, "compiler/%s.lua", eap->arg);
|
||||
if (source_in_path(p_rtp, buf, DIP_ALL) == FAIL) {
|
||||
EMSG2(_("E666: compiler not supported: %s"), eap->arg);
|
||||
}
|
||||
}
|
||||
xfree(buf);
|
||||
|
||||
do_cmdline_cmd(":delcommand CompilerSet");
|
||||
|
@@ -85,5 +85,35 @@ describe('runtime:', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('compiler', function()
|
||||
local compiler_folder = table.concat({xconfig, 'nvim', 'compiler'}, pathsep)
|
||||
|
||||
it('loads lua compilers', function()
|
||||
local compiler_file = table.concat({compiler_folder, 'new_compiler.lua'},
|
||||
pathsep)
|
||||
mkdir_p(compiler_folder)
|
||||
write_file(compiler_file, [[vim.g.lua_compiler = 1]])
|
||||
|
||||
clear{ args_rm={'-' }, env={ XDG_CONFIG_HOME=xconfig }}
|
||||
exec('compiler new_compiler')
|
||||
|
||||
eq(1, eval('g:lua_compiler'))
|
||||
rmdir(compiler_folder)
|
||||
end)
|
||||
|
||||
it('loads vim compilers when both lua and vim version exist', function()
|
||||
local compiler_file = table.concat({compiler_folder, 'new_compiler'},
|
||||
pathsep)
|
||||
mkdir_p(compiler_folder)
|
||||
write_file(compiler_file..'.vim', [[let g:compiler = 'vim']])
|
||||
write_file(compiler_file..'.lua', [[vim.g.compiler = 'lua']])
|
||||
|
||||
clear{ args_rm={'-u' }, env={ XDG_CONFIG_HOME=xconfig }}
|
||||
exec('compiler new_compiler')
|
||||
|
||||
eq('vim', eval('g:compiler'))
|
||||
rmdir(compiler_folder)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
Reference in New Issue
Block a user