Open
Description
Zig files usually begin with a bunch of @imports
like this:
const std = @import("std");
const Ast = std.zig.Ast;
const Server = @import("../Server.zig");
const DocumentStore = @import("../DocumentStore.zig");
const types = @import("lsp").types;
const Analyser = @import("../analysis.zig");
const ast = @import("../ast.zig");
const offsets = @import("../offsets.zig");
const tracy = @import("tracy");
const URI = @import("../uri.zig");
const DocumentScope = @import("../DocumentScope.zig");
const analyser_completions = @import("../analyser/completions.zig");
const data = @import("version_data");
const snipped_data = @import("../snippets.zig");
ZLS should offer to collapse them into one line like other declarations. Here is an example of folding ranges in VS Code:
Care must be taken to ensure that only "imports" or "aliases" are collapsed and no other declarations. The source.organizeImports
code action has dealt with a similar task here.
The implementation of folding ranges can be found in src/features/folding_range.zig.
The LSP specification for textDocument/foldingRange can also be useful.