Skip to content

Feature: find .env files in parent directories #518

@teleivo

Description

@teleivo

Issues

  • I have checked existing issues and there are no existing ones with the same request.

Feature description

Hi 😄 and thank you for your work on this amazing plugin 🥳

I discovered that :Rest env select searches downward from the current buffer's directory. That is surprising to me as most tools search upward stopping at the project root like when finding a .git directory. find_env_files searches downward due to

end, { limit = math.huge, type = "file", path = "./" })

(https://neovim.io/doc/user/lua.html#vim.fs.find() upward=false by default)

This prevents me from reusing .env files at the root of a project with .http files in nested dirs. I can only make it work if I keep the :cd at the project's root. However, that adds .env files in nested dirs that are irrelevant IMHO.

Imagine a project with

  • .env

  • ./a

  • ./a/.env

  • ./a/a.http

  • ./b/b.http

  • When opening b.http from directory ./b (or doing :cd ./b) the root .env is not shown in the select UI.

  • When opening b.http from the root dir ./a/.env is shown in the select UI while from my point of view, its meant to be scoped to ./a

I assume you are open to changes here due to your comment

https://github.com/rest-nvim/rest.nvim/blob/62606c3599bd304227457d6e20580965939b191e/lua/rest-nvim/dotenv.lua#L61C1-L62C63

😋

Changing the search direction is a breaking change so I wonder if we could make this

https://github.com/rest-nvim/rest.nvim/blob/62606c3599bd304227457d6e20580965939b191e/lua/rest-nvim/dotenv.lua#L58C1-L58C28

a configurable function with this one staying the default? Maybe you also have different suggestion 👌🏻

Please let me know what you think! I could give it a try at implementing it if you would want. Thank you again!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions