llogick / zigscient

A Zig Language Server
Other
57 stars 5 forks source link

Put members first in "files as structs" when organizing imports #9

Closed mattnite closed 3 weeks ago

mattnite commented 3 weeks ago

When I organize the following contents:

gpa: std.mem.Allocator,
connections: std.DoublyLinkedList(Node) = .{},

const std = @import("std");

const xev = @import("xev");
const HTTP_Server = @This();
const Node = struct {
    read_comp: xev.Completion,
};

I get the result:

const std = @import("std");

const xev = @import("xev");

gpa: std.mem.Allocator,
connections: std.DoublyLinkedList(Node) = .{},

const HTTP_Server = @This();
const Node = struct {
    read_comp: xev.Completion,
};

I think it's best to put members at the top of the file so it's easy to understand what makes up the struct. I would love to see this as the default and/or a config!

llogick commented 3 weeks ago

I agree, as for other options -- we can simply have separate code actions, eg

"Organize Imports (Imports First)" "Organize Imports (Imports Last)" "Organize Imports (Fields Last)"