zls icon indicating copy to clipboard operation
zls copied to clipboard

Code action to create file

Open SoraTenshi opened this issue 1 year ago • 0 comments

Story

While working on Zig bindings, i was translating quite a bit of C to Zig, so i also tried and structure the code in a way, that i have quite a bit of files. A common pattern that arose is the following:

const Register = @import("register.zig").Register; // This file does not exist (yet)
// ....
const Something = extern struct {
    reg: Register,
    // ...
};

I would think that a code action to just create the file in the corresponding folder would be a great improvement for this specific workflow, but even in other workflows this would make a lot of sense in my opinion.

Being more concrete

Let's imagine the following folder-structure:

──  src
  ├──  linux
  │  └──  import.zig
  └──  windows
     └──  import.zig

and then imagine within the linux/import.zig folder the following Line: const fs = @import("file_system.zig"); It would just make sense that a code action would create the file in the assumed folder, so that it would result in:

──  src
  ├──  linux
  │  ├──  file_system.zig
  │  └──  import.zig
  └──  windows
     └──  import.zig

Another point i'd say supporting this idea is, that probably most people are mostly working in the root of their project, so it would always be a bit cumbersome for us to create the file in the corresponding folder.

SoraTenshi avatar Jul 06 '24 22:07 SoraTenshi