File tree Expand file tree Collapse file tree 3 files changed +18
-10
lines changed
Expand file tree Collapse file tree 3 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,17 @@ local default_config = {
6565 enable = true ,
6666 --- @type string
6767 pattern = " .*%.env.*" ,
68+ --- @type fun (): string[]
69+ find = function ()
70+ local config = require (" rest-nvim.config" )
71+ return vim .fs .find (function (name , _ )
72+ return name :match (config .env .pattern )
73+ end , {
74+ path = vim .fn .getcwd (),
75+ type = " file" ,
76+ limit = math.huge ,
77+ })
78+ end ,
6879 },
6980 --- @class rest.Config.UI
7081 ui = {
Original file line number Diff line number Diff line change @@ -92,6 +92,10 @@ local config
9292--- @field enable ? boolean
9393--- Environment variables file pattern for telescope.nvim (Default: `"%.env.*"`)
9494--- @field pattern ? string
95+ --- Function lists environment files (used for `:Rest env select`)
96+ --- Searches for file matching *rest.Opts.Env.pattern* under same directory by
97+ --- default
98+ --- @field find ? fun (): string[]
9599
96100--- @class rest.Opts.UI
97101--- Set winbar in result pane (Default: `true`)
Original file line number Diff line number Diff line change @@ -53,18 +53,11 @@ function M.show_registered_file(bufnr)
5353 end
5454end
5555
56- --- Find a list of environment files starting from the current directory
56+ --- Find a list of environment files
57+ --- @see rest.Opts.Env.find
5758--- @return string[] files Environment variable files path
5859function M .find_env_files ()
59- -- We are currently looking for any ".*env*" file, e.g. ".env", ".env.json"
60- --
61- -- This algorithm can be improved later on to search from a parent directory if the desired environment file
62- -- is somewhere else but in the current working directory.
63- local files = vim .fs .find (function (name , _ )
64- return name :match (config .env .pattern )
65- end , { limit = math.huge , type = " file" , path = " ./" })
66-
67- return files
60+ return config .env .find ()
6861end
6962
7063--- @return string ? dotenv file
You can’t perform that action at this time.
0 commit comments