QML Language Server is a tool shipped with Qt that helps you write code in your favorite (LSP-supporting) editor. See Language Server Protocol 了解更多信息。
Currently, it enables your editor to:
注意: qmlls is currently in development, see Known Limitations 了解更多细节。
QML Language Server can automatically lint opened QML files and display warnings or errors straight in the editor. See qmllint for more information about the linting process.
QML Language Server can format entire files from inside the editor. See qmlformat for more information about the formatting process.
QML Language Server can find definitions of JavaScript variables, functions, QML object id's and QML properties from their usages.
QML Language Server can also find the definition of types used in type annotations for JavaScript functions, QML object properties, and QML object instantiation.
QML Language Server can find usages of JavaScript variables, QML object properties, JavaScript functions, QML object methods, and QML object id's.
QML Language Server can rename JavaScript variables and functions, as well as QML object properties, methods, and id's, as long as they are defined in a QML file.
QML Language Server provides autocompletion suggestions for JavaScript variables, expressions, and statements, as well as QML object properties, methods, and id's.
QML Language Server can track changes in C++ files defining QML types. It automatically rebuilds CMake QML modules to provide accurate and up-to-date warnings and completion items for C++ defined QML types.
You can disable this feature .
注意:
You can find the QML Language Server binary under
<Qt installation folder>/bin/qmlls
in installations of Qt made with Qt Online Installer.
QML Language Server needs to know the location of your build folder. You can pass it the following ways:
--build-dir
command line option. In this case your editor should invoke
qmlls
as following:
<path/to/qmlls> --build-dir <path/to/build-directory>
QMLLS_BUILD_DIRS
环境变量。
.qmlls.ini
settings file, see
配置文件
.
注意: When the build directory is specified in multiple ways, the command line option takes preference over the environment variable that takes precedence over the setting file.
qmlls
will try to trigger a CMake rebuild when it detects that the source code of a C++ defined QML type has been modified.
To disable this feature, use the following ways:
--no-cmake-calls
command line option. In this case your editor should invoke
qmlls
如下:
<path/to/qmlls> --build-dir <path/to/build-directory> --no-cmake-calls
QMLLS_NO_CMAKE_CALLS
环境变量。
.qmlls.ini
settings file, see
配置文件
.
QML Language Server can be configured via a configuration file
.qmlls.ini
. This file should be in the root source directory of the project. It should be a text file in the ini-format.
注意:
.qmlls.ini
files can be generated automatically via
QT_QML_GENERATE_QMLLS_INI
.
The configuration file should look like this:
// .qmlls.ini [General] buildDir=<path/to/build-directory> no-cmake-calls=<true-or-false>
Currently, the configuration file can be used to set the build directory of the current project and optionally disable the automatic CMake rebuild functionality for C++ defined QML types.
注意:
QML Language Server can create default configuration files using the
--write-defaults
option. This will overwrite an already existing .qmlls.ini file in the current directory.
QML Language Server might emit false positive warnings on projects that were not built, as it needs the build information to find QML modules defined in the same project, for example.
Despite covering many common QML features, the QML Language Server is still in development with some features yet to be supported:
The QML code model in the QML Language Server does not yet support all of the JavaScript language constructs, which means that some features like navigating to definition and finding usages might not work on these language constructs.