How to make a directory tree paragraph

Basically I want to put this in the document:


Foo
 ├── include
 │   └── Foo
 │       ├── Foo.h
 │       └── ...
 ├── src
 │   ├── Foo.cpp
 │   └── ...
 ├── test
 │   └── ...
 └── libs
     ├── A
     │   ├── include
     │   │   └── A
     │   │       ├── A.h
     │   │       └── ...
     │   ├── src
     │   │   ├── A.cpp
     │   │   └── ...
     │   └── test
     │       └── ...
     └── B
         ├── include
         │   └── B
         │       ├── B.h
         │       └── ...
         ├── src
         │   ├── B.cpp
         │   └── ...
         └── test
             └── …

Without needing to use Bash for that. Is there a native way on Writer to do this?

Why not? There’s the tree command that does exactly that and you can copy-paste its output to Writer.

tree yourdir | xclip -selection clipboard

Switch to Writer, apply the Preformatted Text style to your empty current paragraph and Ctrl+V.

The problem is that I’m using an example. The directory does not exist and is not good to create a tmp directory just for for every time I need to use it.
I’ve created a script that I can program it to generate the text for me. If I can’t do it on Writer then I’ll just use another way.

I guess you could replace your script with a macro in writer - choose from Basic, Python, … as languages.
.
But as a command “invent a directory tree” without further data is quite unlikely to find you will have to program it yourself (again).

Short answer: no.

You can manually get something equivalent by using Preformatted Text paragraph style and manually type everything. Very tedious and error-prone.

Another approach is to create a diagram in Draw where you put the nodes (directory names and files) inside text boxes (whether you display a border or not a matter of personal state).
The nodes are linked with connectors. Connectors are not ordinary lines. They attach to shape “glue points” and auto adjust when you move the origin or destination shape.
Consequently, you can position your directory boxes in ad hoc location and move their contained sub-directory and file shapes below until you find a nice layout for the connectors.

Paste the diagram into Writer once you’re satisfied.

Here’s an example of such a diagram when I analysed the relations between classes in an application I’d like to customise.

This will not work for me as I want to represent a directory structure without abstractions. Maybe I will make a script to convert this for me.

You didn’t mention your OS, so can’t give targeted advice. Under Linux and MacOS, you can use utility graphviz to automatically generate an .svg, .pdf, .jpeg, … graphical file representing the directory and its files. Through parameters, you can choose between angle connectors (similar to to your sample) or curved connectors. My preferred format is .svg because is it “vectorial” (not rasterised).

I really want to use text instead of images, this way is a lot easier to do corrections. I’ll just stick with a script to generate this without needing to create the directory.