mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 22:18:33 +00:00
feat: filetype.lua (#16600)
Adds a new vim.filetype module that provides support for filetype detection in Lua.
This commit is contained in:
@@ -434,6 +434,15 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
||||
// [package, loaded, module]
|
||||
lua_setfield(lstate, -2, "vim.F"); // [package, loaded]
|
||||
|
||||
code = (char *)&lua_filetype_module[0];
|
||||
if (luaL_loadbuffer(lstate, code, sizeof(lua_filetype_module) - 1, "@vim/filetype.lua")
|
||||
|| nlua_pcall(lstate, 0, 1)) {
|
||||
nlua_error(lstate, _("E5106: Error while creating vim.filetype module: %.*s"));
|
||||
return 1;
|
||||
}
|
||||
// [package, loaded, module]
|
||||
lua_setfield(lstate, -2, "vim.filetype"); // [package, loaded]
|
||||
|
||||
lua_pop(lstate, 2); // []
|
||||
}
|
||||
|
||||
|
@@ -40,6 +40,9 @@ assert(vim)
|
||||
vim.inspect = package.loaded['vim.inspect']
|
||||
assert(vim.inspect)
|
||||
|
||||
vim.filetype = package.loaded['vim.filetype']
|
||||
assert(vim.filetype)
|
||||
|
||||
local pathtrails = {}
|
||||
vim._so_trails = {}
|
||||
for s in (package.cpath..';'):gmatch('[^;]*;') do
|
||||
|
Reference in New Issue
Block a user