File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
crates/code_analysis/src/config Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ use configs::{
1414 EmmyrcStrict , EmmyrcWorkspace ,
1515} ;
1616use emmylua_parser:: { LuaLanguageLevel , ParserConfig } ;
17+ use regex:: Regex ;
1718use rowan:: NodeCache ;
1819use schemars:: JsonSchema ;
1920use serde:: { Deserialize , Serialize } ;
@@ -118,6 +119,22 @@ fn pre_process_path(path: &str, workspace: &PathBuf) -> String {
118119 . to_string ( ) ;
119120 }
120121
121- path = path. replace ( "${workspaceFolder}" , & workspace. to_string_lossy ( ) ) ;
122+ path = path. replace ( "$" , "" ) ;
123+ path = replace_placeholders ( & path, workspace. to_str ( ) . unwrap ( ) ) ;
122124 path
123125}
126+
127+ fn replace_placeholders ( input : & str , workspace_folder : & str ) -> String {
128+ let re = Regex :: new ( r"\{([^}]+)\}" ) . unwrap ( ) ;
129+ re. replace_all ( input, |caps : & regex:: Captures | {
130+ let key = & caps[ 1 ] ;
131+ if key == "workspaceFolder" {
132+ workspace_folder. to_string ( )
133+ } else if let Some ( env_name) = key. strip_prefix ( "env:" ) {
134+ std:: env:: var ( env_name) . unwrap_or_default ( )
135+ } else {
136+ caps[ 0 ] . to_string ( )
137+ }
138+ } )
139+ . to_string ( )
140+ }
You can’t perform that action at this time.
0 commit comments