forked from qt-creator/qt-creator
Lua: Move lua plugins into normal plugin folder
Change-Id: I14ab0bb755a4279bc255673596fe084cd556433c Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -1129,7 +1129,7 @@ function (add_qtc_lua_plugin name)
|
|||||||
|
|
||||||
qtc_copy_to_builddir(${name}
|
qtc_copy_to_builddir(${name}
|
||||||
FILES ${_arg_SOURCES}
|
FILES ${_arg_SOURCES}
|
||||||
DESTINATION ${IDE_PLUGIN_PATH}/lua-plugins
|
DESTINATION ${IDE_PLUGIN_PATH}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT _arg_EXCLUDE_FROM_INSTALL)
|
if (NOT _arg_EXCLUDE_FROM_INSTALL)
|
||||||
@@ -1138,7 +1138,7 @@ function (add_qtc_lua_plugin name)
|
|||||||
|
|
||||||
install(
|
install(
|
||||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE}
|
FILES ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE}
|
||||||
DESTINATION ${IDE_PLUGIN_PATH}/lua-plugins/${SOURCE_DIR}
|
DESTINATION ${IDE_PLUGIN_PATH}/${SOURCE_DIR}
|
||||||
)
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
@@ -7,6 +7,6 @@ Product {
|
|||||||
prefix: sourceDirectory + '/' + product.name + '/'
|
prefix: sourceDirectory + '/' + product.name + '/'
|
||||||
files: luafiles
|
files: luafiles
|
||||||
qbs.install: true
|
qbs.install: true
|
||||||
qbs.installDir: qtc.ide_plugin_path + '/lua-plugins/' + product.name
|
qbs.installDir: qtc.ide_plugin_path + '/' + product.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ The Lua plugin provides support for writing plugins using the Lua scripting lang
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
The plugin scans the folder `lua-plugins` folder inside the normal plugin folder of Qt Creator
|
The plugin scans the normal plugin folders of Qt Creator
|
||||||
`ExtensionSystem::PluginManager::pluginPaths()`. It loads scripts from any folder that contains
|
`ExtensionSystem::PluginManager::pluginPaths()`. It loads scripts from any folder that contains
|
||||||
a .lua script named the same as the folder.
|
a .lua script named the same as the folder.
|
||||||
Whether or not the script is enabled is determined by the `disabledByDefault` field in the plugin
|
Whether or not the script is enabled is determined by the `disabledByDefault` field in the plugin
|
||||||
@@ -17,7 +17,7 @@ table and the settings configured via the "About Plugins" dialog in Qt Creator.
|
|||||||
A Lua script needs to provide the following table to be considered a plugin:
|
A Lua script needs to provide the following table to be considered a plugin:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- lua-plugins/myluaplugin/myluaplugin.lua
|
-- myluaplugin/myluaplugin.lua
|
||||||
return {
|
return {
|
||||||
name = "MyLuaPlugin",
|
name = "MyLuaPlugin",
|
||||||
version = "1.0.0",
|
version = "1.0.0",
|
||||||
@@ -50,13 +50,13 @@ It must only return the plugin specification table and not execute or require an
|
|||||||
Use `require` to load other files from within the setup function.
|
Use `require` to load other files from within the setup function.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- lua-plugins/myluaplugin/myluaplugin.lua
|
-- myluaplugin/myluaplugin.lua
|
||||||
return {
|
return {
|
||||||
-- ... required fields omitted ..
|
-- ... required fields omitted ..
|
||||||
setup = function() require 'init'.setup() end,
|
setup = function() require 'init'.setup() end,
|
||||||
} --[[@as QtcPlugin]]
|
} --[[@as QtcPlugin]]
|
||||||
|
|
||||||
-- lua-plugins/myluaplugin/init.lua
|
-- myluaplugin/init.lua
|
||||||
local function setup()
|
local function setup()
|
||||||
print("Hello from Lua!")
|
print("Hello from Lua!")
|
||||||
end
|
end
|
||||||
|
@@ -106,10 +106,7 @@ public:
|
|||||||
|
|
||||||
bool delayedInitialize() final
|
bool delayedInitialize() final
|
||||||
{
|
{
|
||||||
scanForPlugins(transform(PluginManager::pluginPaths(), [](const FilePath &path) {
|
scanForPlugins(PluginManager::pluginPaths());
|
||||||
return path / "lua-plugins";
|
|
||||||
}));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user