Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qtqml-tooling-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 qtqml-tooling-qmlls.html
6
\title \QMLLS
7
\brief A tool that helps you write code in your favorite LSP-supporting editor.
8
\ingroup qtqml-tooling
9
\ingroup qtqml-tooling-devtools
10
11
\QMLLS is a tool shipped with Qt that helps you write code
12
in your favorite (LSP-supporting) editor.
13
See \l{https://microsoft.github.io/language-server-protocol/}{Language Server Protocol}
14
for more information.
15
16
Currently, it enables your editor to:
17
\list
18
\li Autocomplete your code
19
\li Display qmllint warnings
20
\li Navigate to definitions in QML files
21
\li Find usages of JavaScript variables and QML objects
22
\li Rename JavaScript variables and QML objects
23
\li Format QML files
24
\li Get help from Qt Documentation
25
\endlist
26
27
\note \c qmlls is currently in development, see
28
\l{#Known Limitations}{Known Limitations} for more details.
29
30
\section1 Supported Features
31
32
\section2 Linting
33
34
\QMLLS can automatically lint opened QML files
35
and display warnings or errors straight in the editor. See
36
\l{qmllint} for more information about the linting process,
37
and \l{QML Lint Warning and Errors} on how to fix warnings and
38
errors.
39
40
\section2 Formatting
41
42
\QMLLS can format entire files from inside
43
the editor. See \l{qmlformat} for more information about the
44
formatting process.
45
46
47
\section2 Finding Definitions
48
49
\QMLLS can find definitions of JavaScript variables,
50
functions, QML object id's and QML properties from their usages.
51
52
\QMLLS can also find the definition of types used in
53
type annotations for JavaScript functions, QML object properties,
54
and QML object instantiation.
55
56
\section2 Finding Usages
57
58
\QMLLS can find usages of JavaScript variables,
59
QML object properties, JavaScript functions, QML object methods,
60
and QML object id's.
61
62
\section2 Renaming
63
64
\QMLLS can rename JavaScript variables and functions,
65
as well as QML object properties, methods, and id's, as long as
66
they are defined in a QML file.
67
68
\section2 Suggesting Autocompletion Items
69
70
\QMLLS provides autocompletion suggestions for
71
JavaScript variables, expressions, and statements, as well as
72
QML object properties, methods, and id's.
73
74
\section2 Tracking Changes in C++ Files
75
76
\QMLLS can track changes in C++ files defining QML
77
types. It automatically rebuilds CMake QML modules to provide
78
accurate and up-to-date warnings and completion items for C++
79
defined QML types.
80
81
You can
82
\l{Configuring Automatic CMake Builds}{disable this feature}.
83
84
\section2 Documentation Hints
85
86
\QMLLS includes a documentation hints feature that
87
provides programmers with quick access to Qt’s documentation
88
by hovering over a keyword. In order to use this feature, your
89
Qt kit should contain the Qt documentation and your project
90
should be built with \l{QT_QML_GENERATE_QMLLS_INI} variable.
91
92
\section1 Setting up \QMLLS in Your Editor
93
94
This section describes how to develop the \QMLLS client or how to
95
use your own \QMLLS client.
96
97
You can find the \QMLLS binary under
98
\c{<Qt installation folder>/bin/qmlls} in installations of Qt
99
made with \QOI. If you want your \QMLLS client to download the binary
100
directly, you can download the standalone version from github via
101
\l{https://github.com/TheQtCompanyRnD/qmlls-workflow/releases} or
102
\l{https://qtccache.qt.io/QMLLS/LatestRelease}.
103
104
\section2 Setting up the Build Directory
105
106
\QMLLS needs to know the location of the project build folder.
107
You can pass the build folder in the following ways.
108
109
\section3 AddBuildDirs LSP Extension
110
111
To pass build directories via the LSP extension, send a notification
112
to \QMLLS for the \c{$/addBuildDirs} method. \c{$/addBuildDirs}
113
accepts one parameter of the form:
114
\badcode
115
interface AddBuildDirsParams {
116
buildDirsToSet: UriToBuildDirs[];
117
}
118
\endcode
119
where \c{UriToBuildDirs} contains a workspace URI and a list of build
120
directories.
121
The workspace URI must designate a workspace advertised to \QMLLS via
122
\l{https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_workspaceFolders}{workspaceFolders}
123
or
124
\l{https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_didChangeWorkspaceFolders}{didChangeWorkspaceFolders}.
125
The build directories are file paths, not URIs.
126
\badcode
127
interface UriToBuildDirs {
128
baseUri: URI;
129
buildDirs: string[];
130
}
131
\endcode
132
133
\section3 --build-dir Command Line Option
134
135
If you don't need to support multiple workspaces, you can pass the build
136
directories via the \c{--build-dir} command line option. In this case
137
your editor should invoke \c{qmlls} as following:
138
\badcode
139
<path/to/qmlls> ... --build-dir <path/to/build-directory> ...
140
\endcode
141
142
The build directory will be applied to all workspaces if you use multiple
143
workspaces in the same \QMLLS. The values from \c{addBuildDirsMethod}
144
have higher precedence than the command line option.
145
146
\section3 QMLLS_BUILD_DIRS Environment Variable
147
148
You can also pass the build directories via the \c{QMLLS_BUILD_DIRS}
149
environment variable. The build directory will be applied to all
150
workspaces if you use multiple workspaces in the same \QMLLS.
151
The values from \c{--build-dir} have higher precedence than the
152
environment variable.
153
154
\section3 \c{.qmlls.ini} Settings File
155
156
If you can't pass the build directories using one of the previous options,
157
you could try passing build directories to \QMLLS via a configuration file.
158
See also \l{Configuration File}.
159
The values from the settings file have lower precedence than
160
\c{--build-dir}, \c{QMLLS_BUILD_DIRS}, and \c{addBuildDirsMethod}.
161
162
\section2 Configuring Automatic CMake Builds
163
164
\QMLLS will try to trigger a CMake rebuild when it detects that the
165
source code of a C++ defined QML type has been modified.
166
167
To disable this feature, use the following ways:
168
\list
169
\li The \c{--no-cmake-calls} command line option. In this case
170
your editor should invoke \c{qmlls} as follows:
171
\badcode
172
<path/to/qmlls> --build-dir <path/to/build-directory> --no-cmake-calls
173
\endcode
174
\li The \c{QMLLS_NO_CMAKE_CALLS} environment variable.
175
\li The \c{.qmlls.ini} settings file, see \l {Configuration File}.
176
\li The \l{QT_QML_GENERATE_QMLLS_INI_NO_CMAKE_CALLS} CMake variable
177
if \l{QT_QML_GENERATE_QMLLS_INI} is enabled.
178
\endlist
179
180
To control the number of jobs used by CMake, use
181
\list
182
\li The \c{--cmake-jobs} command line option. In this case
183
your editor should invoke \c{qmlls} as follows:
184
\badcode
185
<path/to/qmlls> --build-dir <path/to/build-directory> --cmake-jobs <jobs>
186
\endcode
187
\li The \c{QMLLS_CMAKE_JOBS} environment variable.
188
\li The \c{.qmlls.ini} settings file, see \l {Configuration File}.
189
\endlist
190
Accepted values are integers greater than 0 and \c{max} to use all available
191
cores.
192
193
\section2 Modifying the maximum amount of files to search
194
195
\QMLLS respects a limit of files to search when searching the source
196
folders for headers, for example when going to the definition of a QML
197
component defined in a C++ header.
198
199
To set the maximum amount of files to search, write a numeric value in the
200
\c QMLLS_MAX_FILES_TO_SEARCH environment variable. 0 disables the file
201
searching feature, 20000 is the default value.
202
203
\section1 Configuration File
204
205
\QMLLS can be configured via a configuration file \c{.qmlls.ini}.
206
This file should be in the root source directory of the project.
207
It should be a text file in the ini-format.
208
209
The configuration file can have the following entries:
210
\code
211
// .qmlls.ini
212
[General]
213
no-cmake-calls=<true-or-false>
214
CMakeJobs=<some integer value>
215
216
buildDir=<path/to/build-directory> # not required in Qt 6.10 and later
217
docDir=<path/to/qt-documentation> # not required in Qt 6.10 and later
218
importPaths=<path/to/imports> # not required in Qt 6.10 and later
219
\endcode
220
221
To use the configuration file to disable the automatic CMake rebuild
222
functionality, set \c{no-cmake-calls} to \c{true}.
223
224
To control the number of jobs used by automatic CMake rebuilds, set the
225
CMakeJobs value.
226
227
To support clients that can't pass the build directory to \QMLLS, as
228
described in \l{Setting up the Build Directory}, set the buildDir value
229
or let CMake generate the .qmlls.ini via \l {QT_QML_GENERATE_QMLLS_INI}.
230
231
\note \QMLLS can create default configuration files
232
using the \c{--write-defaults} option. This will overwrite an
233
already existing .qmlls.ini file in the current directory.
234
235
\section1 Known Limitations
236
237
Despite covering many common QML features, \QMLLS is still in development with some features
238
yet to be supported:
239
\list
240
\li Suggesting autocompletions on invalid QML files.
241
\li Navigating to definitions of objects defined in C++.
242
\li Autocompleting context properties
243
\endlist
244
245
\QMLLS might emit false positive warnings on projects
246
\list
247
\li using QMake or imperative type registration---see \l{Port QML modules to CMake}
248
\li that were not built---\QMLLS uses the build information to find QML modules
249
\li where QML modules don't follow the guidelines in \l{Modernizing QML Modules}
250
\endlist
251
252
*/
qtdeclarative
src
qml
doc
src
tools
qtqml-tooling-qmlls.qdoc
Generated on
for Qt by
1.16.1