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