Unnamed repository; edit this file 'description' to name the repository.
Rename LanguageConfig language_id as language_name
Michael Davis 2024-01-12
parent 17dd102 · commit 4e1aeb1
-rw-r--r--helix-core/src/syntax.rs27
-rw-r--r--helix-term/src/health.rs15
-rw-r--r--helix-term/src/ui/mod.rs2
-rw-r--r--helix-view/src/document.rs4
-rw-r--r--xtask/src/docgen.rs6
-rw-r--r--xtask/src/querycheck.rs2
6 files changed, 31 insertions, 25 deletions
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index 102ecb15..16b8a13a 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -93,7 +93,7 @@ impl Default for Configuration {
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
pub struct LanguageConfiguration {
#[serde(rename = "name")]
- pub language_id: String, // c-sharp, rust, tsx
+ pub language_name: String, // c-sharp, rust, tsx
#[serde(rename = "language-id")]
// see the table under https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentItem
pub language_server_language_id: Option<String>, // csharp, rust, typescriptreact, for the language-server
@@ -636,21 +636,21 @@ pub fn read_query(language: &str, filename: &str) -> String {
impl LanguageConfiguration {
fn initialize_highlight(&self, scopes: &[String]) -> Option<Arc<HighlightConfiguration>> {
- let highlights_query = read_query(&self.language_id, "highlights.scm");
+ let highlights_query = read_query(&self.language_name, "highlights.scm");
// always highlight syntax errors
// highlights_query += "\n(ERROR) @error";
- let injections_query = read_query(&self.language_id, "injections.scm");
- let locals_query = read_query(&self.language_id, "locals.scm");
+ let injections_query = read_query(&self.language_name, "injections.scm");
+ let locals_query = read_query(&self.language_name, "locals.scm");
if highlights_query.is_empty() {
None
} else {
- let language = get_language(self.grammar.as_deref().unwrap_or(&self.language_id))
+ let language = get_language(self.grammar.as_deref().unwrap_or(&self.language_name))
.map_err(|err| {
log::error!(
"Failed to load tree-sitter parser for language {:?}: {}",
- self.language_id,
+ self.language_name,
err
)
})
@@ -661,7 +661,7 @@ impl LanguageConfiguration {
&injections_query,
&locals_query,
)
- .map_err(|err| log::error!("Could not parse queries for language {:?}. Are your grammars out of sync? Try running 'hx --grammar fetch' and 'hx --grammar build'. This query could not be parsed: {:?}", self.language_id, err))
+ .map_err(|err| log::error!("Could not parse queries for language {:?}. Are your grammars out of sync? Try running 'hx --grammar fetch' and 'hx --grammar build'. This query could not be parsed: {:?}", self.language_name, err))
.ok()?;
config.configure(scopes);
@@ -705,7 +705,7 @@ impl LanguageConfiguration {
}
fn load_query(&self, kind: &str) -> Option<Query> {
- let query_text = read_query(&self.language_id, kind);
+ let query_text = read_query(&self.language_name, kind);
if query_text.is_empty() {
return None;
}
@@ -715,7 +715,7 @@ impl LanguageConfiguration {
log::error!(
"Failed to parse {} queries for {}: {}",
kind,
- self.language_id,
+ self.language_name,
e
)
})
@@ -855,10 +855,13 @@ impl Loader {
.cloned()
}
- pub fn language_config_for_language_id(&self, id: &str) -> Option<Arc<LanguageConfiguration>> {
+ pub fn language_config_for_language_name(
+ &self,
+ name: &str,
+ ) -> Option<Arc<LanguageConfiguration>> {
self.language_configs
.iter()
- .find(|config| config.language_id == id)
+ .find(|config| config.language_name == name)
.cloned()
}
@@ -890,7 +893,7 @@ impl Loader {
InjectionLanguageMarker::Name(string) => self.language_config_for_name(string),
InjectionLanguageMarker::Filename(file) => self.language_config_for_file_name(file),
InjectionLanguageMarker::Shebang(shebang) => {
- self.language_config_for_language_id(shebang)
+ self.language_config_for_language_name(shebang)
}
}
}
diff --git a/helix-term/src/health.rs b/helix-term/src/health.rs
index 44ae2a2f..8e875de3 100644
--- a/helix-term/src/health.rs
+++ b/helix-term/src/health.rs
@@ -179,7 +179,7 @@ pub fn languages_all() -> std::io::Result<()> {
syn_loader_conf
.language
- .sort_unstable_by_key(|l| l.language_id.clone());
+ .sort_unstable_by_key(|l| l.language_name.clone());
let check_binary = |cmd: Option<&str>| match cmd {
Some(cmd) => match which::which(cmd) {
@@ -190,7 +190,7 @@ pub fn languages_all() -> std::io::Result<()> {
};
for lang in &syn_loader_conf.language {
- column(&lang.language_id, Color::Reset);
+ column(&lang.language_name, Color::Reset);
let mut cmds = lang.language_servers.iter().filter_map(|ls| {
syn_loader_conf
@@ -210,7 +210,7 @@ pub fn languages_all() -> std::io::Result<()> {
check_binary(formatter);
for ts_feat in TsFeature::all() {
- match load_runtime_file(&lang.language_id, ts_feat.runtime_filename()).is_ok() {
+ match load_runtime_file(&lang.language_name, ts_feat.runtime_filename()).is_ok() {
true => column("✓", Color::Green),
false => column("✘", Color::Red),
}
@@ -254,7 +254,7 @@ pub fn language(lang_str: String) -> std::io::Result<()> {
let lang = match syn_loader_conf
.language
.iter()
- .find(|l| l.language_id == lang_str)
+ .find(|l| l.language_name == lang_str)
{
Some(l) => l,
None => {
@@ -263,8 +263,11 @@ pub fn language(lang_str: String) -> std::io::Result<()> {
let suggestions: Vec<&str> = syn_loader_conf
.language
.iter()
- .filter(|l| l.language_id.starts_with(lang_str.chars().next().unwrap()))
- .map(|l| l.language_id.as_str())
+ .filter(|l| {
+ l.language_name
+ .starts_with(lang_str.chars().next().unwrap())
+ })
+ .map(|l| l.language_name.as_str())
.collect();
if !suggestions.is_empty() {
let suggestions = suggestions.join(", ");
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index 660bbfea..0b8dae85 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -339,7 +339,7 @@ pub mod completers {
let language_ids = editor
.syn_loader
.language_configs()
- .map(|config| &config.language_id)
+ .map(|config| &config.language_name)
.chain(std::iter::once(&text));
fuzzy_match(input, language_ids, false)
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 0de0cd17..e4cd7d86 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -1085,7 +1085,7 @@ impl Document {
config_loader: Arc<syntax::Loader>,
) -> anyhow::Result<()> {
let language_config = config_loader
- .language_config_for_language_id(language_id)
+ .language_config_for_language_name(language_id)
.ok_or_else(|| anyhow!("invalid language id: {}", language_id))?;
self.set_language(Some(language_config), Some(config_loader));
Ok(())
@@ -1530,7 +1530,7 @@ impl Document {
pub fn language_name(&self) -> Option<&str> {
self.language
.as_ref()
- .map(|language| language.language_id.as_str())
+ .map(|language| language.language_name.as_str())
}
/// Language ID for the document. Either the `language-id`,
diff --git a/xtask/src/docgen.rs b/xtask/src/docgen.rs
index 034d9918..5f0ae5d5 100644
--- a/xtask/src/docgen.rs
+++ b/xtask/src/docgen.rs
@@ -67,7 +67,7 @@ pub fn lang_features() -> Result<String, DynError> {
let mut langs = config
.language
.iter()
- .map(|l| l.language_id.clone())
+ .map(|l| l.language_name.clone())
.collect::<Vec<_>>();
langs.sort_unstable();
@@ -81,9 +81,9 @@ pub fn lang_features() -> Result<String, DynError> {
let lc = config
.language
.iter()
- .find(|l| l.language_id == lang)
+ .find(|l| l.language_name == lang)
.unwrap(); // lang comes from config
- row.push(lc.language_id.clone());
+ row.push(lc.language_name.clone());
for (_feat, support_list) in &ts_features_to_langs {
row.push(
diff --git a/xtask/src/querycheck.rs b/xtask/src/querycheck.rs
index 454d0e5c..06601ef7 100644
--- a/xtask/src/querycheck.rs
+++ b/xtask/src/querycheck.rs
@@ -14,7 +14,7 @@ pub fn query_check() -> Result<(), DynError> {
];
for language in lang_config().language {
- let language_name = &language.language_id;
+ let language_name = &language.language_name;
let grammar_name = language.grammar.as_ref().unwrap_or(language_name);
for query_file in query_files {
let language = get_language(grammar_name);