mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-29 14:43:55 +03:00
Embed a plain text grammar and override settings for that too
This commit is contained in:
parent
2c17ae9aa6
commit
9d7039ed51
@ -518,7 +518,9 @@ impl Editor {
|
||||
_: &workspace::OpenNew,
|
||||
cx: &mut ViewContext<Workspace>,
|
||||
) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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<Language> = 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,
|
||||
|
@ -8,6 +8,7 @@ pub use self::{
|
||||
highlight_map::{HighlightId, HighlightMap},
|
||||
language::{
|
||||
BracketPair, Grammar, Language, LanguageConfig, LanguageRegistry, LanguageServerConfig,
|
||||
PLAIN_TEXT,
|
||||
},
|
||||
};
|
||||
use anyhow::{anyhow, Result};
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user