File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ local M = {}
44
55local dotenv_parser = require (" rest-nvim.parser.dotenv" )
66local config = require (" rest-nvim.config" )
7+ local logger = require (" rest-nvim.logger" )
78
89--- load dotenv file
910--- This function will set environment variables in current editor session.
@@ -85,11 +86,20 @@ function M.find_relevent_env_file()
8586 --- @type string ?
8687 local env_file
8788 -- search for `/same/path/filename.env`
88- env_file = vim .fs .find (filename .. " .env" , { type = " file" })[1 ]
89+ logger .debug (" searching for " .. filename .. " .env file" )
90+ env_file = vim .fs .find (filename .. " .env" , {
91+ path = vim .fn .expand (" %:h" ),
92+ upward = true ,
93+ stop = vim .fn .getcwd (),
94+ type = " file" ,
95+ limit = math.huge ,
96+ })[1 ]
8997 if env_file then
98+ logger .debug (" found .env file:" , env_file )
9099 return env_file
91100 end
92101 -- search upward for `.env` file
102+ logger .debug (" searching for .env file" )
93103 env_file = vim .fs .find (function (name , _ )
94104 return name == " .env"
95105 end , {
@@ -100,7 +110,10 @@ function M.find_relevent_env_file()
100110 limit = math.huge ,
101111 })[1 ]
102112 if env_file then
113+ logger .debug (" found .env file:" , env_file )
103114 return env_file
115+ else
116+ logger .debug (" no .env file found" )
104117 end
105118end
106119
You can’t perform that action at this time.
0 commit comments