Feature improvements
New Type Hints (#1444) (#1512) (#1778)
New inlay hints have been added for variable declarations, captured values and struct literal fields.
These new inlay hints can be separately configured with the following new config options:
inlay_hints_show_parameter_name
inlay_hints_show_variable_type_hints
inlay_hints_show_struct_literal_field_type
Build on Save (#1361)
The new enable_build_on_save
config option enables ZLS compile your project with zig build
and report back diagnostics.
You can control which build step should be executed with the build_on_save_step
config option which defaults to the “install” step.
Please be aware that the vscode-zig extension provides a similar feature through the zig.buildOnSave
config option.
Completions
highlight symbols that call @compileError
as deprecated (#1764)
Any symbol that calls @compileError
will marked as deprecated in completions, hover and semantic highlighting. Different editors/clients may represent this information differently (or not at all).
The error message does not need to start with “Deprecated;”.
Semantic highlighting of deprecated symbols in VS Code
Most Color Themes in VS Code do not visualize deprecated tokens. The following setting can be used in VS Code to highlight deprecated tokens with a strikethrough.
"editor.semanticTokenColorCustomizations": {
"rules": {
"*.deprecated": {
"strikethrough": true
},
}
},
Detail field to pointer deref and optional unwrap operations (#1745)
Completions of the .*
and .?
operations will now show the result type.
Filesystem completion in build files (#1668)
While editing a build.zig
file, you will now receive filesystem completions inside string literals when typing a valid file path.
Module completions for std
and builtin
(#1656)
Completions inside an @import
will include the std
and builtin
module with their file path. (#1656)
completions with ‘replace’ instead of ‘insert’ (#1458)
Editor/Client | Config Option | Default Value |
---|---|---|
VS Code | editor.suggest.insertMode |
"insert" |
Sublime Text LSP | completion_insert_mode |
"insert" |
Helix | completion_replace |
false |
Emacs lsp-mode | lsp-completion-default-behaviour |
:replace |
A config option in Vim/Neovim depends on the LSP or completion plugin being used.
Kate Editor has a config option for this feature Configure
-> Editing
-> Auto Completion
-> Auto word completion
-> Remove tail on complete
but it does not use ZLS.
completions for function aliases with self parameters (#1656)
Declarations to function alias that take a self parameter are now included when providing completions on member access.
The following example would previously not give any completions.
Snippets
Snippets for float and int types have been removed. (#1681)
There are new snippets that add top level declaration for std
, @import
and std_options
(#1498) (#1830)
Configuration
validate configuration options (#1366)
The config system has been revamped to validate config options like executable or directory paths and provide better diagnostics.
When your editor does not support displaying a message window, you will still find them in ZLS’s log output.
ZLS+Zig compatibility check (#1808)
ZLS has the following compatibility requirements:
- A tagged release of Zig or ZLS must be used with the same tagged release of Zig or ZLS
- A master/nightly build of ZLS requires master/nightly build of Zig
As of right now, a master/nightly build of ZLS does try to be mostly usable with the latest tagged release of Zig but this is done as a best effort and is subject to change. (#1020)
When your ZLS and Zig version are incompatible, ZLS will show you a warning:
When your editor does not support displaying a message window, you will still find them in ZLS’s log output.
autofix disabled by default
The autofix feature is now disabled by default. (#1657)
removed enable_ast_check_diagnostics
Getting quickly informed about compile errors while coding is a vital feature that has little reason to be disabled.
removed enable_import_embedfile_argument_completions
This feature has been unstable in the past which is no longer the case.
removed include_at_in_builtins
This options served as a workaround for an issue with builtin completions in Sublime Text 3 which has been resolved.
removed max_detail_length
This options served as a workaround for an issue with long completion detail entries bricking the preview window in Sublime Text (#261) which can automatically be set by querying which editor/client is being used.
Performance
The DocumentScope is an internal datastructure of ZLS that keeps track of variables, declarations and their scopes. Most analysis relies on it to perform symbol lookups, iterate symbols or quickly traverse scopes. Every time a document is modified, the DocumentScope is rebuilt for the entire document so it has been rewritten with Data-oriented design principles in mind to reduce its performance footprint. (#1517)
Here is a benchmark where the DocumentScope is constructed and deinitialized 100 times on Zig’s Sema.zig:
Benchmark 1 (33 runs): ./document_scope_old
measurement mean ± σ min … max outliers delta
wall_time 3.67s ± 23.5ms 3.64s … 3.74s 2 ( 6%) 0%
peak_rss 11.1MB ± 64.1KB 10.9MB … 11.2MB 0 ( 0%) 0%
cpu_cycles 12.8G ± 99.1M 12.6G … 13.0G 1 ( 3%) 0%
instructions 24.3G ± 689 24.3G … 24.3G 2 ( 6%) 0%
cache_references 45.7M ± 848K 44.5M … 47.9M 1 ( 3%) 0%
cache_misses 6.36M ± 284K 5.89M … 6.92M 0 ( 0%) 0%
branch_misses 111M ± 1.20M 110M … 114M 0 ( 0%) 0%
Benchmark 3 (66 runs): ./document_scope_new
measurement mean ± σ min … max outliers delta
wall_time 1.82s ± 13.4ms 1.79s … 1.88s 3 ( 5%) ⚡- 50.4% ± 0.2%
peak_rss 8.19MB ± 57.8KB 8.08MB … 8.32MB 6 ( 9%) ⚡- 26.0% ± 0.2%
cpu_cycles 7.04G ± 51.3M 6.92G … 7.25G 3 ( 5%) ⚡- 44.9% ± 0.2%
instructions 9.86G ± 2.01K 9.86G … 9.86G 0 ( 0%) ⚡- 59.5% ± 0.0%
cache_references 45.4M ± 327K 44.7M … 46.3M 2 ( 3%) - 0.7% ± 0.5%
cache_misses 1.22M ± 462K 651K … 2.53M 8 (12%) ⚡- 80.9% ± 2.7%
branch_misses 79.4M ± 1.27M 75.9M … 81.0M 3 ( 5%) ⚡- 28.7% ± 0.5%
Experiencing issues with ZLS?
When encountering issues, do not hesitate to report your issues on the Github issue tracker or ZLS Discord Server.
New Contributors
- @notcancername made their first contribution in #1407
- @askazakov made their first contribution in #1429
- @Koranir made their first contribution in #1444
- @almmiko made their first contribution in #1458
- @figsoda made their first contribution in #1395
- @westernwontons made their first contribution in #1510
- @danielsan901998 made their first contribution in #1532
- @dnjulek made their first contribution in #1544
- @andreakarasho made their first contribution in #1546
- @alexatcanva made their first contribution in #1597
- @xdBronch made their first contribution in #1615
- @jimying made their first contribution in #1604
- @Beyley made their first contribution in #1653
- @nolanderc made their first contribution in #1656
- @diocletiann made their first contribution in #1696
- @gabydd made their first contribution in #1803
- @mochalins made their first contribution in #1825
- @ianprime0509 made their first contribution in #1839
- @ThisAccountHasBeenSuspended made their first contribution in #1852
Sponsors
We’d like to take a second to thank all our awesome contributors and donators/backers/sponsors; if you have time or money to spare, consider partaking in either of these options - they help keep ZLS awesome for everyone!
Full Changelog: 0.11.0…0.12.0
Release Artifacts
OS | Arch | Filename | Signature | Size |
---|---|---|---|---|
Windows | x86_64 | zls-x86_64-windows.zip | minisig | 3.53 MiB |
Windows | x86 | zls-x86-windows.zip | minisig | 3.67 MiB |
macOS | aarch64 | zls-aarch64-macos.tar.xz | minisig | 891.37 KiB |
macOS | x86_64 | zls-x86_64-macos.tar.xz | minisig | 1014.32 KiB |
Linux | x86_64 | zls-x86_64-linux.tar.xz | minisig | 3.09 MiB |
Linux | x86 | zls-x86-linux.tar.xz | minisig | 3.15 MiB |
Linux | aarch64 | zls-aarch64-linux.tar.xz | minisig | 2.92 MiB |
Wasm | WASI | zls-wasm32-wasi.tar.xz | minisig | 2.13 MiB |