Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qtquick-tool-qmlls.qdoc
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qtquick-tool-qmlls.html
6\title QML Language Server
7\brief Overview of the QML Language Server (qmlls).
8
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}
12for more information.
13
14Currently, it enables your editor to:
15\list
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
20 \li Format QML files
21\endlist
22
23\note qmlls is currently in development, see \l{Known Limitations} for
24more details.
25
26\section1 Supported Features
27
28\section2 Linting
29
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.
33
34\section2 Formatting
35
36QML Language Server can format entire files from inside
37the editor. See \l{qmlformat} for more information about the
38formatting process.
39
40
41\section2 Finding Definitions
42
43QML Language Server can find definitions of JavaScript variables,
44functions, QML object id's and QML properties from their usages.
45
46QML Language Server can also find the definition of types used in
47type annotations for JavaScript functions, QML object properties,
48and QML object instantiation.
49
50\section2 Finding Usages
51
52QML Language Server can find usages of JavaScript variables,
53QML object properties, JavaScript functions, QML object methods,
54and QML object id's.
55
56\section1 Setting up the QML Language Server in Your Editor
57
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.
61
62QML Language Server also needs to know the location of your build
63folder. You can pass it the following ways:
64\list
65 \li The \c{--build-dir} command line option. In this case
66your editor should invoke \c{qmlls} as following:
67\badcode
68<path/to/qmlls> --build-dir <path/to/build-directory>
69\endcode
70 \li The \c{QMLLS_BUILD_DIRS} environment variable.
71 \li The \c{.qmlls.ini} settings file, see \l {Configuration File}.
72\endlist
73
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.
77
78\section1 Configuration File
79
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.
83
84The configuration file should look like this:
85\code
86// .qmlls.ini
87[General]
88buildDir=<path/to/build-directory>
89\endcode
90
91Currently, the configuration file can only be used to set the build
92directory of the current project.
93
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.
97
98\section1 Known Limitations
99
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.
103
104Despite covering many common QML features,
105the QML Language Server is still in development with some features
106yet to be supported:
107
108\list
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++.
114\endlist
115
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.
120
121
122*/