diff --git a/crates/editor/src/lib.rs b/crates/editor/src/lib.rs index da1060b78d..4566badd98 100644 --- a/crates/editor/src/lib.rs +++ b/crates/editor/src/lib.rs @@ -518,7 +518,9 @@ impl Editor { _: &workspace::OpenNew, cx: &mut ViewContext, ) { - let buffer = cx.add_model(|cx| Buffer::new(0, "", cx)); + let buffer = cx.add_model(|cx| { + Buffer::new(0, "", cx).with_language(Some(language::PLAIN_TEXT.clone()), None, cx) + }); workspace.add_item(BufferItemHandle(buffer), cx); } diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index 8cb40438ac..f8201b179b 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -1,6 +1,7 @@ use crate::HighlightMap; use anyhow::{anyhow, Result}; use gpui::{executor::Background, AppContext}; +use lazy_static::lazy_static; use lsp::LanguageServer; use parking_lot::Mutex; use serde::Deserialize; @@ -9,6 +10,19 @@ use theme::SyntaxTheme; use tree_sitter::{self, Query}; pub use tree_sitter::{Parser, Tree}; +lazy_static! { + pub static ref PLAIN_TEXT: Arc = Arc::new(Language::new( + LanguageConfig { + name: "Plain Text".to_string(), + path_suffixes: Default::default(), + brackets: Default::default(), + line_comment: None, + language_server: None, + }, + None, + )); +} + #[derive(Default, Deserialize)] pub struct LanguageConfig { pub name: String, diff --git a/crates/language/src/lib.rs b/crates/language/src/lib.rs index 4d16eb6a24..07602e227f 100644 --- a/crates/language/src/lib.rs +++ b/crates/language/src/lib.rs @@ -8,6 +8,7 @@ pub use self::{ highlight_map::{HighlightId, HighlightMap}, language::{ BracketPair, Grammar, Language, LanguageConfig, LanguageRegistry, LanguageServerConfig, + PLAIN_TEXT, }, }; use anyhow::{anyhow, Result}; diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 16ca6ed67b..c6374c66e7 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -27,6 +27,13 @@ fn main() { let theme = themes.get(DEFAULT_THEME_NAME).unwrap(); let settings = Settings::new("Inconsolata", &app.font_cache(), theme) .unwrap() + .with_overrides( + language::PLAIN_TEXT.name(), + settings::Override { + soft_wrap: Some(settings::SoftWrap::PreferredLineLength), + ..Default::default() + }, + ) .with_overrides( "Markdown", settings::Override {