1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
5\page qtquick-tool-qmlls.html
6\title QML Language Server
7\brief Overview of the QML Language Server (qmlls).
9QML Language Server is a tool shipped with Qt that helps you write code
10in your favorite (LSP-supporting) editor.
11See \l{https://microsoft.github.io/language-server-protocol/}{Language Server Protocol}
14Currently, it enables your editor to:
16 \li Autocomplete your code
17 \li Display qmllint warnings
18 \li Navigate to definitions in QML files
19 \li Find usages of JavaScript variables and QML objects
23\note qmlls is currently in development, see \l{Known Limitations} for
26\section1 Supported Features
30QML Language Server can automatically lint opened QML files
31and display warnings or errors straight in the editor. See
32\l{qmllint} for more information about the linting process.
36QML Language Server can format entire files from inside
37the editor. See \l{qmlformat} for more information about the
41\section2 Finding Definitions
43QML Language Server can find definitions of JavaScript variables,
44functions, QML object id's and QML properties from their usages.
46QML Language Server can also find the definition of types used in
47type annotations for JavaScript functions, QML object properties,
48and QML object instantiation.
50\section2 Finding Usages
52QML Language Server can find usages of JavaScript variables,
53QML object properties, JavaScript functions, QML object methods,
56\section1 Setting up the QML Language Server in Your Editor
58\note You can find the QML Language Server binary under
59\c{<Qt installation folder>/bin/qmlls} in installations of Qt
60made with the official Maintenance Tool.
62QML Language Server also needs to know the location of your build
63folder. You can pass it the following ways:
65 \li The \c{--build-dir} command line option. In this case
66your editor should invoke \c{qmlls} as following:
68<path/to/qmlls> --build-dir <path/to/build-directory>
70 \li The \c{QMLLS_BUILD_DIRS} environment variable.
71 \li The \c{.qmlls.ini} settings file, see \l {Configuration File}.
74\note When the build directory is specified in multiple ways, the
75command line option takes preference over the environment variable
76that takes precedence over the setting file.
78\section1 Configuration File
80QML Language Server can be configured via a configuration file \c{.qmlls.ini}.
81This file should be in the root source directory of the project.
82It should be a text file in the ini-format.
84The configuration file should look like this:
88buildDir=<path/to/build-directory>
91Currently, the configuration file can only be used to set the build
92directory of the current project.
94\note QML Language Server can create default configuration files
95using the \c{--write-defaults} option. This will overwrite an
96already existing .qmlls.ini file in the current directory.
98\section1 Known Limitations
100QML Language Server might emit false positive warnings on projects
101that were not built, as it needs the build information to find
102QML modules defined in the same project, for example.
104Despite covering many common QML features,
105the QML Language Server is still in development with some features
109 \li Renaming symbols (JavaScript variables, QML object id's, QML
110object properties, and so on).
111 \li Formatting only parts of a document.
112 \li Formatting using a configurable set of rules.
113 \li Navigating to definitions of objects defined in C++.
116The QML code model in the QML Language Server does not yet
117support all of the JavaScript language constructs, which means that
118some features like navigating to definition and finding usages might not
119work on these language constructs.