arnaupv / nvim-devcontainer-cli

MIT License
72 stars 0 forks source link

Feature Request: Automatically determine root directory #27

Open erichlf opened 5 months ago

erichlf commented 5 months ago

It would be pretty nice if this could determine the root of the project directory. My project has several git repos below a main workspace like so

.
├── data
├── .devcontainer
├── develop
│   ├── ci
│   ├── .devcontainer
│   ├── docker
│   ├── docs
│   ├── .git
│   └── .gitlab
├── src
│   ├── abb_irb4600
│   ├── behavior_tree
│   ├── classification_with_transfer_learning
│   ├── damage_inspection
│   ├── simulation
│   ├── tool_id_detection
│   └── tool_segmentation
└── .vscode

So we would want to return the top level directory containing .devcontainer. This can be done using telescope projects or possibly a home grown method.

arnaupv commented 5 months ago

Currently the logic that determines the devcontainer root folder is here https://github.com/arnaupv/nvim-devcontainer-cli/blob/main/lua/devcontainer_cli/folder_utils.lua#L4-L28

as you can see currently it chooses the longest path, which is the contrary of returning the top level directory. In other words, the devcontainer that is created by the tool depends on the folder where you open neovim.

what do you think about that?

erichlf commented 5 months ago

And now I see why it doesn't work for me. This assumes that your top project root is a git repo, which is not the case for me. In fact, my workflow is very typical in ROS/ROS2 development, where you have a workspace with a src directory which contains your repos. The plugin that I pointed to uses pattern matching to determine the root of the project. In the case of devcontainers this is pretty easy, just look for .devcontainer.

arnaupv commented 5 months ago

There might be different ways to choose the .devcontainer and also this should be configurable in the nvim plugin