Skip to content

Commit d7a7c56

Browse files
committed
添加新的路径占位符luarocks
1 parent 594f66e commit d7a7c56

File tree

1 file changed

+18
-0
lines changed
  • crates/emmylua_code_analysis/src/config

1 file changed

+18
-0
lines changed

crates/emmylua_code_analysis/src/config/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use regex::Regex;
2020
use rowan::NodeCache;
2121
use schemars::JsonSchema;
2222
use serde::{Deserialize, Serialize};
23+
use std::process::Command;
2324

2425
#[derive(Serialize, Deserialize, Debug, JsonSchema, Default, Clone)]
2526
#[serde(rename_all = "camelCase")]
@@ -197,9 +198,26 @@ fn replace_placeholders(input: &str, workspace_folder: &str) -> String {
197198
workspace_folder.to_string()
198199
} else if let Some(env_name) = key.strip_prefix("env:") {
199200
std::env::var(env_name).unwrap_or_default()
201+
} else if key == "luarocks" {
202+
get_luarocks_deploy_dir()
200203
} else {
201204
caps[0].to_string()
202205
}
203206
})
204207
.to_string()
205208
}
209+
210+
fn get_luarocks_deploy_dir() -> String {
211+
Command::new("luarocks")
212+
.args(["config", "deploy_lua_dir"])
213+
.output()
214+
.ok()
215+
.and_then(|output| {
216+
if output.status.success() {
217+
Some(String::from_utf8_lossy(&output.stdout).trim().to_string())
218+
} else {
219+
None
220+
}
221+
})
222+
.unwrap_or_default()
223+
}

0 commit comments

Comments
 (0)