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\keyword \QMLLS Reference
8\brief A tool that helps you write code in your favorite LSP-supporting editor.
9\ingroup qtqml-tooling
10\ingroup qtqml-tooling-devtools
11
12\QMLLS is a tool shipped with Qt that helps you write code
13in your favorite (LSP-supporting) editor.
14See \l{https://microsoft.github.io/language-server-protocol/}{Language Server Protocol}
15for more information.
16
17Currently, 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
36and display warnings or errors straight in the editor. See
37\l{qmllint} for more information about the linting process,
38and \l{QML Lint Warning and Errors} on how to fix warnings and
39errors.
40
41\section2 Formatting
42
43\QMLLS can format entire files from inside
44the editor. See \l{qmlformat} for more information about the
45formatting process.
46
47
48\section2 Finding Definitions
49
50\QMLLS can find definitions of JavaScript variables,
51functions, QML object id's and QML properties from their usages.
52
53\QMLLS can also find the definition of types used in
54type annotations for JavaScript functions, QML object properties,
55and QML object instantiation.
56
57\section2 Finding Usages
58
59\QMLLS can find usages of JavaScript variables,
60QML object properties, JavaScript functions, QML object methods,
61and QML object id's.
62
63\section2 Renaming
64
65\QMLLS can rename JavaScript variables and functions,
66as well as QML object properties, methods, and id's, as long as
67they are defined in a QML file.
68
69\section2 Suggesting Autocompletion Items
70
71\QMLLS provides autocompletion suggestions for
72JavaScript variables, expressions, and statements, as well as
73QML 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
78types. It automatically rebuilds CMake QML modules to provide
79accurate and up-to-date warnings and completion items for C++
80defined QML types.
81
82You can
83\l{Disabling automatic CMake builds}{disable this feature}.
84
85\section2 Documentation Hints
86
87\QMLLS includes a documentation hints feature that
88provides programmers with quick access to Qt’s documentation
89by hovering over a keyword. In order to use this feature, your
90Qt kit should contain the Qt documentation and your project
91should be built with \l{QT_QML_GENERATE_QMLLS_INI} variable.
92
93\section1 Setting up the \QMLLS in Your Editor
94
95\note You can find the \QMLLS binary under
96\c{<Qt installation folder>/bin/qmlls} in installations of Qt
97made with \QOI.
98
99\section2 Setting up the Build Directory
100
101\QMLLS needs to know the location of your build
102folder. You can pass it in the following ways:
103\list
104 \li The \c{--build-dir} command line option. In this case
105your editor should invoke \c{qmlls} as following:
106\badcode
107<path/to/qmlls> ... --build-dir <path/to/build-directory> ...
108\endcode
109 \li The \c{QMLLS_BUILD_DIRS} environment variable.
110 \li The \c{.qmlls.ini} settings file, see \l {Configuration File}.
111\endlist
112
113\note When the build directory is specified in multiple ways, the
114command line option takes preference over the environment variable
115that takes precedence over the setting file.
116
117\section2 Setting up the import paths
118
119\QMLLS needs to know the import paths of the Qt version that you
120are using in your project. You can pass the import paths in the
121following ways:
122\list
123 \li The \c{-I} command line option. In this case
124your editor should invoke \c{qmlls} as following:
125\badcode
126<path/to/qmlls> ... -I /path/to/imports -I /optional/path/to/another/import ...
127\endcode
128 \li The \c{QML_IMPORT_PATH} environment variable. In this case you
129 should pass the \c{-E} option to \QMLLS.
130 \li The \c{.qmlls.ini} settings file, see \l {Configuration File}.
131\endlist
132
133\note When the import path is specified in multiple ways, the
134command line option takes preference over the environment variable
135that takes precedence over the setting file.
136
137\section2 Setting up the documentation path
138
139\QMLLS can show documentation hints when it knows the documentation
140path of the Qt version that you are using in your project. You can pass
141the documentation path in the following ways:
142\list
143 \li The \c{-d} or \c{-p} command line option. In this case
144your editor should invoke \c{qmlls} as following:
145\badcode
146<path/to/qmlls> ... -d /path/to/docs ...
147\endcode
148 \li The \c{.qmlls.ini} settings file, see \l {Configuration File}.
149\endlist
150
151\note When the documentation path is specified in multiple ways, the
152command line option takes preference over the environment variable
153that takes precedence over the setting file.
154
155\section2 Disabling Automatic CMake Builds
156
157\c{qmlls} will try to trigger a CMake rebuild when it detects that the
158source code of a C++ defined QML type has been modified.
159
160To disable this feature, use the following ways:
161\list
162 \li The \c{--no-cmake-calls} command line option. In this case
163your editor should invoke \c{qmlls} as follows:
164\badcode
165<path/to/qmlls> --build-dir <path/to/build-directory> --no-cmake-calls
166\endcode
167 \li The \c{QMLLS_NO_CMAKE_CALLS} environment variable.
168 \li The \c{.qmlls.ini} settings file, see \l {Configuration File}.
169 \li The \l{QT_QML_GENERATE_QMLLS_INI_NO_CMAKE_CALLS} CMake variable.
170\endlist
171
172\section2 Modifying the maximum amount of files to search
173
174\QMLLS respects a limit of files to search when searching the source
175folders for headers, for example when going to the definition of a QML
176component defined in a C++ header.
177
178To set the maximum amount of files to search, write a numeric value in the
179\c QMLLS_MAX_FILES_TO_SEARCH environment variable. 0 disables the file
180searching feature, 20000 is the default value.
181
182\section1 Configuration File
183
184\QMLLS can be configured via a configuration file \c{.qmlls.ini}.
185This file should be in the root source directory of the project.
186It should be a text file in the ini-format.
187
188The configuration file can have the following entries:
189\code
190// .qmlls.ini
191[General]
192no-cmake-calls=<true-or-false>
193
194buildDir=<path/to/build-directory> # not required in Qt 6.10 and later
195docDir=<path/to/qt-documentation> # not required in Qt 6.10 and later
196importPaths=<path/to/imports> # not required in Qt 6.10 and later
197\endcode
198
199To use the configuration file to disable the automatic CMake rebuild
200functionality, set \c{no-cmake-calls} to \c{true}.
201
202\note \QMLLS can create default configuration files
203using the \c{--write-defaults} option. This will overwrite an
204already existing .qmlls.ini file in the current directory.
205
206\section1 Known Limitations
207
208Despite covering many common QML features, \QMLLS is still in development with some features
209yet to be supported:
210\list
211 \li Suggesting autocompletions on invalid QML files.
212 \li Navigating to definitions of objects defined in C++.
213 \li Autocompleting context properties
214\endlist
215
216\QMLLS might emit false positive warnings on projects
217\list
218 \li using QMake or imperative type registration---see \l{Port QML modules to CMake}
219 \li that were not built---\QMLLS uses the build information to find QML modules
220 \li where QML modules don't follow the guidelines in \l{Modern QML modules}
221\endlist
222
223*/