aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands
diff options
context:
space:
mode:
authorGuillaume2023-02-16 14:48:35 +0000
committerGitHub2023-02-16 14:48:35 +0000
commit78a1e2db6035b326d7536fbd0fb60f9fc586d978 (patch)
tree183cd41715fe36b1adb13dc3a7e20b2f49f47bb9 /helix-term/src/commands
parenta1a6d5f3340ba8a587bbf8c178fe65589f36a51a (diff)
feat: show current language when no argument is provided (#5895)
Diffstat (limited to 'helix-term/src/commands')
-rw-r--r--helix-term/src/commands/typed.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index 6b45b005..b0fd18a7 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -6,6 +6,7 @@ use crate::job::Job;
use super::*;
use helix_core::encoding;
+use helix_view::document::DEFAULT_LANGUAGE_NAME;
use helix_view::editor::{Action, CloseError, ConfigEvent};
use serde_json::Value;
use ui::completers::{self, Completer};
@@ -1697,13 +1698,20 @@ fn language(
return Ok(());
}
+ if args.is_empty() {
+ let doc = doc!(cx.editor);
+ let language = &doc.language_name().unwrap_or(DEFAULT_LANGUAGE_NAME);
+ cx.editor.set_status(language.to_string());
+ return Ok(());
+ }
+
if args.len() != 1 {
anyhow::bail!("Bad arguments. Usage: `:set-language language`");
}
let doc = doc_mut!(cx.editor);
- if args[0] == "text" {
+ if args[0] == DEFAULT_LANGUAGE_NAME {
doc.set_language(None, None)
} else {
doc.set_language_by_language_id(&args[0], cx.editor.syn_loader.clone())?;
@@ -2414,7 +2422,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
TypableCommand {
name: "set-language",
aliases: &["lang"],
- doc: "Set the language of current buffer.",
+ doc: "Set the language of current buffer (show current language if no value specified).",
fun: language,
completer: Some(completers::language),
},